import java . util . * ; public class Calfd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] v = new int [ 3 ] ; v [ 0 ] = Integer . parseInt ( sc . next ( ) ) ; v [ 1 ] = Integer . parseInt ( sc . next ( ) ) ; v [ 2 ] = Integer . parseInt ( sc . next ( ) ) ; int calfd = Integer . parseInt ( sc . next ( ) ) ; Arrays . sort ( v ) ; for ( int i = 0 ; i < calfd ; i ++ ) { v [ 2 ] *= 2 ; } System . out . println ( v [ 0 ] + v [ 1 ] + v [ 2 ] ) ; } } import java . util . Scanner ; public class Qhnfep { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qhnfep = scan . nextInt ( ) ; int first = qhnfep / 100 ; int last = qhnfep % 100 ; String answer = " NA " ; if ( last >= 1 && last <= 12 && first >= 1 && first <= 12 ) { answer = " AMBIGUOUS " ; } else if ( last >= 1 && last <= 12 ) { answer = " YYMM " ; } else if ( first >= 1 && first <= 12 ) { answer = " MMYY " ; } System . out . println ( answer ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Pvdomf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pvdomf = sc . nextInt ( ) ; long [ ] a = new long [ pvdomf ] ; boolean isZero = false ; for ( int i = 0 ; i < pvdomf ; i ++ ) { long tmp = sc . nextLong ( ) ; if ( tmp == 0 ) { isZero = true ; break ; } a [ i ] = tmp ; } sc . close ( ) ; long ans = 1 ; long max = ( long ) Math . pow ( 10 , 9 ) ; int count = 0 ; boolean isLarge = false ; Arrays . sort ( a ) ; for ( int i = pvdomf - 1 ; i >= 0 ; i -- ) { ans *= a [ i ] ; if ( a [ i ] > max ) { count ++ ; } if ( count == 2 || ans > max * max ) { isLarge = true ; break ; } } if ( isZero ) { System . out . println ( 0 ) ; } else if ( isLarge ) { System . out . println ( - 1 ) ; } else { System . out . println ( ans ) ; } } } import java . util . * ; public class Nywii { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int nywii = cin . nextInt ( ) ; int [ ] list = new int [ nywii ] ; for ( int i = 0 ; i < nywii ; i ++ ) { list [ i ] = cin . nextInt ( ) ; } cin . close ( ) ; int result = - 1 ; int tmp = 0 ; for ( int j = 0 ; j < ( int ) Math . pow ( 10 , 7 ) ; j ++ ) { tmp = list [ tmp ] - 1 ; if ( tmp == 1 ) { result = j + 1 ; break ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class Totuhz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int totuhz = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int X = 0 ; int Y = A [ 0 ] + ( totuhz - A [ N - 1 ] ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { X = A [ i + 1 ] - A [ i ] ; if ( X >= Y ) { Y = X ; } } System . out . print ( totuhz - Y ) ; } } import java . util . * ; class Wdsctd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int wdsctd = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] line = scanner . nextLine ( ) . split ( " " , wdsctd ) ; int [ ] arr = new int [ wdsctd ] ; for ( int i = 0 ; i < wdsctd ; i ++ ) { arr [ i ] = Integer . parseInt ( line [ i ] ) ; } Arrays . sort ( arr ) ; int sum = 0 ; for ( int i = 0 ; i < wdsctd - 1 ; i ++ ) { sum += arr [ i ] ; } if ( arr [ wdsctd - 1 ] < sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Fptpm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] nums = new int [ 3 ] , rep = new int [ 2 ] ; rep [ 0 ] = 0 ; rep [ 1 ] = 0 ; for ( int fptpm = 0 ; fptpm < 3 ; fptpm ++ ) { nums [ fptpm ] = sc . nextInt ( ) ; if ( nums [ fptpm ] == 5 ) { rep [ 0 ] ++ ; } else if ( nums [ fptpm ] == 7 ) { rep [ 1 ] ++ ; } } if ( rep [ 0 ] == 2 && rep [ 1 ] == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; class Rdnzzq { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int rdnzzq = sc . nextInt ( ) ; int [ ] a = new int [ rdnzzq + 1 ] ; a [ 0 ] = 0 ; for ( int i = 1 ; i <= rdnzzq ; i ++ ) { a [ i ] = a [ i - 1 ] + sc . nextInt ( ) ; } int min = 10000000 ; for ( int t = 1 ; t < rdnzzq ; t ++ ) { min = Math . min ( Math . abs ( ( a [ t ] - a [ 0 ] ) - ( a [ rdnzzq ] - a [ t ] ) ) , min ) ; } System . out . println ( min ) ; } } import java . util . * ; public class Rllqs { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { long rllqs = in . nextLong ( ) ; long b = in . nextLong ( ) ; long c = LCM ( rllqs , b ) ; long d = rllqs * b / c ; System . out . println ( c + " " + d ) ; } } static long LCM ( long rllqs , long b ) { if ( b == 0 ) { return rllqs ; } else { return LCM ( b , rllqs % b ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Rziyli { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int rziyli = Integer . parseInt ( br . readLine ( ) ) ; String [ ] strArray = br . readLine ( ) . split ( " " ) ; int [ ] array = new int [ rziyli ] ; for ( int i = 0 ; i < rziyli ; i ++ ) { array [ i ] = Integer . parseInt ( strArray [ i ] ) ; } int count = bubbleSor ( array , rziyli ) ; printArray ( array ) ; System . out . println ( count ) ; } static int bubbleSor ( int [ ] array , int rziyli ) { int flag = 1 ; int count = 0 ; while ( flag == 1 ) { flag = 0 ; for ( int j = rziyli - 1 ; j >= 1 ; j -- ) { if ( array [ j ] < array [ j - 1 ] ) { int tmp = array [ j ] ; array [ j ] = array [ j - 1 ] ; array [ j - 1 ] = tmp ; flag = 1 ; count ++ ; } } } return count ; } static void printArray ( int [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { System . out . print ( array [ i ] ) ; if ( i != array . length - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } import java . util . * ; public class Chgfppi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int chgfppi = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; sc . close ( ) ; int result = 0 ; for ( int i = 0 ; i < D ; i ++ ) { if ( chgfppi > 0 ) { result += 1 ; chgfppi -= 1 ; } else if ( B > 0 ) { B -= 1 ; } else { result -= 1 ; C -= 1 ; } } System . out . println ( result ) ; } } import java . util . Scanner ; import java . util . Deque ; import java . util . ArrayDeque ; public class Gfvqlo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Deque < Integer > deq = new ArrayDeque < Integer > ( ) ; String str = " " ; int gfvqlo = 0 , b = 0 ; while ( sc . hasNext ( ) ) { str = sc . next ( ) ; if ( str . equals ( " + " ) ) { gfvqlo = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( gfvqlo + b ) ; } else if ( str . equals ( " - " ) ) { gfvqlo = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( b - gfvqlo ) ; } else if ( str . equals ( " * " ) ) { gfvqlo = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( gfvqlo * b ) ; } else if ( str . equals ( " / " ) ) { gfvqlo = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( b / gfvqlo ) ; } else { deq . addLast ( Integer . parseInt ( str ) ) ; } } System . out . println ( deq . peekLast ( ) ) ; } } 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 Tmusc { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; MyScanner in = new MyScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; A solver = new A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Tmusc { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { int tmusc = in . nextInt ( ) ; int A = in . nextInt ( ) ; out . println ( ( int ) Math . ceil ( tmusc / ( double ) A ) ) ; } } static class Tmusc { private BufferedReader in ; private StringTokenizer st ; public MyScanner ( InputStream stream ) { in = new BufferedReader ( new InputStreamReader ( stream ) ) ; } public String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { String rl = in . readLine ( ) ; if ( rl == null ) { return null ; } st = new StringTokenizer ( rl ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } import java . util . Scanner ; public class Wcgnupk { public static void main ( String [ ] args ) { Scanner x = new Scanner ( System . in ) ; int wcgnupk = x . nextInt ( ) ; int f = x . nextInt ( ) ; int r = x . nextInt ( ) ; int go = wcgnupk + f ; while ( wcgnupk != - 1 || f != - 1 || r != - 1 ) { if ( wcgnupk == - 1 || f == - 1 || go < 30 ) { System . out . println ( " F " ) ; } else if ( go >= 80 ) { System . out . println ( " A " ) ; } else if ( go >= 65 ) { System . out . println ( " B " ) ; } else if ( go >= 50 || r >= 50 ) { System . out . println ( " C " ) ; } else if ( go >= 30 ) { System . out . println ( " D " ) ; } wcgnupk = x . nextInt ( ) ; f = x . nextInt ( ) ; r = x . nextInt ( ) ; go = wcgnupk + f ; } } } import java . util . Scanner ; public class Tfmllq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] nums = new int [ 11 ] ; for ( int tfmllq = 0 ; tfmllq < 3 ; tfmllq ++ ) { int num = sc . nextInt ( ) ; nums [ num ] ++ ; } if ( nums [ 5 ] == 2 && nums [ 7 ] == 1 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; sc . close ( ) ; } } import java . io . IOException ; import java . util . Scanner ; public class Vtmcks { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int vtmcks = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int r = s * t - vtmcks ; System . out . println ( r >= 0 ? " Yes " : " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Mvjexyn { public Main ( ) { } static int mvjexyn ; public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; mvjexyn = Integer . parseInt ( str ) ; System . out . println ( ( int ) Math . pow ( mvjexyn , 3 ) ) ; } } import java . util . * ; public class Jqbtx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jqbtx = sc . nextInt ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; if ( jqbtx >= s . length ) { for ( int i = 0 ; i < s . length ; i ++ ) { System . out . print ( s [ i ] ) ; } } else { for ( int i = 0 ; i < jqbtx ; i ++ ) { System . out . print ( s [ i ] ) ; } System . out . print ( " ... " ) ; } } } import java . util . Scanner ; public class Qpnrpgm { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; long qpnrpgm = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = lcm ( qpnrpgm , b ) ; System . out . println ( ans ) ; sc . close ( ) ; } public long gcd ( long qpnrpgm , long b ) { if ( b == 0 ) { return qpnrpgm ; } long ans = gcd ( b , qpnrpgm % b ) ; return ans ; } public long lcm ( long qpnrpgm , long b ) { long g = gcd ( qpnrpgm , b ) ; return qpnrpgm * b / g ; } } import java . util . * ; public class Ncmiq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ncmiq = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] num = new int [ 2 * ncmiq ] ; int min = 1001 ; for ( int i = 0 ; i < 2 * ncmiq ; i ++ ) { num [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < ncmiq ; i ++ ) { if ( num [ 2 * i + 1 ] > T ) { num [ 2 * i ] = 1001 ; } } for ( int i = 0 ; i < ncmiq ; i ++ ) { if ( min > num [ 2 * i ] ) { min = num [ 2 * i ] ; } } if ( min == 1001 ) { System . out . println ( " TLE " ) ; } else { System . out . println ( min ) ; } } } import java . util . Scanner ; public class Pmdful { private static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int pmdful ; while ( 0 > ( pmdful = scanner . nextInt ( ) ) || pmdful >= 86400 ) ; int hour = pmdful / 3600 ; int minute = ( pmdful - hour * 3600 ) / 60 ; int second = ( pmdful - hour * 3600 - minute * 60 ) ; System . out . println ( hour + " : " + minute + " : " + second ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Uxprqa { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int uxprqa = 0 ; String s = br . readLine ( ) ; String t = br . readLine ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) { uxprqa ++ ; } } System . out . println ( uxprqa ) ; } catch ( Exception e ) { System . out . println ( e ) ; } } } import java . io . * ; import java . util . * ; public class Yschtv { public static void main ( String [ ] args ) { try { BufferedReader br = createBufferedReader ( ) ; String line = br . readLine ( ) ; System . out . println ( method ( line ) ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; } } private static int method ( final String str ) { String [ ] strings = { " SUN " , " MON " , " TUE " , " WED " , " THU " , " FRI " , " SAT " } ; for ( int yschtv = 0 ; yschtv < strings . length ; yschtv ++ ) { if ( str . equals ( strings [ yschtv ] ) ) { return 7 - yschtv ; } } return - 1 ; } private static BufferedReader createBufferedReader ( ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; return new BufferedReader ( isr ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Ticlod { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String op ; String [ ] ArrayX = new String [ 3 ] ; int [ ] ArrayA = new int [ 2 ] ; int ticlod = 0 ; String resultLine = " " ; boolean check = true ; while ( check ) { String line = br . readLine ( ) ; ArrayX = line . split ( " " ) ; op = ArrayX [ 1 ] ; ArrayA [ 0 ] = Integer . parseInt ( ArrayX [ 0 ] ) ; ArrayA [ 1 ] = Integer . parseInt ( ArrayX [ 2 ] ) ; if ( op . equals ( " + " ) ) { ticlod = ArrayA [ 0 ] + ArrayA [ 1 ] ; resultLine = resultLine + ticlod + ( " \n " ) ; } else if ( op . equals ( " - " ) ) { ticlod = ArrayA [ 0 ] - ArrayA [ 1 ] ; resultLine = resultLine + ticlod + ( " \n " ) ; } else if ( op . equals ( " * " ) ) { ticlod = ArrayA [ 0 ] * ArrayA [ 1 ] ; resultLine = resultLine + ticlod + ( " \n " ) ; } else if ( op . equals ( " / " ) ) { ticlod = ( ArrayA [ 0 ] / ArrayA [ 1 ] ) ; resultLine = resultLine + ticlod + ( " \n " ) ; } else if ( op . equals ( " ? " ) ) { check = false ; } } System . out . print ( resultLine ) ; } } import java . util . * ; public class Mwedep { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mwedep = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int a1 = mwedep + b ; int a2 = mwedep - b ; int a3 = mwedep * b ; if ( a1 >= a2 && a1 >= a3 ) { System . out . println ( a1 ) ; } else if ( a2 >= a1 && a2 >= a3 ) { System . out . println ( a2 ) ; } else if ( a3 >= a1 && a3 >= a2 ) { System . out . println ( a3 ) ; } } } import java . util . * ; class Ctvpur { public static void main ( String [ ] args ) { int ctvpur = 0 ; int key = 0 ; int n = 0 ; Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; int [ ] A = new int [ n ] ; for ( int k = 0 ; k < n ; k ++ ) { A [ k ] = sc . nextInt ( ) ; } for ( int j = 1 ; j < A . length ; j ++ ) { key = A [ j ] ; ctvpur = j - 1 ; for ( int k = 0 ; k < A . length - 1 ; k ++ ) { System . out . printf ( " %d " , A [ k ] ) ; } System . out . printf ( " %d \n " , A [ A . length - 1 ] ) ; while ( ctvpur >= 0 && A [ ctvpur ] > key ) { A [ ctvpur + 1 ] = A [ ctvpur ] ; ctvpur -- ; } A [ ctvpur + 1 ] = key ; } for ( int k = 0 ; k < A . length - 1 ; k ++ ) { System . out . printf ( " %d " , A [ k ] ) ; } System . out . printf ( " %d \n " , A [ A . length - 1 ] ) ; } } import java . util . Scanner ; public class Bgyay { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int bgyay = Integer . parseInt ( scanner . nextLine ( ) ) ; char [ ] list = scanner . nextLine ( ) . toCharArray ( ) ; String temp = " ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ " ; char [ ] alph = temp . toCharArray ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < list . length ; i ++ ) { for ( int j = 0 ; j < 27 ; j ++ ) { if ( list [ i ] == alph [ j ] ) { list [ i ] = alph [ j + bgyay ] ; break ; } } } for ( char t : list ) { sb . append ( String . valueOf ( t ) ) ; } System . out . println ( sb . toString ( ) ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Nksrjka { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; char [ ] w = scanner . next ( ) . toCharArray ( ) ; scanner . close ( ) ; if ( w . length % 2 == 1 ) { System . out . println ( " No " ) ; return ; } Map < Character , Integer > map = new HashMap < > ( ) ; for ( char nksrjka : w ) { if ( map . containsKey ( nksrjka ) ) { map . put ( nksrjka , map . get ( nksrjka ) + 1 ) ; } else { map . put ( nksrjka , 1 ) ; } } for ( Integer v : map . values ( ) ) { if ( v % 2 != 0 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; public class Trkmxwe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String w = scan . nextLine ( ) ; String [ ] wArray = new String [ w . length ( ) ] ; for ( int trkmxwe = 0 ; trkmxwe < w . length ( ) ; trkmxwe ++ ) { wArray [ trkmxwe ] = w . substring ( trkmxwe , trkmxwe + 1 ) ; } List < String > wList = new ArrayList < String > ( Arrays . asList ( wArray ) ) ; List < String > wHashList = new ArrayList < String > ( new HashSet < > ( wList ) ) ; int sum = 0 ; for ( int trkmxwe = 0 ; trkmxwe < wHashList . size ( ) ; trkmxwe ++ ) { for ( int j = 0 ; j < w . length ( ) ; j ++ ) { if ( wHashList . get ( trkmxwe ) . equals ( w . substring ( j , j + 1 ) ) ) { sum ++ ; } } if ( sum % 2 == 1 ) { break ; } else { sum = 0 ; } } if ( sum % 2 == 1 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } scan . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Yjhoqt { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strArr = br . readLine ( ) . split ( " " ) ; double yjhoqt = Double . parseDouble ( strArr [ 0 ] ) ; double area = yjhoqt * yjhoqt * Math . PI ; double length = 2 * Math . PI * yjhoqt ; System . out . printf ( " %.6f %.6f \n " , area , length ) ; } } import java . io . InputStreamReader ; import java . io . BufferedReader ; import java . io . IOException ; class Akwwhcz { public static void main ( String [ ] args ) throws IOException { InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader bf = new BufferedReader ( is ) ; while ( true ) { String [ ] strAry = bf . readLine ( ) . split ( " " ) ; int akwwhcz = Integer . parseInt ( strAry [ 0 ] ) ; int w = Integer . parseInt ( strAry [ 1 ] ) ; if ( akwwhcz == 0 && w == 0 ) { break ; } for ( int i = 1 ; i <= akwwhcz ; i ++ ) { if ( i % 2 != 0 ) { for ( int j = 1 ; j <= w ; j ++ ) { if ( j % 2 != 0 ) System . out . print ( " # " ) ; else if ( j % 2 == 0 ) System . out . print ( " . " ) ; } } else if ( i % 2 == 0 ) { for ( int k = 1 ; k <= w ; k ++ ) { if ( k % 2 != 0 ) System . out . print ( " . " ) ; else if ( k % 2 == 0 ) System . out . print ( " # " ) ; } } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . Scanner ; public class Ypebeo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ypebeo = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; String s = sc . next ( ) ; for ( int i = 0 ; i < ypebeo ; i ++ ) { if ( i == K - 1 ) { System . out . print ( ( char ) ( s . charAt ( i ) - 'A' + 'a' ) ) ; } else { System . out . print ( s . charAt ( i ) ) ; } } } } import java . math . BigDecimal ; import java . util . Scanner ; class Gfsxxtx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int gfsxxtx = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; double f = 1.0 * gfsxxtx / y ; BigDecimal g = new BigDecimal ( f ) ; g = g . setScale ( 5 , BigDecimal . ROUND_HALF_UP ) ; System . out . printf ( gfsxxtx / y + " " + gfsxxtx % y + " " + " %.5f " , g ) ; } } import java . util . * ; public class Xlzjepf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xlzjepf = sc . nextInt ( ) ; int now = sc . nextInt ( ) ; int next = 0 ; int count = 0 ; int answer = 0 ; for ( int i = 0 ; i < xlzjepf - 1 ; i ++ ) { next = sc . nextInt ( ) ; if ( now >= next ) { count ++ ; } else { answer = Math . max ( answer , count ) ; count = 0 ; } now = next ; } answer = Math . max ( answer , count ) ; System . out . println ( answer ) ; sc . close ( ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Arlirb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int arlirb = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; ArrayList < Integer > arrayList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < arlirb ; i ++ ) { arrayList . add ( sc . nextInt ( ) ) ; } int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { int idx = 0 ; int min = 999999 ; for ( int j = 0 ; j < arrayList . size ( ) ; j ++ ) { if ( arrayList . get ( j ) < min ) { idx = j ; min = arrayList . get ( j ) ; } } sum += arrayList . get ( idx ) ; arrayList . remove ( idx ) ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Zgiec { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String [ ] input = sc . nextLine ( ) . split ( " " ) ; Result r = renzokuNum ( input ) ; switch ( r ) { case Good : System . out . println ( " Good " ) ; break ; default : System . out . println ( " Bad " ) ; break ; } } } private static Result renzokuNum ( String [ ] input ) { for ( int zgiec = 0 ; zgiec < input . length - 1 ; zgiec ++ ) { if ( input [ zgiec ] . equals ( input [ zgiec + 1 ] ) ) { return Result . Bad ; } } return Result . Good ; } enum Result { Good , Bad } } import java . util . * ; class Lbywyr { Scanner sc ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { int lbywyr = sc . nextInt ( ) ; int [ ] d = new int [ lbywyr ] ; for ( int i = 0 ; i < lbywyr ; i ++ ) d [ i ] = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < lbywyr - 1 ; i ++ ) { for ( int j = i + 1 ; j < lbywyr ; j ++ ) { sum += d [ i ] * d [ j ] ; } } System . out . println ( sum ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . * ; public class Zhyrnwi { Scanner sc = new Scanner ( System . in ) ; int zhyrnwi , b , c , d , e , f , k , l , m , n , x , y , z ; int ans ; String [ ] S ; Main ( ) { n = sc . nextInt ( ) ; zhyrnwi = sc . nextInt ( ) ; b = sc . nextInt ( ) ; System . out . println ( Math . min ( zhyrnwi * n , b ) ) ; } public static void main ( String [ ] args ) { new Main ( ) ; } } import java . util . * ; public class Tzqyhjr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tzqyhjr = sc . nextInt ( ) ; int [ ] A = new int [ tzqyhjr ] ; for ( int i = 0 ; i < tzqyhjr ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int cnt = 0 , tmp = 0 ; for ( int i = 0 ; i < tzqyhjr - 1 ; i ++ ) { for ( int j = tzqyhjr - 1 ; j > i ; j -- ) { if ( A [ j ] < A [ j - 1 ] ) { tmp = A [ j ] ; A [ j ] = A [ j - 1 ] ; A [ j - 1 ] = tmp ; cnt ++ ; } } } for ( int i = 0 ; i < tzqyhjr ; i ++ ) { if ( i == tzqyhjr - 1 ) { System . out . print ( A [ i ] ) ; } else { System . out . print ( A [ i ] + " " ) ; } } System . out . println ( ) ; System . out . println ( cnt ) ; } } import java . util . * ; import java . io . * ; public class Gmnbzgd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gmnbzgd = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; int diff = 1 ; char prev = s . charAt ( 0 ) ; for ( int i = 0 ; i < gmnbzgd ; i ++ ) { if ( s . charAt ( i ) != prev ) { diff ++ ; } prev = s . charAt ( i ) ; } System . out . println ( diff ) ; } } import java . util . * ; public class Cmaxmmb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; String [ ] nums = input . split ( " " ) ; int cmaxmmb = Integer . parseInt ( nums [ 0 ] ) ; int A = Integer . parseInt ( nums [ 1 ] ) ; int B = Integer . parseInt ( nums [ 2 ] ) ; System . out . println ( cmaxmmb * A < B ? cmaxmmb * A : B ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; class Ydhvk { public static long gcd ( long ydhvk , long b ) { if ( b == 0 ) return ydhvk ; return gcd ( b , ydhvk % b ) ; } public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; long ydhvk = s . nextLong ( ) ; long b = s . nextLong ( ) ; long k = gcd ( ydhvk , b ) ; System . out . println ( ( ydhvk * b ) / k ) ; } } import java . util . * ; public class Wpryqa { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int wpryqa = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int count = 0 ; int compare = 0 ; for ( int i = wpryqa ; i > 0 ; i -- ) { compare = 0 ; List < String > split = Arrays . asList ( String . valueOf ( i ) . split ( " " ) ) ; for ( int j = 0 ; j < split . size ( ) ; j ++ ) { compare += Integer . parseInt ( split . get ( j ) ) ; } if ( b <= compare && compare <= c ) { count += i ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Qzmkgme { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int qzmkgme = scanner . nextInt ( ) ; final int b = scanner . nextInt ( ) ; final int value = Integer . parseInt ( Integer . toString ( qzmkgme ) + Integer . toString ( b ) ) ; final int lowerSqrt = ( int ) Math . sqrt ( value ) ; if ( value % lowerSqrt == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Xcquwn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xcquwn = sc . nextInt ( ) ; String [ ] s = new String [ xcquwn ] ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; long result = 0 ; for ( int i = 0 ; i < xcquwn ; i ++ ) { s [ i ] = sc . next ( ) ; char [ ] ch = s [ i ] . toCharArray ( ) ; Arrays . sort ( ch ) ; String sch = new String ( ch ) ; if ( map . containsKey ( sch ) ) { map . replace ( sch , map . get ( sch ) + 1 ) ; result += map . get ( sch ) ; } else { map . put ( sch , 0 ) ; } } System . out . println ( result ) ; sc . close ( ) ; } } import java . io . * ; import java . util . StringTokenizer ; public class Envtb { public static void main ( String [ ] args ) throws IOException { int envtb ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; StringTokenizer st = new StringTokenizer ( s , " " ) ; int a = Integer . parseInt ( st . nextToken ( ) ) ; int b = Integer . parseInt ( st . nextToken ( ) ) ; int c = Integer . parseInt ( st . nextToken ( ) ) ; if ( a > b ) { envtb = a ; a = b ; b = envtb ; } if ( b > c ) { envtb = b ; b = c ; c = envtb ; } if ( a > b ) { envtb = a ; a = b ; b = envtb ; } System . out . println ( a + " " + b + " " + c ) ; } } import java . util . Scanner ; class Emaausg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long emaausg = scanner . nextLong ( ) ; long r = scanner . nextLong ( ) ; scanner . close ( ) ; int count = 0 ; while ( emaausg >= r ) { count += 1 ; emaausg = emaausg / r ; } System . out . println ( count + 1 ) ; } } import java . util . Scanner ; public class Xbikme { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long xbikme = sc . nextLong ( ) ; long R = sc . nextLong ( ) ; final int divide = 2019 ; long ans = 1000000000 ; if ( R - xbikme >= 2019 ) System . out . println ( 0 ) ; else { for ( long i = xbikme ; i < R ; i ++ ) { for ( long j = i + 1 ; j <= R ; j ++ ) { ans = Math . min ( ans , ( i * j ) % divide ) ; } } System . out . println ( ans ) ; } } } import java . io . BufferedReader ; import java . io . * ; import java . util . * ; import java . util . ArrayList ; import java . util . Iterator ; import java . util . List ; import java . util . Collections ; import java . util . Arrays ; public class Gbsyyv { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final List < Integer > list = new ArrayList < > ( ) ; int gbsyyv = sc . nextInt ( ) ; int s1 = 0 ; int s2 = 0 ; int min = 10001 ; for ( int i = 0 ; i < gbsyyv ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } for ( int i = 0 ; i < gbsyyv ; i ++ ) { for ( int j = 0 ; j < gbsyyv ; j ++ ) { if ( j <= i ) { s1 += list . get ( j ) ; } else { s2 += list . get ( j ) ; } } if ( min >= Math . abs ( s1 - s2 ) ) { min = Math . abs ( s1 - s2 ) ; } s1 = 0 ; s2 = 0 ; } System . out . println ( min ) ; } } import java . math . BigInteger ; import java . util . Scanner ; class Gfzxat { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] arg = sc . nextLine ( ) . split ( " " ) ; int gfzxat = Integer . parseInt ( arg [ 0 ] ) ; String d = arg [ 1 ] ; int count = 0 ; for ( int i = 0 ; i < gfzxat ; i ++ ) { String [ ] value = sc . nextLine ( ) . split ( " " ) ; BigInteger x = new BigInteger ( value [ 0 ] ) ; BigInteger y = new BigInteger ( value [ 1 ] ) ; BigInteger xs = x . multiply ( x ) ; BigInteger ys = y . multiply ( y ) ; BigInteger comp = xs . add ( ys ) ; BigInteger dd = new BigInteger ( d ) ; BigInteger ds = dd . multiply ( dd ) ; if ( comp . compareTo ( ds ) <= 0 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class Etotvk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int etotvk = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int x = 0 ; int count = 0 ; int y = 0 ; int z = 0 ; Set < Integer > al = new HashSet < > ( ) ; for ( int i = 0 ; i <= etotvk ; i ++ ) { al . add ( i ) ; } for ( int i = 0 ; i <= etotvk ; i ++ ) { for ( int j = 0 ; j <= etotvk ; j ++ ) { if ( al . contains ( s - i - j ) ) { count ++ ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; class Nvymmxn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int nvymmxn = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int x = scanner . nextInt ( ) ; int y = scanner . nextInt ( ) ; int sum = 0 ; if ( nvymmxn + b < c * 2 ) { sum = nvymmxn * x + b * y ; System . out . println ( sum ) ; } else { while ( x >= 1 && y >= 1 ) { sum += c * 2 ; x -- ; y -- ; } int sum2 = sum ; sum += nvymmxn * x + b * y ; if ( nvymmxn > c * 2 || b > c * 2 ) { while ( x >= 1 || y >= 1 ) { sum2 += c * 2 ; x -- ; y -- ; } x = 0 ; y = 0 ; } sum2 += nvymmxn * x + b * y ; if ( sum < sum2 ) { System . out . println ( sum ) ; } else { System . out . println ( sum2 ) ; } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Xcoqt { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int xcoqt = Integer . parseInt ( br . readLine ( ) ) ; String [ ] string = br . readLine ( ) . split ( " " ) ; int [ ] Progression = new int [ xcoqt ] ; for ( int i = 0 ; i < xcoqt ; i ++ ) { Progression [ i ] = Integer . parseInt ( string [ i ] ) ; } for ( int k = 0 ; k < xcoqt ; k ++ ) { System . out . print ( Progression [ k ] ) ; if ( k < xcoqt - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; int v ; for ( int i = 1 ; i < xcoqt ; i ++ ) { v = Progression [ i ] ; int j = i - 1 ; while ( j >= 0 && Progression [ j ] > v ) { Progression [ j + 1 ] = Progression [ j ] ; j -- ; } Progression [ j + 1 ] = v ; for ( int k = 0 ; k < xcoqt ; k ++ ) { System . out . print ( Progression [ k ] ) ; if ( k < xcoqt - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } } import java . util . * ; public class Vjijqqo { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; double vjijqqo = in . nextDouble ( ) ; double B = in . nextDouble ( ) ; double ho = in . nextDouble ( ) ; double mi = in . nextDouble ( ) ; double rad = 60 / mi ; double radMi = 360 / rad ; double radiHo = ( ho * 30 ) + ( 30 / rad ) ; double radian = 0 ; if ( radiHo > radMi ) { radian = radiHo - radMi ; } else { radian = radMi - radiHo ; } double result = ( vjijqqo * vjijqqo ) + ( B * B ) - 2 * vjijqqo * B * Math . cos ( Math . toRadians ( radian ) ) ; double ans = Math . sqrt ( result ) ; System . out . println ( ans ) ; } } public class Yiwtis { public static void main ( String [ ] args ) { java . util . Scanner scan = new java . util . Scanner ( System . in ) ; int yiwtis = scan . nextInt ( ) ; int H = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; int r = scan . nextInt ( ) ; if ( - 100 <= x && x <= 100 && - 100 <= y && y <= 100 && 0 < r && r <= 100 && 0 < yiwtis && yiwtis <= 100 && 0 < H && H <= 100 ) { if ( yiwtis >= ( x + r ) && H >= ( y + r ) && ( y + r ) > 0 && ( x + r ) > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class Uhwwkm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uhwwkm = sc . nextInt ( ) ; long result = 0 ; for ( int i = 1 ; i <= uhwwkm ; i ++ ) { for ( int j = i ; j <= uhwwkm ; j ++ ) { for ( int k = j ; k <= uhwwkm ; k ++ ) { boolean judge = true ; for ( int l = i ; l > 0 && judge ; l -- ) { if ( i % l == 0 && j % l == 0 && k % l == 0 ) { judge = false ; if ( i == j && j == k ) { result += l ; } else if ( i != j && j != k && i != k ) { result += ( l * 6 ) ; } else { result += ( l * 3 ) ; } } } } } } System . out . println ( result ) ; } } import java . io . IOException ; import java . util . NoSuchElementException ; import java . io . BufferedReader ; import java . io . InputStream ; import java . io . InputStreamReader ; public class Dmuvcas { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { final String s = reader . readLine ( ) ; int dmuvcas = 200001 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'A' ) { dmuvcas = i ; break ; } } int atZ = - 1 ; for ( int i = s . length ( ) - 1 ; 0 <= i ; i -- ) { if ( s . charAt ( i ) == 'Z' ) { atZ = i ; break ; } } System . out . println ( atZ - dmuvcas + 1 ) ; } } } import java . util . * ; public class Umgnv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( Math . pow ( sc . nextDouble ( ) / 3 , 3 ) ) ; } static long factorial ( long num ) { if ( num < 2 ) return 1 ; else return num * factorial ( num - 1 ) ; } static int arraySum ( int [ ] array ) { int umgnv = 0 ; for ( int value : array ) umgnv += value ; return umgnv ; } static long combination ( long a , long b ) { long data = 1 ; for ( int i = 0 ; i < b ; i ++ ) { data *= a - i ; } return data / factorial ( b ) ; } static double log ( double base , double antilogarithm ) { return Math . log ( antilogarithm ) / Math . log ( base ) ; } static long gcd ( long x , long y ) { if ( y == 0 ) return x ; else return gcd ( y , x % y ) ; } static long lcm ( long x , long y ) { return x / gcd ( x , y ) * y ; } static HashMap < Long , Long > factorization ( long num ) { HashMap < Long , Long > hash = new HashMap < > ( ) ; long n = num ; long count = 2 ; while ( n > 1 ) { while ( n % count == 0 ) { n /= count ; if ( hash . containsKey ( count ) ) hash . put ( count , hash . get ( count ) + 1 ) ; else hash . put ( count , 1L ) ; } count ++ ; } return hash ; } } import java . util . Scanner ; public class Bjgmyg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int bjgmyg = scanner . nextInt ( ) ; int Q = scanner . nextInt ( ) ; String S = scanner . next ( ) ; int [ ] a = new int [ Q ] ; int [ ] b = new int [ Q ] ; for ( int i = 0 ; i < Q ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; b [ i ] = scanner . nextInt ( ) ; } int [ ] t = new int [ bjgmyg + 1 ] ; String find = " AC " ; for ( int i = 0 ; i < bjgmyg ; i ++ ) { if ( i == 0 ) { t [ i ] = 0 ; } if ( i >= 1 && S . substring ( i - 1 , i + 1 ) . equals ( find ) ) { t [ i ] = 1 ; } else { t [ i ] = 0 ; } } int [ ] s = new int [ bjgmyg + 1 ] ; for ( int i = 0 ; i < bjgmyg ; i ++ ) { if ( i == 0 ) { s [ i ] = t [ i ] ; } else { s [ i ] = t [ i ] + s [ i - 1 ] ; } } for ( int i = 0 ; i < Q ; i ++ ) { System . out . println ( s [ b [ i ] - 1 ] - s [ a [ i ] - 1 ] ) ; } } } import java . util . Scanner ; class Eiuhob { int eiuhob ; int [ ] d ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Main m = new Main ( sc ) ; m . solve ( ) ; sc . close ( ) ; } Main ( Scanner sc ) { eiuhob = sc . nextInt ( ) ; d = new int [ eiuhob ] ; for ( int i = 0 ; i < eiuhob ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } } void solve ( ) { boolean [ ] cnt = new boolean [ 100 ] ; for ( int i = 0 ; i < eiuhob ; i ++ ) { cnt [ d [ i ] - 1 ] = true ; } int dan = 0 ; for ( boolean f : cnt ) { if ( f ) dan ++ ; } System . out . println ( dan ) ; } } import java . util . * ; public class Kmkomgn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kmkomgn = sc . nextInt ( ) ; int b = 0 ; int [ ] d = new int [ kmkomgn ] ; int [ ] e = new int [ kmkomgn ] ; for ( int i = 0 ; i < kmkomgn ; i ++ ) { d [ i ] = sc . nextInt ( ) ; d [ i ] -- ; e [ d [ i ] ] = i + 1 ; } for ( int i = 0 ; i < kmkomgn ; i ++ ) { System . out . print ( e [ i ] + " " ) ; } } } import java . util . * ; class Gicghnq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int gicghnq = 0 ; gicghnq < 3 ; gicghnq ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { c [ gicghnq ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] d = new int [ 3 ] [ 2 ] ; for ( int gicghnq = 0 ; gicghnq < 3 ; gicghnq ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { d [ gicghnq ] [ j ] = c [ gicghnq ] [ j + 1 ] - c [ gicghnq ] [ j ] ; } } if ( d [ 0 ] [ 0 ] == d [ 1 ] [ 0 ] && d [ 1 ] [ 0 ] == d [ 2 ] [ 0 ] && d [ 0 ] [ 1 ] == d [ 1 ] [ 1 ] && d [ 1 ] [ 1 ] == d [ 2 ] [ 1 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; class Xzosn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xzosn = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( W >= xzosn ) System . out . println ( " unsafe " ) ; else System . out . println ( " safe " ) ; } } import java . util . * ; public class Fnmgf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fnmgf = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; boolean zero = false ; if ( fnmgf - R >= 2019 ) zero = true ; for ( int i = fnmgf ; i < R ; i ++ ) { if ( i % 2019 == 0 ) { zero = true ; break ; } } fnmgf = fnmgf % 2019 ; R = R % 2019 ; int min = 2017 * 2018 ; if ( ! zero ) { for ( int i = fnmgf ; i < R ; i ++ ) { for ( int k = i + 1 ; k <= R ; k ++ ) { if ( min > ( i * k ) % 2019 ) min = ( i * k ) % 2019 ; } } } if ( zero ) System . out . println ( 0 ) ; else System . out . println ( min ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Xuqsw { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int xuqsw = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; int d = 0 ; ArrayList < ArrayList < Integer > > arraylist = new ArrayList < ArrayList < Integer > > ( xuqsw ) ; for ( int i = 0 ; i < xuqsw ; i ++ ) { arraylist . add ( new ArrayList < Integer > ( ) ) ; } for ( int i = 0 ; i < ( 2 * K ) ; i ++ ) { if ( i % 2 == 0 ) { d = scanner . nextInt ( ) ; } else { for ( int s = 0 ; s < d ; s ++ ) { arraylist . get ( scanner . nextInt ( ) - 1 ) . add ( i ) ; } } } int count = 0 ; for ( int i = 0 ; i < xuqsw ; i ++ ) { if ( arraylist . get ( i ) . size ( ) == 0 ) { count += 1 ; } } System . out . println ( count ) ; } } import java . util . * ; public class Aavmcjb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aavmcjb = sc . nextInt ( ) ; int [ ] arr = new int [ aavmcjb ] ; for ( int x = 0 ; x < arr . length ; x ++ ) { arr [ x ] = sc . nextInt ( ) ; } boolean f = true ; Arrays . sort ( arr ) ; for ( int x = 0 ; x < arr . length - 1 ; x ++ ) { if ( arr [ x ] == arr [ x + 1 ] ) f = false ; } if ( f == true ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . Scanner ; import java . io . PrintWriter ; class Aqhay { static String blackjack ( int aqhay , int a2 , int a3 ) { if ( aqhay + a2 + a3 <= 21 ) { return " win " ; } return " bust " ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int aqhay = Integer . parseInt ( sc . next ( ) ) ; int a2 = Integer . parseInt ( sc . next ( ) ) ; int a3 = Integer . parseInt ( sc . next ( ) ) ; out . println ( blackjack ( aqhay , a2 , a3 ) ) ; out . flush ( ) ; } } import java . util . * ; public class Toysxw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String toysxw = scan . nextLine ( ) ; scan . close ( ) ; switch ( toysxw . charAt ( toysxw . length ( ) - 1 ) ) { case '2' : case '4' : case '5' : case '7' : case '9' : System . out . println ( " hon " ) ; break ; case '0' : case '1' : case '6' : case '8' : System . out . println ( " pon " ) ; break ; case '3' : System . out . println ( " bon " ) ; break ; default : break ; } } } import java . util . * ; public class Knnij { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int knnij = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ knnij ] ; for ( int i = 0 ; i < knnij ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int result = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { while ( a [ i ] % 2 == 0 ) { a [ i ] /= 2 ; result ++ ; } } System . out . println ( result ) ; sc . close ( ) ; } } import java . util . * ; public class Pkyln { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String pkyln = sc . next ( ) ; String str2 = pkyln . toLowerCase ( ) ; if ( pkyln . equals ( str2 ) ) { System . out . println ( " a " ) ; } else { System . out . println ( " A " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; public class Xzdlbc { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; char [ ] c = br . readLine ( ) . toCharArray ( ) ; System . out . println ( ++ c [ 0 ] ) ; } } import java . util . * ; public class Uleqm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uleqm = Integer . parseInt ( sc . next ( ) ) ; Map < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 1 ; i <= uleqm ; i ++ ) { map . put ( Integer . parseInt ( sc . next ( ) ) , i ) ; } StringBuilder builder = new StringBuilder ( ) ; for ( int i = 1 ; i <= uleqm ; i ++ ) { builder . append ( map . get ( i ) ) . append ( " " ) ; } System . out . println ( builder . toString ( ) ) ; } } import java . util . Scanner ; public class Mtkcc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long mtkcc = 0 ; long answer = 0 ; double limit = 0.0 ; mtkcc = scan . nextLong ( ) ; answer = mtkcc ; limit = Math . sqrt ( mtkcc ) ; for ( int i = 1 ; i <= limit ; i ++ ) { if ( mtkcc % i == 0 && ( mtkcc / i ) + i - 2 < answer ) { answer = ( mtkcc / i ) + i - 2 ; } } System . out . println ( answer ) ; } } import java . util . Scanner ; class Qzhsywf { public static final String SEVEN = " 7 " ; public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qzhsywf = scan . nextInt ( ) ; scan . close ( ) ; String numN = String . valueOf ( qzhsywf ) ; String charN = null ; for ( int i = 0 ; i < numN . length ( ) ; i ++ ) { if ( i != ( numN . length ( ) - 1 ) ) { charN = numN . substring ( i , i + 1 ) ; } else { charN = numN . substring ( i ) ; } if ( SEVEN . equals ( charN ) ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Cbyxib { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { char [ ] charStr = br . readLine ( ) . toCharArray ( ) ; StringBuilder rvsStr = new StringBuilder ( ) ; for ( int cbyxib = charStr . length - 1 ; cbyxib > - 1 ; cbyxib -- ) rvsStr . append ( charStr [ cbyxib ] ) ; System . out . println ( rvsStr ) ; } } } import java . util . Scanner ; class Xesrw { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int xesrw ; int i = 1 ; while ( true ) { xesrw = scan . nextInt ( ) ; ; if ( xesrw != 0 ) { System . out . println ( " Case " + " " + i + " : " + " " + xesrw ) ; i ++ ; } else { break ; } } } } import java . util . Scanner ; class Awthgp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int awthgp = sc . nextInt ( ) ; String s = sc . next ( ) ; char before = '0' ; int count = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c != before ) { before = c ; count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Rnzijhc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rnzijhc = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] l = new int [ rnzijhc ] ; int d = 0 ; int i = 0 ; for ( int cnt = 0 ; cnt < rnzijhc ; cnt ++ ) { l [ cnt ] = sc . nextInt ( ) ; d += l [ cnt ] ; if ( d > x ) { i = cnt + 1 ; break ; } else { i = rnzijhc + 1 ; } } System . out . println ( i ) ; sc . close ( ) ; } } import java . util . * ; import java . io . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Ootuqeo { static Scanner sc = new Scanner ( in ) ; public static void main ( String [ ] args ) { int ootuqeo = sc . nextInt ( ) ; int [ ] d = new int [ ootuqeo ] ; int ans = 0 ; for ( int i = 0 ; i < ootuqeo ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; ans = max ( 0 , d [ ootuqeo / 2 ] - d [ ootuqeo / 2 - 1 ] ) ; out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class Djqtwz { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int djqtwz = Integer . parseInt ( br . readLine ( ) ) ; String [ ] tmpArray = br . readLine ( ) . split ( " " ) ; int [ ] input = new int [ djqtwz ] ; for ( int i = 0 ; i < djqtwz ; i ++ ) { input [ djqtwz - i - 1 ] = Integer . parseInt ( tmpArray [ i ] ) ; } System . out . print ( input [ 0 ] ) ; for ( int i = 1 ; i < djqtwz ; i ++ ) { System . out . print ( " " + input [ i ] ) ; } System . out . println ( ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Lyezsn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] ss = S . toCharArray ( ) ; ArrayList < Integer > ans = new ArrayList < > ( ) ; int lyezsn = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( ss [ i ] == 'A' || ss [ i ] == 'C' || ss [ i ] == 'G' || ss [ i ] == 'T' ) { lyezsn ++ ; } else { ans . add ( lyezsn ) ; lyezsn = 0 ; } } ans . add ( lyezsn ) ; Collections . sort ( ans , Collections . reverseOrder ( ) ) ; System . out . println ( ans . get ( 0 ) ) ; } } import java . util . * ; public class Tqhtre { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; LinkedList < Integer > ll = new LinkedList < > ( ) ; int tqhtre = 999 ; int x = 999 ; int cnt = 0 ; while ( tqhtre != 0 || x != 0 ) { tqhtre = sc . nextInt ( ) ; x = sc . nextInt ( ) ; int ans = 0 ; if ( tqhtre == 0 && x == 0 ) { break ; } else { cnt ++ ; for ( int i = 1 ; i <= tqhtre ; i ++ ) { for ( int j = 1 ; j < i ; j ++ ) { for ( int k = 1 ; k < j ; k ++ ) { if ( i + k + j == x ) { ans ++ ; } } } } ll . add ( ans ) ; } } for ( int i = 0 ; i < cnt ; i ++ ) { System . out . println ( ll . get ( i ) ) ; } } } import java . util . * ; public class Pqjrs { static final int pqjrs = 1000000007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double w = sc . nextInt ( ) ; double h = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int result = 0 ; if ( x * 2 == w && y * 2 == h ) { result ++ ; } System . out . println ( ( w * h / 2.0 ) + " " + result ) ; } } import java . util . Scanner ; class Xafqti { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int xafqti = stdIn . nextInt ( ) ; int y = stdIn . nextInt ( ) ; int z = stdIn . nextInt ( ) ; int temp ; if ( xafqti > y ) { temp = xafqti ; xafqti = y ; y = temp ; } if ( xafqti > z ) { temp = xafqti ; xafqti = z ; z = temp ; } if ( y > z ) { temp = z ; z = y ; y = temp ; } System . out . printf ( " %d %d %d \n " , xafqti , y , z ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Phjpq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int phjpq = Integer . parseInt ( sc . next ( ) ) ; ArrayList < String > shiritoriList = new ArrayList < > ( ) ; for ( int i = 0 ; i < phjpq ; i ++ ) { shiritoriList . add ( sc . next ( ) ) ; } sc . close ( ) ; ArrayList < String > checkList = new ArrayList < > ( ) ; for ( int i = 0 ; i < shiritoriList . size ( ) ; i ++ ) { String word = shiritoriList . get ( i ) ; if ( i != 0 ) { String formerWords = shiritoriList . get ( i - 1 ) ; char lastWord = formerWords . charAt ( formerWords . length ( ) - 1 ) ; if ( lastWord != word . charAt ( 0 ) ) { System . out . println ( " No " ) ; return ; } if ( checkList . contains ( word ) ) { System . out . println ( " No " ) ; return ; } } checkList . add ( word ) ; } System . out . println ( " Yes " ) ; return ; } } import java . util . * ; import java . lang . * ; import java . awt . * ; class Fdlkl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] t = new int [ 26 ] ; while ( sc . hasNext ( ) ) { String s = sc . nextLine ( ) ; for ( int fdlkl = 0 ; fdlkl < s . length ( ) ; fdlkl ++ ) { int countval = s . toLowerCase ( ) . codePointAt ( fdlkl ) - 97 ; if ( countval >= 0 ) t [ countval ] ++ ; } } for ( int a = 0 ; a < t . length ; a ++ ) { System . out . println ( String . format ( " %s : %d " , ( char ) ( a + 97 ) , t [ a ] ) ) ; } } } import java . io . * ; import java . util . Arrays ; import java . util . Scanner ; public class Yxmkj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String fst = br . readLine ( ) ; int yxmkj = Integer . parseInt ( fst ) ; if ( yxmkj == 0 ) { break ; } String line = br . readLine ( ) ; String [ ] str = line . split ( " " ) ; double [ ] s = new double [ str . length ] ; for ( int j = 0 ; j < yxmkj ; j ++ ) { s [ j ] = Double . parseDouble ( str [ j ] ) ; } double sum = 0.0 ; for ( int j = 0 ; j < yxmkj ; j ++ ) { sum += s [ j ] ; } double num = yxmkj ; double avr = sum / num ; double a = 0.0 ; for ( int j = 0 ; j < yxmkj ; j ++ ) { a += ( s [ j ] - avr ) * ( s [ j ] - avr ) ; } a /= num ; a = Math . sqrt ( a ) ; System . out . printf ( " %.6f \n " , a ) ; } } } import java . util . * ; public class Kditimn { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int kditimn = in . nextInt ( ) ; Integer [ ] nam = new Integer [ kditimn ] ; int max1 = 0 ; int max2 = 0 ; for ( int i = 0 ; i < kditimn ; i ++ ) { nam [ i ] = in . nextInt ( ) ; } Integer [ ] nam2 = nam . clone ( ) ; Arrays . sort ( nam , Collections . reverseOrder ( ) ) ; max1 = nam [ 0 ] ; max2 = nam [ 1 ] ; for ( int i = 0 ; i < kditimn ; i ++ ) { if ( nam2 [ i ] != max1 ) { System . out . println ( max1 ) ; } else { System . out . println ( max2 ) ; } } } } import java . util . * ; public class Vyhxc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vyhxc = Integer . parseInt ( sc . next ( ) ) ; int L = Integer . parseInt ( sc . next ( ) ) ; int [ ] appleValue = new int [ vyhxc ] ; int sum = 0 ; int a = 0 ; int min = 9999 ; for ( int i = 0 ; i < vyhxc ; i ++ ) { int value = L + i ; appleValue [ i ] = value ; sum += appleValue [ i ] ; if ( min > Math . abs ( value ) ) { min = Math . abs ( value ) ; a = value ; } } System . out . println ( sum - a ) ; } } import java . util . * ; public class Wttxq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long wttxq = sc . nextLong ( ) ; long min = ( long ) 999999999999.0 ; for ( long i = 1 ; i <= Math . sqrt ( wttxq ) ; i ++ ) if ( wttxq % i == 0 && min > ( i - 1 ) + ( wttxq / i ) - 1 ) min = ( i - 1 ) + ( wttxq / i ) - 1 ; System . out . println ( min ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Blvfvtg { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String str = br . readLine ( ) ; StringTokenizer st = new StringTokenizer ( str , " " ) ; int blvfvtg = Integer . parseInt ( st . nextToken ( ) ) ; String op = st . nextToken ( ) ; int b = Integer . parseInt ( st . nextToken ( ) ) ; int ans = 0 ; if ( op . equals ( " + " ) ) { ans = blvfvtg + b ; System . out . println ( ans ) ; } else if ( op . equals ( " - " ) ) { ans = blvfvtg - b ; System . out . println ( ans ) ; } else if ( op . equals ( " * " ) ) { ans = blvfvtg * b ; System . out . println ( ans ) ; } else if ( op . equals ( " / " ) ) { ans = blvfvtg / b ; System . out . println ( ans ) ; } else if ( op . equals ( " ? " ) ) { break ; } } } } import java . util . * ; public class Kicecce { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kicecce = Integer . parseInt ( scan . next ( ) ) ; int [ ] lst = new int [ kicecce ] ; int ans = 0 ; for ( int i = 0 ; i < kicecce ; i ++ ) { lst [ i ] = Integer . parseInt ( scan . next ( ) ) ; } for ( int i = 0 ; i < kicecce - 2 ; i ++ ) { if ( ( lst [ i + 1 ] < lst [ i ] && lst [ i + 2 ] < lst [ i + 1 ] ) || ( lst [ i + 1 ] > lst [ i ] && lst [ i + 2 ] > lst [ i + 1 ] ) ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Mzvpsb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mzvpsb = sc . nextLong ( ) ; mzvpsb -- ; String result = " " ; String alp = " abcdefghijklmnopqrstuvwxyz " ; while ( true ) { long syou = mzvpsb / alp . length ( ) ; long mod = mzvpsb % alp . length ( ) ; String tmp = alp . substring ( ( int ) mod , ( int ) mod + 1 ) ; result = tmp + result ; mzvpsb = syou - 1 ; if ( syou == 0 ) { break ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class Buefwr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int buefwr = sc . nextInt ( ) ; final int B = sc . nextInt ( ) ; final int C = sc . nextInt ( ) ; final int X = sc . nextInt ( ) ; final int Y = sc . nextInt ( ) ; final int min = Math . min ( X , Y ) ; final int max = Math . max ( X , Y ) ; System . out . println ( Math . min ( Math . min ( buefwr + B , 2 * C ) * min + buefwr * ( X - min ) + B * ( Y - min ) , max * 2 * C ) ) ; } } import java . util . Scanner ; public class Gaksvp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gaksvp = sc . nextInt ( ) ; int c = 0 ; int prev = 0 ; int max = 0 ; for ( int i = 0 ; i < gaksvp ; i ++ ) { int b = sc . nextInt ( ) ; if ( prev >= b ) { c ++ ; max = Math . max ( c , max ) ; } else { c = 0 ; } prev = b ; } System . out . println ( max ) ; } } import java . util . Scanner ; public class Txcrd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int txcrd = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int Aval , Bval ; for ( int i = 1 ; i <= 1000 ; i ++ ) { Aval = ( int ) ( i * 0.08 ) ; Bval = ( int ) ( i * 0.1 ) ; if ( txcrd == Aval && B == Bval ) { System . out . println ( i ) ; System . exit ( 0 ) ; } } System . out . println ( - 1 ) ; sc . close ( ) ; } } import java . util . * ; class Sqryqkg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sqryqkg = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Ans = 0 ; int Max = Math . max ( sqryqkg , B ) ; Max = Math . max ( Max , C ) ; double pow = Math . pow ( 2 , K ) ; if ( Max == sqryqkg ) { Ans = ( sqryqkg * ( int ) pow ) + B + C ; } else if ( Max == B ) { Ans = ( B * ( ( int ) pow ) ) + sqryqkg + C ; } else { Ans = ( C * ( ( int ) pow ) ) + sqryqkg + B ; } System . out . println ( Ans ) ; } } import java . util . Scanner ; public class Occxqkt { public static void main ( final String ... args ) { final String mode = " b " ; if ( mode . equals ( " a " ) ) { A . solve ( ) ; } else if ( mode . equals ( " b " ) ) { B . solve ( ) ; } } } class Occxqkt { static void solve ( ) { final Scanner sc = new Scanner ( System . in ) ; final int occxqkt = sc . nextInt ( ) ; final int d = sc . nextInt ( ) ; final int res = calc ( occxqkt , d ) ; System . out . println ( res ) ; } static int calc ( final int occxqkt , final int d ) { final int max = ( 2 * d + 1 ) ; int res = occxqkt / max ; if ( occxqkt % max != 0 ) { res += 1 ; } return res ; } } class Occxqkt { static void solve ( ) { final Scanner sc = new Scanner ( System . in ) ; final int r = sc . nextInt ( ) ; final int res = calc ( r ) ; System . out . println ( res ) ; } static int calc ( final int r ) { return 3 * r * r ; } } import java . util . Scanner ; public class Oyfwew { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oyfwew = sc . nextInt ( ) ; int migi = oyfwew % 100 ; int hidari = ( oyfwew - migi ) / 100 ; if ( migi == 0 && hidari == 0 ) { System . out . println ( " NA " ) ; } else if ( hidari > 12 && migi > 12 ) { System . out . println ( " NA " ) ; } else if ( hidari > 12 && migi == 0 ) { System . out . println ( " NA " ) ; } else if ( hidari == 0 && migi > 12 ) { System . out . println ( " NA " ) ; } else if ( hidari > 0 && hidari <= 12 && migi > 0 && migi <= 12 ) { System . out . println ( " AMBIGUOUS " ) ; } else if ( hidari > 0 && hidari <= 12 && migi > 12 ) { System . out . println ( " MMYY " ) ; } else if ( hidari > 0 && hidari <= 12 && migi == 00 ) { System . out . println ( " MMYY " ) ; } else { System . out . println ( " YYMM " ) ; } } } import java . util . Scanner ; public class Ssmsrvd { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int ssmsrvd = scn . nextInt ( ) ; int a = ssmsrvd / 100 ; int b = ( ssmsrvd % 100 ) / 10 ; int c = ssmsrvd % 10 ; int ans = 0 ; if ( a == 9 ) { ans += 100 ; } else if ( a == 1 ) { ans += 900 ; } else { ans += 100 * a ; } if ( b == 9 ) { ans += 10 ; } else if ( b == 1 ) { ans += 90 ; } else { ans += 10 * b ; } if ( c == 9 ) { ans += 1 ; } else if ( c == 1 ) { ans += 9 ; } else { ans += 1 * c ; } System . out . println ( ans ) ; } } import java . util . * ; class Staqw { public static void main ( String [ ] args ) { ArrayList < Integer > list = new ArrayList < Integer > ( ) ; Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { list . add ( String . format ( " %d " , Math . abs ( sc . nextInt ( ) + sc . nextInt ( ) ) ) . length ( ) ) ; } for ( int staqw = 0 , size = list . size ( ) ; staqw < size ; staqw ++ ) { System . out . println ( list . get ( staqw ) ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Obkhf { static int [ ] h ; static int [ ] dp ; public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int obkhf = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; h = new int [ obkhf ] ; dp = new int [ obkhf ] ; for ( int i = 0 ; i < obkhf ; i ++ ) h [ i ] = scan . nextInt ( ) ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < obkhf ; i ++ ) { int min = Integer . MAX_VALUE ; for ( int j = 1 ; i - j >= 0 && j <= k ; j ++ ) min = Math . min ( dp [ i - j ] + Math . abs ( h [ i ] - h [ i - j ] ) , min ) ; dp [ i ] = min ; } System . out . println ( dp [ obkhf - 1 ] ) ; } } import java . util . Scanner ; public class Osotiik { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int osotiik = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int c = stdIn . nextInt ( ) ; int d = stdIn . nextInt ( ) ; if ( c >= b || osotiik >= d ) System . out . println ( 0 ) ; else if ( ( osotiik <= c && b >= d ) || ( c <= osotiik && d >= b ) ) System . out . println ( ( b - osotiik ) < ( d - c ) ? b - osotiik : d - c ) ; else System . out . println ( ( b > c && c >= osotiik ) ? b - c : d - osotiik ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; public class Ifpmofr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ifpmofr = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] tmp = scanner . nextLine ( ) . split ( " " ) ; int [ ] list = new int [ ifpmofr ] ; int ans = 0 ; for ( int i = 0 ; i < ifpmofr ; i ++ ) { list [ i ] = Integer . parseInt ( tmp [ i ] ) ; } for ( int i = 0 ; i < ifpmofr ; i ++ ) { int r = i ; int min = Integer . MAX_VALUE ; while ( list [ i ] != 0 ) { while ( r < ifpmofr && list [ r ] != 0 ) { min = Math . min ( min , list [ r ] ) ; r ++ ; } for ( int k = i ; k < r ; k ++ ) { list [ k ] -= min ; } ans += min ; r = i ; } } System . out . println ( ans ) ; } } import java . util . * ; class Txnvob { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int txnvob = sc . nextInt ( ) ; int [ ] h = new int [ txnvob ] ; for ( int i = 0 ; i < txnvob ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int sum = 0 ; boolean flag = true ; while ( flag ) { flag = false ; boolean ed = false ; for ( int i = 0 ; i < txnvob ; i ++ ) { if ( h [ i ] != 0 ) { h [ i ] = h [ i ] - 1 ; if ( ! ed ) { ed = true ; flag = true ; sum ++ ; } } else { ed = false ; } } } System . out . println ( sum ) ; } } import java . util . * ; public class Tsyxz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tsyxz = sc . nextInt ( ) ; long max = 0L ; int Bi = 0 ; int save = 0 ; for ( int i = 0 ; i < tsyxz ; i ++ ) { if ( i == tsyxz - 1 ) { max += save ; break ; } Bi = sc . nextInt ( ) ; if ( i == 0 ) { max += Bi ; save = Bi ; } else if ( Bi < save ) { max += Bi ; save = Bi ; } else { max += save ; save = Bi ; } } System . out . println ( max ) ; } } import java . util . * ; public class Ytxsqwf { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ytxsqwf = sc . nextInt ( ) ; int [ ] array = new int [ ytxsqwf ] ; for ( int i = 0 ; i < ytxsqwf ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int i = 0 ; i < ytxsqwf ; i ++ ) { while ( true ) { if ( array [ i ] % 2 == 0 ) { array [ i ] /= 2 ; ans ++ ; } else { break ; } } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class Yzhor { public static void main ( String [ ] args ) { int [ ] arr = new int [ 5 ] ; Scanner sc = new Scanner ( System . in ) ; for ( int yzhor = 0 ; yzhor < 5 ; yzhor ++ ) { arr [ yzhor ] = sc . nextInt ( ) ; if ( arr [ yzhor ] == 0 ) System . out . println ( yzhor + 1 ) ; } } } import java . util . * ; public class Kiskxp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long kiskxp = sc . nextLong ( ) ; HashMap < Long , Long > map = new HashMap < > ( ) ; long res = dfs ( kiskxp , map ) ; System . out . println ( res ) ; } public static long dfs ( long kiskxp , HashMap < Long , Long > map ) { long ans = 1 ; if ( kiskxp <= 1 ) return ans ; if ( map . get ( kiskxp ) != null ) return map . get ( kiskxp ) ; long cur = dfs ( kiskxp / 2 , map ) ; ans += 2 * cur ; map . put ( kiskxp , ans ) ; return ans ; } } import java . util . * ; public class Brieoru { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int brieoru = sc . nextInt ( ) ; Integer [ ] p = new Integer [ brieoru ] ; for ( int i = 0 ; i < brieoru ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Integer [ ] p_ = p . clone ( ) ; Arrays . sort ( p ) ; int count = 0 ; for ( int i = 0 ; i < brieoru ; i ++ ) { if ( p [ i ] != p_ [ i ] ) { count ++ ; } } if ( count == 0 || count == 2 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Yynkwj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yynkwj = sc . nextInt ( ) ; String [ ] str = new String [ yynkwj ] ; for ( int i = 0 ; i < yynkwj ; i ++ ) { str [ i ] = sc . next ( ) ; } int acCount = 0 ; int waCount = 0 ; int tleCount = 0 ; int reCount = 0 ; for ( int j = 0 ; j < yynkwj ; j ++ ) { if ( str [ j ] . equals ( " AC " ) ) { acCount ++ ; } else if ( str [ j ] . equals ( " WA " ) ) { waCount ++ ; } else if ( str [ j ] . equals ( " TLE " ) ) { tleCount ++ ; } else if ( str [ j ] . equals ( " RE " ) ) { reCount ++ ; } } System . out . printf ( " AC x %d \n " , acCount ) ; System . out . printf ( " WA x %d \n " , waCount ) ; System . out . printf ( " TLE x %d \n " , tleCount ) ; System . out . printf ( " RE x %d \n " , reCount ) ; } } import java . util . Scanner ; class Ealjtkk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ealjtkk = 0 ; int tas = 0 ; ; int q ; int i ; int z ; int j = 0 ; int b = 0 ; String Bun = scan . nextLine ( ) ; String Miz = scan . nextLine ( ) ; Bun = Bun + Bun ; char [ ] bun = Bun . toCharArray ( ) ; char [ ] miz = Miz . toCharArray ( ) ; for ( q = 0 ; q < miz . length ; q ++ ) { } for ( z = 0 ; z < bun . length ; z ++ ) { } int x = z - q ; for ( i = 0 ; i < x ; i ++ ) { if ( bun [ i ] == miz [ j ] ) { for ( j = 0 ; j <= q ; j ++ ) { if ( bun [ i + j ] != miz [ j ] ) { tas = 0 ; j = 0 ; break ; } tas ++ ; if ( tas == q ) { ealjtkk = 1 ; b = 1 ; break ; } } } if ( b == 1 ) { break ; } } if ( ealjtkk == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Fuuuw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fuuuw = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int tmp ; if ( fuuuw > b ) { tmp = fuuuw ; fuuuw = b ; b = tmp ; } if ( b > c ) { tmp = b ; b = c ; c = tmp ; } if ( fuuuw > b ) { tmp = fuuuw ; fuuuw = b ; b = tmp ; } System . out . println ( fuuuw + " " + b + " " + c ) ; } } import java . util . * ; public class Rjabk { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; int rjabk = kb . nextInt ( ) , k = kb . nextInt ( ) ; int [ ] h = new int [ rjabk ] ; for ( int i = 0 ; i < rjabk ; i ++ ) { h [ i ] = kb . nextInt ( ) ; } int [ ] dp = new int [ rjabk ] ; boolean [ ] visited = new boolean [ rjabk ] ; dp [ 0 ] = 0 ; visited [ 0 ] = true ; for ( int i = 1 ; i < rjabk ; i ++ ) { for ( int j = 1 ; j <= k && j <= i ; j ++ ) { int ksteps = dp [ i - j ] + Math . abs ( h [ i - j ] - h [ i ] ) ; if ( ! visited [ i ] ) { dp [ i ] = ksteps ; visited [ i ] = true ; } else dp [ i ] = Math . min ( dp [ i ] , ksteps ) ; } } System . out . println ( dp [ rjabk - 1 ] ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Jzscc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] sArray = s . split ( " " ) ; String t = sc . next ( ) ; String [ ] tArray = t . split ( " " ) ; String a = " " ; boolean jzscc = false ; for ( int k = 0 ; k < sArray . length ; k ++ ) { a = sArray [ sArray . length - 1 ] ; for ( int i = sArray . length - 1 ; i > 0 ; i -- ) { sArray [ i ] = sArray [ i - 1 ] ; } sArray [ 0 ] = a ; if ( Arrays . equals ( sArray , tArray ) ) { jzscc = true ; break ; } } if ( jzscc ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Wnvtfh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wnvtfh = Integer . parseInt ( scan . next ( ) ) ; List < String > list = new ArrayList < > ( ) ; String W = scan . next ( ) ; list . add ( W ) ; String preW ; for ( int i = 1 ; i < wnvtfh ; i ++ ) { W = scan . next ( ) ; if ( list . contains ( W ) ) { System . out . println ( " No " ) ; return ; } preW = list . get ( i - 1 ) ; if ( preW . charAt ( preW . length ( ) - 1 ) != W . charAt ( 0 ) ) { System . out . println ( " No " ) ; return ; } list . add ( W ) ; } System . out . println ( " Yes " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Utawzpn { int utawzpn , s ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; utawzpn = sc . nextInt ( ) ; s = sc . nextInt ( ) ; solve ( ) ; } void solve ( ) { long count = 0 ; for ( int x = 0 ; x <= utawzpn ; x ++ ) { for ( int y = 0 ; y <= utawzpn ; y ++ ) { int z = s - x - y ; if ( z >= 0 && z <= utawzpn ) { count ++ ; } } } System . out . println ( count ) ; } static class Utawzpn { 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 . Scanner ; public class Cykxmn { private static double cykxmn ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; cykxmn = stdIn . nextDouble ( ) ; double Pi = Math . PI ; System . out . printf ( " %.6f %.6f \n " , ( cykxmn * cykxmn * Pi ) , ( 2 * Pi * cykxmn ) ) ; } } import java . util . Scanner ; public class Gklnfe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gklnfe = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int count = gklnfe / x ; int answer = 0 ; if ( gklnfe % x == 0 ) answer = count ; else answer = count + 1 ; System . out . println ( answer * t ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Snoroxt { private void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] charArray = S . toCharArray ( ) ; List < Integer > counts = new ArrayList < Integer > ( ) ; int snoroxt = 0 ; for ( int i = 0 ; i < charArray . length ; i ++ ) { if ( charArray [ i ] == 'A' || charArray [ i ] == 'C' || charArray [ i ] == 'G' || charArray [ i ] == 'T' ) { snoroxt ++ ; if ( i == charArray . length - 1 ) { counts . add ( snoroxt ) ; } } else { if ( snoroxt != 0 ) { counts . add ( snoroxt ) ; snoroxt = 0 ; } } } Collections . sort ( counts , Collections . reverseOrder ( ) ) ; if ( counts . size ( ) == 0 ) { System . out . print ( 0 ) ; } else { System . out . print ( counts . get ( 0 ) ) ; } } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class Kfyustw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kfyustw = sc . nextInt ( ) ; int max_first = 0 ; int max_second = 0 ; int [ ] a = new int [ kfyustw ] ; for ( int i = 0 ; i < kfyustw ; ++ i ) { a [ i ] = sc . nextInt ( ) ; if ( max_first <= a [ i ] ) { max_second = max_first ; max_first = a [ i ] ; } if ( max_first > a [ i ] && max_second <= a [ i ] ) { max_second = a [ i ] ; } } for ( int ii : a ) { if ( ii != max_first ) System . out . println ( max_first ) ; else if ( ii != 0 ) System . out . println ( max_second ) ; } } } import java . util . * ; public class Ktbpdkv { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int ktbpdkv , b , c ; while ( true ) { ktbpdkv = input . nextInt ( ) ; b = input . nextInt ( ) ; c = input . nextInt ( ) ; if ( ktbpdkv == - 1 && b == - 1 && c == - 1 ) break ; else { if ( ktbpdkv == - 1 || b == - 1 ) System . out . println ( " F " ) ; else if ( ktbpdkv + b < 30 ) System . out . println ( " F " ) ; else if ( ktbpdkv + b < 50 ) { if ( c == - 1 ) { System . out . println ( " D " ) ; } else { if ( c >= 50 ) System . out . println ( " C " ) ; else System . out . println ( " D " ) ; } } else if ( ktbpdkv + b < 65 ) System . out . println ( " C " ) ; else if ( ktbpdkv + b < 80 ) System . out . println ( " B " ) ; else if ( ktbpdkv + b >= 80 ) System . out . println ( " A " ) ; } } } } import java . util . * ; import java . io . * ; public class Mccgk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mccgk = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long div = mccgk / ( a + b ) ; long rem = mccgk % ( a + b ) ; long sum = div * a ; sum += Math . min ( rem , a ) ; System . out . println ( sum ) ; } } import java . io . * ; public class Upjwan { static boolean checkKaibun ( String str ) { StringBuilder t = new StringBuilder ( str ) ; return ( str . equals ( t . reverse ( ) . toString ( ) ) ) ; } public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; br . close ( ) ; int upjwan = s . length ( ) ; boolean ok = checkKaibun ( s ) ; ok &= checkKaibun ( s . substring ( 0 , ( upjwan - 1 ) / 2 ) ) ; ok &= checkKaibun ( s . substring ( ( upjwan + 1 ) / 2 ) ) ; System . out . println ( ok ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Riqctda { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int riqctda , B , C , X , Y ; riqctda = sc . nextInt ( ) ; B = sc . nextInt ( ) ; C = sc . nextInt ( ) ; X = sc . nextInt ( ) ; Y = sc . nextInt ( ) ; int min = riqctda * X + B * Y ; if ( X > Y ) { if ( C * 2 * X < min ) { min = C * 2 * X ; } if ( C * 2 * Y + ( X - Y ) * riqctda < min ) { min = C * 2 * Y + ( X - Y ) * riqctda ; } } else { if ( C * 2 * Y < min ) { min = C * 2 * Y ; } if ( C * 2 * X + ( Y - X ) * B < min ) { min = C * 2 * X + ( Y - X ) * B ; } } System . out . println ( min ) ; } } import java . util . Scanner ; public class Sdcqe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sdcqe = sc . nextInt ( ) ; int larger = sdcqe / 500 ; int smaller = sdcqe - larger * 500 ; int yens = smaller / 5 ; System . out . println ( ( larger * 1000 ) + ( yens * 5 ) ) ; } } import java . io . IOException ; import java . util . Scanner ; public class Ljpbht { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ljpbht = sc . nextInt ( ) ; int [ ] a = new int [ ljpbht ] ; for ( int b = 0 ; b < ljpbht ; ++ b ) { a [ b ] = sc . nextInt ( ) ; } for ( int b = ljpbht - 1 ; b >= 0 ; -- b ) { if ( b != 0 ) { System . out . print ( a [ b ] + " " ) ; } else { System . out . println ( a [ b ] ) ; } } } } import java . util . * ; public class Beebeg { public static void main ( String [ ] args ) { String alphabet = " ABCDEFGHIJKLMNOPQRSTUVWXYZ " ; Scanner sc = new Scanner ( System . in ) ; int beebeg = sc . nextInt ( ) ; String S = sc . next ( ) ; sc . close ( ) ; String ans = " " ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { for ( int j = 0 ; j < alphabet . length ( ) ; j ++ ) { if ( S . substring ( i , i + 1 ) . equals ( alphabet . substring ( j , j + 1 ) ) ) { ans += alphabet . substring ( ( j + beebeg ) % alphabet . length ( ) , ( ( j + beebeg ) % alphabet . length ( ) ) + 1 ) ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Iiztrv { void run ( ) { Scanner scan = new Scanner ( System . in ) ; int iiztrv = scan . nextInt ( ) ; int prime = 0 ; for ( int i = 0 ; i < iiztrv ; i ++ ) { int p = scan . nextInt ( ) ; if ( is_prime ( p ) ) prime += 1 ; } System . out . println ( prime ) ; } boolean is_prime ( int p ) { if ( p == 2 ) return true ; if ( p < 2 || ( p & 1 ) == 0 ) return false ; int i = 3 ; while ( i <= Math . sqrt ( p ) ) { if ( p % i == 0 ) return false ; i = i + 2 ; } return true ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . Scanner ; class Kqxly { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kqxly = sc . nextInt ( ) ; int [ ] b = new int [ kqxly ] ; for ( int i = 0 ; i < kqxly ; i ++ ) { int m = sc . nextInt ( ) ; b [ i ] = m ; } int w ; for ( int h = 0 ; h < ( kqxly / 2 ) ; h ++ ) { w = b [ h ] ; b [ h ] = b [ kqxly - 1 - h ] ; b [ kqxly - 1 - h ] = w ; } for ( int j = 0 ; j < kqxly - 1 ; j ++ ) { System . out . print ( b [ j ] + " " ) ; } System . out . print ( b [ kqxly - 1 ] ) ; System . out . println ( " " ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; class Iogqb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long iogqb = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; System . out . println ( iogqb * b ) ; } } import java . io . * ; import java . util . * ; class Clleuf { public static void main ( String [ ] args ) { solve ( ) ; } public static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; for ( int clleuf = 0 ; clleuf < s . length ( ) ; clleuf ++ ) { if ( clleuf == 3 ) { System . out . print ( 8 ) ; } else { System . out . print ( s . charAt ( clleuf ) ) ; } } System . out . println ( ) ; } } import java . util . Scanner ; import java . util . * ; class Tryfsj { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int tryfsj = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int [ ] sort = { tryfsj , b , c } ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < 2 - i ; j ++ ) { if ( sort [ j ] < sort [ j + 1 ] ) { int temp = sort [ j ] ; sort [ j ] = sort [ j + 1 ] ; sort [ j + 1 ] = temp ; } } } System . out . println ( sort [ 2 ] + " " + sort [ 1 ] + " " + sort [ 0 ] ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Xknuk { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { char [ ] array = scanner . next ( ) . toCharArray ( ) ; Map < Character , Integer > map = new HashMap < > ( ) ; map . put ( '0' , 0 ) ; map . put ( '1' , 0 ) ; for ( char xknuk : array ) { if ( map . containsKey ( xknuk ) ) { map . put ( xknuk , map . get ( xknuk ) + 1 ) ; } } System . out . println ( map . get ( '1' ) ) ; } } } import java . util . Scanner ; public class Dknue { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int dknue = Integer . parseInt ( scanner . next ( ) ) ; System . out . println ( dknue * dknue * dknue ) ; } } import java . util . * ; public class Vyrod { public static void main ( String [ ] arg ) { Scanner scan = new Scanner ( System . in ) ; int vyrod = scan . nextInt ( ) ; int [ ] p = new int [ vyrod ] ; int check = 0 ; for ( int i = 0 ; i < vyrod ; i ++ ) { p [ i ] = scan . nextInt ( ) ; if ( p [ i ] != i + 1 ) { check ++ ; } } if ( check == 0 || check == 2 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; import java . io . * ; public class Jigwuk { public static void main ( String [ ] args ) throws IOException { new ABC133 ( ) . c ( ) ; } } class Jigwuk { void c ( ) { long jigwuk , R ; long M = 2019L ; Scanner in = new Scanner ( System . in ) ; jigwuk = in . nextLong ( ) ; R = in . nextLong ( ) ; int ans = 2018 ; long maxI = ( long ) Math . min ( R , jigwuk + M ) ; for ( long i = jigwuk ; i <= maxI ; ++ i ) { long maxJ = ( long ) Math . min ( R , i + 1L + M ) ; for ( long j = i + 1 ; j <= maxJ ; ++ j ) { ans = ( int ) Math . min ( ans , i * j % M ) ; } } System . out . println ( ans ) ; in . close ( ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Zpqey { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner sc = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int zpqey = Integer . parseInt ( a + b ) ; double number = Math . sqrt ( zpqey ) ; if ( number == Math . floor ( number ) ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } out . close ( ) ; } } import java . util . Scanner ; public class Dsqmb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dsqmb = scan . nextInt ( ) ; int [ ] a = new int [ dsqmb ] ; for ( int i = 0 ; i < dsqmb ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } int count = 0 ; while ( true ) { boolean bool = false ; for ( int an : a ) { if ( an % 2 != 0 ) { bool = true ; } } if ( bool ) { break ; } for ( int i = 0 ; i < dsqmb ; i ++ ) { a [ i ] /= 2 ; } count ++ ; } System . out . println ( count ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Piuhg { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str ; while ( ! ( ( str = br . readLine ( ) ) . equals ( " - " ) ) ) { int piuhg = Integer . parseInt ( br . readLine ( ) ) ; int [ ] arrH = new int [ piuhg ] ; for ( int i = 0 ; i < piuhg ; i ++ ) { arrH [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } shuff ( str , arrH , piuhg ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } public static void shuff ( String s , int [ ] h , int l ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( s ) ; for ( int i = 0 ; i < l ; i ++ ) { sb . append ( sb . substring ( 0 , h [ i ] ) ) ; sb . delete ( 0 , h [ i ] ) ; } System . out . println ( sb . toString ( ) ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Ptffwqz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ptffwqz = in . nextInt ( ) ; int m = in . nextInt ( ) ; int c = in . nextInt ( ) ; int [ ] b = new int [ m ] ; int ret = 0 ; for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = in . nextInt ( ) ; } for ( int j = 0 ; j < ptffwqz ; j ++ ) { int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int a = in . nextInt ( ) ; sum += a * b [ i ] ; } if ( sum + c > 0 ) { ret ++ ; } } System . out . println ( ret ) ; } } import java . util . Scanner ; public class Kteuyyl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long kteuyyl = sc . nextLong ( ) ; int ans = 0 ; for ( int i = 0 ; i < kteuyyl ; i ++ ) { if ( s . charAt ( i ) == '1' ) { if ( i + 1 == kteuyyl ) { ans = i ; break ; } } else { ans = i ; break ; } } System . out . println ( s . charAt ( ans ) ) ; } } import java . util . * ; public class Tftihh { public static void main ( String [ ] args ) { final String RESULT_YES = " Yes " ; final String RESULT_NO = " No " ; Scanner sc = new Scanner ( System . in ) ; int tftihh = sc . nextInt ( ) ; int locationCode = sc . nextInt ( ) ; String val = sc . next ( ) ; boolean result = false ; if ( val . matches ( " [0-9] { " + tftihh + " } -[0-9] { " + locationCode + " } " ) ) { result = true ; } if ( result ) { System . out . println ( RESULT_YES ) ; } else { System . out . println ( RESULT_NO ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Cihnznf { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String readStr ; int cihnznf = 0 ; while ( ( readStr = reader . readLine ( ) ) != null ) { int [ ] list = new int [ 3 ] ; list [ 0 ] = Integer . parseInt ( readStr . split ( " " ) [ 0 ] ) ; list [ 1 ] = Integer . parseInt ( readStr . split ( " " ) [ 1 ] ) ; String sssss = String . format ( " %.6f " , ( 1.0 * list [ 0 ] / list [ 1 ] ) ) ; System . out . println ( ( int ) ( list [ 0 ] / list [ 1 ] ) + " " + ( list [ 0 ] % list [ 1 ] ) + " " + sssss ) ; break ; } } } import java . util . * ; import javax . swing . text . AbstractDocument . BranchElement ; import com . sun . org . apache . xpath . internal . SourceTree ; public class Xbcvq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xbcvq = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; Set < Integer > ans1 = new TreeSet < > ( ) ; for ( int i = 1 ; i <= xbcvq ; i ++ ) { if ( xbcvq % i == 0 ) { ans1 . add ( i ) ; } } Set < Integer > ans2 = new TreeSet < > ( ) ; for ( int i = 1 ; i <= b ; i ++ ) { if ( b % i == 0 ) { ans2 . add ( i ) ; } } List < Integer > result = new ArrayList < > ( ) ; for ( Integer val1 : ans1 ) { for ( Integer val2 : ans2 ) { if ( val1 == val2 ) { result . add ( val1 ) ; } if ( val1 <= val2 ) { break ; } } } System . out . println ( result . get ( result . size ( ) - k ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Bufvz { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String first_line = input . readLine ( ) ; String [ ] array_of_li_col = first_line . split ( " " ) ; int bufvz = Integer . parseInt ( array_of_li_col [ 0 ] ) ; int column = Integer . parseInt ( array_of_li_col [ 1 ] ) ; int [ ] [ ] matrix_array_A = new int [ bufvz ] [ column ] ; int [ ] vector_array_b = new int [ column ] ; for ( int line_A = 0 ; line_A < bufvz ; line_A ++ ) { String elements_A = input . readLine ( ) ; String [ ] elements_A_array = elements_A . split ( " " ) ; for ( int column_A = 0 ; column_A < column ; column_A ++ ) { int elements_A_num = Integer . parseInt ( elements_A_array [ column_A ] ) ; matrix_array_A [ line_A ] [ column_A ] = elements_A_num ; } } for ( int column_b = 0 ; column_b < column ; column_b ++ ) { String elements_b = input . readLine ( ) ; int elements_b_num = Integer . parseInt ( elements_b ) ; vector_array_b [ column_b ] = elements_b_num ; } int elements_Ci = 0 ; for ( int line_A = 0 ; line_A < bufvz ; line_A ++ ) { for ( int column_A = 0 ; column_A < column ; column_A ++ ) { elements_Ci += matrix_array_A [ line_A ] [ column_A ] * vector_array_b [ column_A ] ; } System . out . println ( elements_Ci ) ; elements_Ci = 0 ; } } } import java . util . * ; public class Honui { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int honui = Integer . parseInt ( a + b ) ; for ( int i = 1 ; i < 400 ; i ++ ) { if ( i * i == honui ) { System . out . println ( " Yes " ) ; System . exit ( 0 ) ; } } System . out . println ( " No " ) ; } } import java . io . BufferedInputStream ; import java . math . BigInteger ; import java . util . Scanner ; public class Aydcxy { public static long combination ( int n , int k ) { if ( k == 0 ) return 1 ; else return combination ( n , k - 1 ) * ( n - k + 1 ) / k ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( new BufferedInputStream ( System . in ) ) ; int aydcxy = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = 0 ; c += Main . combination ( aydcxy , 2 ) ; c += Main . combination ( b , 2 ) ; System . out . println ( c ) ; } } import java . util . Scanner ; public class Upfft { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long upfft = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long x1 = upfft * c ; long x2 = upfft * d ; long x3 = b * c ; long x4 = b * d ; long ans = Math . max ( x1 , x2 ) ; ans = Math . max ( ans , x3 ) ; ans = Math . max ( ans , x4 ) ; System . out . println ( ans ) ; } } 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 Otyebu { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Otyebu { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int otyebu = in . nextInt ( ) ; int b = in . nextInt ( ) ; out . println ( otyebu * b % 2 == 1 ? " Odd " : " Even " ) ; } } static class Otyebu { BufferedReader br ; StringTokenizer st ; public InputReader ( InputStream inputStream ) { br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; st = new StringTokenizer ( " " ) ; } public String nextString ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) , " " ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextString ( ) ) ; } } } import java . util . * ; import java . io . * ; public class Rprypvv { public static void main ( String [ ] args ) { FastScanner scanner = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int rprypvv = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; out . println ( Math . max ( c - ( rprypvv - b ) , 0 ) ) ; out . flush ( ) ; } public static class Rprypvv { BufferedReader br ; StringTokenizer st ; public FastScanner ( Reader in ) { br = new BufferedReader ( in ) ; } public FastScanner ( ) { this ( 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 readNextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } import java . util . * ; public class Knzxidb { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int knzxidb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( knzxidb + b <= c * 2 ) { System . out . println ( knzxidb * x + b * y ) ; return ; } int tmp = Math . min ( x , y ) ; int tmp2 = c * tmp * 2 ; int tmp3 = knzxidb * ( x - tmp ) ; int tmp4 = b * ( y - tmp ) ; int tmp5 = Math . max ( x , y ) * c * 2 ; int ans = Math . min ( tmp5 , tmp2 + tmp3 + tmp4 ) ; System . out . println ( ans ) ; } } import java . util . * ; public class Lrzxy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lrzxy = sc . nextInt ( ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; char [ ] s = new char [ lrzxy ] ; char [ ] t = new char [ lrzxy ] ; int i ; int m ; char [ ] b = new char [ 2 * lrzxy ] ; for ( i = 0 ; i < lrzxy ; i ++ ) { s [ i ] = S . charAt ( i ) ; } for ( i = 0 ; i < lrzxy ; i ++ ) { t [ i ] = T . charAt ( i ) ; } for ( i = 0 , m = 0 ; i < lrzxy ; i ++ , m = m + 2 ) { b [ m ] = s [ i ] ; } for ( i = 0 , m = 1 ; i < lrzxy ; i ++ , m = m + 2 ) { b [ m ] = t [ i ] ; } String str = String . valueOf ( b ) ; System . out . println ( str ) ; } } import java . util . Scanner ; public class Tyznlp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double tyznlp = sc . nextDouble ( ) ; double b = sc . nextDouble ( ) ; double h = sc . nextDouble ( ) ; double m = sc . nextDouble ( ) ; final double PI = Math . PI ; double ht = ( ( h * 60 + m ) / 720 ) * 2 * PI ; double mt = ( m / 60 ) * 2 * PI ; double hx = tyznlp * Math . cos ( ht ) ; double hy = tyznlp * Math . sin ( ht ) ; double mx = b * Math . cos ( mt ) ; double my = b * Math . sin ( mt ) ; double dx = hx - mx ; double dy = hy - my ; double ans = Math . sqrt ( dx * dx + dy * dy ) ; System . out . printf ( " %.10f " , ans ) ; } } import java . util . Scanner ; public class Vusiufp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vusiufp = sc . nextInt ( ) ; for ( int i = 1 ; i <= 10 ; i ++ ) { if ( ( vusiufp - 1000 * i ) <= 0 ) { System . out . println ( ( vusiufp - 1000 * i ) * - 1 ) ; break ; } } } } import java . util . * ; public class Wjhdor { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wjhdor = sc . nextInt ( ) ; int [ ] h = new int [ wjhdor ] ; for ( int i = 0 ; i < wjhdor ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int [ ] q = new int [ wjhdor ] ; Arrays . fill ( q , 0 ) ; q [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < wjhdor ; i ++ ) { q [ i ] = Math . min ( q [ i - 1 ] + Math . abs ( h [ i - 1 ] - h [ i ] ) , q [ i - 2 ] + Math . abs ( h [ i - 2 ] - Math . abs ( h [ i ] ) ) ) ; } System . out . println ( q [ wjhdor - 1 ] ) ; } } import java . util . * ; public class Cuwirk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double cuwirk = scan . nextInt ( ) ; System . out . println ( 2 * Math . PI * cuwirk ) ; scan . close ( ) ; return ; } } import java . util . * ; public class Gdsxfp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gdsxfp = sc . nextInt ( ) ; int syainj = sc . nextInt ( ) ; System . out . println ( gdsxfp * syainj ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Tldlk { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int tldlk = Integer . parseInt ( str [ 0 ] ) ; int a = Integer . parseInt ( str [ 1 ] ) ; System . out . println ( ( tldlk + a - 1 ) / a ) ; } } import java . util . Scanner ; public class Fuopi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fuopi = sc . nextInt ( ) ; String S = sc . next ( ) ; int count = 0 ; for ( int i = 0 ; i < fuopi - 2 ; i ++ ) { if ( S . substring ( i , i + 3 ) . equals ( " ABC " ) ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Aierwvh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String buff = " " ; int aierwvh = sc . nextInt ( ) ; long count = 0 , flag = 0 ; long count1 = 0 , count2 = 0 ; int count3 = 0 ; int [ ] array = new int [ 100 ] ; for ( int i = 0 ; i < aierwvh ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < aierwvh - 1 ; i ++ ) { for ( int j = i + 1 ; j < aierwvh ; j ++ ) { count += array [ i ] * array [ j ] ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Dxyke { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int dxyke = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int T = scanner . nextInt ( ) ; int ans = T / dxyke * B ; System . out . println ( ans ) ; scanner . close ( ) ; } } import java . util . Scanner ; public class Yoiiupo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] chars = sc . next ( ) . toCharArray ( ) ; for ( char yoiiupo : chars ) { if ( yoiiupo == '1' ) { System . out . print ( 9 ) ; } else if ( yoiiupo == '9' ) { System . out . print ( 1 ) ; } else { System . out . println ( yoiiupo ) ; } } System . out . println ( ) ; } } import java . util . Scanner ; public class Exkgab { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int exkgab = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; if ( exkgab <= ( 2 * D + 1 ) ) { System . out . println ( 1 ) ; } else { int num = 0 ; while ( exkgab > 0 ) { exkgab -= ( 2 * D + 1 ) ; num ++ ; } System . out . println ( num ) ; } } } import java . util . * ; public class Kpamax { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int kpamax = sc . nextInt ( ) ; int leg = sc . nextInt ( ) ; if ( leg % 2 == 1 ) { System . out . println ( " No " ) ; } else if ( leg < 2 * kpamax ) { System . out . println ( " No " ) ; } else if ( leg > 4 * kpamax ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . lang . reflect . Array ; import java . util . * ; import java . io . * ; import java . lang . * ; public class Rkuzubn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rkuzubn = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( Math . max ( Math . max ( rkuzubn + b , rkuzubn - b ) , rkuzubn * b ) ) ; } } import java . util . * ; class Yqfjrlq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yqfjrlq = sc . nextInt ( ) , count = 0 ; for ( int i = 0 ; i < yqfjrlq ; i ++ ) { if ( sc . nextInt ( ) == count + 1 ) { count ++ ; } } System . out . println ( count == 0 ? - 1 : yqfjrlq - count ) ; } } import java . util . Scanner ; public class Dyhkhjd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dyhkhjd = sc . nextInt ( ) ; int [ ] arrayA = new int [ dyhkhjd ] ; for ( int i = 0 ; i < arrayA . length ; i ++ ) { arrayA [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; double seki = 1.0 ; for ( int a : arrayA ) { seki = seki * a ; } double wa = 0.0 ; for ( int i = 0 ; i < arrayA . length ; i ++ ) { wa = seki / arrayA [ i ] + wa ; } System . out . println ( seki / wa ) ; } } import java . util . Scanner ; public class Lsccx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lsccx = sc . nextInt ( ) ; int [ ] w = new int [ lsccx ] ; for ( int i = 0 ; i < lsccx ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } int min = 1000000000 ; for ( int i = 0 ; i < lsccx ; i ++ ) { int s1 = 0 ; int s2 = 0 ; for ( int j = 0 ; j <= i ; j ++ ) { s1 += w [ j ] ; } for ( int k = i + 1 ; k <= lsccx - 1 ; k ++ ) { s2 += w [ k ] ; } int minTemp = Math . abs ( s1 - s2 ) ; if ( minTemp < min ) { min = minTemp ; } } System . out . println ( min ) ; } } import java . util . Scanner ; public class Utegl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int utegl , M ; utegl = sc . nextInt ( ) ; M = sc . nextInt ( ) ; int [ ] broken = new int [ utegl + 1 ] ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) ; broken [ a ] = 1 ; } int [ ] dp = new int [ utegl + 2 ] ; dp [ utegl ] = 1 ; for ( int i = utegl - 1 ; i >= 0 ; i -- ) { if ( broken [ i ] == 1 ) { dp [ i ] = 0 ; continue ; } dp [ i ] = ( dp [ i + 1 ] + dp [ i + 2 ] ) % 1000000007 ; } System . out . println ( dp [ 0 ] ) ; } } import java . util . Scanner ; public class Cmjiio { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Integer n = Integer . parseInt ( sc . next ( ) ) ; Integer k = Integer . parseInt ( sc . next ( ) ) ; String num = Integer . toString ( n , k ) ; int cmjiio = num . length ( ) ; System . out . println ( cmjiio ) ; } } import java . util . LinkedHashSet ; import java . util . Scanner ; import java . util . Set ; public class Heibvcj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int heibvcj = sc . nextInt ( ) ; int [ ] numbers = new int [ heibvcj ] ; for ( int i = 0 ; i < heibvcj ; i ++ ) { numbers [ i ] = sc . nextInt ( ) ; } int numbers_length = numbers . length ; Set < Integer > linkedHashSet = new LinkedHashSet < Integer > ( ) ; for ( int i = 0 ; i < numbers . length ; i ++ ) { linkedHashSet . add ( numbers [ i ] ) ; } int numbers_length2 = linkedHashSet . size ( ) ; if ( numbers_length == numbers_length2 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Tepic { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; int tepic = scan . nextInt ( ) ; double sum = 0 ; for ( int i = 0 ; i < tepic && scan . hasNextInt ( ) ; i ++ ) { sum += ( 1 / ( double ) scan . nextInt ( ) ) ; } System . out . println ( 1 / sum ) ; } } import java . util . * ; public class Pxqsuu { public static void main ( String [ ] args ) { int pxqsuu = 0 ; double rectangle , width , height , point_x , point_y , max_area = 0.0 ; Scanner sc = new Scanner ( System . in ) ; width = Double . parseDouble ( sc . next ( ) ) ; height = Double . parseDouble ( sc . next ( ) ) ; point_x = Double . parseDouble ( sc . next ( ) ) ; point_y = Double . parseDouble ( sc . next ( ) ) ; rectangle = height * width ; max_area = rectangle / 2.0 ; if ( point_x == width / 2.0 && point_y == height / 2.0 ) pxqsuu = 1 ; System . out . println ( max_area + " " + pxqsuu ) ; } } import java . util . * ; public class Qjcyvt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qjcyvt = sc . nextInt ( ) ; int [ ] nums = new int [ qjcyvt ] ; for ( int i = 0 ; i < qjcyvt ; i ++ ) { nums [ i ] = sc . nextInt ( ) ; } int output = 0 ; flag2 : while ( true ) { for ( int i = 0 ; i < qjcyvt ; i ++ ) { if ( nums [ i ] > 0 ) { output ++ ; for ( int j = 0 ; j < qjcyvt - i ; j ++ ) { if ( nums [ i + j ] == 0 ) { continue flag2 ; } nums [ i + j ] -= 1 ; } continue flag2 ; } } break flag2 ; } System . out . println ( output ) ; } } import java . util . Scanner ; public class Etntwip { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String str = in . nextLine ( ) ; char etntwip ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { etntwip = str . charAt ( i ) ; if ( Character . isUpperCase ( etntwip ) ) System . out . print ( Character . toLowerCase ( etntwip ) ) ; else System . out . print ( Character . toUpperCase ( etntwip ) ) ; } System . out . println ( ) ; } } import java . util . * ; public class Ygaksm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ygaksm = sc . nextInt ( ) ; int bInt = sc . nextInt ( ) ; int seki = ygaksm * bInt ; if ( ( seki % 2 ) == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Scanner ; public class Dkhts { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dkhts = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; int max = 0 ; for ( int i = 0 ; i < dkhts ; i ++ ) { String S = sc . next ( ) ; if ( map . containsKey ( S ) ) { map . put ( S , map . get ( S ) + 1 ) ; } else { map . put ( S , 1 ) ; } max = Math . max ( max , map . get ( S ) ) ; } List < String > list = new ArrayList < String > ( ) ; for ( Map . Entry < String , Integer > key : map . entrySet ( ) ) { if ( key . getValue ( ) == max ) { list . add ( key . getKey ( ) ) ; } } Collections . sort ( list ) ; for ( String S : list ) { System . out . println ( S ) ; } } } import java . util . * ; public class Kfmsn { public static void main ( String [ ] args ) { Scanner t = new Scanner ( System . in ) ; String S = t . nextLine ( ) ; int kfmsn = 0 ; int [ ] v = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { v [ i ] = S . charAt ( i ) ; } if ( v [ 0 ] == v [ 1 ] || v [ 1 ] == v [ 2 ] || v [ 2 ] == v [ 3 ] ) { System . out . println ( " Bad " ) ; } else { System . out . println ( " Good " ) ; t . close ( ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; public class Vsffgk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; List < Integer > heightsOfMountain = new ArrayList < Integer > ( ) ; String vsffgk = null ; while ( ( vsffgk = br . readLine ( ) ) != null ) { heightsOfMountain . add ( Integer . valueOf ( vsffgk ) ) ; } Collections . sort ( heightsOfMountain ) ; Collections . reverse ( heightsOfMountain ) ; System . out . println ( heightsOfMountain . get ( 0 ) ) ; System . out . println ( heightsOfMountain . get ( 1 ) ) ; System . out . println ( heightsOfMountain . get ( 2 ) ) ; } } import java . util . * ; import java . io . * ; public class Bgtqa { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int bgtqa = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char ss = s . charAt ( i ) ; char tt = t . charAt ( i ) ; if ( ss != tt ) bgtqa ++ ; } System . out . println ( bgtqa ) ; } } import java . util . Scanner ; public class Lditju { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; int lditju = input . length ( ) ; String [ ] n = new String [ 30 ] ; for ( int i = 0 ; i < lditju ; i ++ ) { n [ i ] = input . substring ( i , i + 1 ) ; } for ( int i = ( lditju - 1 ) ; i > - 1 ; i -- ) { if ( i == 0 ) System . out . println ( n [ i ] ) ; else System . out . print ( n [ i ] ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Yljffa { final static Long MAX = 1000000000000000000L ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yljffa = sc . nextInt ( ) ; sc . nextLine ( ) ; List < Long > l = new ArrayList < Long > ( ) ; for ( int i = 0 ; i < yljffa ; i ++ ) { l . add ( sc . nextLong ( ) ) ; } sc . close ( ) ; if ( l . contains ( 0L ) ) { System . out . println ( 0 ) ; } else { Long sum = 1L ; for ( Long l2 : l ) { if ( sum > MAX / l2 ) { System . out . println ( - 1 ) ; return ; } sum *= l2 ; } System . out . println ( sum ) ; } } } import java . util . Scanner ; public class Yuuzo { static boolean solve ( int yuuzo , int t , int s ) { if ( s * t >= yuuzo ) return true ; else return false ; } public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int yuuzo , t , s ; yuuzo = stdIn . nextInt ( ) ; t = stdIn . nextInt ( ) ; s = stdIn . nextInt ( ) ; boolean result = solve ( yuuzo , t , s ) ; if ( result ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; stdIn . close ( ) ; } } import java . util . * ; public class Oidbfr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; long oidbfr = sc . nextLong ( ) ; int i = 0 ; while ( i < S . length ( ) && S . charAt ( i ) == '1' ) { i ++ ; } if ( i == S . length ( ) || oidbfr <= i ) { System . out . println ( 1 ) ; } else { System . out . println ( S . charAt ( i ) ) ; } } } import java . util . Scanner ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; class Ptrhvh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > height = new ArrayList < Integer > ( ) ; ArrayList < Integer > width = new ArrayList < Integer > ( ) ; int ptrhvh , W ; while ( true ) { ptrhvh = sc . nextInt ( ) ; W = sc . nextInt ( ) ; if ( ptrhvh == 0 && W == 0 ) break ; height . add ( ptrhvh ) ; width . add ( W ) ; } int countH = 0 ; int countW = 0 ; for ( countH = 0 ; countH < height . size ( ) ; countH ++ ) { for ( int i = 0 ; i < height . get ( countH ) ; i ++ ) { for ( int t = 0 ; t < width . get ( countW ) ; t ++ ) { if ( t < width . get ( countW ) - 1 ) { if ( 0 < t && 0 < i && i < height . get ( countH ) - 1 ) { System . out . print ( " . " ) ; } else { System . out . print ( " # " ) ; } } else if ( t == width . get ( countW ) - 1 ) { System . out . println ( " # " ) ; } } } System . out . println ( " " ) ; countW ++ ; } } } import java . util . * ; public class Vvvhy { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int vvvhy = sc . nextInt ( ) ; int [ ] arr = new int [ vvvhy ] ; int [ ] dp = new int [ vvvhy ] ; for ( int i = 0 ; i < vvvhy ; i ++ ) arr [ i ] = sc . nextInt ( ) ; Arrays . fill ( dp , 0 ) ; if ( vvvhy == 1 ) { System . out . println ( arr [ 0 ] ) ; return ; } dp [ 1 ] = Math . abs ( arr [ 1 ] - arr [ 0 ] ) ; for ( int i = 2 ; i < vvvhy ; i ++ ) { int a = dp [ i - 1 ] + Math . abs ( arr [ i ] - arr [ i - 1 ] ) ; int b = dp [ i - 2 ] + Math . abs ( arr [ i ] - arr [ i - 2 ] ) ; dp [ i ] = Math . min ( a , b ) ; } System . out . println ( dp [ vvvhy - 1 ] ) ; return ; } } import java . util . * ; class Uvqiz { public static void main ( String [ ] args ) { int uvqiz = 0 ; String [ ] ans = { " No " , " Yes " } ; Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; char [ ] a = new char [ str . length ( ) ] ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { a [ i ] = str . charAt ( i ) ; } if ( a [ 0 ] == a [ 1 ] && a [ 1 ] == a [ 2 ] && a [ 2 ] == a [ 3 ] ) { } else if ( a [ 0 ] == a [ 1 ] && a [ 2 ] == a [ 3 ] ) { uvqiz ++ ; } else if ( a [ 0 ] == a [ 2 ] && a [ 1 ] == a [ 3 ] ) { uvqiz ++ ; } else if ( a [ 0 ] == a [ 3 ] && a [ 1 ] == a [ 2 ] ) { uvqiz ++ ; } System . out . print ( ans [ uvqiz ] ) ; } } import java . util . * ; import java . io . * ; public class Giidb { static Scanner inp = new Scanner ( System . in ) ; static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) { Main g = new Main ( ) ; g . main ( ) ; out . close ( ) ; } void main ( ) { String s = inp . next ( ) ; String t = inp . next ( ) ; int giidb = s . length ( ) ; int m = t . length ( ) ; int gg = m ; for ( int i = 0 ; i <= giidb - m ; i ++ ) { int c = m ; for ( int j = 0 ; j < m ; j ++ ) { if ( s . charAt ( i + j ) == t . charAt ( j ) ) c -- ; } gg = Math . min ( gg , c ) ; } System . out . println ( gg ) ; } } import java . util . * ; import java . io . PrintWriter ; import static java . lang . Integer . * ; import static java . lang . Long . * ; import static java . lang . Math . * ; import static java . lang . System . * ; public class Dnwrmq { public static int dnwrmq = 100000 ; public static void main ( String [ ] args ) { int i , j ; Scanner sc = new Scanner ( in ) ; int x = parseInt ( sc . next ( ) ) ; sc . close ( ) ; int ans = 0 ; if ( x == 2 ) { ans = 2 ; } else { if ( x % 2 == 0 ) x ++ ; for ( ; ; ) { boolean f = true ; for ( i = 3 ; i * i <= x ; i += 2 ) { if ( x % i == 0 ) { f = false ; break ; } } if ( f ) { ans = x ; break ; } x += 2 ; } } out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; import java . util . StringTokenizer ; public class Qapivb { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int qapivb = Integer . parseInt ( in . readLine ( ) ) ; StringTokenizer stk = new StringTokenizer ( in . readLine ( ) ) ; String s = stk . nextToken ( ) ; String abc = " ABC " ; int cnt = 0 ; for ( int i = 0 ; i + 3 <= qapivb ; i ++ ) { if ( s . substring ( i , i + 3 ) . equals ( abc ) ) cnt ++ ; } System . out . println ( cnt ) ; } } import java . lang . Math ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; class Ehanjz { public static void main ( String [ ] args ) { Scanner sn = new Scanner ( System . in ) ; ArrayList < Integer > nums = new ArrayList < Integer > ( ) ; nums . add ( sn . nextInt ( ) ) ; nums . add ( sn . nextInt ( ) ) ; nums . add ( sn . nextInt ( ) ) ; Collections . sort ( nums ) ; System . out . println ( String . format ( " %d %d %d " , nums . get ( 0 ) , nums . get ( 1 ) , nums . get ( 2 ) ) ) ; } } class Leswqdr { public static void main ( String [ ] args ) throws java . io . IOException { java . io . BufferedReader br = new java . io . BufferedReader ( new java . io . InputStreamReader ( System . in ) ) ; int leswqdr = Integer . parseInt ( br . readLine ( ) ) ; System . out . println ( ( int ) Math . pow ( leswqdr , 3 ) ) ; } } import java . util . * ; public class Oduqz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oduqz = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int ans = 0 ; ans = ( oduqz + ( d * 2 + 1 ) - 1 ) / ( d * 2 + 1 ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Shxve { public static void main ( String [ ] args ) throws Exception { try ( Scanner sc = new Scanner ( System . in ) ) { int shxve = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int L_MAX = 0 ; int R_MIN = shxve + 1 ; for ( int i = 0 ; i < M ; i ++ ) { L_MAX = Math . max ( L_MAX , sc . nextInt ( ) ) ; R_MIN = Math . min ( R_MIN , sc . nextInt ( ) ) ; } if ( L_MAX <= R_MIN ) { System . out . println ( R_MIN - L_MAX + 1 ) ; } else { System . out . println ( 0 ) ; } } } } import java . util . Scanner ; public class Bfjdoxi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bfjdoxi = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int hitNum = ( int ) Math . ceil ( ( double ) bfjdoxi / A ) ; System . out . print ( hitNum ) ; } } import java . util . * ; class Qhkmngi { Scanner sc ; String s ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { s = sc . next ( ) ; for ( int qhkmngi = 0 ; qhkmngi < s . length ( ) ; qhkmngi ++ ) { char c = s . charAt ( qhkmngi ) ; if ( ( qhkmngi % 2 ) == 0 ) { if ( c != 'R' && c != 'U' && c != 'D' ) { System . out . println ( " No " ) ; return ; } } else { if ( c != 'L' && c != 'U' && c != 'D' ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Hjiruu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int hjiruu = sc . nextInt ( ) , d [ ] = new int [ hjiruu + 1 ] ; for ( int i = 0 ; i < hjiruu ; ++ i ) d [ i ] = sc . nextInt ( ) ; sc . close ( ) ; d [ hjiruu ] = 1000 ; Arrays . sort ( d ) ; int ans = 0 ; for ( int i = 0 ; i < hjiruu ; ++ i ) { if ( d [ i ] != d [ i + 1 ] ) ++ ans ; } System . out . println ( ans ) ; } } import java . util . * ; public class Hjdnug { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hjdnug = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int count = 0 ; for ( int i = hjdnug ; i <= B ; i ++ ) { int a = i / 10000 ; int b = i % 10 ; int c = i / 10 % 10 ; int d = i / 1000 % 10 ; if ( a == b && c == d ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Nglhkuh { public static void main ( String [ ] args ) { Scanner Str = new Scanner ( System . in ) ; int nglhkuh = Integer . parseInt ( Str . next ( ) ) ; int b = Integer . parseInt ( Str . next ( ) ) ; if ( Math . floor ( nglhkuh / 10 ) + Math . floor ( b / 10 ) == 0 ) { System . out . println ( nglhkuh * b ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . * ; public class Pwnvsms { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pwnvsms = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= pwnvsms ; i ++ ) { int [ ] sum = new int [ 5 ] ; sum [ 0 ] = i / 10000 ; sum [ 1 ] = ( i - sum [ 0 ] * 10000 ) / 1000 ; sum [ 2 ] = ( i - ( sum [ 0 ] * 10000 ) - ( sum [ 1 ] * 1000 ) ) / 100 ; sum [ 3 ] = ( i - ( sum [ 0 ] * 10000 ) - ( sum [ 1 ] * 1000 ) - sum [ 2 ] * 100 ) / 10 ; sum [ 4 ] = ( i - ( sum [ 0 ] * 10000 ) - ( sum [ 1 ] * 1000 ) - sum [ 2 ] * 100 - sum [ 3 ] * 10 ) ; int s = sum [ 0 ] + sum [ 1 ] + sum [ 2 ] + sum [ 3 ] + sum [ 4 ] ; if ( s >= A && s <= B ) { count += i ; } } System . out . println ( count ) ; } public static void print ( Object o ) { System . out . print ( o ) ; } public static void println ( Object o ) { System . out . println ( o ) ; } } import java . util . ArrayDeque ; import java . util . Deque ; import java . util . Scanner ; public class Ehdijrh { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { String S = scan . next ( ) ; char [ ] s = new char [ S . length ( ) ] ; s = S . toCharArray ( ) ; Deque < Character > que = new ArrayDeque < Character > ( ) ; for ( int ehdijrh = 0 ; ehdijrh < s . length ; ehdijrh ++ ) que . addLast ( s [ ehdijrh ] ) ; while ( true ) { StringBuilder sb = new StringBuilder ( ) ; for ( int ehdijrh = 0 ; ehdijrh < 5 ; ehdijrh ++ ) sb . append ( que . removeLast ( ) ) ; if ( sb . toString ( ) . equals ( " maerd " ) || sb . toString ( ) . equals ( " esare " ) ) { } else { sb . append ( que . removeLast ( ) ) ; if ( sb . toString ( ) . equals ( " resare " ) ) { } else { sb . append ( que . removeLast ( ) ) ; if ( sb . toString ( ) . equals ( " remaerd " ) ) { } else { System . out . println ( " NO " ) ; System . exit ( 0 ) ; } } } if ( que . isEmpty ( ) ) break ; } System . out . println ( " YES " ) ; } } } import java . io . * ; import java . util . * ; public class Vnsaqnj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; final int vnsaqnj = Integer . parseInt ( sc . next ( ) ) ; long [ ] a = new long [ vnsaqnj + 1 ] ; long [ ] b = new long [ vnsaqnj ] ; for ( int i = 0 ; i < vnsaqnj + 1 ; i ++ ) { a [ i ] = Long . parseLong ( sc . next ( ) ) ; } for ( int i = 0 ; i < vnsaqnj ; i ++ ) { b [ i ] = Long . parseLong ( sc . next ( ) ) ; } long ans = 0 ; for ( int i = 0 ; i < vnsaqnj ; i ++ ) { if ( a [ i ] >= b [ i ] ) { ans += b [ i ] ; } else if ( a [ i ] < b [ i ] && a [ i + 1 ] >= b [ i ] - a [ i ] ) { ans += b [ i ] ; a [ i + 1 ] -= ( b [ i ] - a [ i ] ) ; } else if ( a [ i ] < b [ i ] && a [ i + 1 ] < b [ i ] - a [ i ] ) { ans += ( a [ i ] + a [ i + 1 ] ) ; a [ i + 1 ] = 0 ; } } out . println ( ans ) ; out . flush ( ) ; } } import java . util . * ; public class Utkrfu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int utkrfu = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; String ans = " " ; int max = utkrfu * 5000 ; if ( utkrfu * 10000 >= y ) { calc : for ( int i = y / 10000 ; i >= 0 ; i -- ) { int sum = i * 10000 ; if ( y - sum > max ) { break ; } for ( int j = 0 ; j <= ( utkrfu - i ) ; j ++ ) { int value = sum ; value += j * 5000 ; int k = utkrfu - ( i + j ) ; value += k * 1000 ; if ( value == y ) { ans = i + " " + j + " " + k ; break calc ; } } } } if ( ans . isEmpty ( ) ) { ans = " -1 -1 -1 " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Oxkipkv { public static void main ( String [ ] args ) { int oxkipkv , i , j , big , k ; int count = 0 ; Scanner in = new Scanner ( System . in ) ; int n = Integer . parseInt ( in . nextLine ( ) ) ; int [ ] array = new int [ n ] ; for ( oxkipkv = 0 ; oxkipkv < n ; oxkipkv ++ ) array [ oxkipkv ] = Integer . parseInt ( in . next ( ) ) ; for ( i = 0 ; i < n - 1 ; i ++ ) { for ( j = n - 1 ; j >= i + 1 ; j -- ) { if ( array [ j ] < array [ j - 1 ] ) { big = array [ j - 1 ] ; array [ j - 1 ] = array [ j ] ; array [ j ] = big ; count ++ ; } } } for ( k = 0 ; k < n - 1 ; k ++ ) { System . out . print ( array [ k ] + " " ) ; } if ( k == ( n - 1 ) ) System . out . println ( array [ k ] ) ; System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; public class Vatflv { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int vatflv = Integer . parseInt ( in . readLine ( ) ) ; int ans = 0 ; while ( vatflv >= 5 ) { if ( vatflv >= 500 ) { ans += 1000 * ( vatflv / 500 ) ; vatflv %= 500 ; } else { ans += 5 * ( vatflv / 5 ) ; vatflv %= 5 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Lhmssn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lhmssn = sc . nextInt ( ) ; int cnt = 1 ; while ( true ) { if ( lhmssn == 1 || lhmssn == 2 || lhmssn == 4 ) { System . out . println ( cnt + 3 ) ; return ; } if ( lhmssn % 2 == 0 ) lhmssn /= 2 ; else lhmssn = lhmssn * 3 + 1 ; cnt ++ ; } } } import java . util . Scanner ; public class Tnmybqb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] ar = scanner . nextLine ( ) . split ( " " ) ; for ( int tnmybqb = 0 ; tnmybqb < ar . length ; tnmybqb ++ ) { if ( Integer . parseInt ( ar [ tnmybqb ] ) == 0 ) { System . out . println ( tnmybqb + 1 ) ; } } } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class Zlkzl { public static void main ( String [ ] args ) { solve ( System . in , System . out ) ; } static void solve ( InputStream is , PrintStream os ) { Scanner sc = new Scanner ( is ) ; int zlkzl = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < zlkzl ; i ++ ) { int h = sc . nextInt ( ) ; if ( k <= h ) ans ++ ; } os . println ( ans ) ; } } import java . util . Scanner ; public class Yhobhmc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yhobhmc = sc . nextInt ( ) ; int [ ] h = new int [ yhobhmc ] ; int count = 0 ; for ( int i = 0 ; i < yhobhmc ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int a = 0 ; int b = 0 ; L : while ( a <= yhobhmc - 1 && b <= yhobhmc - 1 ) { if ( h [ a ] == 0 ) { a ++ ; continue ; } b = a ; while ( b <= yhobhmc - 1 ) { if ( h [ b ] != 0 && b != yhobhmc - 1 ) { b ++ ; continue ; } else { for ( int i = a ; i <= b ; i ++ ) { h [ i ] -- ; if ( h [ i ] < 0 ) { h [ i ] = 0 ; } } } count ++ ; continue L ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Fcpbbg { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int fcpbbg = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int [ ] p = new int [ M ] ; String [ ] S = new String [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { p [ i ] = scan . nextInt ( ) ; S [ i ] = scan . next ( ) ; } long seitou = 0 ; long pena = 0 ; String [ ] res = new String [ fcpbbg ] ; int [ ] pe = new int [ fcpbbg ] ; for ( int i = 0 ; i < M ; i ++ ) { if ( res [ p [ i ] - 1 ] == null ) { if ( S [ i ] . equals ( " WA " ) ) { res [ p [ i ] - 1 ] = " WA " ; pe [ p [ i ] - 1 ] ++ ; } else { res [ p [ i ] - 1 ] = " AC " ; seitou ++ ; } } else { if ( res [ p [ i ] - 1 ] . equals ( " WA " ) ) { if ( S [ i ] . equals ( " WA " ) ) { pe [ p [ i ] - 1 ] ++ ; } else { res [ p [ i ] - 1 ] = " AC " ; pena += pe [ p [ i ] - 1 ] ; seitou ++ ; } } } } System . out . println ( seitou ) ; System . out . println ( pena ) ; } } } import java . util . Scanner ; public class Unlqyx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int unlqyx = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= unlqyx ; i ++ ) { int digCount = digCount ( i ) ; if ( digCount % 2 != 0 ) { ans ++ ; } } System . out . println ( ans ) ; } static int digCount ( int unlqyx ) { int res = 0 ; while ( unlqyx > 0 ) { res ++ ; unlqyx /= 10 ; } return res ; } } import java . util . Scanner ; public class Jsdrg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jsdrg = sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; System . out . println ( e - jsdrg > k ? " :( " : " Yay! " ) ; } } import java . util . Scanner ; public class Fvxnc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fvxnc = sc . nextInt ( ) ; long [ ] a = new long [ fvxnc + 1 ] ; long [ ] b = new long [ fvxnc ] ; for ( int i = 0 ; i < fvxnc + 1 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < fvxnc ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } long fii1 = 0 ; long sum = 0 ; for ( int i = 0 ; i < fvxnc ; i ++ ) { long fii = Math . min ( a [ i ] - fii1 , b [ i ] ) ; fii1 = Math . min ( a [ i + 1 ] , b [ i ] - fii ) ; sum += fii + fii1 ; } System . out . println ( sum ) ; } } import java . util . Scanner ; class Gpypp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gpypp , b , c ; gpypp = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; System . out . println ( c + " " + gpypp + " " + b ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Tkbjz { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String tiles = input . readLine ( ) ; System . out . println ( Math . min ( getCount ( tiles , '0' ) , getCount ( tiles , '1' ) ) ) ; } public static int getCount ( String tiles , char tile ) { int tkbjz = 0 ; for ( int i = 0 ; i < tiles . length ( ) ; i ++ ) { if ( tile != tiles . charAt ( i ) ) tkbjz ++ ; tile = tile == '0' ? '1' : '0' ; } return tkbjz ; } } import java . util . Scanner ; class Zdmpqj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zdmpqj = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] A = new int [ zdmpqj ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < zdmpqj ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } sc . nextLine ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } int [ ] c = productVector ( A , b ) ; for ( int i = 0 ; i < zdmpqj ; i ++ ) { System . out . println ( c [ i ] ) ; } } static int [ ] productVector ( int [ ] [ ] a , int [ ] b ) { int [ ] c = new int [ a . length ] ; for ( int i = 0 ; i < a . length ; i ++ ) { for ( int j = 0 ; j < a [ 0 ] . length ; j ++ ) { c [ i ] += ( a [ i ] [ j ] * b [ j ] ) ; } } return c ; } } import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ; class Zgyejmw { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int zgyejmw = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; System . out . println ( Math . max ( 0 , C - ( zgyejmw - B ) ) ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } } import java . util . * ; public class Dkngp { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int dkngp = sc . nextInt ( ) ; int [ ] [ ] array = new int [ dkngp ] [ 2 ] ; for ( int i = 0 ; i < dkngp ; i ++ ) { array [ i ] [ 0 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < dkngp ; i ++ ) { array [ i ] [ 1 ] = sc . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < dkngp ; i ++ ) { int s = array [ i ] [ 0 ] - array [ i ] [ 1 ] ; if ( s > 0 ) { sum += s ; } } System . out . println ( sum ) ; } } import java . util . * ; public class Jjmuvx { Scanner sc ; public static void main ( String [ ] args ) { new Main ( ) . execute ( ) ; } public void execute ( ) { this . sc = new Scanner ( System . in ) ; int jjmuvx = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < jjmuvx ; i ++ ) { int d0 = sc . nextInt ( ) ; int d1 = sc . nextInt ( ) ; if ( d0 == d1 ) { cnt ++ ; if ( cnt >= 3 ) { System . out . println ( " Yes " ) ; return ; } } else { cnt = 0 ; } } System . out . println ( " No " ) ; } } import java . util . * ; public class Mpjfzd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mpjfzd = sc . nextInt ( ) ; long n = sc . nextInt ( ) ; long k = 0 ; boolean stop = false ; if ( mpjfzd < n ) { k = mpjfzd ; } else { k = n ; } for ( ; k >= 1 && stop == false ; k -- ) { if ( n % k == 0 && mpjfzd % k == 0 ) { stop = true ; } } long l = n * mpjfzd / ( k + 1 ) ; System . out . println ( l ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; public class Etjvxu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int etjvxu = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < etjvxu ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } List < Integer > collect = list . stream ( ) . sorted ( ) . collect ( Collectors . toList ( ) ) ; int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { sum += collect . get ( i ) ; } System . out . println ( sum ) ; } } 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 Qzqgec { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AProduct solver = new AProduct ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Qzqgec { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int qzqgec = in . nextInt ( ) ; int b = in . nextInt ( ) ; out . print ( qzqgec * b % 2 == 0 ? " Even " : " Odd " ) ; } } static class Qzqgec implements AutoCloseable { 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 ( ) ) ; } public void close ( ) { } } } import java . util . * ; public class Szjmeb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int szjmeb = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int C = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int a = szjmeb ; int b = B ; int c = C ; for ( int i = 0 ; i < K ; i ++ ) { a *= 2 ; b *= 2 ; c *= 2 ; } System . out . println ( Math . max ( a + B + C , Math . max ( szjmeb + b + C , szjmeb + B + c ) ) ) ; } } import java . util . Scanner ; public class Ausdln { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ausdln = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; if ( m == 0 ) { System . out . println ( " 0 0 " ) ; return ; } String [ ] [ ] p = new String [ m ] [ 2 ] ; for ( int i = 0 ; i < m ; i ++ ) { p [ i ] [ 0 ] = sc . next ( ) ; p [ i ] [ 1 ] = sc . next ( ) ; } boolean [ ] acA = new boolean [ ausdln + 1 ] ; int [ ] waA = new int [ ausdln + 1 ] ; int wa = 0 ; int ac = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int a = Integer . parseInt ( p [ i ] [ 0 ] ) ; if ( acA [ a ] ) continue ; if ( " WA " . equals ( p [ i ] [ 1 ] ) ) { waA [ a ] ++ ; } else { ac ++ ; wa += waA [ a ] ; acA [ a ] = true ; } } System . out . println ( ac + " " + wa ) ; } } import java . util . MissingResourceException ; import java . util . Scanner ; public class Qocmj { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; try { while ( true ) { String line = sc . next ( ) ; if ( line . equals ( " - " ) ) { break ; } int qocmj = sc . nextInt ( ) ; for ( int i = 0 ; i < qocmj ; i ++ ) { int h = sc . nextInt ( ) ; line = line . substring ( h ) + line . substring ( 0 , h ) ; } System . out . println ( line ) ; } } catch ( MissingResourceException e ) { System . out . println ( e ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Gfdap { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int gfdap = stdIn . nextInt ( ) ; for ( int n = 1 ; gfdap != 0 ; n ++ ) { System . out . println ( " Case " + n + " : " + gfdap ) ; gfdap = stdIn . nextInt ( ) ; } } } import java . util . * ; public class Uognzg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uognzg = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int plus = uognzg + B ; int minus = uognzg - B ; int kakeru = uognzg * B ; if ( B > - B ) { if ( plus < kakeru ) System . out . println ( kakeru ) ; else System . out . println ( plus ) ; } else { if ( minus < kakeru ) System . out . println ( kakeru ) ; else System . out . println ( minus ) ; } } } import java . util . Scanner ; class Oiqoe { public static int gcd ( int n1 , int n2 ) { if ( n1 < n2 ) return gcd ( n2 , n1 ) ; if ( n2 == 0 ) return n1 ; if ( n1 == n2 ) return n1 ; return gcd ( n2 , n1 % n2 ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oiqoe = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( gcd ( oiqoe , b ) ) ; } } import java . util . Scanner ; public class Jickrhx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int jickrhx = scanner . nextInt ( ) ; int [ ] h = new int [ jickrhx ] ; int [ ] curH = new int [ jickrhx ] ; for ( int i = 0 ; i < jickrhx ; i ++ ) { h [ i ] = scanner . nextInt ( ) ; } int count = 0 ; outer : while ( true ) { int start = 0 , end = 0 ; for ( start = 0 ; start < jickrhx ; start ++ ) { if ( curH [ start ] < h [ start ] ) { break ; } } if ( start >= jickrhx ) { break ; } count ++ ; int i ; for ( i = start ; i < jickrhx ; i ++ ) { if ( curH [ i ] < h [ i ] ) { curH [ i ] ++ ; } else { break ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Vmhqb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int vmhqb = Integer . parseInt ( scan . next ( ) ) ; int x = 0 ; int y = 0 ; int t = 0 ; boolean possible = true ; for ( int i = 0 ; i < vmhqb ; ++ i ) { int ti = Integer . parseInt ( scan . next ( ) ) ; int xi = Integer . parseInt ( scan . next ( ) ) ; int yi = Integer . parseInt ( scan . next ( ) ) ; int kyori = Math . abs ( x - xi ) + Math . abs ( y - yi ) ; int jikokuNoSa = Math . abs ( ti - t ) ; if ( kyori <= jikokuNoSa && Math . abs ( jikokuNoSa - kyori ) % 2 == 0 ) { t = ti ; x = xi ; y = yi ; } else { possible = false ; break ; } } scan . close ( ) ; if ( possible ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Anvvgc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int anvvgc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; if ( anvvgc == 0 ) { anvvgc = 1 ; } else if ( anvvgc == 1 ) { anvvgc = 100 ; } else { anvvgc = 10000 ; } for ( int i = 1 ; i <= b ; i ++ ) { ans = anvvgc * i ; if ( i >= 100 ) { ans = anvvgc * ( i + 1 ) ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; public class Aolrsr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aolrsr = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a % aolrsr == 0 || b % aolrsr == 0 ) { System . out . println ( " OK " ) ; return ; } int rem = a % aolrsr ; int temp = a - rem ; temp += aolrsr ; for ( int i = temp ; i < b ; i += aolrsr ) { if ( temp > a ) { System . out . println ( " OK " ) ; return ; } } System . out . println ( " NG " ) ; } } import java . io . IOException ; import java . util . * ; public class Mhswd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mhswd = sc . nextInt ( ) ; int [ ] s = new int [ mhswd ] ; for ( int i = 0 ; i < mhswd ; i ++ ) { s [ i ] = sc . nextInt ( ) ; } int q = sc . nextInt ( ) ; int count = 0 ; int left , right , mid , t ; for ( int i = 0 ; i < q ; i ++ ) { left = 0 ; right = mhswd - 1 ; t = sc . nextInt ( ) ; while ( left <= right ) { mid = ( left + right ) / 2 ; if ( s [ mid ] < t ) { left = mid + 1 ; } else if ( s [ mid ] > t ) { right = mid - 1 ; } else { count ++ ; break ; } } } System . out . println ( count ) ; } } import java . lang . Math ; import java . util . ArrayList ; import java . util . Scanner ; class Brelcb { public static void main ( String [ ] args ) { Scanner sn = new Scanner ( System . in ) ; int brelcb = sn . nextInt ( ) ; int b = sn . nextInt ( ) ; int c = sn . nextInt ( ) ; int co = 0 ; for ( int i = brelcb ; i <= b ; i ++ ) { if ( c % i != 0 ) { continue ; } co ++ ; } System . out . println ( co ) ; } } import java . util . * ; public class Teyit { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; String S = keyboard . next ( ) ; String X1 = S . replace ( 'A' , '#' ) ; String X2 = X1 . replace ( 'T' , '#' ) ; String X3 = X2 . replace ( 'G' , '#' ) ; String X4 = X3 . replace ( 'C' , '#' ) ; String [ ] Y = X4 . split ( " " ) ; int teyit = 0 ; int ans = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( Y [ i ] . equals ( " # " ) ) { teyit ++ ; ans = ( teyit > ans ) ? teyit : ans ; if ( teyit == S . length ( ) ) { ans = teyit ; } } else { ans = ( teyit > ans ) ? teyit : ans ; teyit = 0 ; } } System . out . println ( ans ) ; keyboard . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Wjwll { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String wjwll = br . readLine ( ) ; char [ ] ch = wjwll . toCharArray ( ) ; if ( ch [ 0 ] == ch [ 1 ] && ch [ 1 ] == ch [ 2 ] ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Dldcq { void run ( ) { Scanner scan = new Scanner ( System . in ) ; int dldcq = scan . nextInt ( ) ; int [ ] a = new int [ 100 ] ; for ( int i = 0 ; i < dldcq ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } System . out . print ( a [ dldcq - 1 ] ) ; for ( int i = dldcq - 2 ; i >= 0 ; i -- ) { System . out . print ( " " + a [ i ] ) ; } System . out . println ( ) ; } public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . run ( ) ; } } import java . util . Scanner ; public class Mwypa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mwypa = sc . nextInt ( ) ; int [ ] H = new int [ mwypa ] ; for ( int i = 0 ; i < H . length ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int ans = 1 ; int max = H [ 0 ] ; for ( int i = 1 ; i < H . length ; i ++ ) { if ( max <= H [ i ] ) { max = H [ i ] ; ans ++ ; } } System . out . println ( ans ) ; } } import java . text . DecimalFormat ; import java . util . Scanner ; public class Cnfjyn { static DecimalFormat df = new DecimalFormat ( " 0.0000000000000000000 " ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int cnfjyn = sc . nextInt ( ) ; String op = sc . next ( ) ; int b = sc . nextInt ( ) ; if ( op . equals ( " ? " ) ) break ; if ( op . equals ( " + " ) ) System . out . println ( cnfjyn + b ) ; else if ( op . equals ( " - " ) ) System . out . println ( cnfjyn - b ) ; else if ( op . equals ( " * " ) ) System . out . println ( cnfjyn * b ) ; else System . out . println ( cnfjyn / b ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Zsldlgu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int zsldlgu = sc . nextInt ( ) , a = sc . nextInt ( ) , b = sc . nextInt ( ) ; if ( a % zsldlgu == 0 || b % zsldlgu == 0 ) { System . out . println ( " OK " ) ; } else { if ( b / zsldlgu - a / zsldlgu == 0 ) { System . out . println ( " NG " ) ; } else { System . out . println ( " OK " ) ; } } } } import java . util . * ; public class Nfazhcm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int nfazhcm = scan . nextInt ( ) ; HashMap < Integer , Integer > a = new HashMap < Integer , Integer > ( ) ; int [ ] b = new int [ nfazhcm ] ; for ( int i = 0 ; i < nfazhcm ; i ++ ) { int t = scan . nextInt ( ) ; a . put ( t , i + 1 ) ; b [ i ] = t ; } Arrays . sort ( b ) ; for ( int j = 0 ; j < nfazhcm - 1 ; j ++ ) { System . out . print ( a . get ( b [ j ] ) + " " ) ; } System . out . println ( a . get ( b [ nfazhcm - 1 ] ) ) ; } } import java . util . * ; public class Paphxjr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int paphxjr = sc . nextInt ( ) ; if ( paphxjr >= 100 && paphxjr < 112 ) { System . out . println ( 111 ) ; } else if ( paphxjr >= 112 && paphxjr <= 222 ) { System . out . println ( 222 ) ; } else if ( paphxjr > 222 && paphxjr <= 333 ) { System . out . println ( 333 ) ; } else if ( paphxjr > 333 && paphxjr <= 444 ) { System . out . println ( 444 ) ; } else if ( paphxjr > 444 && paphxjr <= 555 ) { System . out . println ( 555 ) ; } else if ( paphxjr > 555 && paphxjr <= 666 ) { System . out . println ( 666 ) ; } else if ( paphxjr > 666 && paphxjr <= 777 ) { System . out . println ( 777 ) ; } else if ( paphxjr > 777 && paphxjr <= 888 ) { System . out . println ( 888 ) ; } else if ( paphxjr > 888 && paphxjr <= 999 ) { System . out . println ( 999 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Omoyi { static int omoyi ; static int B ; public static void main ( String [ ] args ) throws NumberFormatException , IOException { read ( ) ; } private static void read ( ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] word = br . readLine ( ) . split ( " \\ s+ " ) ; omoyi = Integer . parseInt ( word [ 0 ] ) ; B = Integer . parseInt ( word [ 1 ] ) ; System . out . println ( omoyi * B ) ; br . close ( ) ; } } import java . util . Scanner ; import static java . lang . Math . ceil ; class Pdajmm { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int pdajmm = input . nextInt ( ) ; int b = input . nextInt ( ) ; System . out . println ( ( int ) ceil ( ( 1.0 * pdajmm ) / ( 1.0 * b ) ) ) ; } } import java . util . * ; public class Jmbuyrn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int jmbuyrn = scanner . nextInt ( ) ; Integer [ ] d = new Integer [ jmbuyrn ] ; int s = 1 ; for ( int i = 0 ; i < jmbuyrn ; i ++ ) { d [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( d , Comparator . reverseOrder ( ) ) ; for ( int i = 0 ; i < jmbuyrn - 1 ; i ++ ) { if ( d [ i ] > d [ i + 1 ] ) s ++ ; } System . out . println ( s ) ; } } import java . util . * ; public class Dfnjjo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dfnjjo = sc . nextInt ( ) ; int [ ] x = new int [ dfnjjo ] ; int [ ] y = new int [ dfnjjo + 1 ] ; for ( int i = 0 ; i < dfnjjo ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ x [ i ] ] = i + 1 ; } for ( int i = 1 ; i <= dfnjjo ; i ++ ) System . out . print ( y [ i ] + " " ) ; } } import java . io . StringReader ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; class Fawthh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int fawthh = scanner . nextInt ( ) ; int pointSum = 0 ; scanner . useDelimiter ( " [ \r \n ]+ " ) ; scanner = new Scanner ( new StringReader ( scanner . next ( ) ) ) ; List < Integer > users = new ArrayList < > ( ) ; while ( scanner . hasNextInt ( ) ) { int user = scanner . nextInt ( ) ; users . add ( user ) ; pointSum += user ; } int middle = pointSum / fawthh ; if ( ( pointSum % fawthh ) > ( ( double ) fawthh / 2 ) ) { middle ++ ; } long sum = 0 ; for ( Integer u : users ) { sum += Math . pow ( u - middle , 2 ) ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Wpbrie { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wpbrie = scan . nextInt ( ) ; int N = scan . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += A [ i ] ; } System . out . println ( wpbrie > sum ? " No " : " Yes " ) ; } } import java . util . Scanner ; import java . util . Date ; class Tfklt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tfklt , b , c , m , n ; while ( sc . hasNext ( ) ) { tfklt = sc . nextInt ( ) ; b = sc . nextInt ( ) ; m = tfklt ; n = b ; if ( m < n ) { c = n ; n = m ; m = c ; } while ( true ) { if ( n == 0 ) break ; c = n ; n = m % n ; m = c ; } System . out . printf ( " %d %d \n " , m , tfklt / m * b ) ; } } } import java . util . Scanner ; public class Ruekhm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ruekhm = 0 ; while ( sc . hasNext ( ) ) { String s = sc . next ( ) ; if ( s . equals ( " 0 " ) ) { break ; } ruekhm = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; int digit = c - '0' ; ruekhm += digit ; } System . out . printf ( " %d \n " , ruekhm ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class Ywoudp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; ArrayList < Character > c = new ArrayList < Character > ( ) ; char [ ] C = new char [ s . length ( ) ] ; for ( int ywoudp = 0 ; ywoudp < s . length ( ) ; ywoudp ++ ) { C [ ywoudp ] = s . charAt ( ywoudp ) ; } for ( int ywoudp = 0 ; ywoudp < s . length ( ) ; ywoudp ++ ) { if ( C [ ywoudp ] == '1' ) { c . add ( '1' ) ; } if ( C [ ywoudp ] == '0' ) { c . add ( '0' ) ; } if ( C [ ywoudp ] == 'B' && c . size ( ) > 0 ) { c . remove ( c . size ( ) - 1 ) ; } } for ( int ywoudp = 0 ; ywoudp < c . size ( ) ; ywoudp ++ ) { System . out . print ( c . get ( ywoudp ) ) ; } } } import java . util . * ; public class Qyozxqn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qyozxqn = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { qyozxqn -= sc . nextInt ( ) ; } System . out . println ( qyozxqn >= 0 ? qyozxqn : - 1 ) ; } } import java . util . Scanner ; public class Mnruxto { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String [ ] strArray = scan . nextLine ( ) . split ( " " ) ; int mnruxto = Integer . parseInt ( strArray [ 0 ] ) ; int A = Integer . parseInt ( strArray [ 1 ] ) ; int lastCount = 0 ; for ( int i = 1 ; mnruxto > 0 ; i ++ ) { mnruxto = mnruxto - A ; lastCount = i ; } System . out . println ( lastCount ) ; } } import java . util . * ; class Bjvizl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bjvizl = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; for ( int i = bjvizl ; i <= b ; i ++ ) { String as = Integer . toString ( i ) ; List < String > list = Arrays . asList ( Integer . toString ( i ) . split ( " " ) ) ; Collections . reverse ( list ) ; String [ ] bs = ( String [ ] ) list . toArray ( new String [ list . size ( ) ] ) ; String strb = String . join ( " " , bs ) ; if ( as . equals ( strb ) ) ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; public class Nqsekto { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nqsekto = sc . nextInt ( ) ; System . out . println ( Math . ceil ( nqsekto / 2d ) / ( double ) nqsekto ) ; } } import java . util . Scanner ; public class Hqdlwh { public static void main ( String [ ] args ) { int hqdlwh , remainder ; int [ ] next = { 0 , 0 } ; Scanner in = new Scanner ( System . in ) ; next [ 0 ] = Integer . parseInt ( in . next ( ) ) ; next [ 1 ] = Integer . parseInt ( in . next ( ) ) ; if ( next [ 0 ] < next [ 1 ] ) { hqdlwh = next [ 1 ] ; next [ 1 ] = next [ 0 ] ; next [ 0 ] = hqdlwh ; } int i = 1 ; while ( i == 1 ) { remainder = gcd ( next [ 0 ] , next [ 1 ] ) ; if ( remainder == 0 ) { System . out . println ( next [ 1 ] ) ; System . exit ( 0 ) ; } next [ 0 ] = remainder ; remainder = gcd ( next [ 1 ] , next [ 0 ] ) ; if ( remainder == 0 ) { System . out . println ( next [ 0 ] ) ; System . exit ( 0 ) ; } next [ 1 ] = remainder ; } } public static int gcd ( int big , int small ) { int remainder = big % small ; return remainder ; } } import java . util . Scanner ; public class Xhayrom { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xhayrom = scan . nextInt ( ) ; int i ; for ( i = 1 ; i <= xhayrom ; i ++ ) { if ( i > xhayrom ) break ; String x = String . valueOf ( i ) ; if ( ( ( i % 3 ) == 0 ) || ( ( i % 10 ) == 3 ) || ( ( i / 10 ) == 3 ) ) { System . out . print ( " " + i ) ; } else if ( x . contains ( " 3 " ) ) { System . out . print ( " " + i ) ; } } System . out . println ( ) ; } } import java . util . Scanner ; public class Qoyhf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; int qoyhf = sc . nextInt ( ) ; int [ ] a = new int [ qoyhf ] ; for ( int i = 0 ; i < qoyhf ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int t = a [ qoyhf - 1 ] ; int max = 0 , cnt = 0 ; for ( int i = qoyhf - 2 ; i >= 0 ; i -- ) { if ( t <= a [ i ] ) { cnt ++ ; max = Math . max ( max , cnt ) ; } else { cnt = 0 ; } t = a [ i ] ; } System . out . println ( max ) ; } } import java . util . Scanner ; public class Xyevw { private static final Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int xyevw = scanner . nextInt ( ) ; boolean canReach = true ; int prevT = 0 ; int prevX = 0 ; int prevY = 0 ; for ( int i = 0 ; i < xyevw ; i ++ ) { int t = scanner . nextInt ( ) ; int hereX = scanner . nextInt ( ) ; int hereY = scanner . nextInt ( ) ; int distance = Math . abs ( hereX - prevX ) + Math . abs ( hereY - prevY ) ; if ( distance > t || distance % 2 != Math . abs ( t - prevT ) % 2 ) { canReach = false ; break ; } prevT = t ; prevX = hereX ; prevY = hereY ; } System . out . println ( canReach ? " Yes " : " No " ) ; } } import java . util . Scanner ; class Qarnyqr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] sum = new int [ 101 ] ; int [ ] [ ] h = new int [ 101 ] [ 101 ] ; int [ ] m = new int [ 101 ] ; int qarnyqr = scan . nextInt ( ) ; for ( int d = 0 ; d < qarnyqr ; d ++ ) { sum [ d ] = 0 ; } int b = scan . nextInt ( ) ; for ( int c = 0 ; c < qarnyqr ; c ++ ) { for ( int d = 0 ; d < b ; d ++ ) { h [ c ] [ d ] = scan . nextInt ( ) ; } } for ( int d = 0 ; d < b ; d ++ ) { m [ d ] = scan . nextInt ( ) ; } for ( int c = 0 ; c < qarnyqr ; c ++ ) { for ( int d = 0 ; d < b ; d ++ ) { sum [ c ] += h [ c ] [ d ] * m [ d ] ; } } for ( int c = 0 ; c < qarnyqr ; c ++ ) { System . out . println ( sum [ c ] ) ; } } } import java . util . * ; public class Cakawon { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cakawon = sc . nextInt ( ) ; int [ ] A = new int [ cakawon ] ; for ( int i = 0 ; i < cakawon ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } long [ ] L = new long [ cakawon ] ; for ( int i = 1 ; i < cakawon ; i ++ ) { if ( A [ i ] < A [ i - 1 ] ) { L [ i ] = A [ i - 1 ] - A [ i ] ; A [ i ] = A [ i - 1 ] ; } else { L [ i ] = 0 ; } } long S ; S = 0 ; for ( int i = 1 ; i < cakawon ; i ++ ) { S = S + L [ i ] ; } System . out . println ( S ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Ndcsw { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Ndcsw { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int ndcsw = in . next ( ) . length ( ) ; String s = " " ; for ( int i = 0 ; i < ndcsw ; i ++ ) { s += 'x' ; } out . print ( s ) ; } } } import java . util . * ; public class Iygon { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int iygon = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } if ( n == 0 ) { System . out . println ( iygon ) ; return ; } for ( int i = 0 ; i < n ; i ++ ) { int countm = 0 ; int countp = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( iygon - i != p [ j ] ) { countm ++ ; } if ( iygon + i != p [ j ] ) { countp ++ ; } } if ( countm == n ) { System . out . println ( iygon - i ) ; return ; } else if ( countp == n ) { System . out . println ( iygon + i ) ; return ; } } System . out . println ( iygon - 1 ) ; } } import java . util . Scanner ; public class Mmrkurn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int mmrkurn = 0 ; mmrkurn += s . charAt ( 0 ) == '1' ? 1 : 0 ; mmrkurn += s . charAt ( 1 ) == '1' ? 1 : 0 ; mmrkurn += s . charAt ( 2 ) == '1' ? 1 : 0 ; System . out . println ( mmrkurn ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Lwbzws { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; String [ ] depth_width = str . split ( " " , 0 ) ; int lwbzws = Integer . parseInt ( depth_width [ 0 ] ) ; int width = Integer . parseInt ( depth_width [ 1 ] ) ; ; int perimeter = lwbzws * 2 + width * 2 ; int area = lwbzws * width ; System . out . println ( area + " " + perimeter ) ; } } import java . io . PrintStream ; import java . util . Scanner ; public class Nwufj { static final PrintStream out = System . out ; static Scanner sc = new Scanner ( System . in ) ; static final long nwufj = 1000_000_007L ; public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; System . exit ( 0 ) ; } void solve ( ) { long A = nextInt ( ) ; long B = nextInt ( ) ; long K = ( A + B ) / 2 ; if ( Math . abs ( A - K ) == Math . abs ( B - K ) ) { out . println ( K ) ; } else { out . println ( " IMPOSSIBLE " ) ; } } public int [ ] nextIntArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } public long [ ] nextLongArray ( int n ) { long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextLong ( ) ; return a ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public String next ( ) { return sc . next ( ) ; } } import java . util . Scanner ; public class Zpcdpwj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int zpcdpwj = 0 ; zpcdpwj < s . length ( ) ; zpcdpwj ++ ) { if ( zpcdpwj % 2 == 0 ) { sb . append ( '0' ) ; } else { sb . append ( '1' ) ; } } String zero = sb . toString ( ) ; sb = new StringBuffer ( ) ; for ( int zpcdpwj = 0 ; zpcdpwj < s . length ( ) ; zpcdpwj ++ ) { if ( zpcdpwj % 2 == 1 ) { sb . append ( '0' ) ; } else { sb . append ( '1' ) ; } } String one = sb . toString ( ) ; int z = 0 ; int o = 0 ; for ( int zpcdpwj = 0 ; zpcdpwj < s . length ( ) ; zpcdpwj ++ ) { if ( s . charAt ( zpcdpwj ) == zero . charAt ( zpcdpwj ) ) { z ++ ; } else { o ++ ; } } System . out . println ( Math . min ( z , o ) ) ; } } import java . io . * ; class Ezmxbw { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int ezmxbw = Integer . parseInt ( br . readLine ( ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; long min = 1000000 ; long max = - 1000000 ; long sum = 0 ; for ( int i = 0 ; i < ezmxbw ; i ++ ) { long value = Integer . parseInt ( str [ i ] ) ; if ( min > value ) min = value ; if ( max < value ) max = value ; sum += value ; } System . out . println ( min + " " + max + " " + sum ) ; } } import java . util . Scanner ; public class Xwusnad { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xwusnad = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = new Main ( ) . gcd ( Math . max ( xwusnad , b ) , Math . min ( xwusnad , b ) ) ; System . out . println ( ans ) ; } public int gcd ( int b , int l ) { if ( l == 0 ) return b ; if ( l == 1 ) return l ; return gcd ( l , b % l ) ; } } import java . util . Scanner ; public class Ugkth { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ugkth = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; int Q = sc . nextInt ( ) ; long lim = K - Q ; int [ ] winCon = new int [ ugkth + 1 ] ; for ( int i = 0 ; i < Q ; i ++ ) { winCon [ sc . nextInt ( ) ] ++ ; } for ( int i = 1 ; i < winCon . length ; i ++ ) { if ( winCon [ i ] + lim > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; class Xojecsi { int xojecsi , y ; public void suzuki ( ) { Scanner sc = new Scanner ( System . in ) ; xojecsi = sc . nextInt ( ) ; y = sc . nextInt ( ) ; while ( xojecsi != 0 || y != 0 ) { if ( xojecsi > y ) { System . out . println ( y + " " + xojecsi ) ; } else { System . out . println ( xojecsi + " " + y ) ; } xojecsi = sc . nextInt ( ) ; y = sc . nextInt ( ) ; } } public static void main ( String [ ] args ) { new Main ( ) . suzuki ( ) ; } } import java . util . Scanner ; public class Itvkzjk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . nextLine ( ) ; int itvkzjk = Integer . parseInt ( str ) ; for ( int i = 1 ; i < 10 ; i ++ ) { if ( itvkzjk % i == 0 & itvkzjk / i < 10 ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . * ; public class Cjomeuy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cjomeuy = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; Map < Integer , List < String > > result = new HashMap < > ( ) ; for ( int i = 0 ; i < m ; i ++ ) { int p = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( ! result . containsKey ( p ) ) { result . put ( p , new ArrayList < > ( ) ) ; } result . get ( p ) . add ( s ) ; } int ok = 0 ; int ng = 0 ; for ( Map . Entry < Integer , List < String > > entry : result . entrySet ( ) ) { int acIndex = entry . getValue ( ) . indexOf ( " AC " ) ; if ( acIndex == - 1 ) { continue ; } ok ++ ; ng += acIndex ; } System . out . println ( ok + " " + ng ) ; } } import java . util . Scanner ; public class Cojquyo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cojquyo = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < cojquyo ; i ++ ) { sum += isPrimeNumber ( sc . nextLong ( ) ) ? 1 : 0 ; } System . out . println ( sum ) ; } private static boolean isPrimeNumber ( long a ) { if ( a == 2 ) { return true ; } else if ( a < 2 || a % 2 == 0 ) { return false ; } long sqrt = ( long ) Math . sqrt ( a ) ; for ( int i = 3 ; i <= sqrt ; i += 2 ) { if ( a % i == 0 ) { return false ; } } return true ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Oacdkdg { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int oacdkdg = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < oacdkdg ; i ++ ) { String tmp = change ( sc . next ( ) ) ; if ( map . containsKey ( tmp ) ) { map . put ( tmp , map . get ( tmp ) + 1 ) ; } else { map . put ( tmp , 1 ) ; } } long result = 0 ; for ( String str : map . keySet ( ) ) { result += calc ( map . get ( str ) ) ; } System . out . println ( result ) ; } } private static long calc ( long num ) { return ( num * ( num - 1 ) ) / 2 ; } private static String change ( String str ) { char [ ] arr = str . toCharArray ( ) ; Arrays . sort ( arr ) ; return new String ( arr ) ; } } import java . util . * ; import javax . lang . model . util . ElementScanner6 ; public class Ennrpj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ennrpj = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long out = ennrpj ; long a1 = ennrpj ; long b1 = b ; while ( ! ( out % ennrpj == 0 && out % b == 0 ) ) { out = a1 > b1 ? a1 : b1 ; if ( a1 < out ) { a1 += ennrpj ; } if ( b1 < out ) { b1 += b ; } } System . out . println ( out ) ; } } import java . util . Scanner ; public class Vnvct { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; String [ ] you = { " SUN " , " MON " , " TUE " , " WED " , " THU " , " FRI " , " SAT " } ; String s = gs ( ) ; for ( int vnvct = 0 ; vnvct < you . length ; vnvct ++ ) { if ( s . equals ( you [ vnvct ] ) ) { System . out . print ( 7 - vnvct ) ; return ; } } } public static String gs ( ) { return scanner . next ( ) ; } public static int gi ( ) { return Integer . parseInt ( scanner . next ( ) ) ; } public static long gl ( ) { return Long . parseLong ( scanner . next ( ) ) ; } public static double gd ( ) { return Double . parseDouble ( scanner . next ( ) ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Wszmrnd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wszmrnd = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int ans = getKth ( getGcd ( wszmrnd , b ) , k ) ; System . out . println ( ans ) ; } static int getGcd ( int wszmrnd , int b ) { if ( wszmrnd == 0 ) { return b ; } return getGcd ( b % wszmrnd , wszmrnd ) ; } static int getKth ( int n , int k ) { ArrayList < Integer > divisors = new ArrayList < > ( ) ; for ( int i = 1 ; i <= n / 2 ; i ++ ) { if ( n % i == 0 ) { divisors . add ( i ) ; } } divisors . add ( n ) ; return ( divisors . get ( divisors . size ( ) - k ) ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Gjdmxq { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int gjdmxq = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; String s = scan . next ( ) ; char [ ] a = s . toCharArray ( ) ; if ( a [ k - 1 ] >= 'A' && a [ k - 1 ] <= 'Z' ) { a [ k - 1 ] = ( char ) ( a [ k - 1 ] - 'A' + 'a' ) ; } System . out . println ( a ) ; } } import java . util . Collections ; import java . util . PriorityQueue ; import java . util . Scanner ; public class Lbyduky { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int lbyduky = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] aArray = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { aArray [ i ] = sc . nextInt ( ) ; } PriorityQueue < Integer > pq = new PriorityQueue < > ( Collections . reverseOrder ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { int dist = lbyduky - aArray [ n - 1 ] + aArray [ 0 ] ; pq . add ( dist ) ; } else { pq . add ( aArray [ i ] - aArray [ i - 1 ] ) ; } } int max = pq . poll ( ) ; System . out . println ( lbyduky - max ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ekzdupj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int ekzdupj = Integer . parseInt ( str [ 0 ] ) , y = Integer . parseInt ( str [ 1 ] ) , rest ; if ( ekzdupj < y ) { int temp = ekzdupj ; ekzdupj = y ; y = temp ; } do { rest = ekzdupj % y ; ekzdupj = y ; y = rest ; } while ( y != 0 ) ; System . out . println ( ekzdupj ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . text . DecimalFormat ; public class Qrmji { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str ; String [ ] arrStr ; try { str = br . readLine ( ) ; arrStr = str . split ( " " ) ; long qrmji = Integer . parseInt ( arrStr [ 0 ] ) ; long b = Integer . parseInt ( arrStr [ 1 ] ) ; long d = qrmji / b ; long r = qrmji % b ; double f = ( double ) qrmji / b ; DecimalFormat df = new DecimalFormat ( " 0.00000000 " ) ; System . out . println ( d + " " + r + " " + df . format ( f ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class Jctdx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jctdx = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= jctdx ; i ++ ) { double tmp = 1.0 / jctdx ; int now = i ; while ( now < K ) { now *= 2 ; tmp /= 2 ; } ans += tmp ; } System . out . println ( ans ) ; } } import java . io . * ; class Tzuzt { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = buf . readLine ( ) ; int tzuzt = Integer . parseInt ( s ) ; int res = tzuzt * tzuzt * tzuzt ; System . out . println ( res ) ; } } import java . util . * ; public class Zcdynnk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zcdynnk = sc . nextInt ( ) ; int [ ] A = new int [ zcdynnk ] ; for ( int i = 0 ; i < zcdynnk ; i ++ ) { A [ sc . nextInt ( ) - 1 ] = i + 1 ; } for ( int j = 0 ; j < zcdynnk ; j ++ ) { System . out . print ( A [ j ] + " " ) ; } } } import java . util . * ; public class Hookzqf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 2 ] ; while ( true ) { a [ 0 ] = sc . nextInt ( ) ; a [ 1 ] = sc . nextInt ( ) ; if ( a [ 0 ] == 0 && a [ 1 ] == 0 ) break ; Arrays . sort ( a ) ; System . out . println ( a [ 0 ] + " " + a [ 1 ] ) ; } } } import java . util . Scanner ; public class Xlvnjtq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; String [ ] Slist = S . split ( " " ) ; String [ ] Tlist = T . split ( " " ) ; int xlvnjtq = 0 ; for ( int i = 0 ; i <= 2 ; i ++ ) { if ( Slist [ i ] . equals ( Tlist [ i ] ) ) { xlvnjtq ++ ; } } System . out . println ( xlvnjtq ) ; } } import java . util . * ; class Vikxvzt { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int vikxvzt = in . nextInt ( ) ; int [ ] s = new int [ vikxvzt ] ; for ( int i = 0 ; i < vikxvzt ; i ++ ) { s [ i ] = in . nextInt ( ) ; } int q = in . nextInt ( ) ; int [ ] t = new int [ q ] ; for ( int i = 0 ; i < q ; i ++ ) { t [ i ] = in . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < q ; i ++ ) { int ul = s . length ; int ll = - 1 ; boolean flag = false ; while ( ll + 1 < ul ) { int mid = ( ll + ul ) / 2 ; if ( s [ mid ] == t [ i ] ) { flag = true ; break ; } else if ( s [ mid ] < t [ i ] ) { ll = mid ; } else { ul = mid ; } } if ( flag ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Kpdffoc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int kpdffoc = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; String S = scanner . next ( ) ; String [ ] sArray = S . split ( " " ) ; sArray [ K - 1 ] = sArray [ K - 1 ] . toLowerCase ( ) ; System . out . println ( String . join ( " " , sArray ) ) ; scanner . close ( ) ; } } import java . util . * ; public class Pdgmz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pdgmz = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = Integer . valueOf ( String . valueOf ( pdgmz ) + String . valueOf ( b ) ) ; if ( isPerfectSquare ( ( double ) c ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } static boolean isPerfectSquare ( double x ) { double sr = Math . sqrt ( x ) ; return ( ( sr - Math . floor ( sr ) ) == 0 ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Dsiyu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dsiyu = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int i = 0 ; int sum = 0 ; if ( k >= dsiyu ) { sum += dsiyu ; k = k - dsiyu ; } else { sum = k ; k = 0 ; } if ( k >= b ) k = k - b ; else k = 0 ; if ( k >= c ) sum = sum - c ; else sum = sum - k ; System . out . println ( sum ) ; } } import java . util . Scanner ; class Rqdamqh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int rqdamqh , x , x1 , x2 , x3 ; int counter ; while ( true ) { counter = 0 ; rqdamqh = scanner . nextInt ( ) ; x = scanner . nextInt ( ) ; if ( rqdamqh == 0 && x == 0 ) break ; for ( int i = 1 ; i <= rqdamqh ; i ++ ) { x1 = x ; x1 -= i ; if ( x1 > 1 ) { for ( int j = i + 1 ; j <= rqdamqh ; j ++ ) { x2 = x1 ; x2 -= j ; if ( x2 > 0 ) { for ( int k = j + 1 ; k <= rqdamqh ; k ++ ) { x3 = x2 ; x3 -= k ; if ( x3 == 0 ) counter ++ ; } } } } } System . out . println ( counter ) ; } } } import java . util . * ; class Sinovsz { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] argv ) { int sinovsz = scan . nextInt ( ) ; int n1 = sinovsz % 10 ; int n2 = ( sinovsz % 100 - n1 ) / 10 ; int n3 = ( sinovsz - n1 - n1 ) / 100 ; if ( n3 == 9 ) { sinovsz = 999 ; System . out . println ( sinovsz ) ; return ; } if ( n1 > n3 || n2 > n3 ) { n3 += 1 ; } sinovsz = n3 * 100 + n3 * 10 + n3 ; System . out . println ( sinovsz ) ; } } import java . util . * ; public class Iffzxr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iffzxr = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ iffzxr + 1 ] ; for ( int i = 1 ; i <= iffzxr ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int [ ] b = new int [ iffzxr + 1 ] ; b [ 0 ] = 1 ; int i = 1 ; int ans = - 1 ; while ( i <= iffzxr ) { b [ i ] = a [ b [ i - 1 ] ] ; if ( b [ i ] == 2 ) { ans = i ; break ; } i ++ ; } System . out . println ( ans ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Qutxibe { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int qutxibe = sc . nextInt ( ) ; int m = 1 ; Set < Integer > used = new HashSet < > ( ) ; for ( ; ! used . contains ( qutxibe ) ; m ++ ) { used . add ( qutxibe ) ; if ( qutxibe % 2 == 0 ) { qutxibe /= 2 ; } else { qutxibe = qutxibe * 3 + 1 ; } } System . out . println ( m ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Fgfglr { final static int fgfglr = 2 ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] num = new int [ fgfglr + 1 ] ; for ( int i = 0 ; i <= fgfglr ; i ++ ) { num [ i ] = scan . nextInt ( ) ; } Arrays . sort ( num ) ; System . out . println ( num [ 0 ] + " " + num [ 1 ] + " " + num [ 2 ] ) ; scan . close ( ) ; } } import java . util . Scanner ; public class Nprnq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; char [ ] cs = sc . next ( ) . toCharArray ( ) ; for ( char nprnq : cs ) { switch ( nprnq ) { case '1' : sb . append ( nprnq ) ; break ; case '0' : sb . append ( nprnq ) ; break ; case 'B' : if ( sb . length ( ) > 0 ) { sb . deleteCharAt ( sb . length ( ) - 1 ) ; } break ; } } System . out . println ( sb ) ; } } import java . util . Scanner ; public class Bdael { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int bdael = 0 , A2 = 0 , A3 = 0 , result = 0 ; bdael = input . nextInt ( ) ; A2 = input . nextInt ( ) ; A3 = input . nextInt ( ) ; if ( 1 <= bdael && bdael <= 13 && 1 <= A2 && A2 <= 13 && 1 <= A3 && A3 <= 13 ) { if ( bdael + A2 + A3 == 22 || bdael + A2 + A3 > 22 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } } else { } } } import java . io . * ; import java . util . * ; class Gywhwd { public static void main ( String [ ] args ) throws IOException { InputStreamReader in = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( in ) ; String [ ] buf = ( br . readLine ( ) ) . split ( " " ) ; int gywhwd = Integer . parseInt ( buf [ 0 ] ) ; int m = Integer . parseInt ( buf [ 1 ] ) ; ArrayList < Integer > matrix = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < gywhwd ; i ++ ) { buf = ( br . readLine ( ) ) . split ( " " ) ; for ( int j = 0 ; j < m ; j ++ ) { matrix . add ( Integer . parseInt ( buf [ j ] ) ) ; } } ArrayList < Integer > vector = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < m ; i ++ ) { int num_element = Integer . parseInt ( br . readLine ( ) ) ; vector . add ( num_element ) ; } ArrayList < Integer > answer = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < gywhwd ; i ++ ) { int temp = 0 ; for ( int j = 0 ; j < m ; j ++ ) { temp += matrix . get ( i * m + j ) * vector . get ( j ) ; } answer . add ( temp ) ; } for ( int i = 0 ; i < gywhwd ; i ++ ) { System . out . println ( answer . get ( i ) ) ; } } } import java . util . * ; import java . lang . * ; public class Dunmrox { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dunmrox , j , k , l , m , n , x , y , z ; double s = 0 , f = 0 ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( dunmrox = 0 ; dunmrox < n ; dunmrox ++ ) { a [ dunmrox ] = sc . nextInt ( ) ; s = s + a [ dunmrox ] ; } Arrays . sort ( a ) ; s = ( Math . ceil ( s / ( 4 * m ) ) ) ; for ( j = n - 1 ; j >= ( n - m ) ; j -- ) { if ( a [ j ] < ( int ) s ) { f = 1 ; System . out . print ( " No " ) ; break ; } } if ( f != 1 ) { System . out . println ( " Yes " ) ; } } } import java . awt . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; import java . util . List ; public class Bpziwr { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; long bpziwr = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextInt ( ) ; long d = sc . nextInt ( ) ; long x = b - bpziwr + 1 - ( ( b / c ) - ( bpziwr / c ) + ( b / d ) - ( bpziwr / d ) - ( ( b / ( lcm ( c , d ) ) ) - ( bpziwr / ( lcm ( c , d ) ) ) ) ) ; if ( bpziwr % c == 0 ) x -- ; if ( bpziwr % d == 0 ) x -- ; if ( bpziwr % ( lcm ( c , d ) ) == 0 ) x ++ ; System . out . println ( x ) ; } static long gcd ( long bpziwr , long b ) { if ( bpziwr == 0 ) return b ; else return gcd ( b % bpziwr , bpziwr ) ; } static long lcm ( long bpziwr , long b ) { return ( bpziwr * b ) / gcd ( bpziwr , b ) ; } } import java . util . * ; public class Gtcnkzc { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } long gtcnkzc ; long k ; long res ; public void run ( ) { Scanner sc = new Scanner ( System . in ) ; gtcnkzc = sc . nextLong ( ) ; k = sc . nextLong ( ) ; sc . close ( ) ; solve ( ) ; } private void solve ( ) { a ( gtcnkzc % k ) ; System . out . println ( res ) ; } private void a ( long a ) { if ( Math . abs ( a - k ) <= a ) { a = Math . abs ( a - k ) ; a ( a ) ; } else { res = a ; return ; } } } import java . util . * ; class Lpiuh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String [ ] s = S . split ( " " ) ; Map < String , Integer > map = new HashMap < > ( ) ; for ( int lpiuh = 0 ; lpiuh < 4 ; lpiuh ++ ) { if ( map . containsKey ( s [ lpiuh ] ) ) { map . put ( s [ lpiuh ] , map . get ( s [ lpiuh ] ) + 1 ) ; } else { map . put ( s [ lpiuh ] , 1 ) ; } } String ans = " Yes " ; for ( int lpiuh = 0 ; lpiuh < 4 ; lpiuh ++ ) { if ( map . get ( s [ lpiuh ] ) == 2 ) { continue ; } else { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Qiqaw { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int qiqaw = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( qiqaw >= 0 && qiqaw <= 100 ) { if ( b >= 0 && b <= 100 ) { if ( c >= 0 && c <= 100 ) { if ( qiqaw < b && b < c ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } } } } import java . util . * ; import java . math . BigDecimal ; public class Zmsvec { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long zmsvec = sc . nextLong ( ) ; BigDecimal x = BigDecimal . valueOf ( zmsvec ) ; BigDecimal sum = BigDecimal . valueOf ( 100 ) ; BigDecimal foo = BigDecimal . valueOf ( 1.01 ) ; for ( int i = 1 ; sum . compareTo ( x ) == - 1 ; i ++ ) { sum = sum . multiply ( foo ) . setScale ( 0 , BigDecimal . ROUND_DOWN ) ; if ( sum . compareTo ( x ) >= 0 ) { System . out . println ( i ) ; } } } } import java . util . * ; public class Gzmharg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long gzmharg = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = gzmharg / ( a + b ) ; long d = gzmharg % ( a + b ) ; long e = Math . min ( a , d ) ; System . out . println ( c * a + e ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; public class Vhhblvx { static class Vhhblvx { 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 ; } } public static void main ( String [ ] args ) { FastReader ob = new FastReader ( ) ; int vhhblvx = ob . nextInt ( ) , a = ob . nextInt ( ) , b = ob . nextInt ( ) ; int ans = ( a - ( a % vhhblvx ) ) + vhhblvx ; if ( ans >= a && ans <= b || a % vhhblvx == 0 ) { System . out . println ( " OK " ) ; return ; } System . out . println ( " NG " ) ; } } import java . util . Scanner ; public class Wtwjdc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long wtwjdc = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( k == 0 ) { System . out . println ( wtwjdc + " " + b ) ; return ; } if ( wtwjdc >= k ) { System . out . println ( wtwjdc - k + " " + b ) ; return ; } k -= wtwjdc ; if ( b >= k ) { System . out . println ( " 0 " + ( b - k ) ) ; return ; } System . out . println ( " 0 0 " ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Qmsnuk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qmsnuk = sc . nextInt ( ) ; String [ ] array = new String [ qmsnuk ] ; for ( int i = 0 ; i < qmsnuk ; i ++ ) { array [ i ] = sc . next ( ) ; } Arrays . sort ( array ) ; List < String > answerList = new ArrayList < String > ( ) ; int count = 1 ; int maxCount = 1 ; for ( int i = 1 ; i < qmsnuk ; i ++ ) { if ( array [ i - 1 ] . equals ( array [ i ] ) ) { count ++ ; } else { if ( count > maxCount ) { answerList . clear ( ) ; answerList . add ( array [ i - 1 ] ) ; maxCount = count ; count = 1 ; } else if ( count == maxCount ) { answerList . add ( array [ i - 1 ] ) ; count = 1 ; } else { count = 1 ; } } if ( i == qmsnuk - 1 ) { if ( count > maxCount ) { answerList . clear ( ) ; answerList . add ( array [ i ] ) ; } else if ( count == maxCount ) { answerList . add ( array [ i ] ) ; } } } for ( String answer : answerList ) { System . out . println ( answer ) ; } } } import java . util . * ; public class Qpdydq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int qpdydq , count = 1 ; String s ; qpdydq = sc . nextInt ( ) ; s = sc . next ( ) ; for ( int i = 0 ; i < qpdydq - 1 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i + 1 ) ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class Btkugwx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int btkugwx = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int x = sc . nextInt ( ) ; sum += x ; } System . out . println ( btkugwx - sum < 0 ? - 1 : btkugwx - sum ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Awyfzb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int awyfzb = scan . nextInt ( ) ; int odd , even ; if ( awyfzb % 2 == 1 ) { odd = awyfzb / 2 + 1 ; even = awyfzb / 2 ; } else { odd = awyfzb / 2 ; even = awyfzb / 2 ; } if ( awyfzb == 1 ) { System . out . println ( 1 ) ; } else { double ans = ( double ) odd / ( double ) awyfzb ; System . out . println ( ans ) ; } } } import java . util . Scanner ; public class Vrlqjag { public static void main ( String [ ] args ) { long vrlqjag ; try ( Scanner sc = new Scanner ( System . in ) ) { vrlqjag = sc . nextLong ( ) ; } double c = ( double ) vrlqjag / 3 ; double M = c * c * c ; System . out . println ( String . format ( " %.8f " , M ) ) ; } } import java . util . * ; import static java . lang . Math . * ; import java . math . BigInteger ; public class Askndu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String askndu = sc . next ( ) ; String result = " Heisei " ; if ( askndu . compareTo ( " 2019/04/30 " ) > 0 ) result = " TBD " ; System . out . println ( result ) ; } } import java . util . * ; public class Hsvyb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hsvyb = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = hsvyb + B ; int c = ( hsvyb + B ) / 2 ; int ans = 0 ; for ( int k = 0 ; k <= c ; k ++ ) { if ( C == 2 * k ) { ans = k ; } } if ( ans != 0 ) { System . out . println ( ans ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . util . Scanner ; public class Aqjenn { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int aqjenn = in . nextInt ( ) ; int [ ] a = new int [ 100 ] ; for ( int i = 0 ; i < aqjenn ; i ++ ) { int val = in . nextInt ( ) ; a [ i ] = val ; } for ( int i = 1 ; i < aqjenn ; i ++ ) { output ( a , aqjenn ) ; int val = a [ i ] ; int j = i - 1 ; while ( j >= 0 && val < a [ j ] ) { a [ j + 1 ] = a [ j ] ; j -- ; } a [ j + 1 ] = val ; } output ( a , aqjenn ) ; } static void output ( int [ ] a , int aqjenn ) { for ( int i = 0 ; i < aqjenn - 1 ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } System . out . println ( a [ aqjenn - 1 ] ) ; } } import java . util . * ; class Vbvyrp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vbvyrp = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] d = new int [ 3 ] ; d [ 0 ] = vbvyrp ; d [ 1 ] = b ; d [ 2 ] = c ; Arrays . sort ( d ) ; if ( ( d [ 0 ] == 5 && d [ 1 ] == 5 ) && d [ 2 ] == 7 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . * ; public class Nkntcwq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nkntcwq = sc . nextInt ( ) ; int [ ] A ; A = new int [ nkntcwq ] ; for ( int i = 0 ; i < nkntcwq ; i ++ ) A [ i ] = sc . nextInt ( ) ; Arrays . sort ( A ) ; boolean ans = true ; for ( int i = 0 ; i < nkntcwq - 1 ; i ++ ) if ( A [ i ] == A [ i + 1 ] ) ans = false ; System . out . println ( ans ? " YES " : " NO " ) ; } } import java . util . * ; class Hgqegte { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hgqegte = sc . nextInt ( ) ; int [ ] nums = new int [ hgqegte ] ; for ( int i = 0 ; i < hgqegte ; i ++ ) nums [ i ] = sc . nextInt ( ) ; for ( int i = 1 ; i < hgqegte ; i ++ ) { if ( nums [ i - 1 ] < nums [ i ] ) nums [ i ] -- ; else if ( nums [ i - 1 ] > nums [ i ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Mgmee { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mgmee = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( mgmee != 1 && b != 1 ) { System . out . println ( 1 ) ; } else if ( mgmee != 2 && b != 2 ) { System . out . println ( 2 ) ; } else { System . out . println ( 3 ) ; } } } import java . util . Scanner ; public class Lcczia { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lcczia = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; sc . close ( ) ; if ( ( double ) lcczia / T <= S ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; public class Iripryg { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int iripryg = s . nextInt ( ) ; int b = s . nextInt ( ) ; int c = s . nextInt ( ) ; int d = s . nextInt ( ) ; int start ; int end ; if ( iripryg < c ) { start = c ; } else { start = iripryg ; } if ( b < d ) { end = b ; } else { end = d ; } if ( start < end ) { System . out . println ( end - start ) ; } else { System . out . println ( " 0 " ) ; } } } import java . util . Scanner ; import java . util . ArrayList ; public class Fhztyg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fhztyg = sc . nextInt ( ) ; String sura = sc . next ( ) ; ArrayList < Character > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < fhztyg ; i ++ ) { if ( i == 0 ) { list . add ( sura . charAt ( i ) ) ; } else { list . add ( sura . charAt ( i ) ) ; if ( list . get ( list . size ( ) - 2 ) == list . get ( list . size ( ) - 1 ) ) { list . remove ( list . size ( ) - 1 ) ; } } } System . out . println ( list . size ( ) ) ; } } import java . util . * ; public class Rsyhy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rsyhy = sc . nextInt ( ) ; int [ ] A = new int [ rsyhy ] ; int ans = 0 ; for ( int i = 0 ; i < rsyhy ; i ++ ) { A [ i ] = sc . nextInt ( ) ; int count = 0 ; if ( A [ i ] % 2 != 0 ) { ans = 0 ; break ; } while ( A [ i ] % 2 == 0 ) { A [ i ] /= 2 ; count ++ ; } if ( count > 0 ) { if ( ans == 0 ) ans = count ; else ans = Math . min ( ans , count ) ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; class Veeeeyg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long veeeeyg = sc . nextLong ( ) ; double m = sc . nextLong ( ) ; long result = ( long ) Math . round ( m * 100 ) ; result = result * veeeeyg / 100 ; System . out . println ( result ) ; } } import java . util . * ; public class Cfktnc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; String [ ] S1 = S . split ( " / " , 0 ) ; int cfktnc , month , day ; cfktnc = Integer . parseInt ( S1 [ 0 ] ) ; month = Integer . parseInt ( S1 [ 1 ] ) ; day = Integer . parseInt ( S1 [ 2 ] ) ; if ( month >= 5 ) System . out . println ( " TBD " ) ; else System . out . println ( " Heisei " ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Map ; import java . util . Scanner ; import java . util . Set ; public class Thssvp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int thssvp = Integer . parseInt ( scanner . nextLine ( ) ) ; boolean x = false ; for ( int i = 0 ; i < 25 ; i ++ ) { for ( int j = 0 ; j < 15 ; j ++ ) { if ( ( i * 4 + j * 7 ) == thssvp ) { x = true ; } } } if ( x ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Israwou { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int israwou = sc . nextInt ( ) ; int [ ] ary = new int [ israwou ] ; for ( int i = 0 ; i < israwou ; i ++ ) { ary [ i ] = sc . nextInt ( ) ; } boolean flag = true ; int numSwap = 0 ; while ( flag ) { flag = false ; for ( int i = israwou - 1 ; i >= 1 ; i -- ) { if ( ary [ i ] < ary [ i - 1 ] ) { int temp = ary [ i ] ; ary [ i ] = ary [ i - 1 ] ; ary [ i - 1 ] = temp ; numSwap ++ ; flag = true ; } } } for ( int i = 0 ; i < israwou ; i ++ ) { System . out . print ( ary [ i ] ) ; if ( i < israwou - 1 ) { System . out . print ( " " ) ; } } System . out . println ( " " ) ; System . out . println ( numSwap ) ; } } import java . util . * ; public class Nwukkaj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nwukkaj = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int start = Math . max ( nwukkaj , C ) ; int end = Math . min ( B , D ) ; int reult = end - start ; System . out . println ( reult < 0 ? 0 : reult ) ; } } import java . util . * ; public class Yhddh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yhddh = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] alpha = new int [ yhddh ] ; int i , j ; for ( i = 0 ; i < yhddh ; i ++ ) { alpha [ i ] = sc . nextInt ( ) ; } int flag ; for ( j = 1 ; j < alpha . length ; j ++ ) { int key = alpha [ j ] ; i = j - 1 ; while ( i >= 0 && alpha [ i ] > key ) { alpha [ i + 1 ] = alpha [ i ] ; i -- ; } alpha [ i + 1 ] = key ; } int ans = 0 ; for ( j = 0 ; j < k ; j ++ ) { ans += alpha [ j ] ; } System . out . println ( ans ) ; } } import java . util . * ; public class Upcuc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int upcuc = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; list . add ( upcuc ) ; while ( true ) { if ( upcuc % 2 == 0 ) { upcuc /= 2 ; } else { upcuc = upcuc * 3 + 1 ; } if ( list . contains ( upcuc ) ) { list . add ( upcuc ) ; System . out . println ( list . size ( ) ) ; break ; } else { list . add ( upcuc ) ; } } } } import java . util . Scanner ; public class Ooqyehf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String answer = " " ; final String S = sc . next ( ) ; char [ ] s = S . toCharArray ( ) ; char [ ] sA = { s [ 0 ] , s [ 1 ] } ; char [ ] sB = { s [ 2 ] , s [ 3 ] } ; int ooqyehf = Integer . parseInt ( String . valueOf ( sA ) ) ; int b = Integer . parseInt ( String . valueOf ( sB ) ) ; if ( ooqyehf == 0 && b == 0 ) { answer = " NA " ; } else if ( ooqyehf == 0 ) { if ( b <= 12 ) { answer = " YYMM " ; } else { answer = " NA " ; } } else if ( b == 0 ) { if ( ooqyehf <= 12 ) { answer = " MMYY " ; } else { answer = " NA " ; } } else if ( ooqyehf <= 12 ) { if ( b <= 12 ) { answer = " AMBIGUOUS " ; } else { answer = " MMYY " ; } } else { if ( b <= 12 ) { answer = " YYMM " ; } else { answer = " NA " ; } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Mfszgtu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String moji = sc . nextLine ( ) ; char [ ] chmoji = new char [ moji . length ( ) ] ; for ( int mfszgtu = 0 ; mfszgtu < moji . length ( ) ; mfszgtu ++ ) { chmoji [ mfszgtu ] = moji . charAt ( mfszgtu ) ; boolean kekka = Character . isUpperCase ( chmoji [ mfszgtu ] ) ; if ( kekka == true ) { chmoji [ mfszgtu ] = Character . toLowerCase ( chmoji [ mfszgtu ] ) ; } else { chmoji [ mfszgtu ] = Character . toUpperCase ( chmoji [ mfszgtu ] ) ; } System . out . print ( chmoji [ mfszgtu ] ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class Taqfpr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int taqfpr = sc . nextInt ( ) ; for ( int i = 0 ; i < taqfpr ; i ++ ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) ; switch ( biggestLength ( a , b , c ) ) { case 'a' : if ( isRightTriangle ( a , b , c ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } break ; case 'b' : if ( isRightTriangle ( b , a , c ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } break ; case 'c' : if ( isRightTriangle ( c , a , b ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } break ; } } } static char biggestLength ( int a , int b , int c ) { if ( a <= b ) { if ( b <= c ) { return 'c' ; } else { return 'b' ; } } else if ( a <= c ) { return 'c' ; } else { return 'a' ; } } static boolean isRightTriangle ( int longest , int other1 , int other2 ) { int longestP = longest * longest ; int other1P = other1 * other1 ; int other2P = other2 * other2 ; return longestP == other2P + other1P ; } } import java . util . * ; class Jkssbq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jkssbq = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; while ( true ) { C -= B ; if ( C <= 0 ) { System . out . println ( " Yes " ) ; break ; } jkssbq -= D ; if ( jkssbq <= 0 ) { System . out . println ( " No " ) ; break ; } } } } import java . util . Scanner ; public class Lceblb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lceblb = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i <= lceblb ; i ++ ) { for ( int j = 0 ; j <= B ; j ++ ) { int tmp = X - i * 500 - j * 100 ; if ( 0 <= tmp && tmp <= C * 50 ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Qxbzj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qxbzj = sc . nextInt ( ) ; int [ ] list = new int [ qxbzj - 1 ] ; for ( int i = 0 ; i < qxbzj - 1 ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } int ans = 0 ; int lastV = 0 ; for ( int i = 0 ; i < qxbzj - 1 ; i ++ ) { if ( i == 0 ) { ans += list [ i ] ; } else if ( list [ i ] > lastV ) { ans += lastV ; } else { ans += list [ i ] ; } if ( i == qxbzj - 2 ) { ans += list [ i ] ; } lastV = list [ i ] ; } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Cssxtl { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strArr = br . readLine ( ) . split ( " " ) ; long cssxtl = Long . valueOf ( strArr [ 0 ] ) ; long b = Long . valueOf ( strArr [ 1 ] ) ; System . out . println ( gcd ( cssxtl , b ) ) ; } private static long gcd ( long cssxtl , long b ) { long r = cssxtl % b ; if ( r == 0 ) return b ; else return gcd ( b , cssxtl % b ) ; } } import java . util . Scanner ; public class Clysnc { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String line = sc . nextLine ( ) ; String answer = " " ; for ( int clysnc = 0 ; clysnc < line . length ( ) ; clysnc ++ ) { char ch = line . charAt ( clysnc ) ; if ( Character . isLowerCase ( ch ) ) answer = answer + Character . toUpperCase ( ch ) ; else answer = answer + Character . toLowerCase ( ch ) ; } System . out . println ( answer ) ; } } } import java . util . * ; public class Kcbmo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kcbmo = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; if ( S . length ( ) <= kcbmo ) System . out . println ( S ) ; else System . out . println ( S . substring ( 0 , kcbmo ) + " ... " ) ; } } import java . util . Scanner ; class Oftkmwd { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int oftkmwd = in . nextInt ( ) ; int Taro = 0 ; int Hanako = 0 ; while ( oftkmwd != 0 ) { String taro = in . next ( ) ; String hanako = in . next ( ) ; if ( taro . compareTo ( hanako ) < 0 ) { Hanako += 3 ; } else if ( taro . compareTo ( hanako ) > 0 ) { Taro += 3 ; } else { Taro += 1 ; Hanako += 1 ; } oftkmwd -- ; } System . out . println ( Taro + " " + Hanako ) ; } } import java . util . Scanner ; public class Wuids { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; for ( int wuids = 0 ; wuids < 3000 ; wuids ++ ) { int x = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; if ( x == 0 && y == 0 ) { break ; } int z ; if ( x > y ) { z = x ; x = y ; y = z ; } System . out . println ( x + " " + y ) ; } } } import java . util . * ; class Eligvhy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eligvhy = sc . nextInt ( ) ; int min = 200000 ; int cnt = 0 ; for ( int i = 0 ; i < eligvhy ; i ++ ) { int P = sc . nextInt ( ) ; min = Math . min ( min , P ) ; if ( min == P ) cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Kibilfa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long kibilfa = sc . nextLong ( ) ; Set < Long > numSet = new HashSet < > ( ) ; boolean hasSame = false ; for ( int i = 0 ; i < kibilfa ; i ++ ) { Long num = sc . nextLong ( ) ; if ( numSet . contains ( num ) ) { hasSame = true ; break ; } else { numSet . add ( num ) ; } } System . out . println ( hasSame ? " NO " : " YES " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Rtpdj { public static void main ( String [ ] args ) { solve ( ) ; } private static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; char [ ] sCode = sc . next ( ) . toCharArray ( ) ; boolean rtpdj = false ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( sCode [ i ] == sCode [ i + 1 ] ) { rtpdj = true ; break ; } } if ( rtpdj ) { System . out . print ( " Bad " ) ; } else System . out . print ( " Good " ) ; } } import java . util . * ; public class Uolsdv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String uolsdv = sc . next ( ) ; if ( uolsdv . contentEquals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } if ( uolsdv . equals ( " ARC " ) ) { System . out . println ( " ABC " ) ; } } } import java . math . * ; import java . util . * ; public class Pymup { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int [ ] hills = new int [ 10 ] ; for ( int pymup = 0 ; pymup < 10 ; pymup ++ ) { hills [ pymup ] = in . nextInt ( ) * - 1 ; } Arrays . sort ( hills ) ; for ( int pymup = 0 ; pymup < 3 ; pymup ++ ) { System . out . println ( hills [ pymup ] * - 1 ) ; } } } import java . util . Scanner ; public class Ijzlqi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ijzlqi = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= ijzlqi - 1 ; i ++ ) { count += i ; } for ( int i = 1 ; i <= m - 1 ; i ++ ) { count += i ; } System . out . println ( count ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Eweezt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eweezt = sc . nextInt ( ) ; ArrayList < Integer > A = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < eweezt ; i ++ ) A . add ( sc . nextInt ( ) ) ; ArrayList < Integer > output = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < eweezt ; i ++ ) output . add ( 0 ) ; for ( int i = 0 ; i < eweezt ; i ++ ) { int AIndex = A . get ( i ) - 1 ; output . set ( AIndex , i + 1 ) ; } for ( int i = 0 ; i < eweezt ; i ++ ) { System . out . print ( output . get ( i ) + " " ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Leqgm { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int leqgm = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 1 ] ) ; int c = Integer . parseInt ( str [ 2 ] ) ; System . out . println ( ( ( leqgm == b ) && ( b != c ) ) || ( ( b == c ) && ( c != leqgm ) ) || ( ( c == leqgm ) && ( leqgm != b ) ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Yhgnb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yhgnb = Integer . parseInt ( sc . next ( ) ) ; int [ ] p = new int [ yhgnb ] ; for ( int i = 0 ; i < yhgnb ; i ++ ) { p [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int cnt = 0 ; for ( int i = 1 ; i < yhgnb - 1 ; i ++ ) { if ( Math . min ( p [ i - 1 ] , p [ i ] ) == p [ i ] ) { if ( Math . min ( p [ i ] , p [ i + 1 ] ) == p [ i + 1 ] ) { cnt += 1 ; } } else { if ( Math . min ( p [ i ] , p [ i + 1 ] ) == p [ i ] ) { cnt += 1 ; } } } System . out . println ( cnt ) ; } } import java . util . * ; public class Fhjwtg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fhjwtg = 0 ; int sum = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { int x = sc . nextInt ( ) ; fhjwtg = Math . fhjwtg ( fhjwtg , x ) ; sum += x ; } System . out . println ( sum - fhjwtg ) ; } } import java . util . * ; public class Keetqjw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int keetqjw = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int saisi = sc . nextInt ( ) ; int c = keetqjw + b ; if ( keetqjw == - 1 && b == - 1 && saisi == - 1 ) { break ; } if ( keetqjw == - 1 || b == - 1 ) { System . out . println ( " F " ) ; } else if ( c >= 80 ) { System . out . println ( " A " ) ; } else if ( c >= 65 ) { System . out . println ( " B " ) ; } else if ( c >= 50 ) { System . out . println ( " C " ) ; } else if ( c >= 30 ) { if ( saisi >= 50 ) { System . out . println ( " C " ) ; } else { System . out . println ( " D " ) ; } } else { System . out . println ( " F " ) ; } } } } import java . util . Scanner ; public class Mamyvuq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mamyvuq = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; solve ( mamyvuq , X , T ) ; } private static void solve ( int n , int x , int t ) { if ( x == 1 || n == 1 ) System . out . println ( n * t ) ; else { int r = ( n + x - 1 ) / x ; System . out . println ( r * t ) ; } } } import java . util . Scanner ; public class Siqig { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int siqig = 0 ; int o = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '0' ) { siqig ++ ; } else { o ++ ; } } int r = Math . min ( siqig , o ) * 2 ; System . out . print ( r ) ; } } import java . util . Scanner ; public class Jpcbx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int jpcbx = scanner . nextInt ( ) ; String S = scanner . next ( ) ; String [ ] S1 = S . split ( " " ) ; if ( jpcbx >= S1 . length ) { for ( int j = 0 ; j < S1 . length ; j ++ ) { System . out . print ( S1 [ j ] ) ; } } else { for ( int j = 0 ; j < jpcbx ; j ++ ) { System . out . print ( S1 [ j ] ) ; } System . out . println ( " ... " ) ; } } } import java . util . Scanner ; public class Kmupp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int kmupp = s . length ( ) ; int [ ] A = new int [ kmupp ] ; int [ ] B = new int [ kmupp ] ; int i ; for ( i = 0 ; i < kmupp ; i ++ ) { A [ i ] = i % 2 ; B [ i ] = ( i + 1 ) % 2 ; } int tempA = 0 ; int tempB = 0 ; int intS ; for ( i = 0 ; i < kmupp ; i ++ ) { intS = Integer . parseInt ( s . substring ( i , i + 1 ) ) ; if ( intS != A [ i ] ) tempA ++ ; if ( intS != B [ i ] ) tempB ++ ; } System . out . println ( Math . min ( tempA , tempB ) ) ; } } import java . util . * ; public class Kdabozx { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int kdabozx = in . nextInt ( ) ; int ac = 0 ; int wa = 0 ; int tle = 0 ; int re = 0 ; for ( int i = 0 ; i <= kdabozx ; ++ i ) { String curr = in . nextLine ( ) ; if ( curr . equals ( " AC " ) ) ++ ac ; if ( curr . equals ( " WA " ) ) ++ wa ; if ( curr . equals ( " TLE " ) ) ++ tle ; if ( curr . equals ( " RE " ) ) ++ re ; } System . out . println ( " AC x " + ac ) ; System . out . println ( " WA x " + wa ) ; System . out . println ( " TLE x " + tle ) ; System . out . println ( " RE x " + re ) ; } } import java . util . Scanner ; public class Syqcaev { public static void main ( String [ ] argv ) { Scanner scanner = new Scanner ( System . in ) ; String line = scanner . nextLine ( ) ; String [ ] mn = line . split ( " " ) ; int syqcaev = Integer . parseInt ( mn [ 0 ] ) ; int n = Integer . parseInt ( mn [ 1 ] ) ; int ans = syqcaev * ( syqcaev - 1 ) / 2 + n * ( n - 1 ) / 2 ; System . out . println ( ans ) ; } } import java . io . IOException ; import java . util . Scanner ; public class Yswcugp { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int yswcugp = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( yswcugp == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < yswcugp ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Iwtjxcl { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String Sa = scanner . next ( ) ; String Sb = scanner . next ( ) ; String Sc = scanner . next ( ) ; char [ ] [ ] C = new char [ 3 ] [ 100 ] ; C [ 0 ] = Sa . toCharArray ( ) ; C [ 1 ] = Sb . toCharArray ( ) ; C [ 2 ] = Sc . toCharArray ( ) ; int [ ] t = new int [ 3 ] ; int iwtjxcl = 0 ; String ans = " " ; while ( true ) { switch ( C [ iwtjxcl ] [ t [ iwtjxcl ] ] ) { case 'a' : t [ iwtjxcl ] ++ ; iwtjxcl = 0 ; break ; case 'b' : t [ iwtjxcl ] ++ ; iwtjxcl = 1 ; break ; case 'c' : t [ iwtjxcl ] ++ ; iwtjxcl = 2 ; break ; } if ( t [ 0 ] == Sa . length ( ) && iwtjxcl == 0 ) { ans = " A " ; break ; } if ( t [ 1 ] == Sb . length ( ) && iwtjxcl == 1 ) { ans = " B " ; break ; } if ( t [ 2 ] == Sc . length ( ) && iwtjxcl == 2 ) { ans = " C " ; break ; } } System . out . println ( ans ) ; scanner . close ( ) ; } } import java . util . * ; public class Wooircy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int wooircy = 0 ; int steps2 = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { if ( s . charAt ( i ) != '1' ) wooircy ++ ; else steps2 ++ ; } else { if ( s . charAt ( i ) != '1' ) steps2 ++ ; else wooircy ++ ; } } System . out . println ( Math . min ( wooircy , steps2 ) ) ; } } import java . util . Scanner ; public class Xukqxsn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long xukqxsn = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; sc . close ( ) ; if ( xukqxsn < c ) { c -= xukqxsn ; xukqxsn = 0 ; if ( b < c ) { b = 0 ; } else { b -= c ; } } else { xukqxsn -= c ; } System . out . println ( xukqxsn + " " + b ) ; } } import java . util . * ; public class Svgzrjt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int svgzrjt = sc . nextInt ( ) ; int [ ] A = new int [ svgzrjt ] ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < svgzrjt ; i ++ ) { A [ i ] = sc . nextInt ( ) ; list . add ( A [ i ] ) ; } Collections . sort ( list ) ; for ( int i = 0 ; i < svgzrjt ; i ++ ) { if ( A [ i ] == list . get ( svgzrjt - 1 ) ) { System . out . println ( list . get ( svgzrjt - 2 ) ) ; } else { System . out . println ( list . get ( svgzrjt - 1 ) ) ; } } } } import java . util . Scanner ; public class Degxt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int degxt = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i < degxt ; i ++ ) { double calc = Math . sqrt ( Math . pow ( sc . nextInt ( ) , 2 ) + Math . pow ( sc . nextInt ( ) , 2 ) ) ; if ( calc <= d ) result ++ ; } System . out . println ( result ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . * ; import java . util . * ; public class Gklcn { private static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static void main ( String [ ] args ) throws IOException { getLine ( ) ; List < String > strings = getStrOnLine ( ) ; int gklcn = bubbleSort ( strings ) ; String out = String . join ( " " , strings ) ; System . out . println ( out ) ; System . out . println ( gklcn ) ; } private static int bubbleSort ( List < String > list ) { boolean flag = true ; int gklcn = 0 ; while ( flag ) { flag = false ; for ( int j = list . size ( ) - 1 ; j >= 1 ; j -- ) { int a = Integer . parseInt ( list . get ( j ) ) ; int b = Integer . parseInt ( list . get ( j - 1 ) ) ; if ( a < b ) { String tmp = list . get ( j ) ; list . set ( j , list . get ( j - 1 ) ) ; list . set ( j - 1 , tmp ) ; gklcn ++ ; flag = true ; } } } return gklcn ; } public static String getLine ( ) throws IOException { String str = br . readLine ( ) ; return str ; } public static List < String > getStrOnLine ( ) throws IOException { List < String > list = new ArrayList < > ( ) ; String line = getLine ( ) ; list . addAll ( Arrays . asList ( line . split ( " " ) ) ) ; return list ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class Uxddxff { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int uxddxff = sc . nextInt ( ) ; String S = sc . next ( ) ; char [ ] C = S . toCharArray ( ) ; char x = C [ 0 ] ; for ( int i = 1 ; i < uxddxff ; i ++ ) { if ( C [ i ] == x ) { C [ i ] = 0 ; } else { x = C [ i ] ; } } int ans = 0 ; for ( int i = 0 ; i < uxddxff ; i ++ ) { if ( C [ i ] != 0 ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Ecqksem { public static void main ( String [ ] gg ) { Scanner sc = new Scanner ( System . in ) ; int ecqksem = sc . nextInt ( ) ; String s = sc . next ( ) ; int counter = 0 ; int i = 0 ; while ( i < ecqksem - 2 ) { if ( s . charAt ( i ) == 'A' && s . charAt ( i + 1 ) == 'B' && s . charAt ( i + 2 ) == 'C' ) { counter ++ ; i ++ ; } else { i ++ ; } } System . out . println ( counter ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Fwyhh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fwyhh = sc . nextInt ( ) ; long [ ] nums = new long [ fwyhh ] ; for ( int i = 0 ; i < fwyhh ; i ++ ) { nums [ i ] = sc . nextLong ( ) ; } Arrays . sort ( nums ) ; long ans = nums [ 0 ] ; if ( ans == 0 ) { System . out . println ( 0 ) ; } else { boolean over = false ; for ( int i = 1 ; i < fwyhh ; i ++ ) { ans *= nums [ i ] ; if ( 1000000000000000000L < ans || ans <= 0 ) { System . out . println ( - 1 ) ; over = true ; break ; } } if ( ! over ) { System . out . println ( ans ) ; } } } } import java . io . IOException ; import java . util . Scanner ; public class Fhhad { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int fhhad = scan . nextInt ( ) ; boolean [ ] [ ] cards = new boolean [ 4 ] [ 13 ] ; for ( int i = 0 ; i < fhhad ; i ++ ) { String design = scan . next ( ) ; int cardNumber = scan . nextInt ( ) ; int designNumber = 0 ; if ( design . equals ( " S " ) ) { designNumber = 0 ; } else if ( design . equals ( " H " ) ) { designNumber = 1 ; } else if ( design . equals ( " C " ) ) { designNumber = 2 ; } else if ( design . equals ( " D " ) ) { designNumber = 3 ; } cards [ designNumber ] [ cardNumber - 1 ] = true ; } for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 13 ; j ++ ) { if ( cards [ i ] [ j ] == false ) { if ( i == 0 ) { System . out . print ( " S " ) ; } else if ( i == 1 ) { System . out . print ( " H " ) ; } else if ( i == 2 ) { System . out . print ( " C " ) ; } else if ( i == 3 ) { System . out . print ( " D " ) ; } System . out . println ( " " + ( j + 1 ) ) ; } } } } } import java . util . Scanner ; public class Igiguc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int igiguc = Integer . parseInt ( sc . nextLine ( ) ) ; boolean okFlag = true ; int prePosX = 0 ; int prePosY = 0 ; int preTime = 0 ; for ( int i = 1 ; i <= igiguc ; i ++ ) { String [ ] line = sc . nextLine ( ) . split ( " " ) ; int time = Integer . parseInt ( line [ 0 ] ) ; int posX = Integer . parseInt ( line [ 1 ] ) ; int posY = Integer . parseInt ( line [ 2 ] ) ; int disX = Math . abs ( posX - prePosX ) ; int disY = Math . abs ( posY - prePosY ) ; int disTime = Math . abs ( time - preTime ) ; if ( disTime < ( disX + disY ) ) { okFlag = false ; break ; } if ( disTime % 2 != ( disX + disY ) % 2 ) { okFlag = false ; break ; } prePosX = posX ; prePosY = posY ; preTime = time ; } if ( okFlag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import static java . lang . System . * ; import java . math . * ; public class Wfgujts { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wfgujts = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int cnt = 0 ; int plug = 1 ; for ( ; ; ) { if ( plug >= b ) break ; plug = plug + wfgujts - 1 ; cnt ++ ; } out . println ( cnt ) ; } } import java . util . * ; public class Vlcyj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vlcyj = sc . nextInt ( ) ; int tA = sc . nextInt ( ) ; int aH = sc . nextInt ( ) ; int aA = sc . nextInt ( ) ; int tCount = 0 ; while ( vlcyj > 0 ) { vlcyj -= aA ; tCount ++ ; } int aCount = 0 ; while ( aH > 0 ) { aH -= tA ; aCount ++ ; } if ( tCount < aCount ) { System . out . println ( " No " ) ; } else if ( tCount == aCount ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; public class Nebklo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = sc . next ( ) . split ( " " ) ; for ( int nebklo = 0 ; nebklo < s . length ; nebklo ++ ) { if ( s [ nebklo ] . equals ( " 1 " ) ) s [ nebklo ] = " 9 " ; else if ( s [ nebklo ] . equals ( " 9 " ) ) s [ nebklo ] = " 1 " ; System . out . print ( s [ nebklo ] ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; public class Zrujemj { public static void main ( String [ ] args ) throws Exception { InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader reader = new BufferedReader ( is ) ; List < String > mylist = new ArrayList < > ( ) ; String strinput = reader . readLine ( ) ; while ( strinput != null ) { mylist . add ( strinput ) ; strinput = reader . readLine ( ) ; } String [ ] arr01 = mylist . get ( 0 ) . split ( " " ) ; String [ ] arr02 = mylist . get ( 1 ) . split ( " " ) ; int zrujemj = Integer . valueOf ( arr01 [ 0 ] ) ; String [ ] arr_result = new String [ zrujemj ] ; Arrays . fill ( arr_result , " 0 " ) ; for ( int i = zrujemj - 1 ; i >= 1 ; i -- ) { int a = Integer . valueOf ( arr02 [ i - 1 ] ) ; int val = Integer . valueOf ( arr_result [ a - 1 ] ) ; arr_result [ a - 1 ] = String . valueOf ( val + 1 ) ; } String result = String . join ( System . getProperty ( " line.separator " ) , arr_result ) ; System . out . println ( result ) ; } } import java . io . * ; class Jkwgcfi { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int jkwgcfi = Integer . parseInt ( br . readLine ( ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < jkwgcfi ; i ++ ) { if ( i == jkwgcfi - 1 ) { System . out . println ( str [ jkwgcfi - i - 1 ] ) ; } else { System . out . print ( str [ jkwgcfi - i - 1 ] + " " ) ; } } } } import java . util . Scanner ; public class Aanukqu { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int aanukqu = s . nextInt ( ) ; int ones = aanukqu % 10 ; String ans ; if ( ones == 3 ) { ans = " bon " ; } else if ( ones == 0 || ones == 1 || ones == 6 || ones == 8 ) { ans = " pon " ; } else { ans = " hon " ; } System . out . println ( ans ) ; } } import java . util . * ; import java . lang . * ; import java . math . * ; public class Otywyad { Scanner sc = new Scanner ( System . in ) ; void run ( ) { int otywyad = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] ret = new int [ otywyad + 1 ] ; for ( int i = 0 ; i < otywyad + 1 ; i ++ ) ret [ i ] = i ; for ( int k = 0 ; k < n ; k ++ ) { String ts = sc . next ( ) ; ts = ts . replace ( ',' , ' ' ) ; Scanner str = new Scanner ( ts ) ; int d1 = str . nextInt ( ) ; int d2 = str . nextInt ( ) ; int temp = ret [ d1 ] ; ret [ d1 ] = ret [ d2 ] ; ret [ d2 ] = temp ; } for ( int i = 1 ; i < otywyad + 1 ; i ++ ) { System . out . println ( ret [ i ] ) ; } } public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . run ( ) ; } } import java . util . * ; public class Qdjnb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( execute ( sc . nextLine ( ) ) ) ; } public static int execute ( String text ) { int qdjnb = 0 ; for ( int front = 0 ; front < text . length ( ) / 2 ; front ++ ) { int back = text . length ( ) - front - 1 ; String frontChar = String . valueOf ( text . charAt ( front ) ) ; String backChar = String . valueOf ( text . charAt ( back ) ) ; if ( ! frontChar . equals ( backChar ) ) { qdjnb ++ ; } } return qdjnb ; } } import java . util . Arrays ; import java . util . Scanner ; public class Ngekq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ngekq = sc . nextInt ( ) ; int [ ] d = new int [ ngekq ] ; int mid = 0 ; int max = 0 ; int min = 100000 ; for ( int i = 0 ; i < ngekq ; i ++ ) { d [ i ] = sc . nextInt ( ) ; mid += d [ i ] ; if ( d [ i ] > max ) { max = d [ i ] ; } if ( d [ i ] < min ) { min = d [ i ] ; } } int [ ] e = d ; Arrays . sort ( e ) ; mid = e [ ngekq / 2 - 1 ] ; int count = 0 ; System . out . println ( e [ ngekq / 2 ] - e [ ngekq / 2 - 1 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Ukrpolk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String str = br . readLine ( ) ; int ukrpolk = Integer . parseInt ( str ) ; str = br . readLine ( ) ; String [ ] s = str . split ( " " , 0 ) ; int [ ] a = new int [ 8 ] ; for ( int i = 0 ; i < 8 ; i ++ ) { a [ i ] = 0 ; } int count = 0 ; int over = 0 ; for ( int i = 0 ; i < ukrpolk ; i ++ ) { int x = Integer . parseInt ( s [ i ] ) ; if ( x >= 3200 ) { over ++ ; } else if ( a [ x / 400 ] == 0 ) { count ++ ; a [ x / 400 ] ++ ; } } int min = count ; if ( min == 0 ) min = 1 ; int max = over + count ; System . out . println ( min + " " + max ) ; } catch ( Exception e ) { System . exit ( 0 ) ; } } } import java . util . Scanner ; public class Mgvych { public static int gcd ( int a , int b , int c ) { int mgvych = Math . min ( a , Math . min ( b , c ) ) ; for ( int i = mgvych ; i > 0 ; i -- ) { if ( a % i == 0 && b % i == 0 && c % i == 0 ) { return i ; } } return - 1 ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int number = sc . nextInt ( ) ; int total = 0 ; for ( int i = 1 ; i < number + 1 ; i ++ ) { for ( int j = 1 ; j < number + 1 ; j ++ ) { for ( int k = 1 ; k < number + 1 ; k ++ ) { total += gcd ( i , j , k ) ; } } } System . out . println ( total ) ; } } import java . util . * ; public class Ayfmr { Scanner sc = new Scanner ( System . in ) ; void doIt ( ) { sB ( ) ; } void sB ( ) { int ayfmr = sc . nextInt ( ) ; int L ; int max = 0 ; int sum = 0 ; for ( int i = 0 ; i < ayfmr ; i ++ ) { L = sc . nextInt ( ) ; sum += L ; if ( L > max ) max = L ; } if ( sum - max <= max ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } public static void main ( String [ ] args ) { new Main ( ) . doIt ( ) ; } } import java . util . * ; public class Zqzzxk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zqzzxk = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; for ( int i = 1 ; i < 10000 ; i ++ ) { if ( ( int ) Math . floor ( i * 0.08 ) == zqzzxk && ( int ) Math . floor ( i * 0.1 ) == B ) { System . out . println ( i ) ; return ; } } System . out . println ( - 1 ) ; return ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ddpgkr { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = reader . readLine ( ) ; int ddpgkr = Integer . parseInt ( str ) ; long sum = 0 ; for ( int i = 1 ; i <= ddpgkr ; i ++ ) { if ( i % 3 == 0 || i % 5 == 0 ) continue ; sum += i ; } System . out . print ( sum ) ; } } import java . io . * ; public class Yznsak { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String in = br . readLine ( ) ; double yznsak = Math . pow ( Integer . parseInt ( in ) , 3 ) ; System . out . println ( ( int ) yznsak ) ; br . close ( ) ; } } import java . util . Scanner ; public class Srinvs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int srinvs , wid , cnt_wid ; while ( true ) { srinvs = scan . nextInt ( ) ; wid = scan . nextInt ( ) ; if ( srinvs == 0 && wid == 0 ) { break ; } for ( cnt_wid = 0 ; cnt_wid < wid ; cnt_wid ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; for ( int cnt_hei = 0 ; cnt_hei < srinvs - 2 ; cnt_hei ++ ) { System . out . print ( " # " ) ; for ( cnt_wid = 0 ; cnt_wid < wid - 2 ; cnt_wid ++ ) { System . out . print ( " . " ) ; } System . out . print ( " # " ) ; System . out . println ( ) ; } for ( cnt_wid = 0 ; cnt_wid < wid ; cnt_wid ++ ) { System . out . print ( " # " ) ; } System . out . println ( " \n " ) ; } scan . close ( ) ; } } import java . util . Scanner ; public class Nizuuky { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int nizuuky = scanner . nextInt ( ) ; int tarop = 0 ; int hanakop = 0 ; String tarow ; String hanakow ; for ( int i = 0 ; i < nizuuky ; i ++ ) { tarow = scanner . next ( ) ; hanakow = scanner . next ( ) ; if ( tarow . compareTo ( hanakow ) < 0 ) { hanakop = hanakop + 3 ; } else if ( tarow . compareTo ( hanakow ) > 0 ) tarop = tarop + 3 ; else { hanakop = hanakop + 1 ; tarop = tarop + 1 ; } } System . out . println ( tarop + " " + hanakop ) ; } } import java . util . Scanner ; public class Vizvsqn { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String [ ] SSplit = S . split ( " " ) ; int vizvsqn = 0 ; for ( int i = 0 ; i < SSplit . length / 2 ; i ++ ) { if ( ! SSplit [ i ] . equals ( SSplit [ SSplit . length - i - 1 ] ) ) { vizvsqn ++ ; } } System . out . print ( vizvsqn ) ; } } import java . text . * ; import java . util . * ; public class Bbfphj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; try { DateFormat sdf = new SimpleDateFormat ( " yyyy/MM/dd " ) ; Date date1 = sdf . parse ( a ) ; Date date2 = sdf . parse ( " 2019/04/30 " ) ; int bbfphj = date1 . compareTo ( date2 ) ; if ( bbfphj > 0 ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } } catch ( ParseException e ) { e . printStackTrace ( ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Jsuvn { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String str = br . readLine ( ) ; String [ ] strArr = str . split ( " " ) ; int jsuvn = Integer . parseInt ( strArr [ 0 ] ) ; int m = Integer . parseInt ( strArr [ 1 ] ) ; String [ ] [ ] a = new String [ jsuvn ] [ m ] ; String [ ] b = new String [ m ] ; for ( int i = 0 ; i < jsuvn ; i ++ ) { str = br . readLine ( ) ; a [ i ] = str . split ( " " ) ; } for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = br . readLine ( ) ; } int sum ; for ( int i = 0 ; i < jsuvn ; i ++ ) { sum = 0 ; for ( int j = 0 ; j < m ; j ++ ) { sum += Integer . parseInt ( a [ i ] [ j ] ) * Integer . parseInt ( b [ j ] ) ; } System . out . println ( sum ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { try { if ( br != null ) { br . close ( ) ; } } catch ( IOException ioe ) { } } } } import java . util . * ; public class Lutmuj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int lutmuj = sc . nextInt ( ) ; int [ ] li = new int [ lutmuj ] ; for ( int i = 1 ; i <= lutmuj ; i ++ ) { li [ sc . nextInt ( ) - 1 ] = i ; } int i = 0 ; for ( int k : li ) { if ( i != lutmuj - 1 ) { System . out . print ( li [ i ] + " " ) ; } else { System . out . println ( li [ i ] ) ; } i ++ ; } } } import java . util . Scanner ; public class Prlro { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String prlro = sc . next ( ) ; String S = " Sunny " ; String C = " Cloudy " ; String R = " Rainy " ; if ( prlro . equals ( S ) ) { System . out . println ( C ) ; } else if ( prlro . equals ( C ) ) { System . out . println ( R ) ; } else { System . out . println ( S ) ; } } } import java . util . * ; public class Odtvy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int odtvy = 0 ; odtvy < 3 ; odtvy ++ ) { a [ odtvy ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int odtvy = 0 ; odtvy < 2 ; odtvy ++ ) { System . out . print ( a [ odtvy ] + " " ) ; } System . out . println ( a [ 2 ] ) ; } } import java . util . Scanner ; public class Zygycte { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int zygycte = scan . nextInt ( ) ; String op = scan . next ( ) ; int b = scan . nextInt ( ) ; if ( op . equals ( " ? " ) ) { break ; } switch ( op ) { case " + " : System . out . println ( zygycte + b ) ; break ; case " - " : System . out . println ( zygycte - b ) ; break ; case " * " : System . out . println ( zygycte * b ) ; break ; case " / " : System . out . println ( zygycte / b ) ; break ; } } scan . close ( ) ; } } import java . io . PrintWriter ; import java . util . Scanner ; class Nwixh { private static final Scanner sc = new Scanner ( System . in ) ; private static final PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] Args ) { while ( true ) { final int nwixh = Integer . parseInt ( sc . next ( ) ) ; final int f = Integer . parseInt ( sc . next ( ) ) ; final int r = Integer . parseInt ( sc . next ( ) ) ; if ( nwixh == - 1 && f == - 1 && r == - 1 ) break ; if ( nwixh == - 1 || f == - 1 ) out . println ( 'F' ) ; else if ( nwixh + f >= 80 ) out . println ( 'A' ) ; else if ( nwixh + f >= 65 ) out . println ( 'B' ) ; else if ( nwixh + f >= 50 ) out . println ( 'C' ) ; else if ( nwixh + f < 30 ) out . println ( 'F' ) ; else if ( r >= 50 ) out . println ( 'C' ) ; else out . println ( 'D' ) ; } out . flush ( ) ; } } import java . util . * ; import java . math . BigDecimal ; public class Okfrdj { public static void main ( String [ ] args ) { int okfrdj ; int [ ] A ; try ( Scanner sc = new Scanner ( System . in ) ) { okfrdj = sc . nextInt ( ) ; A = new int [ okfrdj ] ; for ( int i = 0 ; i < okfrdj ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } } double answer = solve ( A ) ; System . out . println ( answer ) ; } private static double solve ( int [ ] a ) { int n = a . length ; if ( n == 0 ) { throw new IllegalStateException ( " n must be positive " ) ; } if ( n == 1 ) { return ( double ) a [ 0 ] ; } int n0 = ( int ) Math . ceil ( n / 2 ) ; int n1 = n - n0 ; double r = 0.0d ; if ( n0 > 0 ) { int [ ] a0 = new int [ n0 ] ; System . arraycopy ( a , 0 , a0 , 0 , n0 ) ; double s0 = solve ( a0 ) ; r += 1 / s0 ; } if ( n1 > 0 ) { int [ ] a1 = new int [ n1 ] ; System . arraycopy ( a , n0 , a1 , 0 , n1 ) ; double s1 = solve ( a1 ) ; r += 1 / s1 ; } return 1 / r ; } } import java . util . Scanner ; class Hgfec { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String a = input . next ( ) ; if ( a . length ( ) == 10 ) { if ( a . contains ( " 2017/01/ " ) ) { String temp = " " + a . charAt ( 8 ) + a . charAt ( 9 ) ; int hgfec = Integer . parseInt ( temp ) ; if ( hgfec >= 1 && hgfec <= 31 ) { a = a . replace ( " 2017 " , " 2018 " ) ; System . out . println ( a ) ; } } } } } import java . util . Scanner ; public class Fincv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; try { int fincv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( " a " + ( fincv == b ? " == " : ( fincv < b ? " < " : " > " ) ) + " b " ) ; } finally { sc . close ( ) ; } } } import java . util . Scanner ; public class Ttwakg { public static void select_Sort ( int n , int [ ] A ) { int ttwakg = 0 ; int mini = 0 ; int x = 0 ; int sortNum = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( j == i + 1 ) { ttwakg = A [ j ] ; mini = j ; } if ( ttwakg > A [ j ] ) { ttwakg = A [ j ] ; mini = j ; } } if ( A [ i ] > A [ mini ] ) { x = A [ mini ] ; A [ mini ] = A [ i ] ; A [ i ] = x ; sortNum ++ ; } } System . out . printf ( " %d " , A [ 0 ] ) ; for ( int k = 1 ; k < n ; k ++ ) { System . out . printf ( " %d " , A [ k ] ) ; } System . out . printf ( " \n " ) ; System . out . println ( sortNum ) ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int [ ] A = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { A [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; select_Sort ( n , A ) ; return ; } } import java . io . * ; class Bmrrjuj { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = input . readLine ( ) ; int bmrrjuj = 0 , n = str . length ( ) - 1 ; char [ ] ch = str . toCharArray ( ) ; for ( int i = n ; i >= 0 ; i -- ) { System . out . print ( ch [ i ] ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class Fiwth { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int fiwth = s . nextInt ( ) ; long sum = 0 ; for ( int i = 0 ; i < fiwth ; i ++ ) { if ( ( i + 1 ) % 3 != 0 ) { if ( ( i + 1 ) % 5 != 0 ) { sum = sum + ( i + 1 ) ; } } } System . out . println ( sum ) ; } } import java . util . * ; class Trikzeo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; boolean [ ] a = new boolean [ 3 ] ; for ( int trikzeo = 0 ; trikzeo < 2 ; trikzeo ++ ) { a [ sc . nextInt ( ) - 1 ] = true ; } for ( int trikzeo = 0 ; trikzeo < 3 ; trikzeo ++ ) { if ( ! a [ trikzeo ] ) System . out . println ( trikzeo + 1 ) ; } } } import java . util . * ; public class Ohbyysl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ohbyysl = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int t = scan . nextInt ( ) ; System . out . println ( b * ( t / ohbyysl ) ) ; scan . close ( ) ; } } import java . util . Scanner ; public class Znjim { public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int znjim , b , seki , syu ; znjim = sc . nextInt ( ) ; b = sc . nextInt ( ) ; seki = znjim * b ; syu = ( znjim * 2 ) + ( b * 2 ) ; System . out . println ( seki + " " + syu ) ; } public static void main ( String [ ] args ) { Main obj = new Main ( ) ; obj . solve ( ) ; } } import java . util . Scanner ; public class Cvxuakq { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String cvxuakq = sc . next ( ) ; String [ ] S2 = cvxuakq . split ( " " ) ; if ( S2 [ 0 ] . equals ( S2 [ 1 ] ) && ! S2 [ 0 ] . equals ( S2 [ 2 ] ) && S2 [ 2 ] . equals ( S2 [ 3 ] ) ) { System . out . println ( " Yes " ) ; } else if ( S2 [ 0 ] . equals ( S2 [ 2 ] ) && ! S2 [ 0 ] . equals ( S2 [ 1 ] ) && S2 [ 1 ] . equals ( S2 [ 3 ] ) ) { System . out . println ( " Yes " ) ; } else if ( S2 [ 0 ] . equals ( S2 [ 3 ] ) && ! S2 [ 0 ] . equals ( S2 [ 2 ] ) && S2 [ 2 ] . equals ( S2 [ 1 ] ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . * ; import java . util . * ; public class Voqrjsn { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { StringBuilder sb = new StringBuilder ( ) ; String str = br . readLine ( ) ; String [ ] s = str . split ( " " , 0 ) ; for ( int voqrjsn = 0 ; voqrjsn < s . length ; voqrjsn ++ ) { sb . append ( s [ s . length - 1 - voqrjsn ] ) ; } System . out . println ( sb ) ; } catch ( Exception ex ) { System . exit ( 0 ) ; } } } import java . util . Scanner ; public class Tgtsegj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tgtsegj = scan . nextInt ( ) ; switch ( tgtsegj % 10 ) { case 2 : System . out . println ( " hon " ) ; break ; case 4 : System . out . println ( " hon " ) ; break ; case 5 : System . out . println ( " hon " ) ; break ; case 7 : System . out . println ( " hon " ) ; break ; case 9 : System . out . println ( " hon " ) ; break ; case 0 : System . out . println ( " pon " ) ; break ; case 1 : System . out . println ( " pon " ) ; break ; case 6 : System . out . println ( " pon " ) ; break ; case 8 : System . out . println ( " pon " ) ; break ; case 3 : System . out . println ( " bon " ) ; break ; default : break ; } } } import java . io . * ; import java . util . Scanner ; public class Ddyls { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ddyls = sc . nextInt ( ) ; for ( int i = 1 ; i <= ddyls ; i ++ ) { int x = i ; if ( x % 3 == 0 ) { System . out . print ( " " + i ) ; continue ; } else if ( x % 10 == 3 ) { System . out . print ( " " + i ) ; continue ; } while ( ( x /= 10 ) != 0 ) { if ( x % 10 == 3 ) { System . out . print ( " " + i ) ; break ; } } } System . out . print ( " \n " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Scanner ; public class Wtvpvgr { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { Main main = new Main ( ) ; main . solveA ( sc ) ; } } private void solveD ( Scanner sc ) { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ) { } catch ( IOException e ) { } } private void solveE ( Scanner sc ) { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ) { } catch ( IOException e ) { } } private void solveC ( Scanner sc ) { } void solveB ( Scanner sc ) { } class Wtvpvgr { } class Wtvpvgr { } void solveA ( Scanner sc ) { int wtvpvgr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( Math . max ( c - ( wtvpvgr - b ) , 0 ) ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Nuhjc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nuhjc = sc . nextInt ( ) , count = 0 ; for ( int i = 1 ; i <= nuhjc ; i += 2 ) { if ( divisorEnum ( i ) . size ( ) == 8 ) count ++ ; } System . out . println ( count ) ; } public static List < Long > divisorEnum ( long nuhjc ) { List < Long > l = new ArrayList < > ( ) ; for ( long i = 1 ; i <= Math . sqrt ( nuhjc ) ; i ++ ) { if ( nuhjc % i == 0 ) { l . add ( i ) ; if ( i != Math . sqrt ( nuhjc ) ) l . add ( nuhjc / i ) ; } } l . sort ( null ) ; return l ; } } import java . util . Scanner ; public class Qamiuo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qamiuo = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] d = new int [ qamiuo + 1 ] ; d [ 0 ] = 0 ; int j ; int bound = 1 ; for ( j = 1 ; j <= qamiuo ; j ++ ) { int l = sc . nextInt ( ) ; d [ j ] = d [ j - 1 ] + l ; if ( d [ j ] <= x ) bound ++ ; else { break ; } } System . out . println ( bound ) ; } } import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; public class Jjsoayr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jjsoayr = Integer . parseInt ( sc . next ( ) ) ; int [ ] X = new int [ jjsoayr ] ; int minSum = 2000000 ; int sum = 0 ; for ( int i = 0 ; i < jjsoayr ; i ++ ) { X [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( X ) ; for ( int i = X [ 0 ] ; i <= X [ jjsoayr - 1 ] ; i ++ ) { for ( int j = 0 ; j < jjsoayr ; j ++ ) { sum += ( X [ j ] - i ) * ( X [ j ] - i ) ; } if ( sum < minSum ) { minSum = sum ; } sum = 0 ; } PrintWriter out = new PrintWriter ( System . out ) ; out . println ( minSum ) ; sc . close ( ) ; out . flush ( ) ; } } import java . util . * ; class Jbrgk { public static void main ( String [ ] args ) { new Solver ( ) . run ( ) ; } } class Jbrgk { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int jbrgk = sc . nextInt ( ) ; int [ ] A = new int [ jbrgk ] ; int top1 = 0 ; int idx1 = 0 ; for ( int i = 0 ; i < jbrgk ; i ++ ) { A [ i ] = sc . nextInt ( ) ; if ( top1 < A [ i ] ) { top1 = A [ i ] ; idx1 = i ; } } int top2 = 0 ; for ( int i = 0 ; i < jbrgk ; i ++ ) { if ( i != idx1 && top2 < A [ i ] ) { top2 = A [ i ] ; } } long max = Integer . MIN_VALUE ; for ( int i = 0 ; i < jbrgk ; i ++ ) { if ( A [ i ] == top1 ) { System . out . println ( top2 ) ; } else { System . out . println ( top1 ) ; } } return ; } } import java . util . * ; public class Mprlff { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mprlff = sc . nextInt ( ) ; int [ ] H = new int [ mprlff ] ; for ( int i = 0 ; i < mprlff ; i ++ ) H [ i ] = sc . nextInt ( ) ; int maxMove = 0 ; int currentMove = 0 ; for ( int i = 0 ; i < mprlff - 1 ; i ++ ) { if ( H [ i ] >= H [ i + 1 ] ) { currentMove ++ ; if ( currentMove > maxMove ) maxMove = currentMove ; } else { currentMove = 0 ; } } System . out . println ( maxMove ) ; } } import java . util . Scanner ; public class Kbzqp { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; for ( ; ; ) { int kbzqp = stdIn . nextInt ( ) ; int w = stdIn . nextInt ( ) ; if ( kbzqp == 0 && w == 0 ) break ; for ( int i = 0 ; i < kbzqp ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( ( i + j ) % 2 == 0 ) { System . out . print ( " # " ) ; } else { System . out . print ( " . " ) ; } } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Ybejk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ybejk = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] answerArr = new int [ M ] ; int answer = 0 ; Arrays . fill ( answerArr , 0 ) ; for ( int i = 0 ; i < ybejk ; i ++ ) { int K = sc . nextInt ( ) ; for ( int j = 0 ; j < K ; j ++ ) { int Ki = sc . nextInt ( ) ; answerArr [ Ki - 1 ] ++ ; } } for ( int i = 0 ; i < M ; i ++ ) { if ( answerArr [ i ] == ybejk ) { answer ++ ; } } System . out . println ( answer ) ; } } import java . util . * ; public class Logjqpw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int logjqpw = 0 ; double wk = 0 ; int wk1 = 0 ; int N = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int [ ] [ ] X = new int [ N ] [ D ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= D ; j ++ ) { X [ i - 1 ] [ j - 1 ] = sc . nextInt ( ) ; } } for ( int i = 1 ; i < N ; i ++ ) { for ( int j = i + 1 ; j <= N ; j ++ ) { for ( int k = 1 ; k <= D ; k ++ ) { wk = ( X [ i - 1 ] [ k - 1 ] - X [ j - 1 ] [ k - 1 ] ) * ( X [ i - 1 ] [ k - 1 ] - X [ j - 1 ] [ k - 1 ] ) + wk ; } wk = Math . sqrt ( wk ) ; if ( wk == Math . ceil ( wk ) ) { logjqpw = logjqpw + 1 ; } wk = 0 ; } } System . out . println ( logjqpw ) ; } } import java . util . Scanner ; public class Lgaoi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lgaoi = sc . nextInt ( ) ; int [ ] arr = new int [ lgaoi ] ; boolean flg = true ; int count = 0 ; for ( int i = 0 ; i < lgaoi ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } while ( flg ) { boolean existOdd = false ; for ( int i = 0 ; i < lgaoi ; i ++ ) { if ( arr [ i ] % 2 != 0 ) { flg = false ; } } if ( ! flg ) break ; for ( int j = 0 ; j < lgaoi ; j ++ ) { arr [ j ] = arr [ j ] / 2 ; } count ++ ; } System . out . println ( count ) ; } } import java . util . * ; import java . util . Scanner ; public class Xfduxin { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String xfduxin = sc . next ( ) ; char [ ] b = new char [ 4 ] ; b [ 0 ] = xfduxin . charAt ( 0 ) ; b [ 1 ] = xfduxin . charAt ( 1 ) ; b [ 2 ] = xfduxin . charAt ( 2 ) ; b [ 3 ] = xfduxin . charAt ( 3 ) ; Arrays . sort ( b ) ; if ( b [ 0 ] == b [ 1 ] && b [ 1 ] != b [ 2 ] && b [ 2 ] == b [ 3 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Tttkew { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tttkew = Integer . parseInt ( sc . nextLine ( ) ) ; List < Integer > nums = new ArrayList < > ( ) ; for ( int i = 0 ; i < tttkew ; i ++ ) { nums . add ( sc . nextInt ( ) ) ; } Collections . sort ( nums ) ; int n1 = nums . get ( tttkew / 2 - 1 ) ; int n2 = nums . get ( tttkew / 2 ) ; System . out . println ( n2 - n1 ) ; } } import java . util . * ; import java . io . * ; public class Bvcgoee { static StringTokenizer st ; static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static void main ( String [ ] args ) throws IOException { int bvcgoee = nextInt ( ) ; HashSet < String > kinds = new HashSet < > ( ) ; for ( int x = 0 ; x < bvcgoee ; x ++ ) { String cur = next ( ) ; if ( ! kinds . contains ( cur ) ) { kinds . add ( cur ) ; } } System . out . println ( kinds . size ( ) ) ; } public static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public static long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } public static double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } static String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) . trim ( ) ) ; return st . nextToken ( ) ; } } import java . util . Scanner ; public class Jyzkefj { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int jyzkefj = stdIn . nextInt ( ) ; int x = stdIn . nextInt ( ) ; int [ ] l = new int [ jyzkefj ] ; for ( int i = 0 ; i < jyzkefj ; i ++ ) { l [ i ] = stdIn . nextInt ( ) ; } int counter = 1 ; long zahyou = 0 ; for ( int i = 0 ; i < jyzkefj ; i ++ ) { zahyou += l [ i ] ; if ( x < zahyou ) { break ; } else { counter ++ ; } } System . out . println ( counter ) ; } } import java . util . * ; public class Dltroe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dltroe = sc . nextInt ( ) ; int over = sc . nextInt ( ) ; int outlet = 1 ; int ans = 0 ; while ( outlet < over ) { -- outlet ; outlet += dltroe ; ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; public class Uhjpry { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uhjpry = sc . nextInt ( ) ; int [ ] v = new int [ uhjpry ] ; int [ ] c = new int [ uhjpry ] ; for ( int i = 0 ; i < uhjpry ; i ++ ) { v [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < uhjpry ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int i = 0 ; i < uhjpry ; i ++ ) { if ( v [ i ] > c [ i ] ) { result += v [ i ] - c [ i ] ; } } System . out . println ( result ) ; } } import java . util . Scanner ; class Nicxmcx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String c = scan . next ( ) , str = " " ; for ( int nicxmcx = 0 ; nicxmcx < c . length ( ) ; nicxmcx ++ ) { str = c . substring ( nicxmcx , nicxmcx + 1 ) + str ; } System . out . println ( str ) ; } } import java . util . * ; public class Rbikyi { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String S = s . nextLine ( ) ; int rbikyi = 0 , ans = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == 'A' || S . charAt ( i ) == 'C' || S . charAt ( i ) == 'G' || S . charAt ( i ) == 'T' ) { rbikyi ++ ; if ( ans < rbikyi ) { ans = rbikyi ; } } else { rbikyi = 0 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Bcfnas { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int bcfnas = scan . nextInt ( ) ; if ( bcfnas == 0 ) { break ; } double [ ] s = new double [ bcfnas ] ; int i = 0 ; double sum = 0 ; double sumHensa = 0 ; double ans = 0 ; for ( i = 0 ; i < bcfnas ; i ++ ) { s [ i ] = scan . nextDouble ( ) ; sum += s [ i ] ; } double average = ( double ) sum / bcfnas ; for ( i = 0 ; i < bcfnas ; i ++ ) { sumHensa += ( s [ i ] - average ) * ( s [ i ] - average ) ; } ans = Math . sqrt ( ( double ) sumHensa / bcfnas ) ; System . out . println ( ans ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Ymvrowx { public static void main ( String [ ] args ) { int ymvrowx = in . NI ( ) ; if ( ymvrowx % 2 == 0 ) out . println ( ymvrowx / 2 ) ; else out . println ( ymvrowx / 2 + 1 ) ; out . close ( ) ; } static InputStream inputStream = System . in ; static OutputStream outputStream = System . out ; static InputReader in = new InputReader ( inputStream ) ; static PrintWriter out = new PrintWriter ( outputStream ) ; static class Ymvrowx { 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 NI ( ) { return Integer . parseInt ( next ( ) ) ; } public long NL ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Fucda { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st ; PrintWriter pw = new PrintWriter ( System . out ) ; int fucda = Integer . parseInt ( br . readLine ( ) ) ; int b = Integer . parseInt ( br . readLine ( ) ) ; int x = 1 ^ 2 ^ 3 ; x ^= fucda ; x ^= b ; pw . println ( x ) ; pw . flush ( ) ; pw . close ( ) ; } } import java . util . Scanner ; public class Lwbdmjt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lwbdmjt = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int ab = Math . min ( lwbdmjt + b , c * 2 ) ; int ans = Math . min ( x , y ) * ab ; if ( x > y ) { ans += ( x - y ) * Math . min ( lwbdmjt , c * 2 ) ; } else { ans += ( y - x ) * Math . min ( b , c * 2 ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Bdhcjwu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int bdhcjwu = sc . nextInt ( ) ; String strA = sc . next ( ) ; int b = sc . nextInt ( ) ; if ( strA == " ? " ) { break ; } switch ( strA ) { case " + " : System . out . println ( bdhcjwu + b ) ; break ; case " - " : System . out . println ( bdhcjwu - b ) ; break ; case " * " : System . out . println ( bdhcjwu * b ) ; break ; case " / " : System . out . println ( bdhcjwu / b ) ; break ; } } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; import java . util . Collections ; public class Nyarxw { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; C solver = new C ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Nyarxw { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int nyarxw = Integer . parseInt ( in . next ( ) ) ; int K = Integer . parseInt ( in . next ( ) ) ; Integer [ ] H = new Integer [ nyarxw ] ; long ans = 0 ; for ( int i = 0 ; i < nyarxw ; i ++ ) { H [ i ] = Integer . valueOf ( in . next ( ) ) ; ans += H [ i ] ; } Arrays . sort ( H , Collections . reverseOrder ( ) ) ; if ( K > nyarxw ) K = nyarxw ; for ( int i = 0 ; i < K ; i ++ ) { ans -= H [ i ] ; } out . println ( ans ) ; } } } import java . util . Scanner ; import java . util . Arrays ; import java . util . stream . Stream ; import java . util . stream . IntStream ; import java . lang . StringBuilder ; public class Aihis { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String N = sc . next ( ) ; int [ ] cubes = new int [ 2 ] ; cubes [ 0 ] = 0 ; cubes [ 1 ] = 0 ; for ( int aihis = 0 ; aihis < N . length ( ) ; aihis ++ ) { int tmp = ( int ) ( N . charAt ( aihis ) - '0' ) ; cubes [ tmp ] += 1 ; } System . out . println ( Math . min ( cubes [ 0 ] , cubes [ 1 ] ) * 2 ) ; } } import java . util . Scanner ; public class Lflkehg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; if ( isKaibun ( S ) && isKaibun ( S . substring ( 0 , S . length ( ) / 2 ) ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static boolean isKaibun ( String s ) { boolean lflkehg = true ; int len = s . length ( ) ; for ( int i = 0 ; i <= len / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( len - 1 - i ) ) { lflkehg = false ; break ; } } return lflkehg ; } } import java . util . Scanner ; public class Oathma { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oathma = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( oathma < 10 ) { if ( b < 10 ) { System . out . println ( oathma * b ) ; } else { System . out . println ( - 1 ) ; } } else { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; public class Ameey { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ameey = sc . nextInt ( ) ; int [ ] [ ] A = new int [ ameey + 1 ] [ 3 ] ; for ( int i = 1 ; i <= ameey ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } } A [ 0 ] [ 0 ] = 0 ; A [ 0 ] [ 1 ] = 0 ; A [ 0 ] [ 2 ] = 0 ; sc . close ( ) ; int count = 0 ; for ( int i = 1 ; i <= ameey ; i ++ ) { int tmp = Math . abs ( A [ i ] [ 1 ] - A [ i - 1 ] [ 1 ] ) + Math . abs ( A [ i ] [ 2 ] - A [ i - 1 ] [ 2 ] ) ; int tmp2 = Math . abs ( A [ i ] [ 0 ] - A [ i - 1 ] [ 0 ] ) ; if ( ( tmp2 % 2 == tmp % 2 ) && tmp2 >= tmp ) { count ++ ; } } if ( count == ameey ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Swxzh { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; double swxzh = scn . nextDouble ( ) ; scn . close ( ) ; double ans = 2 * swxzh * 3.1415926535 ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Fopygw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int fopygw = scan . nextInt ( ) ; int zone = scan . nextInt ( ) ; int pos = 0 ; int count = 1 ; for ( int i = 0 ; i < fopygw ; i ++ ) { pos += scan . nextInt ( ) ; if ( pos <= zone ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Zhfxu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; if ( s . charAt ( 0 ) == 'A' ) { int zhfxu = 0 ; int index = 0 ; for ( int j = 2 ; j < s . length ( ) - 1 ; j ++ ) { if ( s . charAt ( j ) == 'C' ) { zhfxu ++ ; index = j ; } } if ( zhfxu == 1 ) { boolean ok = true ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( i == index ) continue ; if ( Character . isUpperCase ( s . charAt ( i ) ) ) ok = false ; } if ( ok ) { System . out . println ( " AC " ) ; return ; } } } System . out . println ( " WA " ) ; } } import java . io . * ; import java . math . * ; import java . util . * ; public class Xrvyyf { static final long xrvyyf = 1000000007L ; static final int INF = 50000000 ; public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; String s = sc . next ( ) ; int d = 0 ; for ( char c : s . toCharArray ( ) ) { d += ( c - '0' ) ; } if ( d % 9 == 0 ) { pw . println ( " Yes " ) ; } else { pw . println ( " No " ) ; } pw . close ( ) ; } static class Xrvyyf { BufferedReader br ; StringTokenizer st ; public FastScanner ( ) { 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 ni ( ) { return Integer . parseInt ( next ( ) ) ; } long nl ( ) { return Long . parseLong ( next ( ) ) ; } double nd ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } import java . util . Scanner ; public class Sqpkj { public static void main ( String [ ] args ) throws Exception { String inputNameA ; String inputNameB ; int sqpkj ; int numberOfB ; String choiceName ; Scanner scanner = new Scanner ( System . in ) ; String inputName = scanner . nextLine ( ) ; String inputNum = scanner . nextLine ( ) ; choiceName = scanner . nextLine ( ) ; scanner . close ( ) ; String [ ] editInputName = inputName . split ( " " ) ; inputNameA = editInputName [ 0 ] ; inputNameB = editInputName [ 1 ] ; String [ ] editInputNum = inputNum . split ( " " ) ; sqpkj = Integer . parseInt ( editInputNum [ 0 ] ) ; numberOfB = Integer . parseInt ( editInputNum [ 1 ] ) ; if ( inputNameA . equals ( choiceName ) ) { sqpkj -- ; } else if ( inputNameB . equals ( choiceName ) ) { numberOfB -- ; } System . out . println ( sqpkj + " " + numberOfB ) ; } } import java . util . Scanner ; public class Snzhtab { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; int [ ] x = new int [ 20000 ] ; x [ 0 ] = kb . nextInt ( ) ; int snzhtab = 0 ; int i = 0 ; while ( x [ snzhtab ] != 0 ) { snzhtab ++ ; x [ snzhtab ] = kb . nextInt ( ) ; } while ( x [ i ] != 0 ) { System . out . printf ( " Case %d: %d \n " , i + 1 , x [ i ] ) ; i ++ ; } } } import java . util . * ; public class Jpaiyss { public static void main ( String [ ] args ) { int [ ] arr = new int [ 100 ] ; Scanner sc = new Scanner ( System . in ) ; int jpaiyss = sc . nextInt ( ) ; for ( int i = 0 ; i < jpaiyss ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } for ( int j = jpaiyss - 1 ; j > 0 ; j -- ) { System . out . print ( arr [ j ] + " " ) ; } System . out . println ( arr [ 0 ] ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; class Hnfxixd { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] numbers = br . readLine ( ) . split ( " " ) ; int hnfxixd = Integer . parseInt ( numbers [ 0 ] ) ; int x = Integer . parseInt ( numbers [ 1 ] ) ; String [ ] length = br . readLine ( ) . split ( " " ) ; int [ ] len = new int [ hnfxixd ] ; for ( int i = 0 ; i < hnfxixd ; i ++ ) { len [ i ] = Integer . parseInt ( length [ i ] ) ; } int [ ] bounces = new int [ hnfxixd + 1 ] ; bounces [ 0 ] = 0 ; for ( int j = 1 ; j <= len . length ; j ++ ) { bounces [ j ] = bounces [ j - 1 ] + len [ j - 1 ] ; } int count = 0 ; for ( int k = 0 ; k < bounces . length ; k ++ ) { if ( bounces [ k ] <= x ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Brqxcnn { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String str = in . nextLine ( ) ; in . close ( ) ; int brqxcnn = 0 ; int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char a = str . charAt ( i ) ; if ( a == 'A' || a == 'C' || a == 'G' || a == 'T' ) { count ++ ; } else { if ( brqxcnn < count ) brqxcnn = count ; count = 0 ; } } if ( brqxcnn < count ) brqxcnn = count ; System . out . println ( brqxcnn ) ; } } import java . util . Scanner ; public class Uvlecjk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String t = scan . next ( ) ; int uvlecjk = t . length ( ) ; for ( int i = 0 ; i <= s . length ( ) - t . length ( ) ; i ++ ) { int diff = 0 ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( i + j ) != t . charAt ( j ) ) { diff ++ ; } } uvlecjk = Math . min ( uvlecjk , diff ) ; } System . out . println ( uvlecjk ) ; } } import java . util . Scanner ; public class Edivix { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int edivix = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] A = new int [ edivix ] ; for ( int i = 0 ; i < edivix ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < edivix ; i ++ ) { if ( A [ i ] >= K ) { count ++ ; } } System . out . println ( count ) ; sc . close ( ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Nnipn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nnipn = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < nnipn ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } Collections . sort ( list ) ; int ans = 0 ; for ( int i = 0 ; i < K ; ++ i ) { ans += list . get ( i ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class Xxttiqc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xxttiqc = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int result = - 1 ; for ( int i = 0 ; i < 2000 ; i ++ ) { int tax8 = getTax ( i , 8 ) ; int tax10 = getTax ( i , 10 ) ; if ( tax8 == xxttiqc && tax10 == B ) { result = i ; break ; } } System . out . println ( result ) ; } public static int getTax ( int base , int rate ) { return base * rate / 100 ; } } import java . util . * ; class Vlytsoy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vlytsoy = sc . nextInt ( ) ; int [ ] cities = new int [ vlytsoy + 1 ] ; int [ ] savers = new int [ vlytsoy ] ; for ( int i = 0 ; i <= vlytsoy ; i ++ ) cities [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < vlytsoy ; i ++ ) savers [ i ] = sc . nextInt ( ) ; double ans = 0 ; for ( int i = 0 ; i < vlytsoy ; i ++ ) { if ( savers [ i ] <= cities [ i ] ) { ans += savers [ i ] ; savers [ i ] = 0 ; continue ; } else { ans += cities [ i ] ; savers [ i ] -= cities [ i ] ; } if ( savers [ i ] <= cities [ i + 1 ] ) { ans += savers [ i ] ; cities [ i + 1 ] -= savers [ i ] ; } else { ans += cities [ i + 1 ] ; cities [ i + 1 ] = 0 ; } } System . out . printf ( " %.0f \n " , ans ) ; } } import java . util . Scanner ; public class Uplaum { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uplaum = sc . nextInt ( ) ; int [ ] v = new int [ uplaum ] ; int sum = 0 ; for ( int i = 0 ; i < uplaum ; ++ i ) { v [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < uplaum ; ++ i ) { int c = sc . nextInt ( ) ; sum = ( v [ i ] > c ) ? sum + v [ i ] - c : sum ; } System . out . println ( sum ) ; } } import java . util . * ; public class Armarin { private static final Scanner sc = new Scanner ( System . in ) ; private void solve ( ) { int armarin = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < armarin ; ++ i ) { set . add ( sc . next ( ) ) ; } System . out . println ( set . size ( ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . * ; public class Ewofvws { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ewofvws = sc . nextInt ( ) ; int a , b , c ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; int count = 0 ; if ( ( a < b && b < c ) || ( c < b && b < a ) ) { count ++ ; } for ( int i = 0 ; i < ewofvws - 3 ; i ++ ) { a = b ; b = c ; c = sc . nextInt ( ) ; if ( ( a < b && b < c ) || ( c < b && b < a ) ) { count ++ ; } } System . out . println ( count ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Tdhaj { private static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String SA = scan . next ( ) ; String SB = scan . next ( ) ; String SC = scan . next ( ) ; int tdhaj = 0 ; int sb = 0 ; int sc = 0 ; char next = 'a' ; boolean flag = true ; char winner = 0 ; while ( flag ) { switch ( next ) { case 'a' : if ( tdhaj == SA . length ( ) ) { flag = false ; winner = 'A' ; } else { next = SA . charAt ( tdhaj ) ; tdhaj ++ ; } break ; case 'b' : if ( sb == SB . length ( ) ) { flag = false ; winner = 'B' ; } else { next = SB . charAt ( sb ) ; sb ++ ; } break ; case 'c' : if ( sc == SC . length ( ) ) { flag = false ; winner = 'C' ; } else { next = SC . charAt ( sc ) ; sc ++ ; } break ; } } System . out . println ( winner ) ; scan . close ( ) ; } } import java . util . Scanner ; public class Stbaub { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { solve ( sc ) ; } } static void solve ( Scanner sc ) { int stbaub = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; if ( d <= stbaub || b <= c ) { System . out . println ( 0 ) ; return ; } if ( c <= stbaub ) { if ( d <= b ) { System . out . println ( d - stbaub ) ; } else { System . out . println ( b - stbaub ) ; } } else if ( c < b ) { if ( d <= b ) { System . out . println ( d - c ) ; } else { System . out . println ( b - c ) ; } } } } import java . util . Scanner ; class Umurlo { public static void main ( String [ ] args ) { int umurlo = 0 ; char c ; String word , temp ; Scanner sc = new Scanner ( System . in ) ; word = sc . next ( ) ; temp = sc . next ( ) ; while ( ! temp . equals ( " END_OF_TEXT " ) ) { if ( temp . equalsIgnoreCase ( word ) ) umurlo ++ ; temp = sc . next ( ) ; } System . out . println ( umurlo ) ; } } import java . util . Scanner ; import java . math . BigDecimal ; public class Wfyrhoz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double wfyrhoz = scan . nextDouble ( ) ; final double CIRCLERATE = 3.141592653589 ; double s = CIRCLERATE * wfyrhoz * wfyrhoz ; double l = 2 * CIRCLERATE * wfyrhoz ; BigDecimal x = new BigDecimal ( s ) ; x = x . setScale ( 5 , BigDecimal . ROUND_HALF_UP ) ; BigDecimal y = new BigDecimal ( l ) ; y = y . setScale ( 5 , BigDecimal . ROUND_HALF_UP ) ; System . out . printf ( " %.5f " + " " + " %.5f " , x , y ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Ygdcf { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; Map < String , Integer > count = new HashMap < > ( ) ; int ygdcf = in . nextInt ( ) ; long res = 0 ; for ( int i = 0 ; i < ygdcf ; i ++ ) { String s = sort ( in . next ( ) ) ; res += ( count . containsKey ( s ) ? count . get ( s ) : 0 ) ; if ( count . containsKey ( s ) ) { count . replace ( s , count . get ( s ) + 1 ) ; } else { count . put ( s , 1 ) ; } } System . out . println ( res ) ; } private static String sort ( String text ) { char [ ] chars = text . toCharArray ( ) ; Arrays . sort ( chars ) ; return new String ( chars ) ; } } import java . util . * ; public class Oizan { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oizan = sc . nextInt ( ) ; int [ ] list = new int [ oizan ] ; for ( int i = 0 ; i < oizan ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } int count = 0 ; int Max = 0 ; for ( int i = 1 ; i < oizan ; i ++ ) { if ( list [ i - 1 ] >= list [ i ] ) { count ++ ; if ( Max < count ) { Max = count ; } } else { if ( Max < count ) { Max = count ; } count = 0 ; } } System . out . println ( Max ) ; } } import java . text . DecimalFormat ; import java . util . Scanner ; public class Ikidcli { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ikidcli = sc . nextInt ( ) ; int hunsin_nagasa = sc . nextInt ( ) ; int jikan = sc . nextInt ( ) ; int hun = sc . nextInt ( ) ; double jisin_kakudo = ( jikan * 60 + hun ) * 0.5 ; double hunsin_kakudo = hun * 6 ; double kakudo_sa = 0 ; if ( jisin_kakudo > hunsin_kakudo ) { kakudo_sa = jisin_kakudo - hunsin_kakudo ; } else { kakudo_sa = hunsin_kakudo - jisin_kakudo ; } double b = ikidcli ; double c = hunsin_nagasa ; double e = kakudo_sa ; double r = Math . sqrt ( Math . pow ( b , 2 ) + Math . pow ( c , 2 ) - 2 * b * c * Math . cos ( Math . toRadians ( e ) ) ) ; System . out . println ( r ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Xyuroaf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xyuroaf = sc . nextInt ( ) ; int [ ] stoneHeights = new int [ xyuroaf ] ; for ( int i = 0 ; i < xyuroaf ; i ++ ) { stoneHeights [ i ] = sc . nextInt ( ) ; } int [ ] minCostForStones = new int [ xyuroaf ] ; Arrays . fill ( minCostForStones , Integer . MAX_VALUE ) ; minCostForStones [ 0 ] = 0 ; for ( int i = 0 ; i < xyuroaf ; i ++ ) { for ( int j = i + 1 ; j < i + 3 ; j ++ ) { if ( j < xyuroaf ) { minCostForStones [ j ] = Math . min ( minCostForStones [ j ] , minCostForStones [ i ] + Math . abs ( stoneHeights [ j ] - stoneHeights [ i ] ) ) ; } } } System . out . println ( minCostForStones [ xyuroaf - 1 ] ) ; } } import java . util . Scanner ; public class Rmfysvf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rmfysvf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = Integer . parseInt ( String . valueOf ( rmfysvf ) + String . valueOf ( b ) ) ; for ( int i = 1 ; i < 330 ; i ++ ) { if ( i * i == n ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . util . * ; import java . util . concurrent . * ; import java . util . regex . * ; public class Mabthpd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mabthpd = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int temp1 = b ; b = mabthpd ; mabthpd = temp1 ; int temp = c ; c = mabthpd ; mabthpd = temp ; System . out . print ( mabthpd + " " + b + " " + c ) ; } } import java . io . * ; import java . util . * ; class Uscmny { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] array = new int [ 26 ] ; Arrays . fill ( array , 0 ) ; char [ ] c_array ; String str ; do { if ( ( str = br . readLine ( ) ) == null ) break ; c_array = str . toCharArray ( ) ; for ( char uscmny : c_array ) { if ( 'a' <= uscmny && uscmny <= 'z' ) array [ uscmny - 'a' ] ++ ; else if ( 'A' <= uscmny && uscmny <= 'Z' ) array [ uscmny - 'A' ] ++ ; } } while ( true ) ; for ( int i = 0 ; i < 26 ; i ++ ) { System . out . println ( ( char ) ( 'a' + i ) + " : " + array [ i ] ) ; } } } import java . util . * ; public class Vvcciww { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vvcciww = sc . nextInt ( ) ; int b = vvcciww ; int ans = 0 ; while ( vvcciww > 0 ) { ans += vvcciww % 10 ; vvcciww /= 10 ; } System . out . println ( b % ans == 0 ? " Yes " : " No " ) ; } } import java . awt . * ; import java . awt . geom . * ; import java . io . * ; import java . util . * ; class Otsdl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] list = new int [ 3 ] ; for ( int otsdl = 0 ; otsdl < 3 ; otsdl ++ ) { list [ otsdl ] = sc . nextInt ( ) ; } Arrays . sort ( list ) ; System . out . print ( list [ 0 ] ) ; for ( int otsdl = 1 ; otsdl < 3 ; otsdl ++ ) { System . out . print ( " " + list [ otsdl ] ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class Bkimxv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String bkimxv = sc . next ( ) ; String b = sc . next ( ) ; String c = sc . next ( ) ; String next = bkimxv . substring ( 0 , 1 ) ; bkimxv = bkimxv . substring ( 1 , bkimxv . length ( ) ) ; for ( ; ; ) { if ( next . equals ( " a " ) ) { if ( bkimxv . isEmpty ( ) ) { System . out . println ( " A " ) ; return ; } next = bkimxv . substring ( 0 , 1 ) ; bkimxv = bkimxv . substring ( 1 , bkimxv . length ( ) ) ; } else if ( next . equals ( " b " ) ) { if ( b . isEmpty ( ) ) { System . out . println ( " B " ) ; return ; } next = b . substring ( 0 , 1 ) ; b = b . substring ( 1 , b . length ( ) ) ; } else { if ( c . isEmpty ( ) ) { System . out . println ( " C " ) ; return ; } next = c . substring ( 0 , 1 ) ; c = c . substring ( 1 , c . length ( ) ) ; } } } } import java . util . * ; public class Kkqpm { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; double kkqpm = stdIn . nextDouble ( ) ; double H = stdIn . nextDouble ( ) ; double x = stdIn . nextDouble ( ) ; double y = stdIn . nextDouble ( ) ; System . out . println ( kkqpm * H / 2 ) ; if ( x == kkqpm / 2 && y == H / 2 ) { System . out . println ( 1 ) ; } else { System . out . println ( 0 ) ; } } } import java . util . Scanner ; import java . util . ArrayList ; import java . util . List ; public class Qwkewsq { public static void main ( String [ ] args ) { Integer [ ] input = readInput ( ) ; int qwkewsq = input [ 0 ] ; int b = input [ 1 ] ; if ( qwkewsq < b ) { System . out . println ( " a < b " ) ; } else if ( qwkewsq > b ) { System . out . println ( " a > b " ) ; } else { System . out . println ( " a == b " ) ; } } public static Integer [ ] readInput ( ) { List < Integer > l = new ArrayList < Integer > ( ) ; Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNextInt ( ) ) { l . add ( sc . nextInt ( ) ) ; } return l . toArray ( new Integer [ l . size ( ) ] ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; public class Sclbhf { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; int sclbhf = Integer . parseInt ( line ) ; int tarouScore = 0 ; int hanakoScore = 0 ; for ( int i = 0 ; i < sclbhf ; i ++ ) { String [ ] s = br . readLine ( ) . split ( " " ) ; String tarou = s [ 0 ] ; String hanako = s [ 1 ] ; ArrayList < String > dic = new ArrayList < String > ( ) ; dic . add ( tarou ) ; dic . add ( hanako ) ; Collections . sort ( dic ) ; if ( tarou . equals ( hanako ) ) { tarouScore += 1 ; hanakoScore += 1 ; } else if ( tarou . equals ( dic . get ( 0 ) ) ) { hanakoScore += 3 ; } else { tarouScore += 3 ; } } System . out . println ( tarouScore + " " + hanakoScore ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Ohnonp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; try { int ohnonp , H , x , y , r ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; String [ ] strAry = str . split ( " " ) ; ohnonp = Integer . parseInt ( strAry [ 0 ] ) ; H = Integer . parseInt ( strAry [ 1 ] ) ; x = Integer . parseInt ( strAry [ 2 ] ) ; y = Integer . parseInt ( strAry [ 3 ] ) ; r = Integer . parseInt ( strAry [ 4 ] ) ; if ( x - r >= 0 && x + r <= ohnonp && y - r >= 0 && y + r <= H ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . Scanner ; public class Irztyj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long irztyj = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = irztyj / ( a + b ) ; long m = irztyj - c * ( a + b ) ; if ( m < a ) System . out . println ( c * a + m ) ; else if ( m >= a ) System . out . println ( c * a + a ) ; sc . close ( ) ; } } import java . util . * ; public class Elyjzcd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int elyjzcd = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int [ ] B = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } int num = 0 ; for ( int i = 0 ; i < elyjzcd ; i ++ ) { int sum = C ; for ( int j = 0 ; j < M ; j ++ ) { sum += B [ j ] * sc . nextInt ( ) ; } if ( sum > 0 ) num ++ ; } System . out . println ( num ) ; } } import java . util . Scanner ; public class Ynbmoqe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ynbmoqe = sc . nextInt ( ) ; long [ ] monster = new long [ ynbmoqe + 1 ] ; long [ ] brave = new long [ ynbmoqe ] ; long anser = 0 ; for ( int i = 0 ; i < ynbmoqe + 1 ; i ++ ) { monster [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < ynbmoqe ; i ++ ) { brave [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < brave . length ; i ++ ) { anser += Math . min ( monster [ i ] , brave [ i ] ) ; anser += Math . min ( monster [ i + 1 ] , Math . max ( brave [ i ] - monster [ i ] , 0 ) ) ; monster [ i + 1 ] -= Math . min ( monster [ i + 1 ] , Math . max ( brave [ i ] - monster [ i ] , 0 ) ) ; } System . out . println ( anser ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Khhqd { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int khhqd = s . nextInt ( ) ; int y = s . nextInt ( ) ; int flag = 0 ; for ( int i = 0 ; i <= khhqd ; i ++ ) { if ( i * 2 + ( khhqd - i ) * 4 == y ) { System . out . println ( " Yes " ) ; flag = 1 ; break ; } } if ( flag == 0 ) { System . out . println ( " No " ) ; } } } import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . BufferedReader ; import java . io . InputStreamReader ; class Ijctldt { public static void main ( String [ ] args ) { InputReader in = new InputReader ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int ijctldt = in . nextInt ( ) ; int y = in . nextInt ( ) ; int z = in . nextInt ( ) ; int p = ijctldt ; System . out . println ( z + " " + ijctldt + " " + y ) ; } static class Ijctldt { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Tgpncwh { public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; for ( ; ; ) { String [ ] numberStr = input . readLine ( ) . split ( " " ) ; int tgpncwh = Integer . parseInt ( numberStr [ 0 ] ) ; int sum = Integer . parseInt ( numberStr [ 1 ] ) ; if ( ( tgpncwh == 0 ) && ( sum == 0 ) ) { break ; } int set = 0 ; for ( int oneNum = 1 ; oneNum <= tgpncwh - 2 ; oneNum ++ ) { for ( int twoNum = oneNum + 1 ; twoNum <= tgpncwh + 1 ; twoNum ++ ) { for ( int threeNum = twoNum + 1 ; threeNum <= tgpncwh ; threeNum ++ ) { if ( oneNum + twoNum + threeNum == sum ) { set ++ ; } } } } System . out . println ( set ) ; } } } import java . io . File ; import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . util . * ; public class Kzupqo { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int kzupqo = sc . nextInt ( ) ; int max = sc . nextInt ( ) ; int count = 1 ; for ( int i = 0 ; i < kzupqo - 1 ; i ++ ) { int input = sc . nextInt ( ) ; if ( input >= max ) { count ++ ; max = input ; } } System . out . println ( count ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Xqdwj { public static void main ( String [ ] args ) { int xqdwj = 0 ; Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] c = new int [ N - 1 ] ; ArrayList < Integer > CN = new ArrayList < > ( ) ; int check , checkB = 0 ; checkB = sc . nextInt ( ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { check = sc . nextInt ( ) ; if ( checkB == ( check - 1 ) ) { CN . add ( checkB ) ; } checkB = check ; } for ( int j = 0 ; j < N ; j ++ ) { xqdwj = xqdwj + sc . nextInt ( ) ; } Collections . sort ( CN ) ; for ( int k = 0 ; k < N - 1 ; k ++ ) { c [ k ] = sc . nextInt ( ) ; } for ( int l = 0 ; l < CN . size ( ) ; l ++ ) { xqdwj = xqdwj + c [ CN . get ( l ) - 1 ] ; } System . out . println ( xqdwj ) ; } } import java . util . * ; public class Ziktmt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ziktmt = scan . nextInt ( ) ; if ( ziktmt % 10 == 7 || ziktmt % 100 - ziktmt % 10 == 70 || ziktmt % 1000 - ziktmt % 100 == 700 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; return ; } } import java . util . * ; public class Pfxlja { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int pfxlja ; pfxlja = in . nextInt ( ) ; int a , b , i , num ; a = in . nextInt ( ) ; b = in . nextInt ( ) ; num = a ; for ( i = num ; i <= b ; i ++ , num ++ ) { if ( i % pfxlja == 0 ) { System . out . println ( " OK " ) ; System . exit ( 0 ) ; } } System . out . println ( " NG " ) ; } } import java . util . Scanner ; public class Rmtqqe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rmtqqe = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( 6 - rmtqqe - b ) ; } } import java . util . Scanner ; public class Ozfwt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ozfwt = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int tmp = 9999 ; int min = 9999 ; int [ ] ci = new int [ ozfwt ] ; int [ ] ti = new int [ ozfwt ] ; int i = 0 ; for ( i = 0 ; i < ozfwt ; i ++ ) { ci [ i ] = sc . nextInt ( ) ; ti [ i ] = sc . nextInt ( ) ; if ( ti [ i ] <= t ) { tmp = ci [ i ] ; if ( min > tmp ) { min = tmp ; } } } if ( min < 9999 ) { System . out . println ( min ) ; } else { System . out . println ( " TLE " ) ; } } } import java . util . Scanner ; public class Qbxek { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qbxek = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] bList = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { bList [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int j = 0 ; j < qbxek ; j ++ ) { int count = 0 ; for ( int k = 0 ; k < m ; k ++ ) { count += sc . nextInt ( ) * bList [ k ] ; } if ( count + c > 0 ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; class Buwjpmb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double buwjpmb = 0.f ; double sum ; double sta ; double dev ; double dev_w ; double dev_sum ; double ave ; double var ; boolean Judge = true ; while ( Judge ) { int stu_num = scanner . nextInt ( ) ; if ( stu_num == 0 ) { break ; } double [ ] stu = new double [ stu_num ] ; sum = 0 ; dev_sum = 0 ; dev_w = 0 ; for ( int i = 0 ; i < stu_num ; i ++ ) { stu [ i ] = scanner . nextDouble ( ) ; sum += stu [ i ] ; } ave = sum / stu_num ; for ( int i = 0 ; i < stu_num ; i ++ ) { dev = ave - stu [ i ] ; dev_w = dev * dev ; dev_sum += dev_w ; } if ( dev_sum != 0 ) { var = dev_sum / stu_num ; } else { var = 0 ; } sta = Math . sqrt ( var ) ; System . out . println ( sta ) ; } scanner . close ( ) ; } } import java . io . * ; import java . util . * ; public class Wgwic { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long wgwic = sc . nextLong ( ) ; int [ ] ary = new int [ 10000 ] ; boolean big = false , flag = true ; ary [ 0 ] = 2 ; int i = 3 , j = 0 ; for ( ; i < 1000000 ; i ++ ) { flag = true ; if ( ary [ j ] >= wgwic ) break ; for ( int k = 0 ; k <= j ; k ++ ) { if ( i % ary [ k ] == 0 ) { flag = false ; break ; } } if ( flag ) { j ++ ; ary [ j ] = i ; } } System . out . println ( ary [ j ] ) ; } } import java . util . * ; public class Spxaf { private static final Scanner scn = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int spxaf = scn . nextInt ( ) , b = scn . nextInt ( ) , c = scn . nextInt ( ) ; System . out . println ( spxaf < b && b < c ? " Yes " : " No " ) ; } } import java . util . * ; class Ogmwyp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ogmwyp = sc . nextInt ( ) ; if ( ogmwyp < 0 ) { System . out . println ( " NA " ) ; return ; } if ( ogmwyp % 100 < 13 && ogmwyp % 100 != 0 ) { if ( ogmwyp / 100 < 13 && ogmwyp / 100 != 0 ) { System . out . println ( " AMBIGUOUS " ) ; return ; } System . out . println ( " YYMM " ) ; return ; } if ( ogmwyp / 100 < 13 && ogmwyp / 100 != 0 ) { System . out . println ( " MMYY " ) ; return ; } System . out . println ( " NA " ) ; } } import java . util . * ; import java . math . * ; public class Kvgim { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long kvgim = sc . nextLong ( ) ; String b = sc . next ( ) ; long B = 0 ; B += b . charAt ( 0 ) - '0' ; B *= 10 ; B += b . charAt ( 2 ) - '0' ; B *= 10 ; B += b . charAt ( 3 ) - '0' ; long res = ( long ) ( kvgim * B / 100 ) ; System . out . println ( res ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Kfjwgbx { public static void main ( String [ ] args ) { Scanner a = new Scanner ( System . in ) ; int [ ] numbers = new int [ 3 ] ; for ( int kfjwgbx = 0 ; kfjwgbx < 3 ; kfjwgbx ++ ) { numbers [ kfjwgbx ] = a . nextInt ( ) ; } Arrays . sort ( numbers ) ; int A = numbers [ 1 ] - numbers [ 0 ] ; int B = numbers [ 2 ] - numbers [ 1 ] ; int C = A + B ; String s = String . valueOf ( C ) ; System . out . println ( s ) ; } } import java . io . * ; class Ygnninp { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int ygnninp = Integer . parseInt ( br . readLine ( ) ) ; for ( int f = 0 ; f < ygnninp ; f ++ ) { String [ ] str = br . readLine ( ) . split ( " \\ s " ) ; int a = Integer . parseInt ( str [ 0 ] ) ; a *= a ; int b = Integer . parseInt ( str [ 1 ] ) ; b *= b ; int c = Integer . parseInt ( str [ 2 ] ) ; c *= c ; if ( a + b == c || b + c == a || c + a == b ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } catch ( IOException e ) { } } } import java . util . Arrays ; import java . util . Scanner ; public class Bvopv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int bvopv = scan . nextInt ( ) ; int [ ] a = new int [ bvopv ] ; for ( int i = 0 ; i < bvopv ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; Arrays . sort ( a ) ; int check = 0 ; for ( int i = 0 ; i < bvopv ; i ++ ) { for ( int j = i + 1 ; j < bvopv ; j ++ ) { if ( i != j ) { if ( a [ i ] == a [ j ] ) { check = 1 ; break ; } else { break ; } } } if ( check == 1 ) break ; } System . out . println ( ( check == 1 ) ? " NO " : " YES " ) ; } } import java . util . Scanner ; class Fngnvqh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fngnvqh = sc . nextInt ( ) ; String str = sc . next ( ) ; char [ ] c = str . toCharArray ( ) ; int count = 0 ; if ( fngnvqh % 2 == 0 ) { for ( int i = 0 ; i < fngnvqh / 2 ; i ++ ) { if ( c [ i ] == c [ fngnvqh / 2 + i ] ) { count ++ ; } } if ( count == fngnvqh / 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Xncaptg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long xncaptg = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; if ( xncaptg >= 0 ) { if ( d >= 0 ) { System . out . println ( b * d ) ; } else { System . out . println ( d * xncaptg ) ; } } else if ( b < 0 ) { if ( c >= 0 ) { System . out . println ( b * c ) ; } else { System . out . println ( c * xncaptg ) ; } } else { if ( d < 0 ) { System . out . println ( c * xncaptg ) ; } else if ( c >= 0 ) { System . out . println ( b * d ) ; } else { if ( xncaptg * c > b * d ) { System . out . println ( xncaptg * c ) ; } else { System . out . println ( b * d ) ; } } } } } import java . util . Scanner ; public class Rhuie { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final StringBuilder S1 = new StringBuilder ( sc . next ( ) ) ; final int rhuie = S1 . length ( ) ; final StringBuilder S2 = new StringBuilder ( S1 . substring ( 0 , ( rhuie - 1 ) / 2 ) ) ; final StringBuilder S3 = new StringBuilder ( S1 . substring ( ( rhuie + 3 ) / 2 - 1 , rhuie ) ) ; final boolean cond1 = S1 . toString ( ) . equals ( S1 . reverse ( ) . toString ( ) ) ; final boolean cond2 = S2 . toString ( ) . equals ( S2 . reverse ( ) . toString ( ) ) ; final boolean cond3 = S3 . toString ( ) . equals ( S3 . reverse ( ) . toString ( ) ) ; if ( cond1 && cond2 && cond3 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Junpmtv { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String info = br . readLine ( ) ; String [ ] split = info . split ( " " ) ; int junpmtv = Integer . parseInt ( split [ 0 ] ) ; int N = Integer . parseInt ( split [ 1 ] ) ; info = br . readLine ( ) ; String [ ] A = info . split ( " " ) ; for ( int i = 0 ; i < N ; i ++ ) { junpmtv = junpmtv - Integer . parseInt ( A [ i ] ) ; } if ( junpmtv <= 0 ) { System . out . println ( " Yes " ) ; } else System . out . println ( " No " ) ; } } import java . math . * ; import java . util . * ; import java . io . * ; import java . lang . * ; public class Paqylq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int paqylq = sc . nextInt ( ) ; if ( isPrime ( paqylq ) ) { System . out . println ( paqylq ) ; } else { while ( ! isPrime ( paqylq ) ) { paqylq ++ ; } System . out . println ( paqylq ) ; } } public static boolean isPrime ( int a ) { BigInteger bi = BigInteger . valueOf ( a ) ; return bi . isProbablePrime ( 1 ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ycywwtm { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] parts = br . readLine ( ) . split ( " " ) ; int ycywwtm = Integer . parseInt ( parts [ 0 ] ) ; int A = Integer . parseInt ( parts [ 1 ] ) ; int a = ycywwtm % A ; if ( a == 0 ) { System . out . println ( ycywwtm / A ) ; } else { System . out . println ( ycywwtm / A + 1 ) ; } } } import java . util . Scanner ; public class Cogdyr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cogdyr = Integer . parseInt ( sc . nextLine ( ) ) ; sc . close ( ) ; int ans = 0 ; if ( cogdyr < 10 ) { ans = cogdyr ; } else if ( cogdyr < 100 ) { ans = 9 ; } else if ( cogdyr < 1000 ) { ans = cogdyr - 99 + 9 ; } else if ( cogdyr < 10000 ) { ans = 999 - 99 + 9 ; } else if ( cogdyr < 100000 ) { ans = cogdyr - 9999 + 999 - 99 + 9 ; } else if ( cogdyr < 1000000 ) { ans = 99999 - 9999 + 999 - 99 + 9 ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Wblfsam { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; while ( sc . hasNext ( ) ) { list . add ( Integer . parseInt ( sc . next ( ) ) ) ; } int wblfsam = list . get ( 0 ) ; int sum = list . get ( 1 ) ; int i = 0 ; if ( sum == 1 ) { System . out . print ( 0 ) ; } else if ( wblfsam >= sum ) { System . out . print ( 1 ) ; } else { sum = sum - wblfsam ; i ++ ; wblfsam -- ; while ( true ) { sum = sum - wblfsam ; i ++ ; if ( sum < 1 ) { System . out . print ( i ) ; break ; } } } } } import java . util . Scanner ; public class Gvhlckb { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int gvhlckb ; double [ ] b = new double [ 1111 ] ; double av ; double sum ; while ( true ) { gvhlckb = input . nextInt ( ) ; if ( gvhlckb == 0 ) break ; else { sum = 0 ; av = 0 ; for ( int i = 0 ; i < gvhlckb ; i ++ ) { b [ i ] = input . nextDouble ( ) ; av += b [ i ] ; } av /= gvhlckb ; for ( int i = 0 ; i < gvhlckb ; i ++ ) { sum += ( b [ i ] - av ) * ( b [ i ] - av ) / gvhlckb ; } System . out . println ( Math . sqrt ( sum ) ) ; } } input . close ( ) ; } } import java . util . * ; class Xxkkgls { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int xxkkgls = 1 , x = 1 ; while ( x > 0 ) { x = scanner . nextInt ( ) ; if ( x == 0 ) { break ; } System . out . println ( " Case " + xxkkgls + " : " + x ) ; xxkkgls ++ ; } } } import java . util . * ; public class Natbj { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int natbj = input . nextInt ( ) ; int h = ( natbj / 500 ) * 1000 ; int f = ( ( natbj % 500 ) / 5 ) * 5 ; System . out . println ( h + f ) ; } } import java . util . * ; public class Zigan { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { boolean zigan = true ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a >= b ) { zigan = false ; } int c = sc . nextInt ( ) ; if ( b >= c ) { zigan = false ; } System . out . println ( zigan == true ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Bpfymq { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String bpfymq = input . nextLine ( ) ; if ( bpfymq . equals ( " SUN " ) ) { System . out . println ( " 7 " ) ; } else if ( bpfymq . equals ( " MON " ) ) { System . out . println ( " 6 " ) ; } else if ( bpfymq . equals ( " TUE " ) ) { System . out . println ( " 5 " ) ; } else if ( bpfymq . equals ( " WED " ) ) { System . out . println ( " 4 " ) ; } else if ( bpfymq . equals ( " THU " ) ) { System . out . println ( " 3 " ) ; } else if ( bpfymq . equals ( " FRI " ) ) { System . out . println ( " 2 " ) ; } else if ( bpfymq . equals ( " SAT " ) ) { System . out . println ( " 1 " ) ; } } } import java . util . Scanner ; public class Klqbvk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String klqbvk = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; String t = sb . append ( klqbvk ) . reverse ( ) . toString ( ) ; t = t . replaceAll ( " resare " , " 1 " ) ; t = t . replaceAll ( " esare " , " 1 " ) ; t = t . replaceAll ( " remaerd " , " 1 " ) ; t = t . replaceAll ( " maerd " , " 1 " ) ; t = t . replaceAll ( " 1 " , " " ) ; if ( t . equals ( " " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . ArrayList ; import java . util . Collections ; class Uforgoj { public static void main ( String [ ] args ) throws NumberFormatException , IOException { ArrayList < Integer > input = new ArrayList < Integer > ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; for ( int uforgoj = 0 ; uforgoj < 10 ; uforgoj ++ ) input . add ( Integer . parseInt ( br . readLine ( ) ) ) ; Collections . sort ( input , Collections . reverseOrder ( ) ) ; for ( int uforgoj = 0 ; uforgoj < 3 ; uforgoj ++ ) System . out . println ( input . get ( uforgoj ) ) ; } } import java . util . Scanner ; public class Nvxsyfb { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; while ( true ) { String word = input . nextLine ( ) ; if ( word . equals ( " - " ) ) break ; int nvxsyfb = input . nextInt ( ) ; for ( int i = 0 ; i < nvxsyfb ; i ++ ) { int index = input . nextInt ( ) ; String move = word . substring ( 0 , index ) ; String left = word . substring ( index ) ; word = left + move ; } input . nextLine ( ) ; System . out . println ( word ) ; } } } import java . util . * ; public class Rxapjbe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rxapjbe = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int judge = 0 ; while ( rxapjbe >= 0 && Y >= 0 ) { if ( Y / 4 == rxapjbe && Y % 4 == 0 ) { judge = 1 ; break ; } rxapjbe = rxapjbe - 1 ; Y = Y - 2 ; } if ( judge == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Hahlcs { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] list = scanner . next ( ) . split ( " " ) ; int hahlcs = 0 ; for ( String s : list ) { if ( Integer . parseInt ( s ) == 1 ) { hahlcs ++ ; } } System . out . println ( hahlcs ) ; scanner . close ( ) ; } } import java . util . * ; public class Yloei { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] ss = new String [ 4 ] ; for ( int yloei = 0 ; yloei < 4 ; yloei ++ ) { ss [ yloei ] = s . substring ( yloei , yloei + 1 ) ; } for ( int yloei = 0 ; yloei < 3 ; yloei ++ ) { if ( ss [ yloei ] . equals ( ss [ yloei + 1 ] ) ) { System . out . println ( " Bad " ) ; return ; } } System . out . println ( " Good " ) ; } } import java . util . * ; public class Ztize { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ztize = sc . nextInt ( ) , n = sc . nextInt ( ) , min = 301 ; int [ ] p = new int [ n ] , a = new int [ 300 - n ] ; for ( int i = 0 ; i < n ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int l = 0 ; for ( int i = - 150 ; i < 150 ; i ++ ) { int f = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( i == p [ j ] ) { f ++ ; break ; } } if ( f == 0 ) { a [ l ] = i ; l ++ ; } } if ( n == 0 ) { System . out . println ( ztize ) ; } else { for ( int i = 0 ; i < a . length ; i ++ ) { if ( min <= ( int ) Math . abs ( ztize - a [ i ] ) ) { System . out . println ( a [ i - 1 ] ) ; break ; } else { min = ( int ) Math . abs ( ztize - a [ i ] ) ; } } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ybtqgur { public static void main ( String [ ] args ) throws IOException , Exception { BufferedReader st = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] data1 = getIntArry ( st ) ; int ybtqgur = data1 [ 0 ] ; int k = data1 [ 1 ] ; int [ ] data2 = getIntArry ( st ) ; int ans = 0 ; for ( int i = 0 ; i < ybtqgur ; i ++ ) { if ( data2 [ i ] >= k ) { ans ++ ; } } anser ( ans ) ; } private static int [ ] getIntArry ( BufferedReader st ) throws Exception , IOException { String line = st . readLine ( ) ; String [ ] strData = line . split ( " " ) ; int [ ] intData = new int [ strData . length ] ; for ( int i = 0 ; i < strData . length ; i ++ ) { intData [ i ] = Integer . parseInt ( strData [ i ] ) ; } return intData ; } private static void anser ( int num ) { System . out . println ( num ) ; } } import java . util . * ; public class Erkxxqw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int erkxxqw = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( ( B + erkxxqw - 3 ) / ( erkxxqw - 1 ) ) ; } } import java . util . Scanner ; public class Qhgkb { public static void main ( String [ ] args ) { Scanner kbd = new Scanner ( System . in ) ; int qhgkb = kbd . nextInt ( ) ; int d = kbd . nextInt ( ) ; int num = 0 ; for ( int i = 0 ; i < qhgkb ; i ++ ) { long x = kbd . nextInt ( ) ; long y = kbd . nextInt ( ) ; if ( Math . sqrt ( x * x + y * y ) <= d ) { num ++ ; } } System . out . println ( num ) ; } } import java . util . * ; public class Pwflemu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int pwflemu = s . length ; char [ ] t = sc . next ( ) . toCharArray ( ) ; int tlen = t . length ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < pwflemu - tlen + 1 ; i ++ ) { int cnt = 0 ; for ( int j = 0 ; j < tlen ; j ++ ) { if ( s [ i + j ] != t [ j ] ) cnt ++ ; } if ( cnt < ans ) ans = cnt ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class Wkvsdgy { public static void main ( String [ ] args ) throws Exception { solve ( System . in , System . out ) ; } static void solve ( InputStream is , PrintStream os ) { Scanner scan = new Scanner ( is ) ; int wkvsdgy = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int ans = 0 ; while ( wkvsdgy >= K ) { wkvsdgy /= K ; ans ++ ; } if ( wkvsdgy != 0 ) ans ++ ; os . println ( ans ) ; } } import java . util . Scanner ; import java . lang . Math ; class Rpxykbn { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int rpxykbn = Integer . parseInt ( stdIn . next ( ) ) ; if ( rpxykbn != 2 && rpxykbn % 2 == 0 ) rpxykbn ++ ; while ( true ) { int i ; double sqrtNum = Math . sqrt ( rpxykbn ) ; for ( i = 3 ; i <= sqrtNum ; i += 2 ) { if ( rpxykbn % i == 0 ) break ; } if ( i > sqrtNum ) break ; rpxykbn += 2 ; } System . out . println ( rpxykbn ) ; } } import java . util . Scanner ; public class Weitn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int weitn = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int X = scan . nextInt ( ) ; int [ ] A = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { A [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; int index1 = X ; int cost1 = 0 ; int cost2 = 0 ; for ( int i = 0 ; i < X - 1 ; i ++ ) { index1 -- ; for ( int j = 0 ; j < M ; j ++ ) { if ( index1 == A [ j ] ) { cost1 ++ ; } } } cost2 = A . length - cost1 ; if ( cost2 > cost1 ) { System . out . println ( cost1 ) ; } else { System . out . println ( cost2 ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Yolhwp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int yolhwp = scan . nextInt ( ) ; int [ ] A = new int [ yolhwp ] ; for ( int i = 0 ; i < yolhwp ; i ++ ) { A [ i ] = scan . nextInt ( ) ; } double c = 0 ; Arrays . sort ( A ) ; c = ( A [ 0 ] + A [ 1 ] ) / 2.0 ; for ( int i = 2 ; i < yolhwp ; i ++ ) { c = ( c + A [ i ] ) / 2.0 ; } System . out . println ( c ) ; } } import java . util . * ; import java . io . * ; import java . nio . charset . StandardCharsets ; public class Xnkqnqe { public static void main ( String [ ] args ) throws IOException { InputStreamReader reader = new InputStreamReader ( System . in , StandardCharsets . UTF_8 ) ; BufferedReader in = new BufferedReader ( reader ) ; char [ ] str = in . readLine ( ) . toCharArray ( ) ; str [ 3 ] = '8' ; String xnkqnqe = new String ( str ) ; System . out . println ( xnkqnqe ) ; } } import java . util . * ; class Gqjfvv { public static void main ( String [ ] args ) { Scanner inp = new Scanner ( System . in ) ; do_ ( inp ) ; inp . close ( ) ; } public static void do_ ( Scanner inp ) { char [ ] ss = inp . next ( ) . toCharArray ( ) ; char gqjfvv = ss [ ss . length - 1 ] ; if ( gqjfvv == '2' || gqjfvv == '4' || gqjfvv == '5' || gqjfvv == '7' || gqjfvv == '9' ) { System . out . println ( " hon " ) ; } else if ( gqjfvv == '0' || gqjfvv == '1' || gqjfvv == '6' || gqjfvv == '8' ) { System . out . println ( " pon " ) ; } else { System . out . println ( " bon " ) ; } } } import java . io . * ; import java . util . * ; public class Nixmjui { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int nixmjui = 1 ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int [ ] a = new int [ n ] ; int x = 0 , cnt = 0 , sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; sum += a [ i ] ; } x = ( int ) Math . ceil ( sum / ( 1.0 * 4 * m ) ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] >= x ) cnt ++ ; } System . out . println ( cnt >= m ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Vcyhcdn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Double r = Double . parseDouble ( sc . next ( ) ) ; double vcyhcdn = Math . PI ; double s = r * r * vcyhcdn ; double l = 2 * r * vcyhcdn ; System . out . printf ( " %.6f " , s ) ; System . out . print ( " " ) ; System . out . printf ( " %.6f \n " , l ) ; } } import java . util . * ; class Rjgcknh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rjgcknh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] array = { 1 , 2 , 3 } ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( ( array [ i ] == rjgcknh ) || ( array [ i ] == b ) ) { array [ i ] = 0 ; } } for ( int i = 0 ; i < 3 ; i ++ ) { if ( array [ i ] != 0 ) { System . out . println ( array [ i ] ) ; return ; } } } } import java . util . * ; class Bbvpoat { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bbvpoat = sc . nextInt ( ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; StringBuilder sb = new StringBuilder ( " " ) ; for ( int i = 0 , j = 0 ; i < a . length ( ) && j < b . length ( ) ; i ++ , j ++ ) { sb . append ( ( char ) a . charAt ( i ) + " " ) . append ( ( char ) b . charAt ( j ) + " " ) ; } System . out . println ( sb ) ; } } import java . awt . * ; import java . awt . geom . * ; import java . io . * ; import java . util . * ; class Yxcksz { static char [ ] xx = new char [ ] { 'S' , 'H' , 'C' , 'D' } ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yxcksz = sc . nextInt ( ) ; boolean [ ] [ ] l = new boolean [ 4 ] [ 13 ] ; for ( int i = 0 ; i < yxcksz ; i ++ ) { char k = sc . next ( ) . charAt ( 0 ) ; int r = sc . nextInt ( ) ; if ( k == 'S' ) { l [ 0 ] [ r - 1 ] = true ; } if ( k == 'H' ) { l [ 1 ] [ r - 1 ] = true ; } if ( k == 'C' ) { l [ 2 ] [ r - 1 ] = true ; } if ( k == 'D' ) { l [ 3 ] [ r - 1 ] = true ; } } for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 13 ; j ++ ) { if ( ! l [ i ] [ j ] ) { System . out . println ( xx [ i ] + " " + ( j + 1 ) ) ; } } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; import java . math . * ; public class Tdpdclp { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] str = br . readLine ( ) . split ( " / " ) ; int tdpdclp = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; if ( tdpdclp > 2019 || ( tdpdclp <= 2019 && m > 4 ) ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } } } import java . util . Scanner ; public class Ptino { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String [ ] t = s . split ( " " ) ; for ( int ptino = 0 ; ptino < t . length ; ptino ++ ) { t [ ptino ] = " x " ; } String u = String . join ( " " , t ) ; System . out . println ( u ) ; } } import java . util . * ; public class Ewovta { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ewovta = sc . next ( ) ; if ( " SAT " . equals ( ewovta ) ) { System . out . println ( " 1 " ) ; } else if ( " FRI " . equals ( ewovta ) ) { System . out . println ( " 2 " ) ; } else if ( " THU " . equals ( ewovta ) ) { System . out . println ( " 3 " ) ; } else if ( " WED " . equals ( ewovta ) ) { System . out . println ( " 4 " ) ; } else if ( " TUE " . equals ( ewovta ) ) { System . out . println ( " 5 " ) ; } else if ( " MON " . equals ( ewovta ) ) { System . out . println ( " 6 " ) ; } else if ( " SUN " . equals ( ewovta ) ) { System . out . println ( " 7 " ) ; } } private static long lcm ( long m , long n ) { return m * n / gcd ( m , n ) ; } private static long gcd ( long m , long n ) { if ( m < n ) return gcd ( n , m ) ; if ( n == 0 ) return m ; return gcd ( n , m % n ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Map ; import java . util . PriorityQueue ; import java . util . Scanner ; public class Cltuu { public static void main ( String [ ] args ) throws Exception { solve ( System . in , System . out ) ; } static void solve ( InputStream is , PrintStream os ) { Scanner scan = new Scanner ( is ) ; int cltuu = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int H = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; double ax = cltuu * Math . cos ( Math . toRadians ( 90 - 30 * H - M / 2.0 ) ) ; double ay = cltuu * Math . sin ( Math . toRadians ( 90 - 30 * H - M / 2.0 ) ) ; double bx = B * Math . cos ( Math . toRadians ( 90 - 6 * M ) ) ; double by = B * Math . sin ( Math . toRadians ( 90 - 6 * M ) ) ; double ans = Math . sqrt ( ( ax - bx ) * ( ax - bx ) + ( ay - by ) * ( ay - by ) ) ; os . println ( ans ) ; } } import java . util . Scanner ; public class Dtvdgaq { public static void main ( String [ ] args ) { try ( final Scanner sc = new Scanner ( System . in ) ) { Resolver resolver = new Resolver ( sc ) ; resolver . resolve ( ) ; } } private static class Dtvdgaq { private final int dtvdgaq , b , t ; private Resolver ( final Scanner sc ) { this . dtvdgaq = sc . nextInt ( ) ; this . b = sc . nextInt ( ) ; this . t = sc . nextInt ( ) ; } private void resolve ( ) { int k = t / dtvdgaq ; System . out . println ( b * k ) ; } } } import java . util . Scanner ; class Bimrl { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int bimrl , c , a [ ] [ ] = new int [ 101 ] [ 101 ] , i , j ; bimrl = stdIn . nextInt ( ) ; c = stdIn . nextInt ( ) ; for ( i = 0 ; i < bimrl ; i ++ ) { for ( j = 0 ; j < c ; j ++ ) { a [ i ] [ j ] = stdIn . nextInt ( ) ; a [ i ] [ c ] += a [ i ] [ j ] ; } } for ( i = 0 ; i < c ; i ++ ) { for ( j = 0 ; j < bimrl ; j ++ ) a [ bimrl ] [ i ] += a [ j ] [ i ] ; a [ bimrl ] [ c ] += a [ bimrl ] [ i ] ; } for ( i = 0 ; i <= bimrl ; i ++ ) { for ( j = 0 ; j <= c ; j ++ ) { if ( j != 0 ) System . out . print ( " " ) ; System . out . print ( a [ i ] [ j ] ) ; } System . out . println ( ) ; } } } import java . util . * ; public class Ajvsixx { public static void main ( String [ ] args ) { boolean ajvsixx = false ; int answer = 0 ; List < Integer > a = new ArrayList < Integer > ( ) ; int s ; int n = 1 ; int ai = 0 ; int count = 0 ; Scanner sc = new Scanner ( System . in ) ; s = sc . nextInt ( ) ; while ( ajvsixx == false ) { if ( count == 0 ) { a . add ( s ) ; count ++ ; } else { n = a . get ( count - 1 ) ; if ( n % 2 == 0 ) { ai = n / 2 ; a . add ( ai ) ; } else { ai = 3 * n + 1 ; a . add ( ai ) ; } count ++ ; } for ( int i = 0 ; i < count - 1 ; i ++ ) { if ( a . get ( i ) == ai ) { answer = a . size ( ) ; ajvsixx = true ; } } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Kqlke { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String nyu = sc . next ( ) ; int kqlke = 0 , mem = 0 , leng ; leng = nyu . length ( ) ; for ( int i = 0 ; i < leng ; i ++ ) { char top = nyu . charAt ( i ) ; switch ( top ) { case 'A' : kqlke += 1 ; break ; case 'C' : kqlke += 1 ; break ; case 'G' : kqlke += 1 ; break ; case 'T' : kqlke += 1 ; break ; default : if ( kqlke > mem ) { mem = kqlke ; kqlke = 0 ; } } } if ( kqlke > mem ) { mem = kqlke ; } System . out . println ( mem ) ; } } import java . util . * ; public class Kparpkf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kparpkf = sc . nextInt ( ) , T = sc . nextInt ( ) ; int [ ] c = new int [ kparpkf ] ; int [ ] t = new int [ kparpkf ] ; for ( int i = 0 ; i < kparpkf ; i ++ ) { c [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; } int ans = INF ; boolean exist = false ; for ( int i = 0 ; i < kparpkf ; i ++ ) { if ( t [ i ] <= T ) { exist = true ; ans = Math . min ( ans , c [ i ] ) ; } } if ( exist ) System . out . println ( ans ) ; else System . out . println ( " TLE " ) ; } public static final int INF = 10000 ; } import java . util . Scanner ; public class Fpzgnmo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; long fpzgnmo = scan . nextLong ( ) ; scan . close ( ) ; int l = S . length ( ) ; int [ ] num = new int [ S . length ( ) ] ; for ( int i = 0 ; i < l ; i ++ ) { num [ i ] = Integer . parseInt ( S . substring ( i , i + 1 ) ) ; } long sum = l ; if ( sum >= fpzgnmo ) { int cnt1 = 0 ; for ( int i = 0 ; i < l ; i ++ ) { if ( num [ i ] == 1 ) { cnt1 ++ ; } else { break ; } } if ( cnt1 >= fpzgnmo ) { System . out . println ( 1 ) ; System . exit ( 0 ) ; } } long cnt = 1 ; int ans = 0 ; for ( int i = 0 ; i < l ; i ++ ) { if ( num [ i ] != 1 ) { ans = num [ i ] ; break ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Urgnhar { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int urgnhar = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ m ] ; boolean [ ] jdg = new boolean [ urgnhar + 1 ] ; long [ ] Dp = new long [ urgnhar + 1 ] ; int p = 1000000007 ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) ; jdg [ a [ i ] ] = true ; } Dp [ 0 ] = 1 ; for ( int i = 1 ; i <= urgnhar ; i ++ ) { if ( jdg [ i ] == false ) { if ( i == 1 ) Dp [ i ] = Dp [ i - 1 ] ; if ( i >= 2 ) { Dp [ i ] = ( Dp [ i - 1 ] ) % p + ( Dp [ i - 2 ] ) % p ; Dp [ i ] = Dp [ i ] % p ; } } if ( jdg [ i ] == true ) { Dp [ i ] = 0 ; } } System . out . println ( Dp [ urgnhar ] ) ; } } import java . util . * ; public class Jtzkpg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jtzkpg , i , answer ; int sum = 0 ; int temp_a = 0 ; int temp_b = 0 ; jtzkpg = Integer . parseInt ( sc . next ( ) ) ; int [ ] weight = new int [ jtzkpg ] ; for ( i = 0 ; i < jtzkpg ; i ++ ) { weight [ i ] = Integer . parseInt ( sc . next ( ) ) ; sum += weight [ i ] ; } for ( i = 0 ; i < jtzkpg ; i ++ ) { temp_a += weight [ i ] ; if ( sum <= 2 * temp_a ) { break ; } else { temp_b = temp_a ; } } temp_a = sum - 2 * temp_a ; temp_b = sum - 2 * temp_b ; temp_a = Math . abs ( temp_a ) ; temp_b = Math . abs ( temp_b ) ; if ( temp_b < temp_a ) { answer = temp_b ; } else { answer = temp_a ; } System . out . println ( answer ) ; } } import java . util . * ; public class Aqqus { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int aqqus = scanner . nextInt ( ) ; int max = Integer . MAX_VALUE ; for ( int i = 0 ; i < aqqus ; i ++ ) { max = Math . min ( max , Integer . numberOfTrailingZeros ( scanner . nextInt ( ) ) ) ; } System . out . println ( max ) ; } } import java . util . Scanner ; public class Zfnuw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; boolean zfnuw = false ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] ans = new int [ n ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; ans [ i ] = 0 ; } ans [ n - 1 ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] != 0 ) ans [ a [ i ] - 1 ] ++ ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( ans [ i ] ) ; } sc . close ( ) ; } } import java . util . * ; public class Ggxzh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int ggxzh = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( '0' == s . charAt ( i ) ) ggxzh ++ ; } System . out . println ( 2 * Math . min ( s . length ( ) - ggxzh , ggxzh ) ) ; } } import java . util . Scanner ; public class Ixviu { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int ixviu = s . nextInt ( ) ; int [ ] ds = new int [ ixviu ] ; int sum = 0 ; for ( int i = 0 ; i < ixviu ; i ++ ) { ds [ i ] = s . nextInt ( ) ; for ( int j = 0 ; j < i ; j ++ ) { sum += ds [ j ] * ds [ i ] ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Ybcazo { static String str ; static int ybcazo , zeroC , oneC ; static int [ ] A ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; str = sc . next ( ) ; ybcazo = str . length ( ) ; A = new int [ ybcazo ] ; for ( int i = 0 ; i < ybcazo ; i ++ ) { A [ i ] = Character . getNumericValue ( str . charAt ( i ) ) ; if ( A [ i ] == 0 ) { zeroC ++ ; } else { oneC ++ ; } } System . out . println ( ybcazo - ( Math . abs ( zeroC - oneC ) ) ) ; } } import java . util . * ; class Snxod { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int snxod = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int price1 ; int price2 ; if ( X > Y ) { price1 = ( C * 2 * Y ) + ( snxod * ( X - Y ) ) ; price2 = C * 2 * X ; } else { price1 = ( C * 2 * X ) + ( B * ( Y - X ) ) ; price2 = C * 2 * Y ; } int price3 = snxod * X + B * Y ; int ans = Math . min ( price1 , price2 ) ; ans = Math . min ( ans , price3 ) ; System . out . println ( + ans ) ; } } import java . util . * ; public class Npiayiv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int npiayiv = sc . nextInt ( ) ; int [ ] H = new int [ npiayiv ] ; for ( int i = 0 ; i < npiayiv ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; boolean out = false ; H [ 0 ] -- ; for ( int i = 0 ; i < npiayiv - 1 ; i ++ ) { if ( H [ i + 1 ] < H [ i ] ) { out = true ; } if ( H [ i + 1 ] - 1 >= H [ i ] ) { H [ i + 1 ] -- ; } } if ( out ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . * ; public class Mdybx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mdybx = sc . nextLong ( ) ; long ans = Long . MAX_VALUE / 2 ; for ( int i = 1 ; ( long ) i * i <= mdybx ; i ++ ) { if ( mdybx % i == 0 ) { long a = i ; long b = mdybx / i ; long tmp = Math . max ( a , b ) ; ans = Math . min ( ans , tmp ) ; } } int res = 0 ; while ( ans > 0 ) { ans /= 10 ; res ++ ; } System . out . println ( res ) ; } } import java . util . Scanner ; public class Fpdbdek { public static void main ( String [ ] args ) { int fpdbdek ; int endNum ; int answer = 0 ; Scanner sc = new Scanner ( System . in ) ; fpdbdek = sc . nextInt ( ) ; endNum = sc . nextInt ( ) ; for ( int i = fpdbdek ; i <= endNum ; i ++ ) { String numStr = String . valueOf ( i ) ; char num1 = numStr . charAt ( 0 ) ; char num2 = numStr . charAt ( 1 ) ; char num4 = numStr . charAt ( 3 ) ; char num5 = numStr . charAt ( 4 ) ; if ( ( num1 == num5 ) && ( num2 == num4 ) ) { answer ++ ; } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Qewvu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qewvu = sc . nextInt ( ) ; int [ ] b = new int [ qewvu ] ; int sum = 0 ; int ans = 0 ; for ( int i = 0 ; i < b . length ; i ++ ) { b [ i ] = sc . nextInt ( ) ; sum += b [ i ] ; } for ( int j = 1 ; j < b . length ; j ++ ) { int half = 0 ; int tmp = 0 ; for ( int x = 0 ; x < j ; x ++ ) { half += b [ x ] ; tmp = sum - ( half * 2 ) ; tmp = Math . abs ( tmp ) ; if ( x == 0 || tmp < ans ) { ans = tmp ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Ylxhv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ylxhv = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( ylxhv % k < k - ( ylxhv % k ) ) k = ylxhv % k ; else k = k - ( ylxhv % k ) ; System . out . println ( k ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Xmssm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xmssm = sc . nextInt ( ) , K = sc . nextInt ( ) ; double [ ] dp = new double [ K + 1 ] ; Arrays . fill ( dp , 0 ) ; for ( int i = 1 ; i <= Math . min ( xmssm , K ) ; ++ i ) dp [ i ] = 1.0 / xmssm ; dp [ K ] += ( double ) Math . max ( 0 , xmssm - K ) / xmssm ; for ( int i = 1 ; i < K ; ++ i ) dp [ Math . min ( i * 2 , K ) ] += dp [ i ] / 2 ; System . out . println ( dp [ K ] ) ; } } import java . util . Scanner ; public class Wyivfoj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wyivfoj = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int min = 0 ; int count = 0 ; if ( wyivfoj < B ) { min = wyivfoj ; } else { min = B ; } for ( int i = min ; i >= 1 ; i -- ) { if ( wyivfoj % i == 0 && B % i == 0 ) { count ++ ; if ( count == K ) { System . out . println ( i ) ; break ; } } } scan . close ( ) ; } } import java . util . * ; public class Kvlgmo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Integer N = sc . nextInt ( ) ; Integer Q = sc . nextInt ( ) ; String S = sc . next ( ) ; Integer [ ] l = new Integer [ Q ] , r = new Integer [ Q ] ; for ( int kvlgmo = 0 ; kvlgmo < Q ; kvlgmo ++ ) { l [ kvlgmo ] = sc . nextInt ( ) ; r [ kvlgmo ] = sc . nextInt ( ) ; } int [ ] a = new int [ N ] ; int count = 0 ; for ( int kvlgmo = 1 ; kvlgmo < N ; kvlgmo ++ ) { if ( S . charAt ( kvlgmo - 1 ) == 'A' && S . charAt ( kvlgmo ) == 'C' ) { count ++ ; a [ kvlgmo ] = count ; } else { a [ kvlgmo ] = count ; } } for ( int kvlgmo = 0 ; kvlgmo < Q ; kvlgmo ++ ) { System . out . println ( a [ r [ kvlgmo ] - 1 ] - a [ l [ kvlgmo ] - 1 ] ) ; } } } import java . util . Scanner ; public class Smlvqab { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int smlvqab = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int C = 0 ; C = smlvqab * B ; System . out . println ( C ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Rboybmg { private static int rboybmg = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] nums = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { nums [ i ] = sc . nextInt ( ) ; } me ( nums ) ; System . out . println ( Main . rboybmg ) ; } public static void me ( int [ ] nums ) { int min = Integer . MAX_VALUE ; for ( int num : nums ) { min = num < min ? num : min ; } Main . rboybmg += min ; int ti = 0 ; int i ; for ( i = 0 ; i < nums . length ; i ++ ) { nums [ i ] -= min ; if ( nums [ i ] == 0 ) { if ( ti < i ) { me ( Arrays . copyOfRange ( nums , ti , i ) ) ; } ti = i + 1 ; } } if ( ti < i ) { me ( Arrays . copyOfRange ( nums , ti , i ) ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Skzyc { public static void main ( String [ ] args ) throws Exception { boolean skzyc = true ; try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String line ; while ( ( line = br . readLine ( ) ) != null ) { String [ ] str = line . split ( " " ) ; int x = Integer . parseInt ( str [ 0 ] ) ; int y = Integer . parseInt ( str [ 1 ] ) ; if ( x == 0 && y == 0 ) { break ; } for ( int i = 0 ; i < x ; i ++ ) { for ( int j = 0 ; j < y ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } } } } import java . util . Scanner ; public class Udhdfc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String w = scan . nextLine ( ) ; int udhdfc = 0 ; while ( scan . hasNext ( ) ) { String T = scan . nextLine ( ) ; if ( T . equals ( " END_OF_TEXT " ) ) { break ; } String [ ] Ts = T . split ( " " ) ; for ( int i = 0 ; i < Ts . length ; i ++ ) { if ( Ts [ i ] . equalsIgnoreCase ( w ) ) { udhdfc ++ ; } } } System . out . println ( udhdfc ) ; } } import java . util . * ; import java . lang . * ; public class Zskqayz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; int [ ] a = new int [ n . length ( ) + 1 ] ; int zskqayz = 0 ; for ( int i = 0 ; i < n . length ( ) ; i ++ ) { a [ i ] = n . charAt ( i ) - '0' ; } for ( int i = 0 ; i < n . length ( ) ; i ++ ) { zskqayz = zskqayz + a [ i ] ; } if ( zskqayz % 9 == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class Zkuztbv { Scanner sc ; int zkuztbv , b ; static String testInput = " 998244353 99824435 " ; public Main ( ) { sc = new Scanner ( System . in ) ; } public Main ( String input ) { sc = new Scanner ( input ) ; } void out ( Object o ) { System . out . println ( o ) ; System . out . flush ( ) ; } public void exec ( ) throws Exception { zkuztbv = sc . nextInt ( ) ; b = sc . nextInt ( ) ; int k = ( zkuztbv + b ) / 2 ; if ( k * 2 != zkuztbv + b ) out ( " IMPOSSIBLE " ) ; else out ( k ) ; } public static void main ( String [ ] args ) throws Exception { Main m = new Main ( ) ; m . exec ( ) ; } } import java . util . * ; public class Ihgpkvy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ihgpkvy = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < A . length ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < A . length ; i ++ ) { ihgpkvy -= A [ i ] ; } if ( ihgpkvy <= 0 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; import java . util . Collections ; import java . util . ArrayList ; public class Aaftp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aaftp = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int a = 0 ; int b = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( sc . nextInt ( ) < X ) { a += 1 ; } else { b += 1 ; } } if ( a <= b ) { System . out . println ( a ) ; } else { System . out . println ( b ) ; } } } import java . util . Scanner ; public class Msciq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char msciq = sc . next ( ) . trim ( ) . charAt ( 0 ) ; StringBuilder sb = new StringBuilder ( ) ; if ( msciq >= 'A' && msciq <= 'Z' ) sb . append ( 'A' + " \n " ) ; else if ( msciq >= 'a' && msciq <= 'z' ) sb . append ( 'a' + " \n " ) ; sc . close ( ) ; System . out . println ( sb ) ; } } import java . util . * ; public class Bbrxt { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] nums = new int [ 3 ] ; for ( int bbrxt = 0 ; bbrxt < 3 ; bbrxt ++ ) nums [ bbrxt ] = sc . nextInt ( ) ; Arrays . sort ( nums ) ; int cost = 0 ; for ( int bbrxt = 1 ; bbrxt < 3 ; bbrxt ++ ) cost += nums [ bbrxt ] - nums [ bbrxt - 1 ] ; System . out . println ( cost ) ; } } import java . io . BufferedReader ; import java . io . * ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . math . * ; public class Sszbv { static class Sszbv { 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 ; } } public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int sszbv = 1 ; long ans = 0 , mod = 1000000007 ; while ( sszbv -- > 0 ) { int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; pw . println ( ( n * ( n - 1 ) ) / 2 + ( m * ( m - 1 ) ) / 2 ) ; } pw . close ( ) ; } } import java . util . Scanner ; public class Iwiihfd { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner stdin = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ ] ; for ( int iwiihfd = 0 ; iwiihfd < 3 ; iwiihfd ++ ) { c [ iwiihfd ] = new int [ 3 ] ; for ( int j = 0 ; j < 3 ; j ++ ) { c [ iwiihfd ] [ j ] = stdin . nextInt ( ) ; } } String result = " No " ; int a2 = c [ 1 ] [ 0 ] - c [ 0 ] [ 0 ] ; int a3 = c [ 2 ] [ 0 ] - c [ 0 ] [ 0 ] ; if ( ( c [ 1 ] [ 1 ] == ( a2 + c [ 0 ] [ 1 ] ) ) && ( c [ 1 ] [ 2 ] == ( a2 + c [ 0 ] [ 2 ] ) ) && ( c [ 2 ] [ 1 ] == ( a3 + c [ 0 ] [ 1 ] ) ) && ( c [ 2 ] [ 2 ] == ( a3 + c [ 0 ] [ 2 ] ) ) ) { result = " Yes " ; } System . out . println ( result ) ; } } import java . util . * ; public class Npjtsr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int npjtsr = Integer . parseInt ( sc . next ( ) ) ; int [ ] l = new int [ npjtsr ] ; for ( int i = 0 ; i < npjtsr ; i ++ ) { l [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( l ) ; int max = Arrays . stream ( l ) . max ( ) . getAsInt ( ) ; int other = Arrays . stream ( l ) . sum ( ) - max ; String result = max < other ? " Yes " : " No " ; System . out . println ( result ) ; sc . close ( ) ; } } import java . util . Scanner ; class Oqbevx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long oqbevx = sc . nextLong ( ) ; sc . close ( ) ; long p = 1 ; long sum = 0 ; for ( int i = 0 ; i < oqbevx ; i ++ ) { if ( p % 5 == 0 || p % 3 == 0 ) { p ++ ; continue ; } else { sum += p ; p ++ ; } } System . out . println ( sum ) ; } } import java . util . * ; public class Otvygdd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long otvygdd = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long ans1 = Math . max ( otvygdd , b ) * Math . max ( c , d ) ; long ans2 = Math . min ( otvygdd , b ) * Math . max ( c , d ) ; long ans3 = Math . max ( otvygdd , b ) * Math . min ( c , d ) ; long ans4 = Math . min ( otvygdd , b ) * Math . min ( c , d ) ; long ans = Math . max ( ans1 , Math . max ( ans2 , Math . max ( ans3 , ans4 ) ) ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Mrodvxw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mrodvxw = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; if ( mrodvxw - c < 0 && mrodvxw + b >= c ) { System . out . println ( " 0 " + ( b - ( c - mrodvxw ) ) ) ; } else if ( mrodvxw + b <= c ) { System . out . println ( " 0 0 " ) ; } else { System . out . println ( mrodvxw - c + " " + b ) ; } } } import java . util . Scanner ; public class Qubyil { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int qubyil = sc . nextInt ( ) ; int c = 0 ; for ( int i = 0 ; i < qubyil ; i ++ ) { if ( PNcheck ( sc . nextInt ( ) ) ) c ++ ; } System . out . println ( c ) ; } static boolean PNcheck ( int qubyil ) { if ( qubyil == 2 ) return true ; if ( ( qubyil % 2 ) == 0 ) return false ; for ( int i = 3 ; i * i <= qubyil ; i = i + 2 ) { if ( ( qubyil % i ) == 0 ) return false ; } return true ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; class Kxeee { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static String S , T ; static int kxeee = 0 ; public static void main ( String [ ] args ) throws Exception { S = br . readLine ( ) ; T = br . readLine ( ) ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { char s = S . charAt ( i ) ; char t = T . charAt ( i ) ; if ( s != t ) { kxeee ++ ; } } System . out . println ( kxeee ) ; } } import java . util . * ; public class Oguolyr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double oguolyr = scanner . nextDouble ( ) ; System . out . println ( String . format ( " %.6f " , Math . pow ( oguolyr / 3 , 3 ) ) ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class Hqqkr { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int hqqkr = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; sc . close ( ) ; R = Math . min ( hqqkr + 2019 , R ) ; int ans = Integer . MAX_VALUE ; for ( int x = hqqkr ; x < R ; x ++ ) { for ( int y = x + 1 ; y <= R ; y ++ ) { if ( x == y ) continue ; int m = ( int ) ( ( ( long ) x * y ) % 2019 ) ; ans = Math . min ( ans , m ) ; } } out . println ( ans ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } } import java . util . Scanner ; class Oojuu { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int oojuu = scn . nextInt ( ) ; int d = scn . nextInt ( ) ; int [ ] [ ] dot = new int [ oojuu ] [ d ] ; int answer = 0 ; for ( int i = 0 ; i < oojuu ; i ++ ) { for ( int j = 0 ; j < d ; j ++ ) { dot [ i ] [ j ] = scn . nextInt ( ) ; } } for ( int i = 0 ; i < oojuu ; i ++ ) { for ( int j = i + 1 ; j < oojuu ; j ++ ) { double check = 0 ; for ( int k = 0 ; k < d ; k ++ ) { check += ( dot [ i ] [ k ] - dot [ j ] [ k ] ) * ( dot [ i ] [ k ] - dot [ j ] [ k ] ) ; } check = Math . sqrt ( check ) ; if ( check == ( int ) check ) { answer ++ ; } } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Wzchs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String wzchs = sc . next ( ) ; if ( wzchs . matches ( " ^A[a-z]+[C] { 1 } +[a-z]+$ " ) ) { System . out . println ( " AC " ) ; } else { System . out . println ( " WA " ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . stream . Collectors ; public class Oltrp { public static void main ( String [ ] args ) throws Exception { InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader reader = new BufferedReader ( is ) ; List < String > mylist = new ArrayList < > ( ) ; String strinput = reader . readLine ( ) ; while ( strinput != null ) { mylist . add ( strinput ) ; strinput = reader . readLine ( ) ; } String [ ] arr01 = mylist . get ( 0 ) . split ( " " ) ; String [ ] arr02 = mylist . get ( 1 ) . split ( " " ) ; int oltrp = Integer . valueOf ( arr01 [ 0 ] ) ; List < String > list01 = Arrays . asList ( arr02 ) ; List < String > list02 = list01 . stream ( ) . distinct ( ) . collect ( Collectors . toList ( ) ) ; System . out . println ( list01 . size ( ) == list02 . size ( ) ? " YES " : " NO " ) ; } } import java . util . * ; public class Drcjsq { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int drcjsq = scn . nextInt ( ) ; int a = scn . nextInt ( ) ; int b = scn . nextInt ( ) ; for ( ; a <= b ; a ++ ) { if ( a % drcjsq == 0 ) { System . out . printf ( " OK \n " ) ; return ; } } System . out . printf ( " NG \n " ) ; } } import java . util . * ; class Vcnpcp { public Main ( ) { int vcnpcp ; String S ; HashMap < String , Integer > HM = new HashMap < String , Integer > ( ) ; Scanner scanner = new Scanner ( System . in ) ; vcnpcp = scanner . nextInt ( ) ; for ( int i = 0 ; i < vcnpcp ; i ++ ) { S = scanner . next ( ) ; if ( HM . containsKey ( S ) ) { HM . put ( S , HM . get ( S ) + 1 ) ; } else { HM . put ( S , 1 ) ; } } int max = 0 ; for ( int v : HM . values ( ) ) { if ( v > max ) max = v ; } ArrayList < String > R = new ArrayList < String > ( ) ; for ( Map . Entry < String , Integer > entry : HM . entrySet ( ) ) { if ( entry . getValue ( ) == max ) R . add ( entry . getKey ( ) ) ; } Collections . sort ( R ) ; for ( String str : R ) { System . out . println ( str ) ; } } public static void main ( String [ ] args ) throws Exception { Main main = new Main ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayDeque ; import java . util . Queue ; public class Zzjze { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder builder = new StringBuilder ( ) ; String [ ] line = reader . readLine ( ) . split ( " " ) ; int zzjze = Integer . parseInt ( line [ 0 ] ) ; int q = Integer . parseInt ( line [ 1 ] ) ; Queue < String [ ] > queue = new ArrayDeque < String [ ] > ( ) ; for ( int i = 0 ; i < zzjze ; i ++ ) { queue . add ( reader . readLine ( ) . split ( " " ) ) ; } String [ ] work = new String [ 2 ] ; int elapse = 0 ; while ( ( work = queue . poll ( ) ) != null ) { int time = Integer . parseInt ( work [ 1 ] ) ; if ( time <= q ) { elapse += time ; builder . append ( work [ 0 ] ) . append ( " " ) . append ( elapse ) . append ( " \n " ) ; } else { time -= q ; elapse += q ; work [ 1 ] = String . valueOf ( time ) ; queue . add ( work ) ; } } System . out . print ( builder ) ; } } import java . util . * ; import java . io . * ; public class Uacungq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uacungq = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] A = new int [ uacungq ] ; for ( int i = 0 ; i < Q ; i ++ ) { int i_ = sc . nextInt ( ) ; A [ i_ - 1 ] ++ ; } sc . close ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; for ( int i = 0 ; i < uacungq ; i ++ ) { if ( 0 < A [ i ] + K - Q ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } } out . flush ( ) ; } } import java . util . Scanner ; public class Orsbxxk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] country = new int [ sc . nextInt ( ) ] ; int orsbxxk = sc . nextInt ( ) ; for ( int i = 0 ; i < orsbxxk ; i ++ ) { int point = sc . nextInt ( ) - 1 ; country [ point ] = country [ point ] + 1 ; point = sc . nextInt ( ) - 1 ; country [ point ] = country [ point ] + 1 ; } for ( int i : country ) { System . out . println ( i ) ; } } } import java . io . * ; import java . util . * ; class Zxrcg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zxrcg = Integer . parseInt ( sc . next ( ) ) ; int [ ] d = new int [ zxrcg ] ; for ( int i = 0 ; i < zxrcg ; i ++ ) { d [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int sum = 0 ; for ( int i = 0 ; i < zxrcg - 1 ; i ++ ) { for ( int j = i + 1 ; j < zxrcg ; j ++ ) { sum += d [ i ] * d [ j ] ; } } System . out . println ( sum ) ; } } import java . util . * ; public class Zdaeh { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int zdaeh = s . nextInt ( ) ; int [ ] An = new int [ zdaeh ] ; int ans = 0 ; for ( int i = 0 ; i < zdaeh ; i ++ ) { An [ i ] = s . nextInt ( ) ; } Arrays . sort ( An ) ; ans = An [ zdaeh - 1 ] - An [ 0 ] ; System . out . print ( ans ) ; } } import java . util . Scanner ; public class Bgfxbn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; boolean bgfxbn = scanner . bgfxbn ( ) ; int n = scanner . nextInt ( ) ; long sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i % 3 != 0 && i % 5 != 0 ) { sum += i ; } if ( i == n ) { System . out . println ( sum ) ; break ; } } scanner . close ( ) ; } } import java . util . * ; public class Imkdnz { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int imkdnz = Integer . parseInt ( s . substring ( 0 , 2 ) ) ; int a2 = Integer . parseInt ( s . substring ( 2 , 4 ) ) ; boolean m1 = false ; if ( 1 <= imkdnz && imkdnz <= 12 ) { m1 = true ; } boolean m2 = false ; if ( 1 <= a2 && a2 <= 12 ) { m2 = true ; } String ans = " " ; if ( m1 && m2 ) { ans = " AMBIGUOUS " ; } else if ( m1 && ! m2 ) { ans = " MMYY " ; } else if ( ! m1 && m2 ) { ans = " YYMM " ; } else { ans = " NA " ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Tihhqhi { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner scanner = new Scanner ( System . in ) ; int tihhqhi = scanner . nextInt ( ) ; String s = scanner . next ( ) ; System . out . println ( rotN ( tihhqhi , s ) ) ; } private static String rotN ( int tihhqhi , String s ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { sb . append ( rot ( tihhqhi , s . charAt ( i ) ) ) ; } return sb . toString ( ) ; } private static char rot ( int tihhqhi , char ch ) { int code = ( int ) ch - 'A' ; return ( char ) ( ( ( code + tihhqhi ) % 26 ) + 'A' ) ; } } import java . util . * ; public class Usgxk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; List < Integer > primes = primeList ( 200 ) ; int usgxk = scanner . nextInt ( ) ; int [ ] nums = new int [ 201 ] ; for ( int i = 1 ; i <= 200 ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { if ( i % j == 0 ) { nums [ i ] ++ ; } } } int cnt = 0 ; for ( int i = 1 ; i <= usgxk ; i += 2 ) { if ( nums [ i ] == 8 ) { cnt ++ ; } } System . out . println ( cnt ) ; } static List < Integer > primeList ( int n ) { List < Integer > list = new ArrayList < > ( ) ; boolean [ ] prime = new boolean [ n + 1 ] ; Arrays . fill ( prime , true ) ; prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int i = 2 ; i < Math . sqrt ( n ) ; i ++ ) { if ( ! prime [ i ] ) continue ; for ( int j = 2 ; i * j <= n ; j ++ ) { prime [ i * j ] = false ; } } for ( int i = 0 ; i < prime . length ; i ++ ) { if ( prime [ i ] ) list . add ( i ) ; } return list ; } } import java . util . * ; import java . lang . * ; class Wkpkjk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double wkpkjk = sc . nextDouble ( ) ; double h = sc . nextDouble ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; double s = wkpkjk * h / 2.0 ; int e ; if ( x == wkpkjk / 2 && y == h / 2 && wkpkjk % 2 == 0 && h % 2 == 0 ) { e = 1 ; } else { e = 0 ; } System . out . println ( s ) ; System . out . println ( e ) ; } } public class Xtnhpm { protected static String calc ( String input ) { final int xtnhpm = Integer . parseInt ( input ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i <= xtnhpm ; i ++ ) { if ( check ( i ) ) { sb . append ( ' ' ) ; sb . append ( i ) ; } } return sb . toString ( ) ; } static boolean check ( int x ) { if ( x % 3 == 0 ) { return true ; } return check0 ( x ) ; } static boolean check0 ( int x ) { if ( x % 10 == 3 ) { return true ; } x /= 10 ; if ( x > 0 ) { return check0 ( x ) ; } return false ; } public static void main ( String [ ] args ) { final String line = readLine ( ) ; System . out . println ( calc ( line ) ) ; } private static String readLine ( ) { java . util . Scanner s = null ; try { s = new java . util . Scanner ( System . in ) ; return s . nextLine ( ) ; } finally { if ( s != null ) { s . close ( ) ; } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Jtdvw { public static void main ( String [ ] args ) { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String x = " " ; try { x = in . readLine ( ) ; } catch ( NumberFormatException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } String [ ] ab = x . split ( " " ) ; int jtdvw = Integer . parseInt ( ab [ 0 ] ) ; int b = Integer . parseInt ( ab [ 1 ] ) ; if ( jtdvw < b ) System . out . println ( " a < b " ) ; if ( jtdvw > b ) System . out . println ( " a > b " ) ; if ( jtdvw == b ) System . out . println ( " a == b " ) ; } } import java . util . * ; public class Mbktup { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int mbktup = sc . nextInt ( ) ; int leg = sc . nextInt ( ) ; for ( int i = 0 ; i < mbktup + 1 ; i ++ ) { if ( ( i * 2 + ( mbktup - i ) * 4 ) == leg ) { System . out . println ( " Yes " ) ; System . exit ( 0 ) ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; class Mxjlzew { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mxjlzew = sc . nextInt ( ) ; int [ ] [ ] A = new int [ 2 ] [ mxjlzew ] ; int [ ] sum = new int [ mxjlzew ] ; int x = 0 , y = 0 , collect = 0 , max = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < mxjlzew ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int j = 0 ; j < mxjlzew ; j ++ ) { for ( int i = 0 ; i < mxjlzew ; i ++ ) { if ( i <= j ) collect += A [ 0 ] [ i ] ; if ( i >= j ) collect += A [ 1 ] [ i ] ; } if ( collect > max ) max = collect ; collect = 0 ; } System . out . println ( max ) ; sc . close ( ) ; } } import java . util . * ; public class Skdqku { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int skdqku = Integer . parseInt ( sc . next ( ) ) ; int cnt = 0 ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 1 ; i <= skdqku ; i ++ ) { if ( i % 2 != 0 ) { for ( int j = 1 ; j <= skdqku ; j ++ ) { if ( i % j == 0 ) { cnt ++ ; } } if ( cnt == 8 ) list . add ( 1 ) ; } cnt = 0 ; } System . out . println ( list . size ( ) ) ; } } import java . util . Scanner ; public class Uwyiqb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int uwyiqb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String u = sc . next ( ) ; if ( s . equals ( u ) ) { System . out . println ( ( uwyiqb - 1 ) + " " + b ) ; } else if ( t . contains ( u ) ) { System . out . println ( uwyiqb + " " + ( b - 1 ) ) ; } sc . close ( ) ; } } import java . util . * ; import java . lang . * ; public class Itzpux { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int itzpux = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < 40 ; i ++ ) { if ( itzpux >= K ) { count ++ ; itzpux = itzpux / K ; } else { break ; } } System . out . println ( count + 1 ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class Tlzte { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String tlzte = sc . next ( ) ; if ( tlzte . equals ( " Sunny " ) ) System . out . println ( " Cloudy " ) ; else if ( tlzte . equals ( " Cloudy " ) ) System . out . println ( " Rainy " ) ; else if ( tlzte . equals ( " Rainy " ) ) System . out . println ( " Sunny " ) ; } } import java . util . * ; public class Rjenn { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int rjenn = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; String ans = " " ; if ( y % 2 != 0 ) { ans = " No " ; } else { if ( ( y / 2 ) >= rjenn && rjenn >= ( ( y / 4 ) + ( y % 4 / 2 ) ) ) { ans = " Yes " ; } else { ans = " No " ; } } System . out . println ( ans ) ; } } } import java . util . * ; class Eemirex { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eemirex = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int count = 0 ; do { count ++ ; eemirex -= a ; if ( eemirex <= 0 ) { System . out . println ( count ) ; } } while ( eemirex > 0 ) ; } } import java . util . * ; class Qkjjvih { long qkjjvih ; long a = 0 ; long b = 0 ; final long START_DISTANCE_FROM_ORIGIN = 2 ; public Problem ( long qkjjvih ) { this . qkjjvih = qkjjvih ; } public void solve ( ) { for ( long i = 1 ; i * i <= qkjjvih ; i ++ ) if ( qkjjvih % i == 0 ) update ( i ) ; } private void update ( long i ) { a = i ; b = qkjjvih / i ; } public void show ( ) { System . out . println ( a + b - START_DISTANCE_FROM_ORIGIN ) ; } } public class Qkjjvih { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long qkjjvih = sc . nextLong ( ) ; Problem p = new Problem ( qkjjvih ) ; p . solve ( ) ; p . show ( ) ; } } import java . util . * ; public class Soqhp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; final int soqhp = scan . nextInt ( ) ; String [ ] words = new String [ soqhp ] ; for ( int i = 0 ; i < soqhp ; i ++ ) { String input = scan . next ( ) ; char [ ] inputChar = input . toCharArray ( ) ; Arrays . sort ( inputChar ) ; words [ i ] = new String ( inputChar ) ; } Arrays . sort ( words ) ; String memory = words [ 0 ] ; long count = 1 ; long answer = 0 ; for ( int i = 1 ; i < soqhp ; i ++ ) { if ( memory . equals ( words [ i ] ) ) { count ++ ; } else { answer += count * ( count - 1 ) / 2 ; memory = words [ i ] ; count = 1 ; } } if ( count >= 2 ) { answer += count * ( count - 1 ) / 2 ; } System . out . println ( answer ) ; } } import java . util . * ; public class Psdfvkh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String num = sc . next ( ) ; String [ ] splitNum = num . split ( " " , 0 ) ; int psdfvkh = Integer . parseInt ( num ) ; int N = 0 ; for ( int i = 0 ; i < num . length ( ) ; i ++ ) { N += Integer . parseInt ( splitNum [ i ] ) ; } System . out . println ( psdfvkh % N == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Eormy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int eormy = 0 ; eormy < 3 ; eormy ++ ) { a [ eormy ] = sc . nextInt ( ) ; } if ( a [ 0 ] <= a [ 1 ] * a [ 2 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . util . regex . * ; public class Oacpvzt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oacpvzt = sc . nextInt ( ) , n = sc . nextInt ( ) , a , b , z ; int [ ] amida = new int [ oacpvzt ] ; for ( int i = 0 ; i < oacpvzt ; i ++ ) amida [ i ] = i + 1 ; for ( int i = 0 ; i < n ; i ++ ) { String s = sc . next ( ) ; Pattern pattern = Pattern . compile ( " \\ D " ) ; String [ ] splitStr = pattern . split ( s ) ; a = Integer . parseInt ( splitStr [ 0 ] ) ; b = Integer . parseInt ( splitStr [ 1 ] ) ; z = amida [ a - 1 ] ; amida [ a - 1 ] = amida [ b - 1 ] ; amida [ b - 1 ] = z ; } for ( int i = 0 ; i < oacpvzt ; i ++ ) System . out . println ( amida [ i ] ) ; sc . close ( ) ; } } import java . util . * ; public class Nmourqu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nmourqu = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; int sum = 0 ; for ( int i = 0 ; i <= nmourqu ; i ++ ) { for ( int j = 0 ; j <= nmourqu ; j ++ ) { sum = S - ( i + j ) ; if ( 0 <= sum && sum <= nmourqu ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Inoebaa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int inoebaa = sc . nextInt ( ) ; int [ ] b = new int [ inoebaa - 1 ] ; int sum = 0 ; for ( int i = 0 ; i < inoebaa - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } sum += b [ 0 ] ; for ( int i = 1 ; i < inoebaa - 1 ; i ++ ) { sum += min ( b [ i - 1 ] , b [ i ] ) ; } sum += b [ inoebaa - 2 ] ; System . out . println ( sum ) ; } public static int min ( int x , int y ) { if ( x < y ) { return x ; } else { return y ; } } } import java . util . Scanner ; class Upxarmr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int upxarmr = scanner . nextInt ( ) ; int [ ] arr = new int [ upxarmr ] ; for ( int i = 0 ; i < upxarmr ; i ++ ) { arr [ i ] = scanner . nextInt ( ) ; } System . out . println ( frog1 ( arr ) ) ; scanner . close ( ) ; } public static int frog1 ( int [ ] arr ) { int [ ] sol = new int [ arr . length ] ; sol [ arr . length - 1 ] = 0 ; for ( int j = arr . length - 2 ; j >= 0 ; j -- ) { int cost1 = Integer . MAX_VALUE , cost2 = Integer . MAX_VALUE ; if ( j + 1 < arr . length ) { cost1 = Math . abs ( arr [ j + 1 ] - arr [ j ] ) + sol [ j + 1 ] ; } if ( j + 2 < arr . length ) { cost2 = Math . abs ( arr [ j + 2 ] - arr [ j ] ) + sol [ j + 2 ] ; } sol [ j ] = Math . min ( cost1 , cost2 ) ; } return sol [ 0 ] ; } } import java . util . * ; import java . io . * ; public class Cdbmoob { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; str = str . replaceAll ( " eraser " , " " ) ; str = str . replaceAll ( " erase " , " " ) ; str = str . replaceAll ( " dreamer " , " " ) ; str = str . replaceAll ( " dream " , " " ) ; int cdbmoob = str . split ( " " ) . length ; if ( cdbmoob > 0 ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } } import java . util . * ; import java . io . * ; import java . math . BigDecimal ; public class Cnudu { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int cnudu = fs . nextInt ( ) ; double y = ( double ) cnudu / 3 ; BigDecimal x = BigDecimal . valueOf ( y ) ; BigDecimal ans = x . multiply ( x ) ; ans = ans . multiply ( x ) ; System . out . printf ( " %.12f " , ans ) ; } static class Cnudu { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; public String next ( ) { while ( ! st . hasMoreElements ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public int [ ] readArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = nextInt ( ) ; } return a ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } } import java . util . Scanner ; public class Zxjnt { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int zxjnt = scanner . nextInt ( ) ; int n = scanner . nextInt ( ) ; long first = 0 ; long previous = 0 ; long max = 0 ; long sum = 0 ; for ( long i = 0 ; i < n ; i ++ ) { int a = scanner . nextInt ( ) ; if ( i == 0 ) { first = a ; previous = a ; max = a ; sum = a ; } else { long aida = a - previous ; previous = a ; sum = sum + aida ; if ( aida > max ) { max = aida ; } } } long saigo = zxjnt - sum + first ; if ( saigo > max ) { max = saigo ; } System . out . println ( zxjnt - max ) ; } } import java . util . * ; public class Lctga { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lctga = sc . nextInt ( ) , M = sc . nextInt ( ) ; int min = 0 , max = 100000 ; for ( int i = 0 ; i < M ; i ++ ) { int l = sc . nextInt ( ) , r = sc . nextInt ( ) ; min = Math . max ( min , l ) ; max = Math . min ( max , r ) ; } int ans = Math . max ( max - min + 1 , 0 ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Vujyt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vujyt = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; int left = Math . max ( X - ( vujyt - 1 ) , - 1000000 ) ; int right = Math . min ( X + ( vujyt - 1 ) , 1000000 ) ; for ( int i = left ; i <= right ; i ++ ) { sb . append ( i ) ; sb . append ( " " ) ; } System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; class Epzmxxf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int epzmxxf = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; double A = ( t - a ) * 1000 / 6.0 ; double [ ] h = new double [ epzmxxf ] ; for ( int i = 0 ; i < epzmxxf ; i ++ ) { h [ i ] = Math . abs ( sc . nextInt ( ) - A ) ; } int idx = 0 ; for ( int i = 1 ; i < epzmxxf ; i ++ ) { if ( h [ i ] < h [ idx ] ) { idx = i ; } } System . out . println ( idx + 1 ) ; } } import java . util . Scanner ; public class Hxhazk { public static void main ( String [ ] args ) { Scanner in = new java . util . Scanner ( System . in ) ; int hxhazk = in . nextInt ( ) ; int N = in . nextInt ( ) ; if ( hxhazk == 0 ) { if ( N == 100 ) { System . out . print ( N + 1 ) ; } else { System . out . print ( N ) ; } } else if ( hxhazk == 1 ) { if ( N == 100 ) { System . out . print ( 100 * ( N + 1 ) ) ; } else { System . out . print ( 100 * N ) ; } } else if ( hxhazk == 2 ) { if ( N == 100 ) { System . out . print ( 100 * 100 * ( N + 1 ) ) ; } else { System . out . print ( 100 * 100 * N ) ; } } in . close ( ) ; } } import java . util . * ; public class Yjhoh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; boolean yjhoh = false ; for ( int i = 1 ; i < n . length ( ) ; i ++ ) { if ( n . charAt ( i ) > n . charAt ( 0 ) ) { yjhoh = true ; break ; } } String ans = " " ; if ( yjhoh ) { for ( int i = 0 ; i < n . length ( ) ; i ++ ) { ans += ( char ) ( n . charAt ( 0 ) + 1 ) ; } } else { for ( int i = 0 ; i < n . length ( ) ; i ++ ) { ans += n . charAt ( 0 ) ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Koskc { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String h = sc . nextLine ( ) ; String s = sc . nextLine ( ) ; int koskc = Integer . parseInt ( h ) ; int len = String . valueOf ( s ) . length ( ) ; if ( len <= koskc ) { System . out . println ( s ) ; } else { for ( int i = 0 ; i < koskc ; i ++ ) { System . out . print ( s . charAt ( i ) ) ; } System . out . print ( " ... " ) ; } } } import java . util . Scanner ; class Uuzqgp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uuzqgp = sc . nextInt ( ) ; double x ; if ( uuzqgp % 2 == 0 ) x = 1.0 / 2.0 ; else x = ( double ) ( uuzqgp / 2 + 1 ) / ( double ) uuzqgp ; System . out . println ( x ) ; } } import java . util . Scanner ; public class Cufiwml { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cufiwml = sc . nextInt ( ) ; int [ ] r = new int [ cufiwml ] ; int maxv = - 999999999 ; for ( int i = 0 ; i < r . length ; i ++ ) { r [ i ] = sc . nextInt ( ) ; } int minv = r [ 0 ] ; for ( int i = 1 ; i < cufiwml ; i ++ ) { maxv = r [ i ] - minv > maxv ? r [ i ] - minv : maxv ; minv = minv > r [ i ] ? r [ i ] : minv ; } System . out . println ( maxv ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Arrays ; public class Impix { public static void main ( String [ ] args ) { try { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String sStr = stdReader . readLine ( ) ; String [ ] inputStr = sStr . split ( " " ) ; int impix = Integer . valueOf ( inputStr [ 0 ] ) . intValue ( ) ; int h = Integer . valueOf ( inputStr [ 1 ] ) . intValue ( ) ; int x = Integer . valueOf ( inputStr [ 2 ] ) . intValue ( ) ; int y = Integer . valueOf ( inputStr [ 3 ] ) . intValue ( ) ; int r = Integer . valueOf ( inputStr [ 4 ] ) . intValue ( ) ; if ( impix >= x + r && h >= y + r && ( x > 0 && y > 0 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } stdReader . close ( ) ; } catch ( Exception e ) { System . exit ( - 1 ) ; } } } import java . util . Scanner ; public class Xhtghg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int xhtghg , side , area , circum ; xhtghg = sc . nextInt ( ) ; side = sc . nextInt ( ) ; area = xhtghg * side ; circum = ( xhtghg + side ) * 2 ; System . out . println ( area + " " + circum ) ; } } import java . util . * ; public class Lkdyte { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long lkdyte = 0 ; while ( s . length ( ) > 0 ) { lkdyte += Integer . parseInt ( s . substring ( 0 , 1 ) ) ; s = s . substring ( 1 ) ; } System . out . println ( lkdyte % 9 == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Qgemsgn { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int qgemsgn , B , T ; qgemsgn = sc . nextInt ( ) ; B = sc . nextInt ( ) ; T = sc . nextInt ( ) ; int sum = 0 ; for ( int time = 1 ; time <= T ; time ++ ) { if ( time % qgemsgn == 0 ) { sum += B ; } } System . out . println ( sum ) ; } catch ( Exception e ) { } } } import java . util . * ; class Mtpsio { public static void main ( String [ ] args ) { Scanner obj = new Scanner ( System . in ) ; int mtpsio = obj . nextInt ( ) ; int m = obj . nextInt ( ) ; int [ ] a = new int [ mtpsio ] ; for ( int i = 0 ; i < mtpsio ; i ++ ) { a [ i ] = obj . nextInt ( ) ; } Arrays . sort ( a ) ; int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) sum = sum + a [ i ] ; System . out . println ( sum ) ; } } import java . util . * ; public class Hgffhjq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hgffhjq = sc . nextInt ( ) ; int [ ] a = new int [ hgffhjq ] ; int max = 0 ; int m = 0 ; for ( int i = 0 ; i < hgffhjq ; i ++ ) { a [ i ] = sc . nextInt ( ) ; max = Math . max ( max , a [ i ] ) ; m += a [ i ] ; } System . out . println ( ( m > 2 * max ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Jxwiw { Scanner scan = new Scanner ( System . in ) ; void compute ( ) { int jxwiw = scan . nextInt ( ) ; int D = scan . nextInt ( ) ; double x = ( double ) jxwiw / ( double ) ( 2 * D + 1 ) ; int y = jxwiw / ( 2 * D + 1 ) ; if ( 0 < x - y ) { y ++ ; } System . out . println ( y ) ; } public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } } import java . util . * ; public class Gxzsa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gxzsa = sc . nextInt ( ) ; double [ ] data = new double [ 1000 ] ; int v ; double temp ; double lenkin ; for ( int i = 0 ; i < gxzsa ; i ++ ) { v = sc . nextInt ( ) ; data [ i ] = v ; } for ( int i = 0 ; i < gxzsa ; i ++ ) { for ( int j = i + 1 ; j < gxzsa ; j ++ ) { if ( data [ i ] > data [ j ] ) { temp = data [ i ] ; data [ i ] = data [ j ] ; data [ j ] = temp ; } } } lenkin = ( data [ 0 ] + data [ 1 ] ) / 2 ; for ( int i = 2 ; i < gxzsa ; i ++ ) { lenkin = ( lenkin + data [ i ] ) / 2 ; } System . out . println ( lenkin ) ; } } import java . util . * ; public class Lvoxrrt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lvoxrrt = sc . nextInt ( ) ; int max = 1 ; for ( int b = 1 ; b < 32 ; b ++ ) { for ( int p = 2 ; p < 10 ; p ++ ) { double exp = Math . pow ( b , p ) ; if ( exp > lvoxrrt ) { break ; } if ( max < exp ) { max = ( int ) exp ; } } } System . out . println ( max ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Quvml { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int quvml = Integer . parseInt ( sc . next ( ) ) ; int [ ] l = new int [ quvml ] ; for ( int i = 0 ; i < quvml ; i ++ ) { l [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( l ) ; int x = 0 ; for ( int i = 0 ; i < quvml - 1 ; i ++ ) { x += l [ i ] ; } if ( l [ quvml - 1 ] < x ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Dwlohm { public static void main ( String [ ] args ) { int dwlohm , k = 0 ; int [ ] A = new int [ 100 ] ; Scanner stdIn = new Scanner ( System . in ) ; dwlohm = stdIn . nextInt ( ) ; for ( int i = 0 ; i < dwlohm ; i ++ ) { A [ i ] = stdIn . nextInt ( ) ; } k = bubbleSort ( dwlohm , A ) ; trace ( dwlohm , A , k ) ; } public static void trace ( int dwlohm , int [ ] A , int k ) { for ( int i = 0 ; i < dwlohm ; i ++ ) { if ( i > 0 ) System . out . print ( " " ) ; System . out . print ( A [ i ] ) ; } System . out . println ( ) ; System . out . println ( k ) ; } public static int bubbleSort ( int dwlohm , int [ ] A ) { int k = 0 ; for ( int i = 0 ; i < dwlohm - 1 ; i ++ ) { for ( int j = dwlohm - 1 ; j > i ; j -- ) { if ( A [ j ] < A [ j - 1 ] ) { int tmp = A [ j - 1 ] ; A [ j - 1 ] = A [ j ] ; A [ j ] = tmp ; k ++ ; } } } return k ; } } import java . util . Scanner ; public class Yscfm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yscfm = sc . nextInt ( ) ; Integer [ ] p = new Integer [ yscfm ] ; for ( int i = 0 ; i < yscfm ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int i = 1 ; i < yscfm - 1 ; i ++ ) { if ( Math . max ( p [ i - 1 ] , p [ i + 1 ] ) >= p [ i ] && Math . min ( p [ i - 1 ] , p [ i + 1 ] ) <= p [ i ] ) { result ++ ; } } System . out . println ( result ) ; } } import java . util . * ; import java . io . PrintWriter ; public class Wfklep { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wfklep = sc . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= wfklep ; i ++ ) { for ( int j = 1 ; j <= wfklep ; j ++ ) { for ( int t = 1 ; t <= wfklep ; t ++ ) { ans += gcd ( gcd ( i , j ) , t ) ; } } } System . out . println ( ans ) ; } private static long gcd ( long m , long n ) { if ( m < n ) return gcd ( n , m ) ; while ( n != 0 ) { long tmp = m ; m = n ; n = tmp % n ; } return m ; } } import java . util . * ; public class Uprwt { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String uprwt = in . nextLine ( ) ; char [ ] array = uprwt . toCharArray ( ) ; array [ 3 ] = '8' ; System . out . println ( array ) ; } } import java . util . * ; public class Gqmitl { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int gqmitl = sc . nextInt ( ) ; long [ ] H = new long [ gqmitl ] ; int counter = 0 ; int countMax = 0 ; for ( int i = 0 ; i < gqmitl ; i ++ ) { H [ i ] = sc . nextLong ( ) ; if ( i > 0 ) { if ( H [ i - 1 ] >= H [ i ] ) { counter ++ ; } if ( H [ i - 1 ] < H [ i ] ) { if ( counter > countMax ) { countMax = counter ; } counter = 0 ; } } } if ( counter > countMax ) { countMax = counter ; } System . out . println ( countMax ) ; } } import java . util . Scanner ; class Jzbuvjq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jzbuvjq = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; scan . close ( ) ; if ( ( 1 <= jzbuvjq && jzbuvjq < 10 ) && ( 1 <= b && b < 10 ) ) System . out . println ( jzbuvjq * b ) ; else System . out . println ( - 1 ) ; } } import java . util . Scanner ; class Cjkfuck { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int cjkfuck , a , b ; cjkfuck = sc . nextInt ( ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; int sum = 0 , ans = 0 ; for ( int i = 0 ; i <= cjkfuck ; i ++ ) { String x = Integer . toString ( i ) ; sum = 0 ; for ( int j = 0 ; j < x . length ( ) ; j ++ ) { sum += x . charAt ( j ) - '0' ; } if ( a <= sum && sum <= b ) { ans += i ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Cgjlxc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String y = sc . next ( ) ; String j = sc . next ( ) ; int cgjlxc = 0 ; for ( int i = 0 ; i < y . length ( ) ; i ++ ) { if ( y . charAt ( i ) == j . charAt ( i ) ) { cgjlxc += 1 ; } } System . out . println ( cgjlxc ) ; } } import java . util . * ; public class Teermo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ans = " No " ; String s = sc . next ( ) ; String t = sc . next ( ) ; int teermo = s . length ( ) ; int temp = 0 ; int count = 0 ; for ( int i = 0 ; i < teermo ; i ++ ) { for ( int j = 0 ; j < teermo ; j ++ ) { if ( s . charAt ( j ) != t . charAt ( ( j + temp ) % teermo ) ) { temp ++ ; count = 0 ; break ; } else { count ++ ; } } if ( count == teermo ) { ans = " Yes " ; break ; } } System . out . println ( ans ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Tebmhs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; sc . nextLine ( ) ; String word = null ; String prevWord = null ; Set < String > wordSet = new HashSet < > ( ) ; boolean tebmhs = false ; while ( sc . hasNextLine ( ) ) { word = sc . nextLine ( ) ; if ( ! wordSet . add ( word ) ) { tebmhs = true ; break ; } if ( prevWord != null ) { boolean chained = ( prevWord . charAt ( prevWord . length ( ) - 1 ) == word . charAt ( 0 ) ) ; if ( ! chained ) { tebmhs = true ; break ; } } prevWord = word ; } System . out . println ( tebmhs ? " No " : " Yes " ) ; } } import java . util . * ; public class Huntggd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int huntggd = Integer . parseInt ( sc . nextLine ( ) ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < huntggd ; i ++ ) { String s = sc . nextLine ( ) ; char [ ] c = s . toCharArray ( ) ; Arrays . sort ( c ) ; s = new String ( c ) ; list . add ( s ) ; } Collections . sort ( list ) ; long ans = 0 ; long count = 0 ; String t = " " ; String u = " " ; boolean check = false ; for ( int i = 0 ; i < huntggd ; i ++ ) { check = false ; if ( i == 0 ) { t = list . get ( i ) ; count ++ ; continue ; } u = list . get ( i ) ; if ( t . equals ( u ) && i < huntggd - 1 ) { count ++ ; } else if ( t . equals ( u ) && i == huntggd - 1 ) { count ++ ; check = true ; } else { t = u ; check = true ; } if ( check ) { ans += ( count * ( count - 1 ) ) / 2 ; t = u ; count = 1 ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Brnsuyi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int brnsuyi = sc . nextInt ( ) ; int ans = brnsuyi % 1000 ; if ( ans != 0 ) { ans = 1000 - ans ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Igewv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int igewv = scan . nextInt ( ) ; int [ ] a = new int [ igewv ] ; int [ ] b = new int [ igewv ] ; int [ ] c = new int [ igewv ] ; for ( int i = 0 ; i < igewv ; i ++ ) { a [ i ] = scan . nextInt ( ) - 1 ; } for ( int i = 0 ; i < igewv ; i ++ ) { b [ i ] = scan . nextInt ( ) ; } for ( int i = 1 ; i < igewv ; i ++ ) { c [ i ] = scan . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < igewv ; i ++ ) { sum = sum + b [ a [ i ] ] ; if ( i != 0 && a [ i ] - a [ i - 1 ] == 1 ) { sum = sum + c [ a [ i ] ] ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Gnnlmh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int gnnlmh = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '+' ) { gnnlmh = gnnlmh + 1 ; } else { gnnlmh = gnnlmh - 1 ; } } System . out . println ( gnnlmh ) ; } } import java . io . * ; public class Jhgxwcn { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = buf . readLine ( ) ; String [ ] ra = str . split ( " " ) ; int jhgxwcn = Integer . parseInt ( ra [ 0 ] ) ; int y = Integer . parseInt ( ra [ 1 ] ) ; int d , r ; String f = String . format ( " %.5f " , ( double ) jhgxwcn / ( double ) y ) ; d = jhgxwcn / y ; y = jhgxwcn % y ; System . out . printf ( d + " " + y + " " + f ) ; } } import java . util . Scanner ; public class Rcaro { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rcaro = sc . nextInt ( ) ; int [ ] a = new int [ rcaro ] ; int j = 1 ; for ( int i = 0 ; i < rcaro ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( j == a [ i ] ) { j ++ ; } } if ( j == 1 ) { System . out . println ( - 1 ) ; return ; } System . out . println ( rcaro - j + 1 ) ; } } import java . util . Scanner ; public class Hrjclnd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int hrjclnd = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( hrjclnd == 0 && W == 0 ) break ; for ( int i = 1 ; i <= hrjclnd ; i ++ ) { if ( i == 1 || i == hrjclnd ) { for ( int j = 1 ; j <= W ; j ++ ) { System . out . print ( " # " ) ; } } else { for ( int j = 1 ; j <= W ; j ++ ) { if ( j == 1 || j == W ) System . out . print ( " # " ) ; else System . out . print ( " . " ) ; } } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . Scanner ; public class Jspdzdd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int jspdzdd = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( jspdzdd == 0 && W == 0 ) break ; for ( int i = 1 ; i <= jspdzdd ; i ++ ) { for ( int j = 1 ; j <= W ; j ++ ) { if ( i % 2 == 1 ) { if ( j % 2 == 1 ) System . out . print ( " # " ) ; else System . out . print ( " . " ) ; } else { if ( j % 2 == 1 ) System . out . print ( " . " ) ; else System . out . print ( " # " ) ; } } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . Scanner ; public class Vbccot { public static void main ( String [ ] args ) { int vbccot , o ; int q , minj , j , taihi ; int count = 0 ; Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . nextLine ( ) ) ; int [ ] array = new int [ n ] ; for ( vbccot = 0 ; vbccot < n ; vbccot ++ ) array [ vbccot ] = Integer . parseInt ( sc . next ( ) ) ; for ( q = 0 ; q < n ; q ++ ) { minj = q ; for ( j = q ; j < n ; j ++ ) { if ( array [ j ] < array [ minj ] ) minj = j ; } if ( q != minj ) { taihi = array [ q ] ; array [ q ] = array [ minj ] ; array [ minj ] = taihi ; count ++ ; } } for ( o = 0 ; o < n - 1 ; o ++ ) System . out . print ( array [ o ] + " " ) ; System . out . println ( array [ o ] ) ; System . out . println ( count ) ; } } import java . util . Scanner ; public class Nheszl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nheszl = sc . nextInt ( ) ; int be = sc . nextInt ( ) ; int ans = 0 ; boolean check1 = false , check2 = false ; for ( int i = 1 ; i < nheszl ; i ++ ) { int ch = sc . nextInt ( ) ; if ( be < ch ) { if ( check1 == true ) ans ++ ; check1 = true ; check2 = false ; } else if ( be > ch ) { if ( check2 == true ) ans ++ ; check1 = false ; check2 = true ; } else { check1 = false ; check2 = false ; } be = ch ; } System . out . println ( ans ) ; } } import java . util . * ; public class Enlovx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int enlovx = sc . nextInt ( ) ; int [ ] a = new int [ enlovx ] ; for ( int i = 0 ; i < enlovx ; ++ i ) a [ i ] = sc . nextInt ( ) ; sc . close ( ) ; String [ ] ans = { " YES " , " NO " } ; int an = 0 ; Arrays . sort ( a ) ; int t = a [ 0 ] ; for ( int i = 1 ; i < enlovx ; ++ i ) { if ( t == a [ i ] ) { an = 1 ; break ; } t = a [ i ] ; } System . out . println ( ans [ an ] ) ; } } import java . io . * ; import java . util . * ; public class Fbqrne { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fbqrne = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ fbqrne ] ; int [ ] b = new int [ n ] ; int [ ] c = new int [ n ] ; int temp = 0 ; int i = 0 ; String str ; for ( i = 0 ; i < n ; i ++ ) { str = sc . next ( ) ; String [ ] bc = str . split ( " , " ) ; b [ i ] = Integer . parseInt ( bc [ 0 ] ) - 1 ; c [ i ] = Integer . parseInt ( bc [ 1 ] ) - 1 ; } for ( i = 0 ; i < fbqrne ; i ++ ) { a [ i ] = i + 1 ; } for ( i = 0 ; i < n ; i ++ ) { temp = a [ b [ i ] ] ; a [ b [ i ] ] = a [ c [ i ] ] ; a [ c [ i ] ] = temp ; } for ( i = 0 ; i < fbqrne ; i ++ ) { System . out . println ( a [ i ] ) ; } } } import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Stfges { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int stfges = sc . nextInt ( ) ; int [ ] [ ] a = new int [ 2 ] [ stfges + 1 ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 1 ; j <= stfges ; j ++ ) { a [ i ] [ j ] = a [ i ] [ j - 1 ] + sc . nextInt ( ) ; } } int ans = 0 ; for ( int i = 1 ; i <= stfges ; i ++ ) { for ( int j = 1 ; j <= stfges ; j ++ ) { ans = max ( ans , a [ 0 ] [ i ] + ( a [ 1 ] [ stfges ] - a [ 1 ] [ i - 1 ] ) ) ; } } out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Myxtm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int myxtm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int count = 0 ; for ( int i = myxtm ; i <= b ; i ++ ) { for ( int j = c ; j <= d ; j ++ ) { if ( i == j ) { count ++ ; break ; } } } if ( count > 0 ) { count -- ; } System . out . println ( count ) ; } } import java . util . Scanner ; class Eagyzg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int eagyzg = scan . nextInt ( ) ; int [ ] num = new int [ eagyzg ] ; boolean t ; int count = 0 ; for ( int i = 0 ; i < eagyzg ; i ++ ) { num [ i ] = scan . nextInt ( ) ; if ( isPrime ( num [ i ] ) ) { count ++ ; } } System . out . println ( count ) ; } static boolean isPrime ( int x ) { if ( x == 2 ) return true ; if ( x < 2 || ( x % 2 ) == 0 ) return false ; for ( int i = 3 ; i <= Math . sqrt ( x ) ; i += 2 ) { if ( x % i == 0 ) { return false ; } } return true ; } } import java . util . Scanner ; class Pjnnt { public static void main ( String [ ] args ) { int pjnnt , point1 = 0 , point2 = 0 ; String card1 , card2 ; Scanner sc = new Scanner ( System . in ) ; pjnnt = sc . nextInt ( ) ; for ( int i = 0 ; i < pjnnt ; i ++ ) { card1 = sc . next ( ) ; card2 = sc . next ( ) ; if ( card2 . compareTo ( card1 ) < 0 ) { point1 += 3 ; } else if ( card1 . equals ( card2 ) ) { point1 ++ ; point2 ++ ; } else { point2 += 3 ; } } System . out . println ( point1 + " " + point2 ) ; } } public class Jfjdqwi { public static void main ( String ... args ) { int jfjdqwi = new java . util . Scanner ( System . in ) . nextInt ( ) ; int sum = jfjdqwi * jfjdqwi * jfjdqwi ; System . out . println ( sum ) ; } } import java . io . * ; import java . util . Scanner ; public class Uaxerso { public static void main ( String [ ] args ) { int uaxerso ; Scanner in = new Scanner ( System . in ) ; int [ ] height = new int [ 10 ] ; int i ; int x ; for ( i = 0 ; i < 10 ; i ++ ) { height [ i ] = in . nextInt ( ) ; } for ( i = 0 ; i < 10 ; i ++ ) { for ( uaxerso = i + 1 ; uaxerso < 10 ; uaxerso ++ ) if ( height [ i ] > height [ uaxerso ] ) { int temp = height [ i ] ; height [ i ] = height [ uaxerso ] ; height [ uaxerso ] = temp ; } } for ( i = 9 ; i > 6 ; i -- ) { System . out . println ( height [ i ] ) ; } } } import java . util . ArrayDeque ; import java . lang . reflect . Array ; import java . util . Arrays ; import sun . tools . jar . resources . jar ; import java . util . * ; public class Mrgjw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mrgjw = sc . nextInt ( ) ; long a = mrgjw / 500 ; mrgjw %= 500 ; long b = mrgjw / 5 ; System . out . println ( 1000 * a + ( 5 * b ) ) ; } } import java . util . Scanner ; public class Ecwzise { public static void main ( String [ ] args ) { Scanner Ahmad = new Scanner ( System . in ) ; int ecwzise , y ; ecwzise = Ahmad . nextInt ( ) ; y = Ahmad . nextInt ( ) ; if ( ( ecwzise + y ) % 2 == 0 ) { System . out . println ( ( ecwzise + y ) / 2 ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . io . IOException ; import java . util . Scanner ; class Tazge { public static void main ( String [ ] args ) throws IOException { Scanner scane = new Scanner ( System . in ) ; int tazge = 0 , f = 0 , r = 0 ; int sum = 0 ; tazge = scane . nextInt ( ) ; f = scane . nextInt ( ) ; r = scane . nextInt ( ) ; while ( ( tazge + f + r ) != - 3 ) { sum = tazge + f ; if ( tazge == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } if ( ( tazge != - 1 && f != - 1 ) && sum >= 80 ) { System . out . println ( " A " ) ; } else if ( ( tazge != - 1 && f != - 1 ) && sum < 80 && sum >= 65 ) { System . out . println ( " B " ) ; } else if ( ( tazge != - 1 && f != - 1 ) && sum < 65 && sum >= 50 ) { System . out . println ( " C " ) ; } else if ( ( tazge != - 1 && f != - 1 ) && sum < 50 && sum >= 30 ) { if ( r >= 50 ) { System . out . println ( " C " ) ; } else { System . out . println ( " D " ) ; } } else if ( sum < 30 ) { System . out . println ( " F " ) ; } tazge = scane . nextInt ( ) ; f = scane . nextInt ( ) ; r = scane . nextInt ( ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Awxmkd { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; char awxmkd ; StringBuilder build = new StringBuilder ( ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { awxmkd = str . charAt ( i ) ; if ( Character . isLowerCase ( awxmkd ) ) { build . append ( Character . toUpperCase ( awxmkd ) ) ; } else { build . append ( Character . toLowerCase ( awxmkd ) ) ; } } System . out . print ( build . toString ( ) + " \n " ) ; } } import java . util . * ; public class Qirzwea { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Queue < String > name_queue = new ArrayDeque < > ( ) ; Queue < Integer > queue = new ArrayDeque < > ( ) ; int qirzwea = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; for ( int i = 0 ; i < qirzwea ; i ++ ) { name_queue . add ( sc . next ( ) ) ; queue . add ( sc . nextInt ( ) ) ; } int count_time = 0 ; while ( true ) { String name = name_queue . poll ( ) ; if ( queue . peek ( ) == null ) break ; int num = queue . poll ( ) ; if ( num <= q ) { count_time += num ; System . out . println ( name + " " + count_time ) ; } else { count_time += q ; num -= q ; queue . add ( num ) ; name_queue . add ( name ) ; } } } } import java . util . * ; public class Qsuiyiq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qsuiyiq = sc . nextInt ( ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; String ans = " " ; for ( int i = 0 ; i < qsuiyiq ; i ++ ) { ans = ans + s1 . charAt ( i ) + s2 . charAt ( i ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Fgpxzr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String input = scanner . nextLine ( ) ; String [ ] inputs = input . split ( " " ) ; int fgpxzr = Integer . parseInt ( inputs [ 0 ] ) ; int x = Integer . parseInt ( inputs [ 1 ] ) ; String lineStr = scanner . nextLine ( ) ; String [ ] lines = lineStr . split ( " " ) ; int [ ] line = new int [ fgpxzr ] ; for ( int i = 0 ; i < fgpxzr ; i ++ ) { line [ i ] = Integer . parseInt ( lines [ i ] ) ; } int answer = 1 ; int distance = 0 ; for ( int i = 0 ; i < fgpxzr ; i ++ ) { distance = distance + line [ i ] ; if ( distance > x ) { break ; } answer ++ ; } System . out . println ( answer ) ; scanner . close ( ) ; } } import java . util . Scanner ; public class Bgvwveu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int bgvwveu = scan . nextInt ( ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int ans = bgvwveu * a ; if ( ans < b ) { System . out . println ( ans ) ; } else { System . out . println ( b ) ; } } } import java . util . Scanner ; import java . util . Arrays ; public class Vtgrp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vtgrp = sc . nextInt ( ) ; int [ ] b = new int [ vtgrp ] ; for ( int i = 0 ; i < b . length ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } Arrays . sort ( b ) ; double c = ( double ) ( b [ 0 ] + b [ 1 ] ) / 2 ; for ( int j = 2 ; j < b . length ; j ++ ) { c = ( double ) ( c + b [ j ] ) / 2 ; } System . out . println ( c ) ; } } import java . util . * ; public class Yikwqd { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; String yikwqd = scan . next ( ) ; switch ( yikwqd ) { case " SAT " : System . out . println ( " 1 " ) ; break ; case " FRI " : System . out . println ( " 2 " ) ; break ; case " THU " : System . out . println ( " 3 " ) ; break ; case " WED " : System . out . println ( " 4 " ) ; break ; case " TUE " : System . out . println ( " 5 " ) ; break ; case " MON " : System . out . println ( " 6 " ) ; break ; case " SUN " : System . out . println ( " 7 " ) ; break ; } } } import java . io . IOException ; import java . util . ArrayList ; import java . util . Scanner ; public class Elfzicv { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; while ( sc . hasNextLine ( ) ) { String str = sc . nextLine ( ) ; if ( " " . equals ( str ) ) { break ; } list . add ( Integer . parseInt ( str ) ) ; } int elfzicv = list . get ( 0 ) ; int B = list . get ( 1 ) ; if ( ( elfzicv == 1 && B == 2 ) || ( elfzicv == 2 && B == 1 ) ) System . out . println ( 3 ) ; else if ( ( elfzicv == 1 && B == 3 ) || ( elfzicv == 3 && B == 1 ) ) System . out . println ( 2 ) ; else if ( ( elfzicv == 2 && B == 3 ) || ( elfzicv == 3 && B == 2 ) ) System . out . println ( 1 ) ; } } import java . util . Scanner ; public class Uotdna { public static int uotdna = 0 ; public static int head2 = 0 ; public static int tail = 0 ; public static String [ ] queue1 = new String [ 1000000 ] ; public static int [ ] queue2 = new int [ 1000000 ] ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int n = stdIn . nextInt ( ) ; int q = stdIn . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String a = stdIn . next ( ) ; int b = stdIn . nextInt ( ) ; enqueue ( a , b ) ; } int time = 0 ; while ( uotdna != tail ) { String a = strDequeue ( ) ; int b = intDequeue ( ) ; if ( b <= q ) { time += b ; System . out . println ( a + " " + time ) ; } else { time += q ; b -= q ; enqueue ( a , b ) ; } } } public static void enqueue ( String x , int y ) { queue1 [ tail ] = x ; queue2 [ tail ] = y ; tail ++ ; } public static String strDequeue ( ) { return queue1 [ uotdna ++ ] ; } public static int intDequeue ( ) { return queue2 [ head2 ++ ] ; } } import java . util . Scanner ; public class Gaxfq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int gaxfq = scanner . nextInt ( ) ; int [ ] a = new int [ gaxfq ] ; int count = 0 ; int v = 1 ; int flg = 0 ; for ( int i = 0 ; i < gaxfq ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < gaxfq ; i ++ ) { v = a [ v - 1 ] ; count ++ ; if ( v == 2 ) { System . out . println ( count ) ; count = 0 ; break ; } } if ( count == gaxfq ) { System . out . println ( - 1 ) ; } } } import java . util . * ; import java . io . * ; public class Oonkr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter ou = new PrintWriter ( System . out ) ; int oonkr = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int [ ] s = new int [ oonkr ] ; int i ; Arrays . fill ( s , k - q ) ; for ( i = 0 ; i < q ; i ++ ) { s [ Integer . parseInt ( sc . next ( ) ) - 1 ] ++ ; } for ( i = 0 ; i < oonkr ; i ++ ) { if ( s [ i ] > 0 ) ou . print ( " Yes \n " ) ; else ou . print ( " No \n " ) ; } ou . flush ( ) ; } } import java . util . * ; public class Rndlxhs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int rndlxhs = S . length ( ) ; int tmp = 0 ; String [ ] part = new String [ rndlxhs * ( rndlxhs + 1 ) / 2 ] ; for ( int i = 0 ; i < rndlxhs ; i ++ ) { for ( int j = i ; j < rndlxhs ; j ++ ) { part [ tmp ] = S . substring ( i , j + 1 ) ; tmp = tmp + 1 ; } } int answer = 0 ; for ( int i = 0 ; i < part . length ; i ++ ) { if ( isATGC ( part [ i ] ) ) { if ( answer < part [ i ] . length ( ) ) { answer = part [ i ] . length ( ) ; } } } System . out . println ( answer ) ; } public static boolean isATGC ( String s ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . substring ( i , i + 1 ) . equals ( " A " ) || s . substring ( i , i + 1 ) . equals ( " T " ) || s . substring ( i , i + 1 ) . equals ( " G " ) || s . substring ( i , i + 1 ) . equals ( " C " ) ) { continue ; } else { return false ; } } return true ; } } import java . util . Scanner ; public class Rsigip { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rsigip = Integer . valueOf ( sc . next ( ) ) ; int b = Integer . valueOf ( sc . next ( ) ) ; int t = Integer . valueOf ( sc . next ( ) ) ; System . out . println ( t / rsigip * b ) ; } } import java . util . Scanner ; public class Pypdbz { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { long pypdbz = ( long ) Math . pow ( 10 , 18 ) ; int n = sc . nextInt ( ) ; long ans = 1 ; boolean isOver = false ; for ( int i = 0 ; i < n ; i ++ ) { long ai = sc . nextLong ( ) ; if ( ai == 0 ) { System . out . println ( " 0 " ) ; return ; } if ( ! isOver ) { try { ans = Math . multiplyExact ( ans , ai ) ; } catch ( Exception e ) { isOver = true ; } } if ( ans > pypdbz || ans < 0 ) { isOver = true ; } } if ( isOver ) { System . out . println ( " -1 " ) ; } else { System . out . println ( ans ) ; } } } } import java . util . Scanner ; public class Aaegdi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aaegdi = sc . nextInt ( ) ; int ans = 0 ; int [ ] array = new int [ aaegdi ] ; for ( int i = 0 ; i < aaegdi ; i ++ ) { array [ i ] = Integer . parseInt ( sc . next ( ) ) ; if ( i == 0 || i == 1 ) { continue ; } int a = array [ i - 2 ] ; int b = array [ i - 1 ] ; int c = array [ i ] ; if ( a == b && b == c ) { continue ; } int diff = ( a - b ) * ( b - c ) ; if ( diff >= 0 ) { ans ++ ; } } sc . close ( ) ; System . out . println ( ans ) ; } } import java . util . * ; public class Cjiovr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int cjiovr = s . length ( ) ; int m = t . length ( ) ; int count = 0 ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < cjiovr - m + 1 ; i ++ ) { String ss = s . substring ( i , i + m ) ; for ( int j = 0 ; j < ss . length ( ) ; j ++ ) { if ( ss . charAt ( j ) != t . charAt ( j ) ) { count ++ ; } } ans = Math . min ( ans , count ) ; count = 0 ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Psdml { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; double psdml = s . nextDouble ( ) ; double n = s . nextDouble ( ) ; double m = 0 ; for ( int i = 0 ; i < n ; i ++ ) { m += s . nextDouble ( ) ; } if ( m >= psdml ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; public class Lwbaw { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int lwbaw = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i < lwbaw ; i ++ ) { result += calc ( d , scan ) ; } System . out . println ( result ) ; } } private static int calc ( int d , Scanner scan ) { if ( Math . sqrt ( Math . pow ( scan . nextInt ( ) , 2 ) + Math . pow ( scan . nextInt ( ) , 2 ) ) <= d ) { return 1 ; } return 0 ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Eexcswh { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = input . readLine ( ) ; String answer = " " ; for ( int eexcswh = 0 ; eexcswh < str . length ( ) ; eexcswh ++ ) { if ( String . valueOf ( str . charAt ( eexcswh ) ) . equals ( " B " ) && answer . length ( ) != 0 ) { answer = answer . substring ( 0 , answer . length ( ) - 1 ) ; } else if ( String . valueOf ( str . charAt ( eexcswh ) ) . equals ( " 0 " ) || String . valueOf ( str . charAt ( eexcswh ) ) . equals ( " 1 " ) ) { answer = answer + str . charAt ( eexcswh ) ; } } System . out . println ( answer ) ; } } import java . util . * ; public class Fghzi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; String c = sc . next ( ) ; int fghzi = 1 ; int bIndex = 0 ; int cIndex = 0 ; char tmp = a . charAt ( 0 ) ; while ( true ) { switch ( tmp ) { case 'a' : if ( a . length ( ) == fghzi ) { System . out . println ( " A " ) ; System . exit ( 0 ) ; } tmp = a . charAt ( fghzi ++ ) ; break ; case 'b' : if ( b . length ( ) == bIndex ) { System . out . println ( " B " ) ; System . exit ( 0 ) ; } tmp = b . charAt ( bIndex ++ ) ; break ; case 'c' : if ( c . length ( ) == cIndex ) { System . out . println ( " C " ) ; System . exit ( 0 ) ; } tmp = c . charAt ( cIndex ++ ) ; break ; } } } } import java . util . Scanner ; public class Dgekzhq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dgekzhq = sc . nextInt ( ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; String [ ] Sarray = S . split ( " " , 0 ) ; String [ ] Tarray = T . split ( " " , 0 ) ; String ans = " " ; for ( int i = 0 ; i < dgekzhq ; i ++ ) { ans = ans + Sarray [ i ] ; ans = ans + Tarray [ i ] ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Vrhdbqo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Integer a = sc . nextInt ( ) ; Integer b = sc . nextInt ( ) ; if ( a % 2 == 1 && b % 2 == 1 ) { System . out . println ( " Odd " ) ; } else { System . out . println ( " Even " ) ; } } } import java . util . * ; public class Rlbcs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String t = sc . nextLine ( ) ; int rlbcs = Integer . MAX_VALUE ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i + t . length ( ) <= s . length ( ) ) { int tot = 0 ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( i + j ) != t . charAt ( j ) ) tot ++ ; } rlbcs = Math . rlbcs ( rlbcs , tot ) ; } } System . out . println ( rlbcs ) ; } } import java . util . Scanner ; public class Wpkpdte { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wpkpdte = 1 ; while ( true ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( x == 0 && y == 0 ) break ; if ( x < y ) { System . out . println ( x + " " + y ) ; } else { System . out . println ( y + " " + x ) ; } wpkpdte ++ ; } } } import java . util . Scanner ; public class Rawfyew { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String rawfyew = sc . next ( ) ; if ( ( rawfyew . charAt ( 0 ) == rawfyew . charAt ( 1 ) ) || ( rawfyew . charAt ( 1 ) == rawfyew . charAt ( 2 ) ) || ( rawfyew . charAt ( 2 ) == rawfyew . charAt ( 3 ) ) ) { System . out . println ( " Bad " ) ; } else { System . out . println ( " Good " ) ; } } } import java . util . Scanner ; public class Tmiixxs { public static void main ( String [ ] args ) { int tmiixxs = 0 ; int [ ] prime = new int [ 10000000 ] ; Scanner stdIn = new Scanner ( System . in ) ; int st ; do { st = stdIn . nextInt ( ) ; } while ( st < 2 || st > 100000 ) ; int min = 0 ; prime [ tmiixxs ++ ] = 2 ; prime [ tmiixxs ++ ] = 3 ; for ( int n = 5 ; n <= 1000000 ; n += 2 ) { boolean flag = false ; for ( int i = 1 ; prime [ i ] * prime [ i ] <= n ; i ++ ) { if ( n % prime [ i ] == 0 ) { flag = true ; break ; } } if ( ! flag ) { prime [ tmiixxs ++ ] = n ; if ( n >= st ) { min = n ; break ; } } } if ( st == 2 ) min = 2 ; if ( st == 3 ) min = 3 ; System . out . println ( min ) ; } } import java . util . Scanner ; public class Xemasqa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xemasqa = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( b == 1 ) { System . out . println ( 0 ) ; return ; } if ( b <= xemasqa ) { System . out . println ( 1 ) ; return ; } int sum = 0 ; for ( int i = 1 ; ; i ++ ) { sum += xemasqa ; if ( sum >= b ) { System . out . println ( i ) ; return ; } sum -= 1 ; } } } import java . util . Scanner ; public class Kbtkls { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kbtkls = Integer . parseInt ( sc . next ( ) ) ; int kR = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int [ ] np = new int [ kbtkls ] ; for ( int i = 0 ; i < q ; i ++ ) { int a = Integer . parseInt ( sc . next ( ) ) ; np [ a - 1 ] ++ ; } StringBuilder sb = new StringBuilder ( ) ; for ( int j = 0 ; j < kbtkls ; j ++ ) { if ( kR - q + np [ j ] > 0 ) { sb . append ( " Yes " ) ; } else { sb . append ( " No " ) ; } if ( j < kbtkls - 1 ) { sb . append ( " \n " ) ; } } System . out . println ( sb ) ; sc . close ( ) ; } } import java . util . * ; public class Gqcgf { static public void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gqcgf = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] sunuke = new int [ gqcgf ] ; for ( int i = 0 ; i < gqcgf ; i ++ ) { sunuke [ i ] = 0 ; } int di , A ; for ( int j = 0 ; j < K ; j ++ ) { di = sc . nextInt ( ) ; for ( int k = 0 ; k < di ; k ++ ) { A = sc . nextInt ( ) ; if ( sunuke [ A - 1 ] == 0 ) { sunuke [ A - 1 ] ++ ; } } } int count = 0 ; for ( int h = 0 ; h < gqcgf ; h ++ ) { if ( sunuke [ h ] == 0 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; public class Vruyahc { public static int solve ( int n , int k , int [ ] arr ) { int [ ] dp = new int [ n ] ; for ( int vruyahc = 1 ; vruyahc < n ; vruyahc ++ ) { int ans = Integer . MAX_VALUE ; for ( int j = vruyahc - 1 ; j >= 0 && ( vruyahc - j ) <= k ; j -- ) { int diff = Math . abs ( arr [ vruyahc ] - arr [ j ] ) ; ans = Math . min ( ans , diff + dp [ j ] ) ; } dp [ vruyahc ] = ans ; } return dp [ n - 1 ] ; } public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int k = s . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int vruyahc = 0 ; vruyahc < n ; vruyahc ++ ) { arr [ vruyahc ] = s . nextInt ( ) ; } System . out . println ( solve ( n , k , arr ) ) ; } } import java . util . Arrays ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; class Jcvxgbv { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String jcvxgbv = br . readLine ( ) ; String [ ] str2 = jcvxgbv . split ( " " ) ; int [ ] x = { Integer . parseInt ( str2 [ 0 ] ) , Integer . parseInt ( str2 [ 1 ] ) , Integer . parseInt ( str2 [ 2 ] ) } ; Arrays . sort ( x ) ; System . out . println ( x [ 0 ] + " " + x [ 1 ] + " " + x [ 2 ] ) ; } catch ( IOException e ) { System . err . println ( e . toString ( ) ) ; } } } class Isregpu { public static void main ( String [ ] s ) { long isregpu = 1 , a = 101 , o = new java . util . Scanner ( System . in ) . nextLong ( ) ; for ( ; a < o ; isregpu ++ ) a += a / 100 ; System . out . print ( isregpu ) ; } } import java . io . * ; class Kjxiio { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader re = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String line = re . readLine ( ) ; String [ ] w = line . split ( " " , 0 ) ; int kjxiio = Integer . parseInt ( w [ 0 ] ) ; int H = Integer . parseInt ( w [ 1 ] ) ; int x = Integer . parseInt ( w [ 2 ] ) ; int y = Integer . parseInt ( w [ 3 ] ) ; int r = Integer . parseInt ( w [ 4 ] ) ; String ret = " No " ; if ( kjxiio >= ( x + r ) && H >= ( y + r ) && ( x - r ) >= 0 && ( y - r ) >= 0 ) ret = " Yes " ; System . out . println ( ret ) ; re . close ( ) ; } } import java . util . Scanner ; public class Rlqymne { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String H = sc . next ( ) ; int rlqymne = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String U = sc . next ( ) ; if ( U . equals ( S ) ) { rlqymne -- ; } else if ( U . equals ( H ) ) { B -- ; } System . out . println ( rlqymne ) ; System . out . println ( B ) ; } } import java . util . Scanner ; public class Fijwgo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fijwgo = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int c = 0 ; for ( int x = 0 ; x <= fijwgo ; x ++ ) { for ( int y = 0 ; y <= fijwgo ; y ++ ) { int z = S - x - y ; if ( 0 <= z && z <= fijwgo ) { c += 1 ; } } } System . out . println ( c ) ; } } import java . util . Scanner ; public class Yazuvk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yazuvk , T , A ; yazuvk = sc . nextInt ( ) ; T = sc . nextInt ( ) ; A = sc . nextInt ( ) ; int [ ] H = new int [ yazuvk ] ; double max = 99999 ; int ans = 0 ; for ( int i = 0 ; i < yazuvk ; i ++ ) { H [ i ] = sc . nextInt ( ) ; double t = T - H [ i ] * 0.006 ; if ( max > Math . abs ( A - t ) ) { ; max = Math . abs ( A - t ) ; ans = i + 1 ; } } sc . close ( ) ; System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Npjstnx { public static void main ( String [ ] args ) throws IOException { Scanner scan = new java . util . Scanner ( System . in ) ; InputStreamReader input = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( input ) ; StringBuilder sb = new StringBuilder ( ) ; while ( true ) { int npjstnx = Integer . parseInt ( br . readLine ( ) ) ; if ( npjstnx == 0 ) break ; int [ ] s = new int [ npjstnx ] ; String [ ] dataset = br . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < npjstnx ; i ++ ) { s [ i ] = Integer . parseInt ( dataset [ i ] ) ; } int goukei = 0 ; for ( int i : s ) { goukei += i ; } double m = ( double ) goukei / ( double ) npjstnx ; double alfa2 = 0.0 ; for ( int i : s ) { alfa2 += ( i - m ) * ( i - m ) ; } alfa2 = alfa2 / npjstnx ; double alfa = Math . sqrt ( alfa2 ) ; System . out . println ( alfa ) ; } } } import java . util . * ; import java . io . * ; public class Ewmrkef { public static void main ( String [ ] args ) throws Exception { FastReader s = new FastReader ( ) ; int ewmrkef = s . nextInt ( ) ; long sum = 0 ; int max = Integer . MIN_VALUE ; int [ ] arr = new int [ ewmrkef ] ; for ( int i = 0 ; i < ewmrkef ; i ++ ) { arr [ i ] = s . nextInt ( ) ; if ( arr [ i ] < max ) { sum += max - arr [ i ] ; } max = Math . max ( max , arr [ i ] ) ; } System . out . println ( sum ) ; } static class Ewmrkef { 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 . Scanner ; public class Dvkaeg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dvkaeg = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( Math . max ( Math . max ( dvkaeg + b , dvkaeg - b ) , dvkaeg * b ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Gfimwdw { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int gfimwdw = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; int min = 2018 ; if ( R - gfimwdw > 2019 ) { System . out . print ( 0 ) ; } else { int LMod = Math . floorMod ( gfimwdw , 2019 ) ; int RMod = Math . floorMod ( R , 2019 ) ; if ( LMod < RMod ) { for ( int i = LMod ; i < RMod ; i ++ ) { for ( int j = i + 1 ; j <= RMod ; j ++ ) { int surPlus = ( i * j ) % 2019 ; if ( surPlus < min ) { min = surPlus ; } } } System . out . print ( min ) ; } else { System . out . print ( 0 ) ; } } } } import java . util . * ; public class Xqvopr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; int xqvopr = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { xqvopr += ( Math . pow ( 10 , i ) * ( s . charAt ( 3 - i ) - 48 ) ) ; } xqvopr *= 10000 ; xqvopr += ( s . charAt ( 5 ) - 48 ) * 1000 ; xqvopr += ( s . charAt ( 6 ) - 48 ) * 100 ; xqvopr += ( s . charAt ( 8 ) - 48 ) * 10 ; xqvopr += s . charAt ( 9 ) - 48 ; if ( xqvopr < 20190431 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . Scanner ; public class Asfjypb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int asfjypb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int sum = 0 ; for ( int x = asfjypb ; x <= b ; x ++ ) { if ( c % x == 0 ) { sum ++ ; } } System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Nrysm { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int nrysm = stdIn . nextInt ( ) ; int [ ] a = new int [ nrysm ] ; for ( int i = 0 ; i < nrysm ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; } long ans = 0 ; for ( int i = 1 ; i < nrysm ; i ++ ) { if ( a [ i - 1 ] > a [ i ] ) { ans += a [ i - 1 ] - a [ i ] ; a [ i ] = a [ i - 1 ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Nxbtwmk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nxbtwmk = sc . nextInt ( ) ; int [ ] A = new int [ nxbtwmk ] ; for ( int i = 0 ; i < nxbtwmk ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } bubbleSort ( A , nxbtwmk ) ; } public static void bubbleSort ( int [ ] A , int nxbtwmk ) { int flag = 1 , count = 0 ; while ( flag == 1 ) { flag = 0 ; int i = 0 ; for ( int j = i ; j < nxbtwmk - 1 ; j ++ ) { if ( A [ j + 1 ] < A [ j ] ) { int c = A [ j + 1 ] ; A [ j + 1 ] = A [ j ] ; A [ j ] = c ; count ++ ; flag = 1 ; } } i ++ ; } for ( int i = 0 ; i < nxbtwmk ; i ++ ) { System . out . print ( A [ i ] ) ; if ( i != nxbtwmk - 1 ) System . out . print ( " " ) ; } System . out . printf ( " \n %d \n " , count ) ; } } import java . util . Scanner ; class Tctnx { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long tctnx , max ; int i , j , a [ ] [ ] ; int t = s . nextInt ( ) ; a = new int [ t ] [ 2 ] ; for ( j = 0 ; j < 2 ; j ++ ) { for ( i = 0 ; i < t ; i ++ ) a [ i ] [ j ] = s . nextInt ( ) ; } tctnx = a [ 0 ] [ 0 ] ; for ( i = 0 ; i < t ; i ++ ) tctnx = tctnx + a [ i ] [ 1 ] ; max = tctnx ; for ( i = 1 ; i < t ; i ++ ) { tctnx = tctnx - a [ i - 1 ] [ 1 ] + a [ i ] [ 0 ] ; if ( tctnx > max ) max = tctnx ; } System . out . println ( max ) ; } } import java . util . * ; public class Khbunq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int khbunq = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int cnt = 0 ; while ( true ) { if ( khbunq > k ) { cnt += k ; k = 0 ; break ; } else { cnt += khbunq ; k -= khbunq ; } if ( k <= 0 ) { break ; } if ( b > k ) { k = 0 ; break ; } else { k -= b ; } if ( k <= 0 ) { break ; } if ( c > k ) { cnt -= k ; k = 0 ; break ; } else { cnt -= c ; k -= c ; } if ( k <= 0 ) { break ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Eialiuh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long eialiuh = scan . nextLong ( ) ; long moveCnt = ( long ) Math . pow ( 10 , 18 ) ; for ( long i = 1 ; i * i <= eialiuh ; i ++ ) { if ( eialiuh % i != 0 ) continue ; long j = eialiuh / i ; if ( moveCnt > i + j - 2 ) { moveCnt = i + j - 2 ; } } System . out . println ( moveCnt ) ; } } import java . util . Scanner ; public class Mgfjdnt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mgfjdnt = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] A = new int [ mgfjdnt ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < mgfjdnt ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int k = 0 ; k < m ; k ++ ) { b [ k ] = sc . nextInt ( ) ; } int [ ] c = new int [ mgfjdnt ] ; for ( int i = 0 ; i < mgfjdnt ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { c [ i ] += A [ i ] [ j ] * b [ j ] ; } } for ( int ans : c ) System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Ltnefxe { static int ltnefxe ; public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int N = s . nextInt ( ) ; int X = s . nextInt ( ) ; int [ ] race = new int [ N ] ; int donuts = 0 ; int result = 0 ; for ( int i = 0 ; i < N ; i ++ ) { race [ i ] = s . nextInt ( ) ; donuts += race [ i ] ; } int rest = X - donuts ; Arrays . sort ( race ) ; if ( race [ 0 ] < rest ) { result = rest / race [ 0 ] ; System . out . println ( result + N ) ; } else { System . out . println ( N ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Vraqzfr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vraqzfr = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ vraqzfr ] ; for ( int i = 0 ; i < vraqzfr ; i ++ ) { A [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; Arrays . sort ( A ) ; System . out . println ( Math . abs ( A [ 0 ] - A [ vraqzfr - 1 ] ) ) ; } } import java . util . Scanner ; public class Pgdcu { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; StringBuilder out ; int pgdcu = sc . nextInt ( ) ; int [ ] a = new int [ pgdcu ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sort ( a ) ; } static void sort ( int [ ] a ) { printArray ( a ) ; for ( int i = 1 ; i < a . length ; i ++ ) { int v = a [ i ] ; int j = i - 1 ; while ( j >= 0 && a [ j ] > v ) { a [ j + 1 ] = a [ j ] ; j -- ; } a [ j + 1 ] = v ; printArray ( a ) ; } } static void printArray ( int [ ] a ) { for ( int i = 0 ; i < a . length - 1 ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } System . out . println ( a [ a . length - 1 ] ) ; } } import java . util . * ; import javax . lang . model . util . ElementScanner6 ; public class Qicqscc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int qicqscc = 0 ; int h = 0 ; int t = s . length ( ) - 1 ; while ( h < t ) { if ( s . charAt ( h ) != s . charAt ( t ) ) { qicqscc += 1 ; } h += 1 ; t -= 1 ; } System . qicqscc . println ( qicqscc ) ; } } import java . util . Scanner ; public class Edpge { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = getLine ( sc ) ; show ( calc ( S ) ) ; } private static String calc ( String S ) { int edpge = Integer . parseInt ( S . substring ( 0 , 2 ) ) ; int back = Integer . parseInt ( S . substring ( 2 , 4 ) ) ; if ( isMonth ( edpge ) ) { if ( isMonth ( back ) ) return " AMBIGUOUS " ; else return " MMYY " ; } else { if ( isMonth ( back ) ) return " YYMM " ; else return " NA " ; } } private static boolean isMonth ( int n ) { return 0 < n && n < 13 ; } private static String getLine ( Scanner sc ) { return sc . next ( ) ; } private static void show ( String answer ) { System . out . println ( answer ) ; } } import java . util . * ; import java . io . * ; public class Extggli { public static void main ( String [ ] args ) throws Exception { InputStreamReader r = new InputStreamReader ( System . in ) ; long extggli = nextInt ( r ) ; long B = nextInt ( r ) ; long ans = extggli > B ? calcLCM ( extggli , B ) : calcLCM ( B , extggli ) ; System . out . println ( ans ) ; } public static int nextInt ( InputStreamReader r ) throws Exception { String str = " " ; while ( true ) { int c = r . read ( ) ; if ( c == 32 || c == 10 || c == - 1 ) { break ; } str += ( char ) c ; } return Integer . parseInt ( str ) ; } public static long calcLCM ( long large , long small ) { long result = 0 ; long tmp = small ; while ( true ) { if ( small % large == 0 ) { result = small ; break ; } else { small += tmp ; } } return result ; } } import java . util . Scanner ; public class Blltbwn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; int blltbwn = 0 ; int one = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '0' ) { blltbwn ++ ; } else { one ++ ; } } System . out . println ( 2 * Math . min ( blltbwn , one ) ) ; } } import java . util . * ; public class Rffaz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rffaz = sc . nextInt ( ) ; int height = sc . nextInt ( ) ; int [ ] fh = new int [ rffaz ] ; int count = 0 ; for ( int i = 0 ; i < rffaz ; i ++ ) { fh [ i ] = sc . nextInt ( ) ; if ( fh [ i ] >= height ) { count ++ ; } } System . out . println ( count ) ; } } import java . io . * ; import java . util . * ; public class Wxcfttw { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int wxcfttw = in . nextInt ( ) ; int x = in . nextInt ( ) ; int t = in . nextInt ( ) ; System . out . println ( ( int ) Math . ceil ( 1.0 * wxcfttw / x ) * t ) ; } } class Wxcfttw { public static BufferedReader reader ; public static StringTokenizer token ; scan ( InputStream str ) { reader = new BufferedReader ( new InputStreamReader ( str ) ) ; token = null ; } static int nextInt ( ) { while ( token == null || ! token . hasMoreTokens ( ) ) { try { token = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return Integer . parseInt ( token . nextToken ( ) ) ; } static long nextLong ( ) { while ( token == null || ! token . hasMoreTokens ( ) ) { try { token = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return Long . parseLong ( token . nextToken ( ) ) ; } static String next ( ) { while ( token == null || ! token . hasMoreTokens ( ) ) { try { token = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return token . nextToken ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Waplwl { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str ; String [ ] arrStr ; StringBuilder sb = new StringBuilder ( ) ; try { while ( true ) { str = br . readLine ( ) ; arrStr = str . split ( " " ) ; int waplwl = Integer . parseInt ( arrStr [ 0 ] ) ; int w = Integer . parseInt ( arrStr [ 1 ] ) ; if ( waplwl == 0 && w == 0 ) { break ; } boolean iKisu = false ; for ( int i = 0 ; i < waplwl ; i ++ ) { iKisu = ( i % 2 == 0 ) ; for ( int j = 0 ; j < w ; j ++ ) { if ( iKisu ) { sb . append ( j % 2 == 0 ? " # " : " . " ) ; } else { sb . append ( j % 2 == 0 ? " . " : " # " ) ; } } sb . append ( " \n " ) ; } System . out . println ( sb . toString ( ) ) ; sb . setLength ( 0 ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . Scanner ; public class Zrfni { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int zrfni ; zrfni = in . nextInt ( ) ; System . out . println ( zrfni * zrfni * zrfni ) ; } } import java . util . Scanner ; public class Lhpqfnl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lhpqfnl = sc . nextInt ( ) ; sc . nextLine ( ) ; String S = sc . next ( ) ; System . out . println ( solve ( lhpqfnl , S ) ) ; } private static String solve ( int N , String s ) { if ( N % 2 == 1 ) return " No " ; if ( s . substring ( 0 , N / 2 ) . equals ( s . substring ( N / 2 ) ) ) return " Yes " ; return " No " ; } } import java . util . Scanner ; public class Snttoml { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; String snttoml = kb . next ( ) ; String j = kb . next ( ) ; kb . close ( ) ; String k = " 123 " . replace ( snttoml , " " ) ; k = k . replace ( j , " " ) ; System . out . println ( k ) ; } } 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 Hnkfbc { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BDigitSums solver = new BDigitSums ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Hnkfbc { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int hnkfbc = in . nextInt ( ) ; int sum = 0 ; int tmp = hnkfbc ; while ( tmp > 0 ) { sum += tmp % 10 ; tmp /= 10 ; } out . println ( hnkfbc % sum == 0 ? " Yes " : " No " ) ; } } static class Hnkfbc { private BufferedReader br ; private StringTokenizer st ; public InputReader ( InputStream inputStream ) { br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; st = new StringTokenizer ( " " ) ; } public String nextString ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) , " " ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextString ( ) ) ; } } } import java . util . Scanner ; class Fkolmw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fkolmw = sc . nextInt ( ) ; int yoko = sc . nextInt ( ) ; int men ; int syu ; men = fkolmw * yoko ; syu = fkolmw * 2 + yoko * 2 ; System . out . println ( men + " " + syu ) ; sc . close ( ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Sibmvgq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String [ ] b = a . split ( " " ) ; List < String > word = new ArrayList < String > ( ) ; List < String > rev_word = new ArrayList < String > ( ) ; for ( int sibmvgq = 0 ; sibmvgq < b . length ; sibmvgq ++ ) { word . add ( b [ sibmvgq ] ) ; rev_word . add ( b [ sibmvgq ] ) ; } Collections . reverse ( rev_word ) ; int count = 0 ; for ( int i = 0 ; i < word . size ( ) ; i ++ ) { if ( ! word . get ( i ) . equals ( rev_word . get ( i ) ) ) count ++ ; } System . out . println ( count / 2 ) ; } } import java . util . Scanner ; class Anjwcov { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String s = stdIn . next ( ) ; int anjwcov = s . indexOf ( " 7 " ) ; if ( anjwcov == - 1 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . * ; import java . util . Map . Entry ; class Fafyt { static int fafyt = ( int ) ( Math . pow ( 10 , 9 ) + 7 ) ; static int [ ] ans ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long ans1 = 0 ; long ans2 = 0 ; ans1 = A * ( N / ( A + B ) ) ; ans2 = B * ( N / ( A + B ) ) ; if ( N % ( A + B ) < A ) { ans1 = ans1 + N % ( A + B ) ; } else { ans1 = ans1 + A ; ans2 = ans2 + N % ( A + B ) - A ; } System . out . println ( ans1 ) ; return ; } } import java . util . Scanner ; public class Njpxkd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int njpxkd = 0 ; njpxkd < 3 ; njpxkd ++ ) { c [ njpxkd ] [ 0 ] = Integer . parseInt ( scanner . next ( ) ) ; c [ njpxkd ] [ 1 ] = Integer . parseInt ( scanner . next ( ) ) ; c [ njpxkd ] [ 2 ] = Integer . parseInt ( scanner . next ( ) ) ; } scanner . close ( ) ; for ( int njpxkd = 0 ; njpxkd < c . length ; njpxkd ++ ) { int min = Integer . MAX_VALUE ; for ( int j = 0 ; j < c [ njpxkd ] . length ; j ++ ) { int num = c [ njpxkd ] [ j ] ; if ( min > num ) { min = num ; } } for ( int j = 0 ; j < c [ njpxkd ] . length ; j ++ ) { c [ njpxkd ] [ j ] -= min ; } } for ( int njpxkd = 0 ; njpxkd < c . length ; njpxkd ++ ) { if ( c [ 0 ] [ njpxkd ] != c [ 1 ] [ njpxkd ] || c [ 1 ] [ njpxkd ] != c [ 2 ] [ njpxkd ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Vefetl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double vefetl = sc . nextDouble ( ) ; double r = vefetl * 2 * 3.14 ; System . out . println ( r ) ; } } import java . util . Scanner ; class Mbnuqg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mbnuqg = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int cnt = 0 ; int z ; for ( int i = 0 ; i <= mbnuqg ; i ++ ) { z = x - 500 * i ; for ( int j = 0 ; j <= b ; j ++ ) { z -= 100 * j ; for ( int k = 0 ; k <= c ; k ++ ) { z = z - 50 * k ; if ( z == 0 ) { cnt ++ ; } z = z + 50 * k ; } z += 100 * j ; } } System . out . println ( cnt ) ; } } import java . io . * ; public class Cnrwwab { public static void main ( String [ ] args ) { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int cnrwwab , b , c ; String [ ] arange = null ; try { arange = in . readLine ( ) . split ( " " , 0 ) ; } catch ( Exception e ) { } cnrwwab = Integer . parseInt ( arange [ 0 ] ) ; b = Integer . parseInt ( arange [ 1 ] ) ; c = Integer . parseInt ( arange [ 2 ] ) ; if ( cnrwwab <= b && cnrwwab <= c ) { if ( b < c ) System . out . println ( cnrwwab + " " + b + " " + c ) ; else System . out . println ( cnrwwab + " " + c + " " + b ) ; } else if ( b <= cnrwwab && b <= c ) { if ( cnrwwab < c ) System . out . println ( b + " " + cnrwwab + " " + c ) ; else System . out . println ( b + " " + c + " " + cnrwwab ) ; } else { if ( cnrwwab < b ) System . out . println ( c + " " + cnrwwab + " " + b ) ; else System . out . println ( c + " " + b + " " + cnrwwab ) ; } } } import java . util . Scanner ; class Uoktu { public void fun ( ) { Scanner sc = new Scanner ( System . in ) ; int uoktu = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] a ; a = new int [ n ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int i = 0 ; while ( i < a . length ) { uoktu = uoktu - a [ i ] ; i ++ ; } if ( uoktu <= 0 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } public static void main ( String [ ] arr ) { Main m = new Main ( ) ; m . fun ( ) ; } } import java . util . * ; public class Llkpvag { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; char llkpvag ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { llkpvag = s . charAt ( i ) ; if ( llkpvag >= 'A' && llkpvag <= 'Z' ) { llkpvag += 'a' - 'A' ; } else if ( llkpvag >= 'a' && llkpvag <= 'z' ) { llkpvag += 'A' - 'a' ; } System . out . print ( llkpvag ) ; } System . out . println ( " " ) ; sc . close ( ) ; } } import java . util . * ; public class Kghqvk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String Ss = S . substring ( 0 , 4 ) + S . substring ( 5 , 7 ) + S . substring ( 8 , 10 ) ; int kghqvk = Integer . parseInt ( Ss ) ; if ( kghqvk <= 20190430 ) System . out . println ( " Heisei " ) ; else System . out . println ( " TBD " ) ; } } import java . util . * ; public class Yyyph { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yyyph = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; for ( int i = x - yyyph + 1 ; i <= x + yyyph - 1 ; i ++ ) { System . out . print ( i ) ; if ( i < x + yyyph - 1 ) { System . out . print ( " " ) ; } else { System . out . println ( " " ) ; } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Ahmpvhq { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int ahmpvhq = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; String res = " TLE " ; int minCost = Integer . MAX_VALUE ; for ( int i = 0 ; i < ahmpvhq ; i ++ ) { int c = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; if ( T <= t ) { if ( c < minCost ) { minCost = c ; res = " " + c ; } } } System . out . println ( res ) ; } static class Ahmpvhq { 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 . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Bsznv { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int bsznv = Integer . parseInt ( br . readLine ( ) ) ; String [ ] inputData = br . readLine ( ) . split ( " " ) ; Integer [ ] number = new Integer [ bsznv ] ; for ( int i = 0 ; i < inputData . length ; i ++ ) { number [ i ] = Integer . parseInt ( inputData [ i ] ) ; } for ( int i = number . length - 1 ; i >= 1 ; i -- ) { sb . append ( number [ i ] + " " ) ; } sb . append ( number [ 0 ] ) ; System . out . println ( sb ) ; } } import java . util . Scanner ; public class Lydfi { public static void main ( String [ ] args ) { Main mainObj = new Main ( ) ; mainObj . exec ( ) ; } public void exec ( ) { Scanner sc = new Scanner ( System . in ) ; int lydfi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; sc . close ( ) ; if ( ! inRange ( lydfi ) || ! inRange ( b ) ) { System . out . println ( - 1 ) ; return ; } System . out . println ( lydfi * b ) ; } boolean inRange ( int lydfi ) { if ( lydfi >= 1 && lydfi <= 9 ) { return true ; } else { return false ; } } } import java . util . * ; class Gdcpd { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int gdcpd = sc . nextInt ( ) ; double [ ] v = new double [ gdcpd ] ; for ( int i = 0 ; i < gdcpd ; i ++ ) { v [ i ] = sc . nextDouble ( ) ; } Arrays . sort ( v ) ; for ( int i = 0 ; i < gdcpd - 1 ; i ++ ) { v [ i + 1 ] = ( v [ i ] + v [ i + 1 ] ) / 2d ; } System . out . println ( v [ gdcpd - 1 ] ) ; sc . close ( ) ; } } import java . util . Scanner ; import java . util . Collections ; import java . util . List ; import java . util . ArrayList ; public class Waeqv { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; int waeqv = scan . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; while ( scan . hasNextInt ( ) ) { list . add ( scan . nextInt ( ) ) ; } Collections . sort ( list ) ; double x = 0 ; for ( int num : list ) { x = x == 0 ? num : ( num + x ) / 2 ; } System . out . println ( x ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Zcekyy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String zcekyy = sc . next ( ) ; System . out . println ( zcekyy . charAt ( 2 ) == zcekyy . charAt ( 3 ) && zcekyy . charAt ( 4 ) == zcekyy . charAt ( 5 ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Agmgcbt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String sub ; int agmgcbt = - 1 ; sub = s . substring ( s . indexOf ( " A " ) , s . lastIndexOf ( " Z " ) + 1 ) ; agmgcbt = sub . length ( ) ; System . out . println ( agmgcbt ) ; } } import java . util . * ; public class Jbonokq { public static void main ( String [ ] args ) { Scanner sn = new Scanner ( System . in ) ; int jbonokq = sn . nextInt ( ) ; int B = sn . nextInt ( ) ; int C = sn . nextInt ( ) ; if ( ( jbonokq == B && jbonokq != C ) || ( jbonokq == C && jbonokq != B ) || ( B == C && B != jbonokq ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; public class Kqvmddq { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int kqvmddq = in . nextInt ( ) ; if ( kqvmddq % 1000 == 0 ) { System . out . println ( " 0 " ) ; } else { int a = ( kqvmddq / 1000 ) + 1 ; System . out . println ( ( a * 1000 ) - kqvmddq ) ; } } } import java . util . Scanner ; public class Swqzuk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int swqzuk = sc . nextInt ( ) ; int [ ] ans = new int [ swqzuk + 1 ] ; for ( int i = 1 ; i < swqzuk ; i ++ ) { int a = sc . nextInt ( ) ; ans [ a ] ++ ; } for ( int i = 1 ; i <= swqzuk ; i ++ ) { System . out . println ( ans [ i ] ) ; } } } import java . util . Scanner ; public class Jtklqo { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; String s = std . next ( ) ; String [ ] texts = s . split ( " / " ) ; String monthS = texts [ 1 ] ; String dayS = texts [ 2 ] ; int jtklqo = Integer . parseInt ( monthS ) ; int day = Integer . parseInt ( dayS ) ; if ( jtklqo <= 4 && day <= 30 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Diidwu { public static void main ( String [ ] args ) { Scanner tan = new Scanner ( System . in ) ; while ( tan . hasNext ( ) ) { int diidwu , k , sum = 0 ; diidwu = tan . nextInt ( ) ; k = tan . nextInt ( ) ; int [ ] a = new int [ diidwu ] ; for ( int i = 0 ; i < diidwu ; i ++ ) { a [ i ] = tan . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int i = 0 ; i < k ; i ++ ) { sum = sum + a [ i ] ; } System . out . println ( sum ) ; } } } import java . util . * ; public class Vjocw { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int vjocw = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; ArrayList < Integer > A = new ArrayList < Integer > ( ) ; while ( sc . hasNext ( ) ) { A . add ( sc . nextInt ( ) ) ; } int [ ] right = new int [ N ] ; int max = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( i == N - 2 ) { right [ i + 1 ] = ( ( vjocw - A . get ( i + 1 ) ) + A . get ( 0 ) ) ; } right [ i ] = A . get ( i + 1 ) - A . get ( i ) ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( max < Math . max ( right [ i + 1 ] , right [ i ] ) ) max = Math . max ( right [ i + 1 ] , right [ i ] ) ; } System . out . println ( vjocw - max ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . * ; import java . math . * ; import java . util . * ; class Sojhcc { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String S = br . readLine ( ) ; String t = br . readLine ( ) ; int sojhcc = Integer . MAX_VALUE ; for ( int i = 0 ; i < S . length ( ) - t . length ( ) + 1 ; i ++ ) { String s = S . substring ( i , i + t . length ( ) ) ; int count = 0 ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( t . charAt ( j ) != s . charAt ( j ) ) { count ++ ; } if ( count >= sojhcc ) { break ; } } sojhcc = Math . sojhcc ( sojhcc , count ) ; } System . out . print ( sojhcc ) ; } } import java . util . Scanner ; public class Nvmylwa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nvmylwa = sc . nextInt ( ) , n = sc . nextInt ( ) ; int sum = 0 , count = 0 , flag = 0 , max = - 999999 , min = 99999 ; if ( nvmylwa == 0 ) { if ( n != 100 ) System . out . println ( n ) ; else System . out . println ( n + 1 ) ; } else if ( nvmylwa == 1 ) { if ( n != 100 ) System . out . println ( n * 100 ) ; else System . out . println ( ( n + 1 ) * 100 ) ; } else { if ( n != 100 ) System . out . println ( n * 10000 ) ; else System . out . println ( ( n + 1 ) * 10000 ) ; } } public static int sample ( int n ) { return n ; } } import java . util . * ; class Gpxyos { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gpxyos = sc . nextInt ( ) ; int max = 0 ; int num = 0 ; for ( int i = 0 ; i < gpxyos ; i ++ ) { int l = sc . nextInt ( ) ; if ( l > max ) { num = num + max ; max = l ; } else { num = num + l ; } } if ( max < num ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; class Bymyy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bymyy = 0 ; int [ ] [ ] nums = new int [ 3 ] [ 3 ] ; for ( int i = 0 ; i < 9 ; i ++ ) { nums [ i / 3 ] [ i % 3 ] = sc . nextInt ( ) ; } System . out . println ( nums [ 1 ] [ 0 ] - nums [ 0 ] [ 0 ] == nums [ 1 ] [ 1 ] - nums [ 0 ] [ 1 ] && nums [ 1 ] [ 1 ] - nums [ 0 ] [ 1 ] == nums [ 1 ] [ 2 ] - nums [ 0 ] [ 2 ] && nums [ 2 ] [ 0 ] - nums [ 1 ] [ 0 ] == nums [ 2 ] [ 1 ] - nums [ 1 ] [ 1 ] && nums [ 2 ] [ 1 ] - nums [ 1 ] [ 1 ] == nums [ 2 ] [ 2 ] - nums [ 1 ] [ 2 ] ? " Yes " : " No " ) ; } } import java . math . BigDecimal ; import java . math . RoundingMode ; import java . util . Scanner ; class Pontdp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigDecimal A = sc . nextBigDecimal ( ) ; BigDecimal B = sc . nextBigDecimal ( ) ; BigDecimal w = A . multiply ( B ) ; BigDecimal ans = w . setScale ( 0 , RoundingMode . DOWN ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Tehceo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; if ( str . charAt ( 0 ) != 'A' ) { System . out . println ( " WA " ) ; return ; } else { int tehceo = 0 ; int i ; int length = str . length ( ) ; for ( i = 2 ; i < length - 1 ; i ++ ) { if ( str . charAt ( i ) == 'C' ) { tehceo ++ ; } if ( tehceo > 1 ) { System . out . println ( " WA " ) ; return ; } } if ( tehceo == 0 ) { System . out . println ( " WA " ) ; return ; } int big = 0 ; for ( i = 0 ; i < length ; i ++ ) { if ( Character . isUpperCase ( str . charAt ( i ) ) ) { big ++ ; if ( big > 2 ) { System . out . println ( " WA " ) ; return ; } } } } System . out . println ( " AC " ) ; } } import java . util . * ; public class Biomewr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; if ( T . equals ( S ) ) { System . out . println ( " Yes " ) ; return ; } for ( int biomewr = 0 ; biomewr < S . length ( ) ; biomewr ++ ) { String U = S . substring ( biomewr , S . length ( ) ) + S . substring ( 0 , biomewr ) ; if ( T . equals ( U ) ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . * ; public class Opnzb { public static double opnzb = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double x = sc . nextInt ( ) ; if ( ( x % 2 ) == 0 ) { opnzb = ( ( x / 2 ) / x ) ; } else { if ( x == 1 ) { opnzb = 1 ; } else { opnzb = ( ( ( ( x - 1 ) / 2 ) + 1 ) / x ) ; } } System . out . println ( String . format ( " %.10f " , opnzb ) ) ; } } import java . util . * ; class Dpuipf { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { char dpuipf = scan . next ( ) . charAt ( 0 ) ; if ( dpuipf >= 'A' && dpuipf <= 'Z' ) { System . out . println ( " A " ) ; } else if ( dpuipf >= 'a' && dpuipf <= 'z' ) { System . out . println ( " a " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Exavr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int exavr = sc . nextInt ( ) ; int [ ] p = new int [ exavr ] ; int [ ] q = new int [ exavr ] ; int replaceCnt = 0 ; String result = " YES " ; for ( int i = 0 ; i < exavr ; i ++ ) { p [ i ] = sc . nextInt ( ) ; q [ i ] = p [ i ] ; } Arrays . sort ( q ) ; for ( int i = 0 ; i < exavr ; i ++ ) { if ( p [ i ] != q [ i ] ) { replaceCnt ++ ; if ( replaceCnt > 2 ) { result = " NO " ; break ; } } } System . out . println ( result ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Shpfj { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int shpfj = Integer . valueOf ( br . readLine ( ) ) ; String [ ] z = br . readLine ( ) . split ( " " ) ; String nums1 = z [ 0 ] ; String nums2 = z [ 1 ] ; for ( int i = 0 ; i < shpfj ; i ++ ) { System . out . print ( nums1 . charAt ( i ) ) ; System . out . print ( nums2 . charAt ( i ) ) ; } } } import java . util . * ; import java . lang . * ; public class Zxtqz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zxtqz = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; String [ ] ac = new String [ zxtqz + 1 ] ; int [ ] wa = new int [ zxtqz + 1 ] ; for ( int i = 0 ; i < zxtqz + 1 ; i ++ ) { ac [ i ] = " Q " ; } int count1 = 0 ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) ; String ss = sc . next ( ) ; if ( ss . equals ( " AC " ) ) { ac [ a ] = " AC " ; } else { if ( ac [ a ] . equals ( " Q " ) ) { wa [ a ] ++ ; } } } int count2 = 0 ; for ( int i = 0 ; i < zxtqz + 1 ; i ++ ) { if ( ac [ i ] . equals ( " AC " ) ) { count1 ++ ; } else { wa [ i ] = 0 ; } count2 += wa [ i ] ; } System . out . println ( count1 + " " + count2 ) ; } } import java . util . Scanner ; class Mrtwm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mrtwm = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += sc . nextInt ( ) ; } System . out . print ( mrtwm <= sum ? " Yes " : " No " ) ; } } import java . util . * ; public class Kxudf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int kxudf = 0 ; int tmp = 0 ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { char ch = s . charAt ( i ) ; if ( ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T' ) ++ tmp ; else tmp = 0 ; if ( tmp > kxudf ) kxudf = tmp ; } System . out . println ( kxudf ) ; } } import java . util . Scanner ; class Fflhke { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int fflhke = scanner . nextInt ( ) ; int a ; int [ ] order = new int [ fflhke ] ; for ( int i = 0 ; i < fflhke ; i ++ ) { a = scanner . nextInt ( ) ; order [ a - 1 ] = i + 1 ; } for ( int syusseki : order ) { System . out . println ( syusseki ) ; } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Mdrzl { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BPapersPlease solver = new BPapersPlease ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Mdrzl { public void solve ( int testNumber , Scanner in , PrintWriter out ) { boolean mdrzl = true ; int n = in . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; if ( a [ i ] % 2 == 0 ) { mdrzl = mdrzl && ( a [ i ] % 3 == 0 || a [ i ] % 5 == 0 ) ; } } out . println ( mdrzl ? " APPROVED " : " DENIED " ) ; } } } import java . util . Scanner ; import java . util . List ; import java . util . ArrayList ; import java . util . Map ; import java . util . HashMap ; class Qqfaox { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int qqfaox = scanner . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < qqfaox ; i ++ ) { list . add ( scanner . next ( ) ) ; } scanner . close ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; for ( String val : list ) { map . put ( val , 0 ) ; } System . out . println ( map . size ( ) ) ; } } import java . util . Scanner ; public class Asgxoup { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int asgxoup = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ asgxoup + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ sc . nextInt ( ) ] ++ ; } long [ ] cmb = new long [ asgxoup + 1 ] ; cmb [ 0 ] = 1 ; cmb [ 1 ] = a [ 1 ] ^ 1 ; final long mod = 1_000_000_007 ; for ( int i = 2 ; i <= asgxoup ; i ++ ) { cmb [ i ] = ( a [ i ] ^ 1 ) * ( cmb [ i - 2 ] + cmb [ i - 1 ] ) % mod ; } System . out . println ( cmb [ asgxoup ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Cdxmib { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; br . readLine ( ) ; int cdxmib = 0 ; String str ; while ( ( str = br . readLine ( ) ) != null ) { if ( isPrime ( Long . valueOf ( str ) ) ) cdxmib ++ ; } System . out . println ( cdxmib ) ; } private static boolean isPrime ( long n ) { if ( n < 2 ) return false ; else if ( n == 2 ) return true ; if ( n % 2 == 0 ) return false ; for ( long i = 3 ; i <= n / i ; i += 2 ) if ( n % i == 0 ) return false ; return true ; } } import java . util . Scanner ; public class Dzbdeb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String num = sc . next ( ) ; int [ ] x ; x = new int [ 1000 ] ; int dzbdeb = num . dzbdeb ( ) ; int sum = 0 ; for ( int i = 0 ; i < dzbdeb ; i ++ ) x [ i ] = num . charAt ( i ) - '0' ; for ( int i = 0 ; i < dzbdeb ; i ++ ) sum += x [ i ] ; if ( sum == 0 ) { break ; } else { System . out . println ( sum ) ; } } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Pfwoue { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; A solver = new A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Pfwoue { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String s = in . next ( ) ; int pfwoue = s . charAt ( 0 ) ; char ans = ( char ) ++ pfwoue ; out . println ( ans ) ; } } } import java . util . Scanner ; public class Xhelsg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String xhelsg = scanner . nextLine ( ) ; System . out . println ( ( xhelsg . equals ( " ABC " ) ) ? " ARC " : " ABC " ) ; } } import java . util . * ; public class Xnmww { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xnmww = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; sc . close ( ) ; int cnt = 0 ; if ( xnmww >= 2 ) { cnt += xnmww * ( xnmww - 1 ) / 2 ; } if ( m >= 2 ) { cnt += m * ( m - 1 ) / 2 ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Cdqnr { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String ns = s . nextLine ( ) ; String str = s . nextLine ( ) ; int cdqnr = Integer . parseInt ( ns ) ; int [ ] arr = new int [ cdqnr + 1 ] ; arr [ 0 ] = 0 ; String [ ] sss = str . split ( " \\ s " ) ; for ( int i = 1 ; i <= cdqnr ; i ++ ) { arr [ i ] = Integer . parseInt ( sss [ i - 1 ] ) ; } int [ ] a = new int [ cdqnr + 1 ] ; a [ 0 ] = 0 ; for ( int i = 1 ; i <= cdqnr ; i ++ ) { a [ ( arr [ i ] ) ] = i ; } for ( int i = 1 ; i <= cdqnr ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } } } import java . util . Scanner ; public class Jeixyaa { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int jeixyaa = sc . nextInt ( ) ; int [ ] rate = new int [ 8 ] ; int red = 0 ; for ( int i = 0 ; i < jeixyaa ; i ++ ) { int a = sc . nextInt ( ) ; if ( 3200 <= a ) { red ++ ; } else { rate [ ( a / 400 ) ] ++ ; } } int min = 0 ; int max = 0 ; int count = 0 ; for ( int i = 0 ; i < 8 ; i ++ ) { if ( rate [ i ] >= 1 ) { count ++ ; } } min = Math . max ( count , 1 ) ; max = count + red ; System . out . println ( min + " " + max ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Bmmbr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bmmbr = Integer . parseInt ( sc . next ( ) ) ; ArrayList < Integer > nums = new ArrayList < Integer > ( bmmbr ) ; for ( int i = 0 ; i < bmmbr ; i ++ ) { nums . add ( Integer . parseInt ( sc . next ( ) ) ) ; } int ans = 0 ; while ( true ) { int max = Collections . max ( nums ) ; if ( max == 0 ) { break ; } int index = nums . indexOf ( max ) ; while ( true ) { nums . set ( index , max - 1 ) ; if ( index == bmmbr - 1 ) { break ; } else if ( nums . get ( index ) == nums . get ( index + 1 ) - 1 ) { index += 1 ; } else { break ; } } ans ++ ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Rkeawxb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; sc . next ( ) ; int rkeawxb = 1 ; char [ ] str = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; for ( int i = 0 ; i < str . length - 1 ; i ++ ) { if ( str [ i ] != str [ i + 1 ] ) ++ rkeawxb ; } System . out . println ( rkeawxb ) ; } } import java . util . Scanner ; public class Drybp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String drybp = sc . nextLine ( ) ; sc . close ( ) ; String s2 = drybp . replace ( " 0 " , " " ) ; System . out . println ( s2 . length ( ) ) ; } } import java . util . * ; class Jemyxsb { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int jemyxsb = sc . nextInt ( ) ; long [ ] A = new long [ jemyxsb ] ; for ( int i = 0 ; i < jemyxsb ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } Arrays . sort ( A ) ; long ans = 1 ; for ( int i = 0 ; i < jemyxsb ; i ++ ) { if ( ans == 0 ) break ; if ( A [ i ] > ( long ) Math . pow ( 10 , 18 ) / ans ) { ans = - 1 ; break ; } ans *= A [ i ] ; } System . out . println ( ans ) ; } } import java . util . Scanner ; class Jqdog { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int jqdog = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( jqdog == 0 && W == 0 ) { break ; } for ( int x = 0 ; x < jqdog ; x ++ ) { for ( int y = 0 ; y < W ; y ++ ) { if ( x == 0 || y == 0 || x == jqdog - 1 || y == W - 1 ) { System . out . print ( " # " ) ; } else { System . out . print ( " . " ) ; } } System . out . println ( " " ) ; } System . out . println ( " " ) ; } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Lwyna { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; GrandGarden solver = new GrandGarden ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Lwyna { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int lwyna = in . nextInt ( ) ; int [ ] h = new int [ lwyna ] ; for ( int i = 0 ; i < lwyna ; i ++ ) { h [ i ] = in . nextInt ( ) ; } long result = 0 ; int i = 0 ; while ( i < lwyna ) { if ( h [ i ] == 0 ) { i ++ ; continue ; } int v = 1 ; result += 1 ; h [ i ] -= v ; for ( int j = i + 1 ; j < lwyna ; j ++ ) { if ( h [ j ] > 0 ) { h [ j ] = ( h [ j ] >= v ) ? h [ j ] - v : 0 ; } else { break ; } } } out . print ( result ) ; } } } import java . util . Scanner ; public class Rwyqqxy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rwyqqxy = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int h = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; double kakudo = Math . abs ( ( m * 360 / 60 ) - ( ( h + ( double ) m / 60 ) * 360 / 12 ) ) ; double x = Math . pow ( rwyqqxy , 2 ) + Math . pow ( b , 2 ) - 2 * rwyqqxy * b * Math . cos ( Math . toRadians ( kakudo ) ) ; System . out . println ( Math . sqrt ( x ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Mbhfhs { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String result = " No " ; String inStr = br . readLine ( ) ; String target = br . readLine ( ) ; String ring = inStr + inStr ; if ( inStr . length ( ) >= target . length ( ) ) for ( int mbhfhs = 0 ; mbhfhs < inStr . length ( ) ; mbhfhs ++ ) { if ( target . charAt ( 0 ) == ring . charAt ( mbhfhs ) ) { if ( target . equals ( ring . substring ( mbhfhs , mbhfhs + target . length ( ) ) ) ) { result = " Yes " ; break ; } } } System . out . println ( result ) ; } } } import java . util . Scanner ; public class Xlqmg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xlqmg , B ; xlqmg = sc . nextInt ( ) ; B = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( solve ( xlqmg , B ) ) ; } static long solve ( int a , int b ) { long result = 1 ; int i ; for ( i = 2 ; i <= a && i <= b ; i ++ ) { if ( a % i == 0 && b % i == 0 ) { result = result * i ; a = a / i ; b = b / i ; i = 1 ; } } return result * ( long ) a * ( long ) b ; } } import java . util . * ; public class Kiedbi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kiedbi = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int taxi = sc . nextInt ( ) ; int train , ans ; train = kiedbi * a ; if ( train >= taxi ) { System . out . println ( taxi ) ; } else { System . out . println ( train ) ; } } } import java . util . Scanner ; public class Oztwe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { long oztwe = sc . nextLong ( ) ; long n = sc . nextLong ( ) ; System . out . printf ( " %d %d \n " , gcd ( oztwe , n ) , lcm ( oztwe , n ) ) ; } } public static long gcd ( long a , long b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } public static long lcm ( long a , long b ) { return a * b / gcd ( a , b ) ; } } import java . util . * ; import java . io . * ; public class Uuhbw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uuhbw = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int d ; int A ; int [ ] people = new int [ uuhbw ] ; for ( int i = 0 ; i < uuhbw ; i ++ ) { people [ i ] = 0 ; } for ( int i = 0 ; i < k ; i ++ ) { d = sc . nextInt ( ) ; for ( int j = 0 ; j < d ; j ++ ) { A = sc . nextInt ( ) ; A -- ; people [ A ] ++ ; } } int res = 0 ; for ( int i = 0 ; i < uuhbw ; i ++ ) { if ( people [ i ] == 0 ) res ++ ; } System . out . println ( res ) ; } } import java . util . * ; class Eosqmqa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eosqmqa = sc . nextInt ( ) ; System . out . println ( eosqmqa / 3600 + " : " + eosqmqa % 3600 / 60 + " : " + eosqmqa % 3600 % 60 ) ; } } import java . util . * ; public class Iierzf { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String N = input . next ( ) ; int iierzf = N . charAt ( N . length ( ) - 1 ) - 48 ; if ( iierzf == 3 ) { System . out . print ( " bon " ) ; } else if ( iierzf == 0 || iierzf == 1 || iierzf == 6 || iierzf == 8 ) { System . out . print ( " pon " ) ; } else { System . out . print ( " hon " ) ; } } } import java . util . Scanner ; public class Chvrwtv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int chvrwtv = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int [ ] l = new int [ chvrwtv ] ; for ( int i = 0 ; i < chvrwtv ; i ++ ) { l [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; int d = 0 ; int cnt = 1 ; for ( int i = 0 ; i < chvrwtv ; i ++ ) { d = d + l [ i ] ; if ( d <= x ) cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . * ; class Drjmxa { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; for ( ; ; ) { int drjmxa = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( drjmxa == 0 && b == 0 ) break ; System . out . println ( " " + Math . min ( drjmxa , b ) + " " + Math . max ( drjmxa , b ) ) ; } } } import java . util . * ; class Btgjb { Scanner sc ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { String btgjb = sc . next ( ) ; switch ( btgjb ) { case " Sunny " : System . out . println ( " Cloudy " ) ; break ; case " Cloudy " : System . out . println ( " Rainy " ) ; break ; case " Rainy " : System . out . println ( " Sunny " ) ; break ; } } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . * ; class Qafbdij { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qafbdij = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; long S , L ; long Ri = 1 ; if ( qafbdij > B ) { L = qafbdij ; S = B ; } else { L = B ; S = qafbdij ; } long X = L % S ; for ( long i = 1 ; i <= S ; i ++ ) { if ( ( i * L ) % S == 0 ) { Ri = i ; i = S + 1 ; } } System . out . println ( Ri * L ) ; } } import java . util . * ; class Fijuvv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fijuvv = sc . nextInt ( ) ; int rest = fijuvv % 7 ; for ( int i = 0 ; i < 25 ; i ++ ) { for ( int j = 0 ; j < 14 ; j ++ ) { if ( i * 4 + j * 7 == fijuvv ) { System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } } import java . util . * ; public class Yszcodp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yszcodp = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] b = new int [ yszcodp ] ; for ( int i = 0 ; i < k ; i ++ ) { int d = sc . nextInt ( ) ; int [ ] a = new int [ d ] ; for ( int j = 0 ; j < d ; j ++ ) { a [ j ] = sc . nextInt ( ) ; int c = a [ j ] ; b [ c - 1 ] = 1 ; } } int count = 0 ; for ( int x = 0 ; x < b . length ; x ++ ) { if ( b [ x ] == 0 ) { count = count + 1 ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Unlhmj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int unlhmj = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int keypress = ( B < D ? B : D ) - ( unlhmj > C ? unlhmj : C ) ; System . out . println ( keypress > 0 ? keypress : 0 ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; class Vkwtf { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String input = br . readLine ( ) ; int vkwtf = 0 ; if ( input . contains ( " A " ) ) { vkwtf ++ ; } if ( input . contains ( " B " ) ) { vkwtf ++ ; } if ( vkwtf == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class Ggvbu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ggvbu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = ggvbu ; int ans = 1 ; while ( sum < b ) { ans ++ ; sum += ggvbu - 1 ; } if ( b == 1 ) ans = 0 ; System . out . print ( ans ) ; } } import java . util . * ; public class Fidzw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; sc . close ( ) ; String [ ] s_arr = s . split ( " " ) ; String [ ] t_arr = t . split ( " " ) ; int fidzw = 0 ; for ( int i = 0 ; i < s_arr . length ; i ++ ) { if ( s_arr [ i ] . equals ( t_arr [ i ] ) ) { fidzw ++ ; } } System . out . println ( fidzw ) ; } } import java . util . Scanner ; public class Dysqbv { public static void main ( String ... args ) { Scanner scanner = new Scanner ( System . in ) ; int dysqbv = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; System . out . println ( lcm ( dysqbv , B ) ) ; } static long gcd ( long a , long b ) { long max = Math . max ( a , b ) ; long min = Math . min ( a , b ) ; long r = max % min ; if ( r == 0 ) { return min ; } else { return gcd ( min , r ) ; } } static long lcm ( long a , long b ) { return a * b / gcd ( a , b ) ; } } import java . util . * ; public class Vcuxqzb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vcuxqzb = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( vcuxqzb <= 9 && B <= 9 ) { System . out . println ( vcuxqzb * B ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . Scanner ; public class Wvxculg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; long wvxculg = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { wvxculg += s . charAt ( i ) - '0' ; } if ( wvxculg % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Zjqaon { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final String EOT = " END_OF_TEXT " ; String w , t ; int zjqaon = 0 ; w = sc . next ( ) ; while ( true ) { t = sc . next ( ) ; if ( t . equals ( EOT ) ) { break ; } if ( t . equalsIgnoreCase ( w ) ) { zjqaon ++ ; } } System . out . println ( zjqaon ) ; } } import java . util . Scanner ; public class Pykla { public static void main ( String [ ] args ) { int pykla = 0 ; Scanner sc = new Scanner ( System . in ) ; pykla = sc . nextInt ( ) ; pykla += sc . nextInt ( ) ; pykla += sc . nextInt ( ) ; if ( pykla > 21 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } } } import java . util . * ; public class Tahhu { Scanner sc = new Scanner ( System . in ) ; final int tahhu = ( int ) 1e9 + 7 ; final int MAX = Integer . MAX_VALUE ; final long LMAX = Long . MAX_VALUE ; int len = ( int ) 1e7 ; void doIt ( ) { int N = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; map . put ( " AC " , 0 ) ; map . put ( " WA " , 0 ) ; map . put ( " TLE " , 0 ) ; map . put ( " RE " , 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { String S = sc . next ( ) ; map . put ( S , map . get ( S ) + 1 ) ; } System . out . println ( " AC x " + map . get ( " AC " ) ) ; System . out . println ( " WA x " + map . get ( " WA " ) ) ; System . out . println ( " TLE x " + map . get ( " TLE " ) ) ; System . out . println ( " RE x " + map . get ( " RE " ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . doIt ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigDecimal ; import java . math . RoundingMode ; class Edlii { public static void main ( String [ ] args ) throws Exception { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; double edlii = Double . parseDouble ( br . readLine ( ) ) ; double countOdd = Math . round ( edlii / 2 ) ; BigDecimal result = new BigDecimal ( countOdd / edlii ) ; result . setScale ( 10 , RoundingMode . HALF_UP ) ; System . out . println ( result ) ; } catch ( IOException | NumberFormatException e ) { e . printStackTrace ( ) ; System . exit ( 0 ) ; } catch ( final Exception e ) { e . printStackTrace ( ) ; System . exit ( 0 ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class Epmdb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int epmdb = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; ArrayList < Integer > d = new ArrayList < Integer > ( ) ; for ( int i = Math . max ( epmdb , B ) ; i >= 1 ; i -- ) { if ( epmdb % i == 0 && B % i == 0 ) d . add ( i ) ; } System . out . println ( d . get ( K - 1 ) ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Cvvfyk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; while ( true ) { String [ ] line = br . readLine ( ) . split ( " " ) ; int cvvfyk = Integer . parseInt ( line [ 0 ] ) ; int w = Integer . parseInt ( line [ 1 ] ) ; if ( cvvfyk == 0 && w == 0 ) break ; for ( int i = 0 ; i < cvvfyk ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( ( i % 2 == 0 && j % 2 != 0 ) || ( i % 2 != 0 && j % 2 == 0 ) ) sb . append ( " . " ) ; else sb . append ( " # " ) ; } sb . append ( " \n " ) ; } sb . append ( " \n " ) ; } System . out . print ( sb ) ; } } import java . util . Scanner ; public class Afempb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int afempb = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; if ( afempb != 1 && M != 1 ) { System . out . print ( 1 ) ; } else if ( afempb != 2 && M != 2 ) { System . out . print ( 2 ) ; } else if ( afempb != 3 && M != 3 ) { System . out . print ( 3 ) ; } return ; } } import java . util . Scanner ; public class Xukrhl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xukrhl = Integer . parseInt ( sc . next ( ) ) ; int ans = 1 ; int count = 0 ; for ( int i = 1 ; i <= xukrhl ; i ++ ) { int divi = i ; int roop = 0 ; while ( divi % 2 == 0 ) { divi = divi / 2 ; roop ++ ; } if ( count < roop ) { count = roop ; ans = i ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Jsqcrv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jsqcrv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; ArrayList < Integer > divisor = new ArrayList < Integer > ( ) ; for ( int i = jsqcrv ; i > 0 ; i -- ) { if ( jsqcrv % i == 0 && b % i == 0 ) { divisor . add ( i ) ; } } System . out . println ( divisor . get ( k - 1 ) ) ; } } import java . util . * ; class Wwtjv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wwtjv = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = 0 ; int T = wwtjv * A ; if ( T < B ) { ans = T ; } else { ans = B ; } System . out . println ( ans ) ; } } import java . io . PrintWriter ; import java . util . * ; public class Jsedjhl { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int jsedjhl = Integer . parseInt ( stdin . next ( ) ) ; int [ ] H = new int [ jsedjhl ] ; int flag ; if ( jsedjhl == 1 ) { flag = 1 ; } else { flag = 0 ; } for ( int i = 0 ; i < jsedjhl ; i ++ ) { H [ i ] = Integer . parseInt ( stdin . next ( ) ) ; } for ( int i = jsedjhl - 1 ; i > 0 ; i -- ) { if ( H [ i - 1 ] - H [ i ] > 1 ) { flag = 0 ; break ; } else if ( H [ i ] < H [ i - 1 ] ) { H [ i - 1 ] -= 1 ; } } for ( int i = 0 ; i < jsedjhl - 1 ; i ++ ) { if ( H [ i ] <= H [ i + 1 ] ) { flag = 1 ; } else { flag = 0 ; break ; } } if ( flag == 1 ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } out . flush ( ) ; } } import java . util . * ; import java . io . * ; class Dsruach { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dsruach = Integer . parseInt ( sc . next ( ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; out . print ( ( int ) ( dsruach + Math . pow ( dsruach , 2 ) + Math . pow ( dsruach , 3 ) ) ) ; out . flush ( ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Oaqee { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int oaqee = scan . nextInt ( ) ; int [ ] arr = new int [ oaqee ] ; for ( int i = 0 ; i < oaqee ; i ++ ) arr [ i ] = scan . nextInt ( ) ; for ( int i = 0 ; i < oaqee ; i ++ ) { int tmp = arr [ i ] , j = i ; for ( ; 0 < j && tmp <= arr [ j - 1 ] ; j -- ) arr [ j ] = arr [ j - 1 ] ; arr [ j ] = tmp ; for ( j = 0 ; j < oaqee ; j ++ ) System . out . print ( ( j == 0 ? " " : " " ) + arr [ j ] ) ; System . out . println ( ) ; } } } import java . util . * ; public class Wnkkt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] array = new int [ 3 ] ; int wnkkt = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } Arrays . sort ( array ) ; wnkkt = array [ 0 ] + array [ 1 ] ; System . out . println ( wnkkt ) ; } } import java . util . Scanner ; public class Egfxim { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long egfxim = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; b = Math . max ( Math . min ( egfxim + b - k , b ) , 0 ) ; egfxim = Math . max ( egfxim - k , 0 ) ; System . out . println ( egfxim + " " + b ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Yctfqsm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int yctfqsm = sc . nextInt ( ) ; if ( yctfqsm == 10 ) { System . out . println ( s . length ( ) ) ; } else { long n = 0 ; while ( Math . pow ( yctfqsm , n ) < Long . valueOf ( s ) + 1 ) { n ++ ; } System . out . println ( n ) ; } } } import java . util . * ; import java . math . BigDecimal ; public class Ysjpdmx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigDecimal L = new BigDecimal ( sc . next ( ) ) ; BigDecimal three = new BigDecimal ( " 3 " ) ; L = L . divide ( three , 6 , BigDecimal . ROUND_HALF_UP ) ; System . out . println ( L . multiply ( L ) . multiply ( L ) ) ; } } import java . util . Scanner ; class Dsyqe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dsyqe = 0 ; int W = 0 ; boolean flg = true ; while ( true ) { dsyqe = sc . nextInt ( ) ; W = sc . nextInt ( ) ; if ( dsyqe == 0 && W == 0 ) { break ; } for ( int i = 1 ; i <= dsyqe ; i ++ ) { if ( i % 2 == 0 ) { flg = false ; } else { flg = true ; } for ( int j = 1 ; j <= W ; j ++ ) { if ( flg == true ) { System . out . print ( " # " ) ; flg = false ; } else { System . out . print ( " . " ) ; flg = true ; } } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . io . * ; import java . util . Scanner ; import java . util . Arrays ; public class Nwcwef { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nwcwef = sc . nextInt ( ) ; if ( nwcwef % 2 == 0 ) { System . out . println ( " 0.5000000000 " ) ; } else { int s = nwcwef / 2 + 1 ; double ans = ( double ) s / nwcwef ; System . out . println ( String . format ( " %.10f " , ans ) ) ; } } } import java . util . Scanner ; public class Wqggc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder answer = new StringBuilder ( ) ; int wqggc = sc . nextInt ( ) ; int i = 1 ; if ( wqggc >= 3 && wqggc <= 10000 ) { while ( i <= wqggc ) { if ( i % 3 == 0 ) { answer . append ( " " ) . append ( String . valueOf ( i ) ) ; } else { int x ; x = i ; while ( x != 0 ) { if ( x % 10 == 3 ) { answer . append ( " " ) . append ( String . valueOf ( i ) ) ; break ; } x = x / 10 ; } } i ++ ; } } System . out . println ( answer . toString ( ) ) ; } } import java . util . Scanner ; public class Zxirxox { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zxirxox = sc . nextInt ( ) ; int ans = 0 ; for ( int a = 1 ; a <= zxirxox ; a ++ ) { for ( int b = 1 ; b <= zxirxox ; b ++ ) { for ( int c = 1 ; c <= zxirxox ; c ++ ) { ans += gcd ( a , b , c ) ; } } } System . out . println ( ans ) ; } public static int gcd ( int a , int b , int c ) { return gcd ( a , gcd ( b , c ) ) ; } public static int gcd ( int x , int y ) { int ret = 0 ; if ( x % y == 0 ) return y ; else { int z = x % y ; ret = gcd ( y , z ) ; } return ret ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Grzlshd { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; A solver = new A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Grzlshd { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String grzlshd = in . next ( ) ; if ( grzlshd . charAt ( 0 ) == 'A' && grzlshd . charAt ( 1 ) == 'A' && grzlshd . charAt ( 2 ) == 'A' ) { out . println ( " No " ) ; return ; } if ( grzlshd . charAt ( 0 ) == 'B' && grzlshd . charAt ( 1 ) == 'B' && grzlshd . charAt ( 2 ) == 'B' ) { out . println ( " No " ) ; return ; } out . println ( " Yes " ) ; } } } import java . util . * ; class Lukwlu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lukwlu = sc . nextInt ( ) ; int [ ] [ ] a = new int [ 2 ] [ lukwlu ] ; for ( int i = 0 ; i < lukwlu ; i ++ ) { a [ 0 ] [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < lukwlu ; i ++ ) { a [ 1 ] [ i ] = sc . nextInt ( ) ; } int x = 0 ; int y = 0 ; int max = 0 ; for ( int i = 0 ; i < lukwlu ; i ++ ) { x += a [ 0 ] [ i ] ; for ( int j = i ; j < lukwlu ; j ++ ) { y += a [ 1 ] [ j ] ; } if ( max < x + y ) { max = x + y ; } y = 0 ; } System . out . println ( max ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Rakiluo { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int rakiluo = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; scanner . nextLine ( ) ; List < Integer > alList = new ArrayList < > ( ) ; for ( int i = 1 ; i <= M ; i ++ ) { alList . add ( i ) ; } while ( scanner . hasNextLine ( ) ) { scanner . nextInt ( ) ; String string = scanner . nextLine ( ) ; String [ ] s = string . split ( " " ) ; List < String > kIntegers = new ArrayList < > ( ) ; for ( String k : s ) { kIntegers . add ( k ) ; } List < Integer > nothing = new ArrayList < > ( ) ; for ( int i = 1 ; i <= M ; i ++ ) { if ( ! kIntegers . contains ( String . valueOf ( i ) ) ) { nothing . add ( i ) ; } } alList . removeAll ( nothing ) ; } System . out . println ( alList . size ( ) ) ; } } import java . util . Scanner ; public class Mxybyk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; if ( s . length ( ) % 2 == 0 ) { System . out . println ( " Yes " ) ; return ; } int mxybyk = s . length ( ) ; String s1 = s . substring ( 0 , ( mxybyk - 1 ) / 2 ) ; String s2 = s . substring ( ( mxybyk + 3 ) / 2 - 1 , mxybyk ) ; String res = s2 + s . charAt ( ( mxybyk + 1 ) / 2 - 1 ) + s1 ; if ( res . equals ( s ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; sc . close ( ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; import java . util . List ; import java . util . ArrayList ; import java . util . Comparator ; import java . util . Arrays ; class Pmlibek { public static void main ( String [ ] args ) { int pmlibek = 0 ; Scanner scanner = new Scanner ( System . in ) ; int d = scanner . nextInt ( ) ; int n = scanner . nextInt ( ) ; switch ( d ) { case 0 : if ( n == 100 ) { System . out . println ( n + 1 ) ; } else { System . out . println ( n ) ; } break ; case 1 : if ( n == 100 ) { System . out . println ( n * 100 + 100 ) ; } else { System . out . println ( n * 100 ) ; } break ; case 2 : if ( n == 100 ) { System . out . println ( n * 10000 + 10000 ) ; } else { System . out . println ( n * 10000 ) ; } break ; } scanner . close ( ) ; } } import java . util . Scanner ; public class Jyvlyb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jyvlyb = sc . nextInt ( ) ; int max = 0 ; int count = 0 ; for ( int i = 0 ; i < jyvlyb ; i ++ ) { int temp = sc . nextInt ( ) ; if ( max <= temp ) { count ++ ; max = temp ; } } System . out . println ( count ) ; } } import java . util . * ; class Itios { public static void main ( String [ ] args ) { new Solver ( ) . run ( ) ; } } class Itios { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int itios = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = itios ; i <= B ; i ++ ) { char [ ] s = new StringBuilder ( ) . append ( i ) . toString ( ) . toCharArray ( ) ; boolean ok = true ; for ( int j = 0 ; j < 5 / 2 ; j ++ ) { if ( s [ j ] != s [ 4 - j ] ) { ok = false ; break ; } } if ( ok ) cnt ++ ; } System . out . println ( cnt ) ; return ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Pevttqs { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st ; PrintWriter pw = new PrintWriter ( System . out ) ; int pevttqs = Integer . parseInt ( br . readLine ( ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; char [ ] c1 = st . nextToken ( ) . toCharArray ( ) ; char [ ] c2 = st . nextToken ( ) . toCharArray ( ) ; for ( int i = 0 ; i < pevttqs ; i ++ ) { pw . print ( c1 [ i ] ) ; pw . print ( c2 [ i ] ) ; } pw . flush ( ) ; pw . close ( ) ; } } import java . util . * ; public class Qcvagy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qcvagy = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N + 1 ] ; int total = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; total += A [ i ] ; } if ( total >= qcvagy ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Gauriy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gauriy = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ m ] ; int s = 0 ; int v = - 1 ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) ; s += a [ i ] ; } if ( gauriy > s ) v = gauriy - s ; else if ( gauriy == s ) v = 0 ; else v = - 1 ; System . out . println ( v ) ; } } import java . util . * ; public class Hoqzwp { public static void main ( String [ ] args ) { int hoqzwp = 0 ; Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int d = Integer . parseInt ( sc . next ( ) ) ; int x , y ; for ( int i = 0 ; i < n ; i ++ ) { x = Integer . parseInt ( sc . next ( ) ) ; y = Integer . parseInt ( sc . next ( ) ) ; if ( d >= Math . sqrt ( Math . pow ( x , 2 ) + Math . pow ( y , 2 ) ) ) hoqzwp ++ ; } System . out . println ( hoqzwp ) ; } } import java . util . Scanner ; public class Xpygnwi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xpygnwi = scan . nextInt ( ) ; int [ ] W = new int [ xpygnwi ] ; int [ ] sub = new int [ xpygnwi ] ; int ans ; for ( int i = 0 ; i < xpygnwi ; i ++ ) { W [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < xpygnwi ; i ++ ) { int S1 = 0 , S2 = 0 ; for ( int k = i ; k >= 0 ; k -- ) { S1 = S1 + W [ k ] ; } for ( int k = i + 1 ; k < xpygnwi ; k ++ ) { S2 = S2 + W [ k ] ; } sub [ i ] = Math . abs ( S1 - S2 ) ; } ans = sub [ 0 ] ; for ( int n : sub ) { if ( ans > n ) { ans = n ; } } System . out . println ( ans ) ; scan . close ( ) ; } } import java . util . Scanner ; class Gqqqzs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; do { int gqqqzs = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; if ( gqqqzs == 0 && l == 0 ) { break ; } else { for ( int i = 0 ; i < gqqqzs ; i ++ ) { for ( int j = 0 ; j < l ; j ++ ) { System . out . print ( '#' ) ; } System . out . println ( ) ; } System . out . println ( ) ; } } while ( true ) ; } } import javax . print . DocFlavor ; import java . awt . * ; import java . io . PrintWriter ; import java . lang . reflect . Array ; import java . math . BigInteger ; import java . util . * ; import java . util . List ; public class Vgykqjq { static String br = System . getProperty ( " line.separator " ) ; static Scanner sc = new Scanner ( System . in ) ; static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) { int vgykqjq = nextInt ( ) ; int B = nextInt ( ) ; if ( vgykqjq == 1 ) { if ( B == 3 ) { println ( 2 ) ; return ; } else { println ( 3 ) ; return ; } } else if ( vgykqjq == 2 ) { if ( B == 1 ) { println ( 3 ) ; return ; } else { println ( 1 ) ; return ; } } else { if ( B == 1 ) { println ( 2 ) ; return ; } else { println ( 1 ) ; return ; } } } static int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } static Long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } static String next ( ) { return sc . next ( ) ; } static String nextLine ( ) { return sc . nextLine ( ) ; } static void println ( Object o ) { out . println ( o ) ; out . flush ( ) ; } static void print ( Object o ) { PrintWriter out = new PrintWriter ( System . out ) ; out . print ( o ) ; out . flush ( ) ; } } import java . io . * ; import java . util . * ; class Lkiqnz { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int lkiqnz ; int j ; while ( true ) { String [ ] str = br . readLine ( ) . split ( " " ) ; int h = Integer . parseInt ( str [ 0 ] ) ; int w = Integer . parseInt ( str [ 1 ] ) ; if ( h == 0 || w == 0 ) break ; for ( lkiqnz = 0 ; lkiqnz < h ; lkiqnz ++ ) { System . out . print ( " " ) ; for ( j = 0 ; j < w - 1 ; j ++ ) { if ( ( lkiqnz % 2 != 0 && j % 2 == 0 ) ^ ( lkiqnz % 2 == 0 && j % 2 != 0 ) ) { System . out . print ( " . " ) ; } else { System . out . print ( " # " ) ; } } if ( ( lkiqnz % 2 != 0 && j % 2 == 0 ) ^ ( lkiqnz % 2 == 0 && j % 2 != 0 ) ) { System . out . println ( " . " ) ; } else { System . out . println ( " # " ) ; } } System . out . print ( " \n " ) ; } } } import java . util . * ; public class Yblloco { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] num = new int [ 5 ] ; for ( int yblloco = 0 ; yblloco < 5 ; yblloco ++ ) { num [ yblloco ] = sc . nextInt ( ) ; } int k = sc . nextInt ( ) ; String result = " Yay! " ; out : for ( int yblloco = 0 ; yblloco < 5 ; yblloco ++ ) { for ( int j = yblloco + 1 ; j < 5 ; j ++ ) { if ( Math . abs ( num [ yblloco ] - num [ j ] ) > k ) { result = " :( " ; break out ; } } } System . out . println ( result ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Yjwakx { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int yjwakx = stdIn . nextInt ( ) ; int [ ] d = new int [ yjwakx ] ; List < Integer > list = new ArrayList < > ( ) ; int cnt = 0 ; for ( int i = 0 ; i < yjwakx ; i ++ ) { int a = stdIn . nextInt ( ) ; if ( ! list . contains ( a ) ) { list . add ( a ) ; cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Yxsdsjo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String yxsdsjo = scan . next ( ) ; System . out . println ( yxsdsjo . equals ( " ABC " ) ? " ARC " : " ABC " ) ; } } import java . util . Scanner ; public class Lundv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double lundv = sc . nextDouble ( ) ; double h = sc . nextDouble ( ) ; double x = sc . nextDouble ( ) ; double y = sc . nextDouble ( ) ; System . out . print ( h * lundv / 2.0 ) ; System . out . print ( " " ) ; if ( x == lundv / 2.0 && y == h / 2.0 ) System . out . print ( 1 ) ; else System . out . print ( 0 ) ; } } import java . util . Scanner ; public class Lknswe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String N_str = sc . next ( ) ; String [ ] N_list = N_str . split ( " " ) ; int lknswe = 0 ; for ( int i = 0 ; i < N_list . length ; i ++ ) { lknswe += Integer . parseInt ( N_list [ i ] ) ; } if ( lknswe % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Wxuqqfr { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Wxuqqfr { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String wxuqqfr = in . next ( ) ; String t = in . next ( ) ; out . println ( wxuqqfr . equals ( t . substring ( 0 , wxuqqfr . length ( ) ) ) ? " Yes " : " No " ) ; } } } import java . util . * ; public class Dodrp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] ABC = new int [ 3 ] ; for ( int dodrp = 0 ; dodrp < 3 ; dodrp ++ ) { ABC [ dodrp ] = sc . nextInt ( ) ; } Arrays . sort ( ABC ) ; boolean flg = false ; if ( ABC [ 0 ] == 5 ) { if ( ABC [ 1 ] == 5 ) { if ( ABC [ 2 ] == 7 ) { flg = true ; } } } if ( flg ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; import static java . lang . Integer . * ; import static java . lang . System . * ; import java . io . PrintWriter ; public class Lgdheqs { public static void main ( String [ ] args ) { int lgdheqs , j , k ; Scanner sc = new Scanner ( in ) ; int n = parseInt ( sc . next ( ) ) ; sc . close ( ) ; int [ ] so = { 3 * 5 * 7 , 3 * 5 * 11 , 3 * 5 * 13 , 3 * 3 * 3 * 5 , 3 * 3 * 3 * 7 } ; int cnt = 0 ; for ( lgdheqs = 0 ; lgdheqs < so . length ; lgdheqs ++ ) { if ( so [ lgdheqs ] <= n ) cnt ++ ; } out . println ( cnt ) ; } } import java . util . Scanner ; public class Raoqa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long raoqa = sc . nextLong ( ) ; String b = sc . next ( ) ; b = b . replace ( " . " , " " ) ; int bb = Integer . parseInt ( b ) ; System . out . println ( raoqa * bb / 100 ) ; } } import java . util . Scanner ; public class Wfjzz { public static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int wfjzz , sum ; wfjzz = nextInt ( ) ; sum = 0 ; int [ ] arr = new int [ wfjzz ] ; for ( int i = 0 ; i < wfjzz ; i ++ ) { arr [ i ] = nextInt ( ) ; } for ( int i = 0 ; i < wfjzz - 1 ; i ++ ) { for ( int j = i + 1 ; j < wfjzz ; j ++ ) { sum += arr [ i ] * arr [ j ] ; } } print ( sum ) ; } public static int nextInt ( ) { return Integer . parseInt ( scan . next ( ) ) ; } public static long nextLong ( ) { return Long . parseLong ( scan . next ( ) ) ; } public static String next ( ) { return scan . next ( ) ; } public static double nextDouble ( ) { return Double . parseDouble ( scan . next ( ) ) ; } public static float nextFloat ( ) { return Float . parseFloat ( scan . next ( ) ) ; } public static void yesNo ( boolean flag ) { if ( flag ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void print ( Object a ) { System . out . println ( a ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Zfcaqx { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int zfcaqx , t ; int [ ] data = new int [ 3 ] ; zfcaqx = cin . nextInt ( ) ; while ( zfcaqx -- > 0 ) { for ( int i = 0 ; i < 3 ; i ++ ) { t = cin . nextInt ( ) ; data [ i ] = t * t ; } Arrays . sort ( data ) ; if ( data [ 0 ] + data [ 1 ] == data [ 2 ] ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } } import java . util . * ; class Updulc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; sc . close ( ) ; int updulc = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . substring ( i , i + 1 ) . equals ( T . substring ( i , i + 1 ) ) ) updulc ++ ; } System . out . println ( updulc ) ; } } import java . util . * ; class Rlpfy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rlpfy , ans ; while ( sc . hasNext ( ) ) { rlpfy = sc . nextInt ( ) ; ans = 100000 ; for ( int i = 0 ; i < rlpfy ; i ++ ) { ans += ans / 20 ; if ( ans != ( ans = ans / 1000 * 1000 ) ) { ans += 1000 ; } } System . out . println ( ans ) ; } } } import java . util . * ; public class Lyxyivm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int lyxyivm = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int ans = 0 ; int p = lyxyivm + M ; switch ( p ) { case 3 : ans = 3 ; break ; case 5 : ans = 1 ; break ; case 4 : ans = 2 ; break ; } System . out . println ( ans ) ; } } import java . util . * ; class Fkklwmh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fkklwmh = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int t = ( y - 2 * fkklwmh ) / 2 ; int c = fkklwmh - t ; if ( t < 0 || c < 0 || y % 2 == 1 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Cczgdge { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; String T = scanner . next ( ) ; int cczgdge = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == T . charAt ( i ) ) continue ; cczgdge ++ ; } System . out . println ( cczgdge ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Rykixbq { public static void main ( String [ ] args ) { InputStreamReader in = new InputStreamReader ( System . in ) ; BufferedReader bufferedReader = new BufferedReader ( in ) ; try { String input = bufferedReader . readLine ( ) ; String [ ] inputsArrays = input . split ( " " ) ; int rykixbq = Integer . parseInt ( inputsArrays [ 0 ] ) ; int X = Integer . parseInt ( inputsArrays [ 1 ] ) ; int T = Integer . parseInt ( inputsArrays [ 2 ] ) ; int timeTaken = 0 ; while ( rykixbq > 0 ) { timeTaken += T ; rykixbq -= X ; } System . out . println ( timeTaken ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . * ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; public class Xgqixkr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xgqixkr = scan . nextInt ( ) ; System . out . println ( xgqixkr + xgqixkr * xgqixkr + xgqixkr * xgqixkr * xgqixkr ) ; } } import java . util . * ; import java . io . * ; class Oxtwtjg { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; if ( line . length ( ) <= 20 && line . length ( ) > 0 ) { char [ ] str = line . toCharArray ( ) ; for ( int oxtwtjg = str . length - 1 ; oxtwtjg >= 0 ; oxtwtjg -- ) { System . out . print ( str [ oxtwtjg ] ) ; } } else { System . exit ( 0 ) ; } System . out . println ( " " ) ; System . exit ( 0 ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Pvhvvap { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int pvhvvap = in . nextInt ( ) ; int k = in . nextInt ( ) ; System . out . println ( solve ( pvhvvap , k ) ) ; in . close ( ) ; } private static double solve ( int pvhvvap , int k ) { double r = 0 ; for ( int i = 1 ; i <= pvhvvap ; i ++ ) { int p = i ; double x = 1 ; x /= pvhvvap ; while ( p < k ) { p *= 2 ; x /= 2 ; } r += x ; } return r ; } } import java . util . * ; public class Okntg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int okntg , B , T ; okntg = sc . nextInt ( ) ; B = sc . nextInt ( ) ; T = sc . nextInt ( ) ; int result = ( T / okntg ) * B ; System . out . println ( result ) ; } } import java . util . Scanner ; public class Oxzma { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int oxzma = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; if ( B == 1 ) { System . out . println ( 0 ) ; return ; } int count = 0 ; while ( ( oxzma * count - ( count - 1 ) ) < B ) { count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Lztqz { public static int g ( long x ) { int lztqz = 0 ; while ( x > 0 ) { ++ lztqz ; x /= 10 ; } return lztqz ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; int lztqz = Integer . MAX_VALUE ; for ( long i = 1 ; i * i <= N ; ++ i ) { if ( N % i == 0 ) { long a = N / i ; lztqz = Math . min ( lztqz , Math . max ( g ( i ) , g ( a ) ) ) ; } } System . out . println ( lztqz ) ; } } import java . io . * ; import java . util . * ; public class Atlldbq { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int atlldbq = sc . nextInt ( ) ; int [ ] a = new int [ atlldbq ] ; int sum = 0 ; for ( int i = 0 ; i < atlldbq ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int i = 0 ; i < atlldbq - 1 ; i ++ ) { sum += a [ i ] ; } System . out . println ( a [ atlldbq - 1 ] < sum ? " Yes " : " No " ) ; } public static PrintWriter out ; public static class Atlldbq { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } import java . util . Scanner ; public class Wsoxh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wsoxh = scan . nextInt ( ) ; scan . close ( ) ; long sum = 0 ; for ( int a = 1 ; a <= wsoxh ; a ++ ) { for ( int b = 1 ; b <= wsoxh ; b ++ ) { for ( int c = 1 ; c <= wsoxh ; c ++ ) { sum += gcd ( a , gcd ( b , c ) ) ; } } } System . out . println ( sum ) ; } public static int gcd ( int a , int b ) { int r = a % b ; while ( r != 0 ) { a = b ; b = r ; r = a % b ; } return b ; } } import java . util . Scanner ; class Ckqhkwg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ckqhkwg , c , e = 0 ; ckqhkwg = scan . nextInt ( ) ; c = scan . nextInt ( ) ; int [ ] [ ] a = new int [ ckqhkwg ] [ c ] ; for ( int i = 0 ; i < ckqhkwg ; i ++ ) { int b = 0 ; for ( int j = 0 ; j < c ; j ++ ) { a [ i ] [ j ] = scan . nextInt ( ) ; b += a [ i ] [ j ] ; System . out . print ( a [ i ] [ j ] + " " ) ; } e += b ; System . out . println ( b ) ; } for ( int i = 0 ; i < c ; i ++ ) { int d = 0 ; for ( int j = 0 ; j < ckqhkwg ; j ++ ) { d += a [ j ] [ i ] ; } System . out . print ( d + " " ) ; } System . out . println ( e ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class Xfftgxi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigDecimal a = sc . nextBigDecimal ( ) ; BigDecimal b = sc . nextBigDecimal ( ) ; BigDecimal c = b . multiply ( a ) ; long xfftgxi = c . longValue ( ) ; System . out . println ( xfftgxi ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Bfazl { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int bfazl , B , C , mili = 0 ; bfazl = reader . nextInt ( ) ; B = reader . nextInt ( ) ; C = reader . nextInt ( ) ; mili = ( B + C ) - bfazl ; if ( mili > 0 ) { System . out . println ( mili ) ; } else { System . out . println ( 0 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; public class Bbljpqd { public static void main ( String [ ] args ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; PrintWriter out = new PrintWriter ( System . out ) ; try { String strData = br . readLine ( ) ; String [ ] strDat = strData . split ( " " , - 1 ) ; int bbljpqd = Integer . parseInt ( strDat [ 0 ] ) ; int intGate = Integer . parseInt ( strDat [ 1 ] ) ; int [ ] intL = new int [ intGate ] ; int [ ] intR = new int [ intGate ] ; int intSt ; int intEd ; intSt = 0 ; intEd = bbljpqd ; for ( int i = 0 ; i < intGate ; i ++ ) { strData = br . readLine ( ) ; strDat = strData . split ( " " , - 1 ) ; intL [ i ] = Integer . parseInt ( strDat [ 0 ] ) ; intR [ i ] = Integer . parseInt ( strDat [ 1 ] ) ; if ( intL [ i ] > intSt ) intSt = intL [ i ] ; if ( intR [ i ] < intEd ) intEd = intR [ i ] ; } int ans = 0 ; ans = intEd - intSt + 1 ; if ( ans < 0 ) ans = 0 ; System . out . println ( ans ) ; out . flush ( ) ; } catch ( IOException e ) { } } } import java . util . * ; class Gtkix { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gtkix = sc . nextInt ( ) ; int [ ] v = new int [ gtkix ] ; for ( int c = 0 ; c < gtkix ; c ++ ) { v [ c ] = sc . nextInt ( ) ; } Arrays . sort ( v ) ; double ans = ( double ) v [ 0 ] ; for ( int d = 1 ; d < gtkix ; d ++ ) { ans = ( ans + v [ d ] ) / 2 ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Phmmle { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int phmmle = sc . nextInt ( ) ; sc . nextLine ( ) ; final List < Integer > ls = new ArrayList < > ( ) ; int max = - 1 ; int maxId = - 1 ; for ( int i = 0 ; i < phmmle ; i ++ ) { final int l = sc . nextInt ( ) ; ls . add ( l ) ; if ( l > max ) { max = l ; maxId = i ; } } int sum = 0 ; for ( int i = 0 ; i < phmmle ; i ++ ) { if ( i == maxId ) { continue ; } sum += ls . get ( i ) ; } if ( max < sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Neihu { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int neihu = scanner . nextInt ( ) ; int ans = neihu + ( int ) Math . pow ( neihu , 2 ) + ( int ) Math . pow ( neihu , 3 ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; class Ecbijp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ecbijp = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 1 ; i <= ecbijp ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( i != tmp ) { cnt ++ ; } } if ( cnt == 0 || cnt == 2 ) { System . out . print ( " YES " ) ; } else { System . out . print ( " NO " ) ; } } } import java . util . Scanner ; public class Tzwcmo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tzwcmo = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < tzwcmo ; i ++ ) { if ( i == k - 1 ) { sb . appendCodePoint ( s . charAt ( i ) + 32 ) ; } else { sb . append ( s . charAt ( i ) ) ; } } System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; public class Sblbup { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long sblbup = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long cnt = sblbup / ( a + b ) * a ; sblbup %= ( a + b ) ; cnt += Math . min ( a , sblbup ) ; System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Tfcvhg { public static int eukleides ( int a , int b ) { if ( b % a == 0 ) { return a ; } int tfcvhg = b % a ; return eukleides ( tfcvhg , a ) ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int border = scan . nextInt ( ) ; int gcd = eukleides ( Math . min ( a , b ) , Math . max ( a , b ) ) ; int count = 0 ; for ( int i = gcd ; i >= 1 ; i -- ) { if ( gcd % i == 0 ) { count ++ ; } if ( count == border ) { System . out . println ( i ) ; break ; } } } } import java . util . * ; import java . io . * ; class Jkkhk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jkkhk = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] l = new int [ jkkhk ] ; for ( int i = 0 ; i < jkkhk ; i ++ ) l [ i ] = sc . nextInt ( ) ; int point = 0 , cnt = 1 ; for ( int i = 0 ; i < jkkhk ; i ++ ) { point += l [ i ] ; if ( point <= x ) cnt ++ ; else break ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Egbvktu { public static void swap ( int [ ] A , int a , int b ) { int egbvktu = A [ a ] ; A [ a ] = A [ b ] ; A [ b ] = egbvktu ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int cnt = 0 ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { int min = i ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( a [ j ] < a [ min ] ) min = j ; } if ( i != min ) { swap ( a , i , min ) ; cnt ++ ; } } for ( int i = 0 ; i < n - 1 ; i ++ ) System . out . printf ( " %d " , a [ i ] ) ; System . out . println ( a [ n - 1 ] ) ; System . out . println ( cnt ) ; } } import java . util . * ; class Cexof { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int cexof = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; long [ ] dp = new long [ cexof + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { int a = scanner . nextInt ( ) ; dp [ a ] = - 1 ; } dp [ 0 ] = 1 ; if ( dp [ 1 ] == 0 ) { dp [ 1 ] = 1 ; } else { dp [ 1 ] = 0 ; } for ( int i = 2 ; i <= cexof ; i ++ ) { if ( dp [ i ] >= 0 ) { dp [ i ] = ( dp [ i - 1 ] + dp [ i - 2 ] ) % 1000000007 ; } else { dp [ i ] = 0 ; } } System . out . println ( dp [ cexof ] ) ; } } import java . util . Scanner ; public class Jeugtm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jeugtm = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; sc . close ( ) ; int maiX = 0 , maiY = 0 , maiZ = 0 ; int kaiX = - 1 , kaiY = - 1 , kaiZ = - 1 ; for ( maiX = 0 ; maiX <= jeugtm ; maiX ++ ) { if ( kaiX != - 1 ) { break ; } if ( maiX * 10000 > Y ) { break ; } for ( maiZ = 0 ; maiX + maiZ <= jeugtm ; maiZ ++ ) { maiY = jeugtm - ( maiX + maiZ ) ; if ( maiX * 10000 + maiY * 5000 + maiZ * 1000 == Y ) { kaiX = maiX ; kaiY = maiY ; kaiZ = maiZ ; break ; } } } System . out . println ( kaiX + " " + kaiY + " " + kaiZ ) ; } } import java . util . Scanner ; public class Qqgbxxy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qqgbxxy = scan . nextInt ( ) ; boolean flag = false ; for ( int i = 0 ; i <= 25 ; i ++ ) { for ( int j = 0 ; j <= 14 ; j ++ ) { int a = 7 * j + i * 4 ; if ( qqgbxxy == a ) { flag = true ; } } } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Tfrcu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tfrcu = sc . nextInt ( ) ; int [ ] h = new int [ tfrcu ] ; for ( int i = 0 ; i < tfrcu ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int tmp = 0 ; int count = 0 ; do { tmp = count ; int min = 100 ; int index = 0 ; int lastValue = 0 ; for ( int i = 0 ; i < tfrcu ; i ++ ) { if ( h [ i ] == 0 ) { if ( lastValue == 0 ) { index = i + 1 ; continue ; } for ( int j = index ; j < i ; j ++ ) { h [ j ] -= min ; } count += min ; min = 100 ; index = i + 1 ; lastValue = 0 ; } else if ( i == tfrcu - 1 ) { min = ( min < h [ i ] ) ? min : h [ i ] ; for ( int j = index ; j <= i ; j ++ ) { h [ j ] -= min ; } count += min ; min = 100 ; index = i + 1 ; } min = ( min < h [ i ] ) ? min : h [ i ] ; lastValue = h [ i ] ; } } while ( tmp != count ) ; System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . ArrayList ; import java . util . Collections ; public class Ahjln { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ahjln = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; ArrayList < String > S = new ArrayList < > ( ) ; for ( int i = 0 ; i < ahjln ; i ++ ) { S . add ( sc . next ( ) ) ; } Collections . sort ( S ) ; for ( int i = 0 ; i < ahjln ; i ++ ) System . out . print ( S . get ( i ) ) ; sc . close ( ) ; } } import java . util . * ; public class Ryohd { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ryohd = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int five = 0 ; int seven = 0 ; if ( ryohd == 5 ) { five ++ ; } else if ( ryohd == 7 ) { seven ++ ; } if ( b == 5 ) { five ++ ; } else if ( b == 7 ) { seven ++ ; } if ( c == 5 ) { five ++ ; } else if ( c == 7 ) { seven ++ ; } if ( five == 2 && seven == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Rnpvgxs { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new java . io . InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; double rnpvgxs = Double . parseDouble ( st . nextToken ( ) ) ; double B = Double . parseDouble ( st . nextToken ( ) ) ; double H = Double . parseDouble ( st . nextToken ( ) ) ; double M = Double . parseDouble ( st . nextToken ( ) ) ; double angle_H = ( 60 * H + M ) / 720 * 360 ; double angle_M = M / 60 * 360 ; double A_x = rnpvgxs * Math . cos ( Math . toRadians ( angle_H ) ) ; double A_y = rnpvgxs * Math . sin ( Math . toRadians ( angle_H ) ) ; double B_x = B * Math . cos ( Math . toRadians ( angle_M ) ) ; double B_y = B * Math . sin ( Math . toRadians ( angle_M ) ) ; double ans = Math . sqrt ( Math . pow ( ( A_x - B_x ) , 2 ) + Math . pow ( ( A_y - B_y ) , 2 ) ) ; pw . println ( ans ) ; br . close ( ) ; pw . close ( ) ; } } import java . util . * ; class Puapk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] devider = { " maerd " , " remaerd " , " esare " , " resare " } ; String str = new StringBuffer ( sc . nextLine ( ) ) . reverse ( ) . toString ( ) ; boolean puapk = true ; for ( int i = 0 ; i < str . length ( ) ; ) { boolean flag2 = false ; for ( int j = 0 ; j < 4 ; j ++ ) { String d = devider [ j ] ; String d2 = str . substring ( i , i ) ; if ( ( i + d . length ( ) ) <= str . length ( ) ) { d2 = str . substring ( i , i + d . length ( ) ) ; } if ( d2 . equals ( d ) ) { flag2 = true ; i += d . length ( ) ; } } if ( ! flag2 ) { puapk = false ; break ; } } System . out . println ( puapk ? " YES " : " NO " ) ; } } import java . util . Scanner ; public class Rvuop { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int rvuop = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; sc . close ( ) ; int bb = ( Y - 2 * rvuop ) ; if ( bb % 2 != 0 || bb < 0 ) { System . out . println ( " No " ) ; return ; } int b = bb / 2 ; int a = rvuop - b ; if ( a >= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } return ; } } import java . util . Scanner ; public class Dusxs { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long dusxs = in . nextInt ( ) ; long sum = 0 ; for ( long i = 0 ; i <= dusxs ; i ++ ) { if ( i % 3 != 0 && i % 5 != 0 ) sum += i ; } System . out . println ( sum ) ; } } import java . util . * ; public class Irxpk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int irxpk = S . length ( ) ; char [ ] tmp ; tmp = new char [ irxpk ] ; for ( int i = 0 ; i < irxpk ; i ++ ) { tmp [ i ] = 'x' ; } System . out . println ( tmp ) ; } } import java . io . * ; class Dackf { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int dackf = Integer . parseInt ( br . readLine ( ) ) ; double result = 100000 ; for ( int i = 0 ; i < dackf ; i ++ ) { result *= 1.05 ; result = Math . ceil ( result / 1000 ) * 1000 ; } System . out . println ( ( int ) result ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Vovai { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vovai = sc . nextInt ( ) ; int [ ] ary = new int [ vovai ] ; for ( int i = 0 ; i < ary . length ; i ++ ) { ary [ i ] = sc . nextInt ( ) ; } Arrays . sort ( ary ) ; long sum = 0 ; for ( int i = 0 ; i < ary . length ; i ++ ) { sum += ary [ i ] ; } System . out . printf ( " %d %d %d%n " , ary [ 0 ] , ary [ vovai - 1 ] , sum ) ; } } import java . util . Scanner ; public class Yfdlfk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long yfdlfk = scanner . nextLong ( ) ; long k = scanner . nextLong ( ) ; int len = 0 ; if ( yfdlfk == 0 ) { System . out . println ( 1 ) ; return ; } while ( yfdlfk > 0 ) { ++ len ; yfdlfk /= k ; } System . out . println ( len ) ; } } import java . util . Scanner ; public class Mfebu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mfebu = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ mfebu ] ; int [ ] c = new int [ mfebu ] ; int ans = 0 ; for ( int i = 0 ; i < mfebu ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < mfebu ; i ++ ) { ans += Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 1 ; i < mfebu ; i ++ ) { c [ i ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < mfebu - 1 ; i ++ ) { if ( a [ i ] + 1 == a [ i + 1 ] ) { ans += c [ a [ i ] ] ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Dckrnse { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dckrnse = sc . nextInt ( ) ; int [ ] a = new int [ dckrnse ] ; int count1 = 0 ; for ( int i = 0 ; i < dckrnse ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( a [ i ] == 1 ) { count1 ++ ; } } if ( count1 == 0 ) { System . out . println ( - 1 ) ; return ; } int ans = 0 ; int num = 1 ; for ( int i = 0 ; i < dckrnse ; i ++ ) { if ( a [ i ] == num ) { num ++ ; } else { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Mmkobfi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mmkobfi = scan . nextInt ( ) ; for ( int i = 0 ; i < mmkobfi ; i ++ ) { int a = scan . nextInt ( ) ; if ( a % 2 == 0 && ! ( a % 3 == 0 || a % 5 == 0 ) ) { System . out . println ( " DENIED " ) ; scan . close ( ) ; return ; } } System . out . println ( " APPROVED " ) ; scan . close ( ) ; return ; } } import java . util . Scanner ; public class Mbglqas { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { String str = scan . nextLine ( ) ; if ( str . equals ( " 0 " ) ) break ; int mbglqas = 0 ; char [ ] box = str . toCharArray ( ) ; for ( int i = 0 ; i < box . length ; i ++ ) mbglqas += box [ i ] - '0' ; System . out . println ( mbglqas ) ; } } } import java . util . * ; public class Bdgwz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bdgwz = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < > ( ) ; String s = sc . next ( ) ; list . add ( s ) ; String lastWord = s . split ( " " ) [ s . length ( ) - 1 ] ; boolean ruled = true ; for ( int i = 1 ; i < bdgwz ; i ++ ) { String value = sc . next ( ) ; if ( list . contains ( value ) ) { ruled = false ; break ; } else if ( ! value . substring ( 0 , 1 ) . equals ( lastWord ) ) { ruled = false ; break ; } lastWord = value . split ( " " ) [ value . length ( ) - 1 ] ; list . add ( value ) ; } System . out . println ( ruled ? " Yes " : " No " ) ; } } import java . math . BigDecimal ; import java . math . RoundingMode ; import java . util . Scanner ; public class Odshf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigDecimal a = new BigDecimal ( sc . next ( ) ) ; BigDecimal b = new BigDecimal ( sc . next ( ) ) ; System . out . println ( a . multiply ( b ) . setScale ( 0 , RoundingMode . DOWN ) ) ; } } import java . util . * ; public class Stychrx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int stychrx = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int cnt = 0 ; while ( stychrx > 0 ) { cnt ++ ; stychrx = ( stychrx / l ) ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Tungwrg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tungwrg = sc . nextInt ( ) ; int [ ] v = new int [ tungwrg ] ; int [ ] c = new int [ tungwrg ] ; int [ ] a = new int [ tungwrg ] ; for ( int i = 0 ; i < tungwrg ; i ++ ) { v [ i ] = sc . nextInt ( ) ; } for ( int j = 0 ; j < tungwrg ; j ++ ) { c [ j ] = sc . nextInt ( ) ; a [ j ] = v [ j ] - c [ j ] ; } int ans = 0 ; for ( int i = 0 ; i < tungwrg ; i ++ ) { if ( a [ i ] >= 0 ) { ans += a [ i ] ; } } System . out . println ( ans ) ; } } import java . io . * ; public class Wiwcwrk { public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int wiwcwrk , n , right , left , x ; String str ; wiwcwrk = Integer . parseInt ( bf . readLine ( ) ) ; n = Integer . parseInt ( bf . readLine ( ) ) ; int [ ] order = new int [ wiwcwrk ] ; for ( int i = 0 ; i < wiwcwrk ; i ++ ) { order [ i ] = i + 1 ; } for ( int i = 0 ; i < 2 * n ; i += 2 ) { str = bf . readLine ( ) ; String [ ] deta = str . split ( " , " , 0 ) ; left = Integer . parseInt ( deta [ 0 ] ) ; right = Integer . parseInt ( deta [ 1 ] ) ; x = order [ left - 1 ] ; order [ left - 1 ] = order [ right - 1 ] ; order [ right - 1 ] = x ; } for ( int i = 0 ; i < wiwcwrk ; i ++ ) { System . out . println ( order [ i ] ) ; } } } import java . util . * ; public class Zzluj { public static void main ( String [ ] args ) { boolean zzluj = false ; Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s1 = String . valueOf ( a ) ; String s2 = String . valueOf ( b ) ; double n = Integer . parseInt ( s1 + s2 ) ; int h = ( int ) Math . sqrt ( n ) ; if ( Math . sqrt ( n ) == h ) { System . out . println ( " Yes " ) ; } else System . out . println ( " No " ) ; sc . close ( ) ; } } import java . util . * ; import java . lang . * ; import java . util . stream . * ; public class Errks { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Long x = scanner . nextLong ( ) ; Long y = scanner . nextLong ( ) ; Long z = scanner . nextLong ( ) ; Long rest_of_takahshi_cokie = x - z ; Long rest_of_aoki_cokie = rest_of_takahshi_cokie + y ; if ( rest_of_takahshi_cokie > 0 ) { System . out . println ( rest_of_takahshi_cokie + " " + y ) ; } else { if ( rest_of_aoki_cokie < 0 ) { System . out . println ( 0 + " " + 0 ) ; } else { System . out . println ( 0 + " " + rest_of_aoki_cokie ) ; } } } } import java . io . * ; import java . util . * ; public class Vuwnh { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter output = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( input . readLine ( ) ) ; int vuwnh = Integer . parseInt ( st . nextToken ( ) ) ; int K = Integer . parseInt ( st . nextToken ( ) ) ; st = new StringTokenizer ( input . readLine ( ) ) ; int [ ] arr = new int [ vuwnh ] ; int [ ] dp = new int [ vuwnh + 1 ] ; Arrays . fill ( dp , Integer . MAX_VALUE ) ; dp [ 0 ] = 0 ; for ( int i = 0 ; i < vuwnh ; i ++ ) { arr [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; } for ( int i = 0 ; i < vuwnh ; i ++ ) { for ( int k = 1 ; k < K + 1 ; k ++ ) { if ( i + k < vuwnh ) dp [ i + k ] = Math . min ( dp [ i + k ] , dp [ i ] + Math . abs ( arr [ i ] - arr [ i + k ] ) ) ; } } output . println ( dp [ vuwnh - 1 ] ) ; output . close ( ) ; } } import java . util . * ; public class Pltloop { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] line1 = line . split ( " " ) ; int pltloop = Integer . parseInt ( line1 [ 0 ] ) ; int k = Integer . parseInt ( line1 [ 1 ] ) ; int q = Integer . parseInt ( line1 [ 2 ] ) ; int [ ] ary = new int [ pltloop ] ; for ( int i = 0 ; i < pltloop ; i ++ ) ary [ i ] = k - q ; for ( int i = 0 ; i < q ; i ++ ) { int a = sc . nextInt ( ) ; ary [ a - 1 ] ++ ; } for ( int i = 0 ; i < pltloop ; i ++ ) { if ( ary [ i ] <= 0 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } } import java . util . * ; public class Nlthj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nlthj = sc . nextInt ( ) ; long d = sc . nextInt ( ) ; d = d * d ; int cnt = 0 ; for ( int i = 0 ; i < nlthj ; i ++ ) { long x = sc . nextInt ( ) ; long y = sc . nextInt ( ) ; if ( d >= x * x + y * y ) cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Ojycp { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ojycp = in . nextInt ( ) ; int b = in . nextInt ( ) ; int sum1 = 0 , sum2 = 0 , sum = 0 ; ojycp = ojycp - 1 ; b = b - 1 ; sum1 = ( ojycp * ( ojycp + 1 ) ) / 2 ; sum2 = ( b * ( b + 1 ) ) / 2 ; sum = sum1 + sum2 ; System . out . println ( sum ) ; } } import java . util . Scanner ; public class Pphktpx { public static int pphktpx ( int a , int b , int c ) { int pphktpx = 0 ; pphktpx = pphktpx + Math . abs ( b - a ) + Math . abs ( c - b ) ; return ( pphktpx ) ; } public static void main ( String [ ] args ) { int A = 0 ; int B = 0 ; int C = 0 ; Scanner in = new Scanner ( System . in ) ; A = Integer . parseInt ( in . next ( ) ) ; B = Integer . parseInt ( in . next ( ) ) ; C = Integer . parseInt ( in . next ( ) ) ; in . close ( ) ; int [ ] costSum = new int [ 6 ] ; costSum [ 0 ] = pphktpx ( A , B , C ) ; costSum [ 1 ] = pphktpx ( A , C , B ) ; costSum [ 2 ] = pphktpx ( B , A , C ) ; costSum [ 3 ] = pphktpx ( B , C , A ) ; costSum [ 4 ] = pphktpx ( C , A , B ) ; costSum [ 5 ] = pphktpx ( C , B , A ) ; int min = costSum [ 0 ] ; for ( int i = 0 ; i < costSum . length ; i ++ ) { if ( min > costSum [ i ] ) { min = costSum [ i ] ; } } System . out . println ( min ) ; } } import java . util . * ; public class Iisubo { private static final int iisubo = Integer . MAX_VALUE ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = 0 ; int r = iisubo ; for ( int tmp = 0 ; tmp < m ; tmp ++ ) { int x = sc . nextInt ( ) ; l = Math . max ( x , l ) ; int y = sc . nextInt ( ) ; r = Math . min ( y , r ) ; } System . out . println ( l <= r ? r - l + 1 : 0 ) ; } } import java . util . Scanner ; public class Xigkb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; int xigkb = Integer . parseInt ( n ) ; int [ ] sn = new int [ n . length ( ) ] ; int S = 0 ; sc . close ( ) ; for ( int i = 0 ; i < n . length ( ) ; i ++ ) { sn [ i ] = Integer . parseInt ( n . substring ( i , i + 1 ) ) ; S += sn [ i ] ; } if ( xigkb % S == 0 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; import java . util . Collections ; public class Phslua { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int phslua = sc . nextInt ( ) ; HashSet < Integer > A = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < phslua ; i ++ ) { A . add ( sc . nextInt ( ) ) ; } System . out . println ( A . size ( ) ) ; } } import java . util . * ; public class Xaopeqb { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int xaopeqb = sc . nextInt ( ) ; int [ ] a = new int [ xaopeqb ] ; for ( int i = 0 ; i < xaopeqb ; i ++ ) a [ i ] = sc . nextInt ( ) ; int t = a [ 0 ] ; long sum = 0 ; for ( int i = 1 ; i < xaopeqb ; i ++ ) { if ( t > a [ i ] ) sum = sum + ( t - a [ i ] ) ; else { t = a [ i ] ; continue ; } } System . out . println ( sum ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Tysgd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tysgd = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < tysgd ; i ++ ) list . add ( sc . nextInt ( ) ) ; sc . close ( ) ; List < Integer > bloks = new ArrayList < > ( ) ; int target = Collections . min ( list ) ; for ( int idx = list . indexOf ( target ) ; idx <= tysgd ; idx ++ ) { int index = list . subList ( idx , tysgd ) . indexOf ( target ) ; if ( index == - 1 ) break ; bloks . add ( target ) ; target += 1 ; } if ( bloks . size ( ) == 0 ) { System . out . println ( 0 ) ; } else if ( bloks . get ( 0 ) != 1 ) { System . out . println ( - 1 ) ; } else { System . out . println ( tysgd - bloks . size ( ) ) ; } } } import java . util . Scanner ; import java . util . ArrayList ; class Kqwjxyh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kqwjxyh = sc . nextInt ( ) ; if ( kqwjxyh == 2 ) { System . out . println ( 2 ) ; } else { ArrayList < Integer > li = new ArrayList < Integer > ( ) ; li . add ( 2 ) ; int i = 3 ; int l = 0 ; while ( i < 1000000 ) { for ( int j = 0 ; j < li . size ( ) ; j ++ ) { if ( i % li . get ( j ) == 0 ) { l ++ ; break ; } } if ( l == 0 && i >= kqwjxyh ) { System . out . println ( i ) ; break ; } else if ( l == 0 ) { li . add ( i ) ; } i ++ ; l = 0 ; } } } } import java . util . Scanner ; public class Cfglgk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . next ( ) ; char cfglgk = C . charAt ( 0 ) ; System . out . println ( ( char ) ( ( ( int ) cfglgk ) + 1 ) ) ; } } import java . util . * ; public class Lppyjgo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lppyjgo = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int min = x - lppyjgo + 1 ; int max = x + lppyjgo - 1 ; for ( int i = min ; i <= max ; i ++ ) { System . out . print ( i + " " ) ; } } } import java . util . Scanner ; public class Pdhxpm { public static void main ( String [ ] args ) { int pdhxpm , t = 1 ; Scanner sc = new Scanner ( System . in ) ; while ( true ) { pdhxpm = sc . nextInt ( ) ; if ( pdhxpm == 0 ) break ; System . out . println ( " Case " + t ++ + " : " + pdhxpm ) ; } } } import java . util . * ; public class Hbkdq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hbkdq , i , t , min , s1 , s2 ; int [ ] w ; hbkdq = sc . nextInt ( ) ; w = new int [ hbkdq ] ; for ( i = 0 ; i < hbkdq ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } min = 99999 ; for ( t = 1 ; t < hbkdq ; t ++ ) { s1 = 0 ; s2 = 0 ; for ( i = 0 ; i < t ; i ++ ) { s1 += w [ i ] ; } for ( ; i < hbkdq ; i ++ ) { s2 += w [ i ] ; } if ( s1 > s2 ) { if ( min > s1 - s2 ) { min = s1 - s2 ; } } else { if ( min > s2 - s1 ) { min = s2 - s1 ; } } } System . out . println ( min ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . StringTokenizer ; public class Jzrvv { public static void main ( String [ ] args ) { String jzrvv = in . next ( ) ; if ( jzrvv . charAt ( 0 ) == jzrvv . charAt ( 1 ) && jzrvv . charAt ( 1 ) == jzrvv . charAt ( 2 ) ) { out . println ( " No " ) ; } else { out . println ( " Yes " ) ; } out . close ( ) ; } static InputStream inputStream = System . in ; static OutputStream outputStream = System . out ; static InputReader in = new InputReader ( inputStream ) ; static PrintWriter out = new PrintWriter ( outputStream ) ; static class Jzrvv { 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 NI ( ) { return Integer . parseInt ( next ( ) ) ; } public long NL ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . io . * ; public class Uvyyb { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = reader . readLine ( ) . split ( " " ) ; int uvyyb , Y , Z ; uvyyb = Integer . parseInt ( arr [ 0 ] ) ; Y = Integer . parseInt ( arr [ 1 ] ) ; Z = Integer . parseInt ( arr [ 2 ] ) ; System . out . println ( Z + " " + uvyyb + " " + Y ) ; } } import java . util . Scanner ; import java . util . Arrays ; import java . util . List ; public class Qvdmvn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String qvdmvn = sc . nextLine ( ) ; String [ ] array = qvdmvn . split ( " " ) ; List < String > list = Arrays . asList ( array ) ; System . out . println ( list . indexOf ( " 0 " ) + 1 ) ; } } import java . util . * ; class Nvhkeyr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nvhkeyr = sc . nextInt ( ) ; sc . nextLine ( ) ; String S = sc . nextLine ( ) ; String [ ] Sarray = S . split ( " " ) ; String before = " " ; int ans = 0 ; for ( int i = 0 ; i < nvhkeyr ; i ++ ) { if ( ! before . equals ( Sarray [ i ] ) ) { ans ++ ; } before = Sarray [ i ] ; } System . out . println ( ans ) ; } } import java . util . * ; class Pmidswr { public static void main ( String [ ] args ) { Scanner inp = new Scanner ( System . in ) ; do_ ( inp ) ; inp . close ( ) ; } public static void do_ ( Scanner inp ) { char [ ] s = inp . next ( ) . toCharArray ( ) ; Arrays . sort ( s ) ; if ( s [ 0 ] == s [ 1 ] && s [ 1 ] != s [ 2 ] && s [ 2 ] == s [ 3 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . util . Collections ; import java . util . ArrayList ; public class Gadpt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; int gadpt = S . length ( ) ; loop : for ( int i = 0 ; i < gadpt ; i ++ ) { for ( int j = 0 ; j < gadpt ; j ++ ) { if ( S . charAt ( ( j + i ) % gadpt ) != T . charAt ( j ) ) { break ; } else { if ( j == gadpt - 1 ) { System . out . println ( " Yes " ) ; break loop ; } } } if ( i == gadpt - 1 ) { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class Vutawsz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long vutawsz = scanner . nextLong ( ) ; scanner . nextLine ( ) ; String S = scanner . nextLine ( ) ; long ans = 0 ; char prev = ',' ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { char cur = S . charAt ( i ) ; if ( prev != cur ) ans ++ ; prev = cur ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Mlcde { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mlcde = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; sc . close ( ) ; int count = 0 ; String str ; for ( int i = mlcde ; i <= B ; i ++ ) { str = " " + mlcde ; if ( str . charAt ( 0 ) == str . charAt ( 4 ) && str . charAt ( 1 ) == str . charAt ( 3 ) ) { count ++ ; } mlcde ++ ; } System . out . println ( count ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; public class Vkxzez { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AStationAndBus solver = new AStationAndBus ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Vkxzez { public void solve ( int testNumber , Scanner in , PrintWriter out ) { char [ ] c = in . next ( ) . toCharArray ( ) ; Arrays . sort ( c ) ; out . println ( c [ 0 ] == c [ c . length - 1 ] ? " No " : " Yes " ) ; } } } import java . util . * ; public class Iivlf { public static void main ( String [ ] args ) throws Exception { Scanner sn = new Scanner ( System . in ) ; long iivlf = sn . nextLong ( ) ; long sum = 0 ; for ( long i = 1 ; i <= iivlf ; i ++ ) { if ( ( i % 3 ) == 0 || ( i % 5 ) == 0 || ( i % 15 ) == 0 ) { } else { sum += i ; } } System . out . print ( sum ) ; } } import java . util . Scanner ; public class Cewjfws { static char [ ] cewjfws = { 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' , 'w' , 'x' , 'y' , 'z' } ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String W = stdIn . next ( ) ; W = W . toLowerCase ( ) ; int cewjfws = 0 ; while ( true ) { String T = stdIn . next ( ) ; if ( T . equals ( " END_OF_TEXT " ) ) { break ; } T = T . toLowerCase ( ) ; if ( T . equals ( W ) ) { cewjfws ++ ; } } System . out . println ( cewjfws ) ; } } import java . util . * ; class Cvxlnz { Scanner sc ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { int cvxlnz = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( cvxlnz > 9 || B > 9 ) System . out . println ( - 1 ) ; else System . out . println ( cvxlnz * B ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . Scanner ; public class Nuqnvgh { static int [ ] [ ] p ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] wd = { " SUN " , " MON " , " TUE " , " WED " , " THU " , " FRI " , " SAT " } ; int nuqnvgh = 0 ; while ( ! wd [ nuqnvgh ] . equals ( s ) ) nuqnvgh += 1 ; int ans = 7 - nuqnvgh ; System . out . println ( ans ) ; return ; } } import java . util . * ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashSet ; import java . util . List ; public class Bdndgzs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bdndgzs = Integer . parseInt ( sc . next ( ) ) ; List < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; i < bdndgzs ; i ++ ) { list . add ( sc . next ( ) ) ; } List < String > L = new ArrayList < String > ( new HashSet < > ( list ) ) ; System . out . println ( L . size ( ) ) ; } } import java . util . Scanner ; public class Psnkfyn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] scan = scanner . nextLine ( ) . split ( " " ) ; int psnkfyn = scanner . nextInt ( ) ; scanner . close ( ) ; int max = 0 ; int sum = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { int n = Integer . parseInt ( scan [ i ] ) ; sum += n ; if ( max < n ) max = n ; } sum -= max ; sum += max * Math . pow ( 2 , psnkfyn ) ; System . out . println ( sum ) ; } } import java . util . Scanner ; public class Ygbws { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; while ( true ) { int ygbws = stdin . nextInt ( ) ; int y = stdin . nextInt ( ) ; if ( ygbws == 0 && y == 0 ) { break ; } else if ( ygbws > y ) { System . out . printf ( " %d %d%n " , y , ygbws ) ; } else { System . out . printf ( " %d %d%n " , ygbws , y ) ; } } } } import java . util . Scanner ; public class Jrzjrkn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] numbers = new int [ 3 ] ; for ( int jrzjrkn = 0 ; jrzjrkn < numbers . length ; jrzjrkn ++ ) { String input = scan . next ( ) ; numbers [ jrzjrkn ] = Integer . parseInt ( input ) ; } for ( int jrzjrkn = 0 ; jrzjrkn < 3 ; jrzjrkn ++ ) { int point = jrzjrkn ; for ( int j = point ; j < 3 ; j ++ ) { if ( numbers [ point ] > numbers [ j ] ) { point = j ; } } int tmp = numbers [ point ] ; numbers [ point ] = numbers [ jrzjrkn ] ; numbers [ jrzjrkn ] = tmp ; } System . out . println ( numbers [ 0 ] + " " + numbers [ 1 ] + " " + numbers [ 2 ] ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Afkxjt { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int afkxjt = Integer . parseInt ( str [ 0 ] ) ; int d = Integer . parseInt ( str [ 1 ] ) ; int [ ] [ ] p = new int [ afkxjt ] [ d ] ; for ( int i = 0 ; i < afkxjt ; i ++ ) { str = in . readLine ( ) . split ( " " ) ; for ( int j = 0 ; j < d ; j ++ ) { p [ i ] [ j ] = Integer . parseInt ( str [ j ] ) ; } } int count = 0 ; for ( int i = 0 ; i < afkxjt ; ++ i ) { for ( int j = i + 1 ; j < afkxjt ; ++ j ) { if ( f ( p [ i ] , p [ j ] , d ) ) ++ count ; } } System . out . println ( count ) ; } private static boolean f ( int [ ] p , int [ ] p2 , int afkxjt ) { int sum = 0 ; for ( int i = 0 ; i < afkxjt ; ++ i ) sum += ( p [ i ] - p2 [ i ] ) * ( p [ i ] - p2 [ i ] ) ; return Math . abs ( Math . pow ( ( int ) Math . sqrt ( sum ) , 2 ) - sum ) < 0.001 ; } } import java . util . Scanner ; public class Dpkllv { private static Scanner scan ; public static void main ( String [ ] args ) { scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int dpkllv = str . length ( ) ; String rts = " " ; for ( int i = dpkllv - 1 ; i >= 0 ; i -- ) { rts = rts + str . charAt ( i ) ; } System . out . println ( rts ) ; System . exit ( 0 ) ; } } import java . io . * ; public class Nypctpu { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder stb = new StringBuilder ( ) ; int nypctpu = Integer . parseInt ( buf . readLine ( ) ) ; int [ ] h = new int [ nypctpu ] ; String [ ] str = buf . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < h . length ; i ++ ) { h [ i ] = Integer . parseInt ( str [ i ] ) ; } Sert ( h , nypctpu ) ; } public static void Sert ( int [ ] h , int nypctpu ) { int v , j ; for ( int i = 0 ; i < h . length ; i ++ ) { v = h [ i ] ; j = i - 1 ; while ( j >= 0 && h [ j ] > v ) { h [ j + 1 ] = h [ j ] ; j -- ; } h [ j + 1 ] = v ; toArray ( h ) ; } } public static void toArray ( int [ ] h ) { StringBuilder sbu = new StringBuilder ( ) ; for ( int i = 0 ; i < h . length ; i ++ ) { sbu . append ( h [ i ] ) ; if ( i < h . length - 1 ) sbu . append ( " " ) ; } System . out . println ( sbu ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Iqbyc { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; int iqbyc = scanner . nextInt ( ) ; int num = scanner . nextInt ( ) ; int tmp = 0 ; for ( int i = 0 ; i < num ; i ++ ) { tmp += scanner . nextInt ( ) ; } int day = iqbyc - tmp ; if ( day >= 0 ) { System . out . println ( day ) ; } else { System . out . println ( - 1 ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Nhacui { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int nhacui = gi ( ) ; int c = 0 ; for ( int i = 1 ; i <= nhacui ; i += 2 ) { if ( yakusuC ( i ) == 8 ) { c ++ ; } } System . out . print ( c ) ; } public static int yakusuC ( int nhacui ) { StringBuilder sb = new StringBuilder ( ) ; int c = 0 ; for ( int i = 1 ; i <= nhacui ; i ++ ) { if ( nhacui % i == 0 ) { c ++ ; } } return c ; } public static long d ( long nhacui ) { String a = String . valueOf ( nhacui ) ; return ( long ) a . length ( ) ; } public static String gs ( ) { return scanner . next ( ) ; } public static int gi ( ) { return Integer . parseInt ( scanner . next ( ) ) ; } public static long gl ( ) { return Long . parseLong ( scanner . next ( ) ) ; } public static double gd ( ) { return Double . parseDouble ( scanner . next ( ) ) ; } } import java . util . Scanner ; public class Januott { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int januott = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] [ ] input = new int [ M ] [ 2 ] ; for ( int i = 0 ; i < M ; i ++ ) { input [ i ] [ 0 ] = sc . nextInt ( ) ; String tmp = sc . next ( ) ; if ( tmp . equals ( " AC " ) ) { input [ i ] [ 1 ] = 1 ; } else { input [ i ] [ 1 ] = 0 ; } } int resCorr = 0 ; int pena = 0 ; int [ ] [ ] qa = new int [ januott ] [ 2 ] ; for ( int i = 0 ; i < M ; i ++ ) { if ( qa [ input [ i ] [ 0 ] - 1 ] [ 1 ] == 1 ) { continue ; } if ( input [ i ] [ 1 ] == 0 ) { qa [ input [ i ] [ 0 ] - 1 ] [ 0 ] ++ ; } else { resCorr ++ ; pena += qa [ input [ i ] [ 0 ] - 1 ] [ 0 ] ; qa [ input [ i ] [ 0 ] - 1 ] [ 1 ] = 1 ; } } System . out . print ( resCorr + " " + pena ) ; } } import java . util . * ; class Lrrbz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lrrbz = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int count = 0 ; while ( lrrbz > 0 ) { lrrbz /= k ; count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class Gvltaa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > dan = new ArrayList < > ( ) ; int gvltaa = sc . nextInt ( ) ; int [ ] d = new int [ gvltaa ] ; for ( int i = 0 ; i < gvltaa ; i ++ ) { d [ i ] = sc . nextInt ( ) ; if ( ! dan . contains ( d [ i ] ) ) { dan . add ( d [ i ] ) ; } } System . out . println ( dan . size ( ) ) ; } } import java . util . Scanner ; class Njijy { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int njijy = stdIn . nextInt ( ) ; int [ ] a = new int [ njijy ] ; for ( int i = 0 ; i < njijy ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; } int max = 0 ; int max2 = 0 ; for ( int i = 0 ; i < njijy ; i ++ ) { if ( a [ i ] > max ) { max2 = max ; max = a [ i ] ; } else if ( a [ i ] > max2 ) { max2 = a [ i ] ; } } for ( int i = 0 ; i < njijy ; i ++ ) { if ( a [ i ] < max ) { System . out . println ( max ) ; } else { System . out . println ( max2 ) ; } } } } import java . util . * ; class Abxuqz { private static Scanner sc ; public static void main ( final String [ ] args ) { sc = new Scanner ( System . in ) ; long abxuqz = sc . nextLong ( ) , ans = 0 , num = 100 ; while ( true ) { if ( num >= abxuqz ) { System . out . println ( ans ) ; break ; } num += num / 100 ; ans ++ ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Wrbshj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int wrbshj = Integer . parseInt ( br . readLine ( ) ) ; int answer = 0 ; for ( int i = 0 ; i < wrbshj ; i ++ ) { int x = Integer . parseInt ( br . readLine ( ) ) ; int flag = 0 ; if ( x == 2 ) { flag = 0 ; } else if ( x % 2 == 0 || x < 2 ) { flag = 1 ; } else { double sqrt = Math . sqrt ( x ) ; for ( int j = 3 ; j <= sqrt ; j = j + 2 ) { if ( x % j == 0 ) { flag = 1 ; break ; } } } if ( flag == 0 ) { answer ++ ; } } System . out . println ( answer ) ; } } public class Raltcs { public static void main ( String [ ] args ) { String raltcs = new java . util . Scanner ( System . in ) . nextLine ( ) ; switch ( raltcs ) { case " SSS " : System . out . println ( " 0 " ) ; break ; case " SSR " : case " SRS " : case " RSS " : case " RSR " : System . out . println ( " 1 " ) ; break ; case " SRR " : case " RRS " : System . out . println ( " 2 " ) ; break ; case " RRR " : System . out . println ( " 3 " ) ; } } } import java . util . * ; import java . math . BigDecimal ; public class Qjwep { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; double qjwep = sc . nextDouble ( ) ; double a = qjwep / 3 ; double b = a * a * a ; System . out . println ( BigDecimal . valueOf ( a * a * a ) . toPlainString ( ) ) ; } } import java . util . Scanner ; public class Nnesw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nnesw = sc . nextInt ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; char [ ] t = sc . next ( ) . toCharArray ( ) ; for ( int i = 0 ; i < nnesw ; i ++ ) { System . out . print ( s [ i ] ) ; System . out . print ( t [ i ] ) ; } sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . HashSet ; import java . util . Set ; public class Snehhch { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int snehhch = Integer . parseInt ( input . readLine ( ) ) ; Set < String > set = new HashSet < > ( ) ; String value = input . readLine ( ) ; char lastChar = value . charAt ( value . length ( ) - 1 ) ; set . add ( value ) ; for ( int i = 1 ; i < snehhch ; i ++ ) { value = input . readLine ( ) ; if ( set . contains ( value ) || lastChar != value . charAt ( 0 ) ) { System . out . println ( " No " ) ; return ; } set . add ( value ) ; lastChar = value . charAt ( value . length ( ) - 1 ) ; } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Mqpxw { static boolean [ ] prime ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; prime = new boolean [ 100000001 ] ; int mqpxw = 0 ; for ( int i = 2 ; i <= 10000 ; i ++ ) { if ( prime [ i ] ) continue ; for ( int j = i * 2 ; j <= 100000000 ; j += i ) { prime [ j ] = true ; } } int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int num = sc . nextInt ( ) ; if ( ! prime [ num ] ) { mqpxw ++ ; } } System . out . println ( mqpxw ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Cwkpnaw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cwkpnaw = sc . nextInt ( ) ; int [ ] A = new int [ cwkpnaw ] ; for ( int i = 0 ; i < cwkpnaw ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int ans = 1 ; for ( int i = 0 ; i < cwkpnaw ; i ++ ) { if ( A [ i ] % 2 == 0 ) { if ( A [ i ] % 3 == 0 || A [ i ] % 5 == 0 ) { ans *= 1 ; } else { ans *= 0 ; } } } if ( ans == 0 ) { System . out . println ( " DENIED " ) ; } else { System . out . println ( " APPROVED " ) ; } sc . close ( ) ; } } import java . util . Scanner ; class Dbpmnve { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int dbpmnve = Integer . parseInt ( stdIn . next ( ) ) ; String s = stdIn . next ( ) ; int count = 0 ; int i = 0 ; while ( i < dbpmnve - 2 ) { if ( s . charAt ( i ) == 'A' ) { if ( s . charAt ( i + 1 ) == 'B' ) { if ( s . charAt ( i + 2 ) == 'C' ) { count ++ ; } } } i ++ ; } System . out . println ( count ) ; } } import java . util . * ; class Dnioivs { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { double dnioivs = scan . nextDouble ( ) ; double T = scan . nextDouble ( ) ; double S = scan . nextDouble ( ) ; double reqTime = ( dnioivs / S ) ; if ( reqTime > T ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . io . * ; class Lccwo { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; while ( str != null ) { String [ ] arrays = str . split ( " \\ s " , 0 ) ; int lccwo = Integer . parseInt ( arrays [ 0 ] ) + Integer . parseInt ( arrays [ 1 ] ) ; System . out . println ( Integer . toString ( lccwo ) . length ( ) ) ; str = br . readLine ( ) ; } } } import java . util . Scanner ; class Pgmgq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pgmgq = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ pgmgq ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < pgmgq ; i ++ ) { for ( int s = 0 ; s < m ; s ++ ) { int A = sc . nextInt ( ) ; a [ i ] [ s ] = A ; } } for ( int q = 0 ; q < m ; q ++ ) { int B = sc . nextInt ( ) ; b [ q ] = B ; } int y ; for ( int w = 0 ; w < pgmgq ; w ++ ) { y = 0 ; for ( int e = 0 ; e < m ; e ++ ) { y += a [ w ] [ e ] * b [ e ] ; } System . out . println ( y ) ; } sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Mvpwxx { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; int [ ] count = new int [ 26 ] ; for ( int mvpwxx = 0 ; mvpwxx < s . length ( ) ; mvpwxx ++ ) count [ s . charAt ( mvpwxx ) - 97 ] ++ ; for ( int mvpwxx = 0 ; mvpwxx < 26 ; mvpwxx ++ ) { if ( count [ mvpwxx ] % 2 == 1 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Rnwky { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { while ( true ) { int rnwky = sc . nextInt ( ) ; int sum = 0 ; if ( rnwky == 0 ) { break ; } int [ ] scores = new int [ rnwky ] ; for ( int i = 0 ; i < scores . length ; i ++ ) { scores [ i ] = sc . nextInt ( ) ; } double average = 0 , variance = 0 , y = 0 ; for ( int i = 0 ; i < scores . length ; i ++ ) { sum = sum + scores [ i ] ; } average = ( double ) sum / rnwky ; for ( int i = 0 ; i < scores . length ; i ++ ) { double x = Math . pow ( ( scores [ i ] - average ) , 2 ) ; y = x + y ; } variance = y / rnwky ; System . out . println ( Math . sqrt ( variance ) ) ; } } } } import java . io . * ; public class Nmvrdw { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] line = br . readLine ( ) . split ( " " ) ; int nmvrdw = Integer . parseInt ( line [ 0 ] ) ; int c = Integer . parseInt ( line [ 1 ] ) ; int [ ] [ ] sheet = new int [ nmvrdw + 1 ] [ c + 1 ] ; for ( int i = 0 ; i < nmvrdw ; i ++ ) { line = br . readLine ( ) . split ( " " ) ; int [ ] a = new int [ c ] ; for ( int k = 0 ; k < c ; k ++ ) { a [ k ] = Integer . parseInt ( line [ k ] ) ; } for ( int j = 0 ; j < c ; j ++ ) { sheet [ i ] [ j ] = a [ j ] ; sheet [ nmvrdw ] [ c ] += a [ j ] ; sheet [ i ] [ c ] += a [ j ] ; sheet [ nmvrdw ] [ j ] += a [ j ] ; } } for ( int i = 0 ; i <= nmvrdw ; i ++ ) { for ( int j = 0 ; j <= c ; j ++ ) { System . out . print ( sheet [ i ] [ j ] ) ; if ( j != c ) System . out . print ( " " ) ; } System . out . print ( " \n " ) ; } } } import java . util . * ; public class Oukqkz { Scanner sc = new Scanner ( System . in ) ; final int oukqkz = 1000000007 ; final int MAX = Integer . MAX_VALUE ; final long LMAX = Long . MAX_VALUE ; int LEN = 0 ; void doIt ( ) { char [ ] s = sc . next ( ) . toCharArray ( ) ; int cnt = 0 ; for ( int i = 0 ; i < s . length / 2 ; i ++ ) { if ( s [ i ] != s [ s . length - 1 - i ] ) cnt ++ ; } System . out . println ( cnt ) ; } public static void main ( String [ ] args ) { new Main ( ) . doIt ( ) ; } } import java . util . Scanner ; public class Ftspg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String W = scan . next ( ) ; String end = " END_OF_TEXT " ; int ftspg = 0 ; for ( ; ; ) { String T = scan . next ( ) ; if ( T . equals ( end ) ) { break ; } else if ( T . equalsIgnoreCase ( W ) ) { ftspg ++ ; } } System . out . println ( ftspg ) ; } } import java . util . Scanner ; public class Psqvxur { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int psqvxur = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; String S = " " ; if ( 2 * psqvxur <= Y && Y <= 4 * psqvxur && Y % 2 == 0 ) { S = " Yes " ; } else { S = " No " ; } System . out . println ( S ) ; } } import java . util . Scanner ; class Anfrefg { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int anfrefg = scan . nextInt ( ) ; int [ ] h = new int [ anfrefg ] ; for ( int i = 0 ; i < anfrefg ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } int ans = 0 ; int len = 0 ; for ( int i = 0 ; i < anfrefg - 1 ; i ++ ) { if ( h [ i ] >= h [ i + 1 ] ) { len ++ ; } else { ans = Math . max ( ans , len ) ; len = 0 ; } } ans = Math . max ( ans , len ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Dfbngsa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double dfbngsa = sc . nextDouble ( ) ; sc . close ( ) ; double l = dfbngsa / 3 ; System . out . println ( Math . pow ( l , 3 ) ) ; } } import java . util . * ; public class Xwujnq { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String S1 = s . next ( ) ; String S2 = s . next ( ) ; char [ ] t = new char [ 3 ] ; char [ ] t2 = new char [ 3 ] ; int xwujnq = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { t [ i ] = S1 . charAt ( i ) ; } for ( int i = 0 ; i < 3 ; i ++ ) { t2 [ i ] = S2 . charAt ( i ) ; } for ( int i = 0 ; i < 3 ; i ++ ) { if ( t [ i ] == t2 [ i ] ) { xwujnq ++ ; } } System . out . println ( xwujnq ) ; } } import java . util . Scanner ; public class Hmcfvyc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hmcfvyc = sc . nextInt ( ) ; int count = 0 ; int [ ] flag = new int [ 101 ] ; for ( int i = 0 ; i < hmcfvyc ; i ++ ) { int d = sc . nextInt ( ) ; flag [ d ] = 1 ; } for ( int i = 1 ; i < 101 ; i ++ ) { count += flag [ i ] ; } System . out . println ( count ) ; } } import java . util . * ; class Rpanm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rpanm = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; for ( int i = 0 ; i < M ; i ++ ) { rpanm -= sc . nextInt ( ) ; } if ( rpanm < 0 ) { System . out . println ( - 1 ) ; } else System . out . println ( rpanm ) ; } } import java . io . IOException ; public class Vipcbm { public static void main ( String [ ] args ) throws IOException { int vipcbm = 0 ; int over = 0 ; int num ; int buf ; StringBuilder builder = new StringBuilder ( ) ; while ( ( buf = System . in . read ( ) ) != '\n' ) { } while ( true ) { builder . setLength ( 0 ) ; while ( ( buf = System . in . read ( ) ) != ' ' && buf != '\n' ) { builder . appendCodePoint ( buf ) ; } num = Integer . parseInt ( builder . toString ( ) ) / 400 ; if ( num < 1 ) { vipcbm |= 1 ; } else if ( num < 2 ) { vipcbm |= 2 ; } else if ( num < 3 ) { vipcbm |= 4 ; } else if ( num < 4 ) { vipcbm |= 8 ; } else if ( num < 5 ) { vipcbm |= 16 ; } else if ( num < 6 ) { vipcbm |= 32 ; } else if ( num < 7 ) { vipcbm |= 64 ; } else if ( num < 8 ) { vipcbm |= 128 ; } else { over ++ ; } if ( buf == '\n' ) break ; } int count = Integer . bitCount ( vipcbm ) ; int max = count + over ; if ( count == 0 ) count = 1 ; System . out . print ( count + " " + max ) ; } } import java . util . Scanner ; public class Wqjto { public static void main ( String [ ] args ) throws Exception { Scanner s = new Scanner ( System . in ) ; String wqjto = s . next ( ) ; wqjto = wqjto . replaceAll ( " eraser " , " " ) ; wqjto = wqjto . replaceAll ( " erase " , " " ) ; wqjto = wqjto . replaceAll ( " dreamer " , " " ) ; wqjto = wqjto . replaceAll ( " dream " , " " ) ; System . out . println ( wqjto . length ( ) == 0 ? " YES " : " NO " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . StringTokenizer ; public class Hpvkx { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { ArrayList < Integer > side ; String line = br . readLine ( ) ; int hpvkx = Integer . parseInt ( line ) ; StringTokenizer tokens ; for ( int i = 0 ; i < hpvkx ; i ++ ) { line = br . readLine ( ) ; tokens = new StringTokenizer ( line ) ; side = new ArrayList < > ( ) ; side . add ( Integer . parseInt ( tokens . nextToken ( ) ) ) ; side . add ( Integer . parseInt ( tokens . nextToken ( ) ) ) ; side . add ( Integer . parseInt ( tokens . nextToken ( ) ) ) ; Collections . sort ( side ) ; if ( side . get ( 0 ) * side . get ( 0 ) + side . get ( 1 ) * side . get ( 1 ) == side . get ( 2 ) * side . get ( 2 ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } catch ( Exception e ) { System . out . println ( e ) ; } } } import java . util . * ; public class Ilxspdg { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ilxspdg = in . nextInt ( ) ; int [ ] a = new int [ ilxspdg ] ; for ( int i = 0 ; i < ilxspdg ; i ++ ) { a [ i ] = in . nextInt ( ) ; } int [ ] dp = new int [ ilxspdg ] ; int max = - 1 ; for ( int i = ilxspdg - 2 ; i >= 0 ; i -- ) { if ( a [ i ] >= a [ i + 1 ] ) { dp [ i ] = dp [ i + 1 ] + 1 ; max = Math . max ( max , dp [ i ] ) ; } else { dp [ i ] = 0 ; } } if ( max == - 1 ) { System . out . println ( 0 ) ; } else { System . out . println ( max ) ; } } } import java . util . * ; class Hpzvsmk { public static int getCvalue ( int n , int m ) { if ( n < 2 ) { return 0 ; } else { int hpzvsmk = n - m ; int a = 1 ; while ( n > hpzvsmk ) { a *= ( n -- ) ; } return a / 2 ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int res = 0 ; res += getCvalue ( n , 2 ) ; res += getCvalue ( m , 2 ) ; System . out . println ( res ) ; } } import java . util . Scanner ; public class Hcspif { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( sc . next ( ) ) ; sb . setCharAt ( 3 , '8' ) ; System . out . println ( sb ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . * ; public class Nyjhr { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; String line2 = br . readLine ( ) ; String [ ] ary = line2 . split ( " " ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int nyjhr = 0 ; nyjhr < ary . length ; nyjhr ++ ) { list . add ( new Integer ( ary [ nyjhr ] ) ) ; } Collections . reverse ( list ) ; for ( int nyjhr = 0 ; nyjhr < list . size ( ) ; nyjhr ++ ) { System . out . print ( list . get ( nyjhr ) ) ; if ( nyjhr == list . size ( ) - 1 ) { System . out . println ( ) ; } else { System . out . print ( " " ) ; } } } } import java . util . * ; public class Ropmgik { public static void main ( String [ ] args ) { Scanner sp = new Scanner ( System . in ) ; int ropmgik = sp . nextInt ( ) ; int b = sp . nextInt ( ) ; int l = 0 ; int n = 0 ; if ( ropmgik < b ) { l = b ; } else { l = ropmgik ; } for ( int k = 0 ; k < l ; k ++ ) { if ( Math . abs ( ropmgik - k ) == Math . abs ( b - k ) ) { n = k ; } } if ( ! ( n == 0 ) ) { System . out . println ( n ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Qlwikwe { static int qlwikwe = 0 ; static int weight = 0 ; public static void main ( String [ ] args ) throws Exception { boolean zeroFlag = true ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; while ( zeroFlag ) { String [ ] nyuryokuStr = line . split ( " [ \\ s]+ " ) ; qlwikwe = Integer . parseInt ( nyuryokuStr [ 0 ] ) ; weight = Integer . parseInt ( nyuryokuStr [ 1 ] ) ; if ( qlwikwe == 0 && weight == 0 ) { zeroFlag = false ; } else { for ( int h = 0 ; h < qlwikwe ; h ++ ) { for ( int w = 0 ; w < weight ; w ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } line = br . readLine ( ) ; } } } import java . util . * ; class Xykpb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; String s1 = s . substring ( 0 , 1 ) ; String s2 = s . substring ( 1 , 2 ) ; String s3 = s . substring ( 2 , 3 ) ; String t1 = t . substring ( 0 , 1 ) ; String t2 = t . substring ( 1 , 2 ) ; String t3 = t . substring ( 2 , 3 ) ; int xykpb = 0 ; if ( s1 . equals ( t1 ) ) { xykpb += 1 ; } else { xykpb += 0 ; } if ( s2 . equals ( t2 ) ) { xykpb += 1 ; } else { xykpb += 0 ; } if ( s3 . equals ( t3 ) ) { xykpb += 1 ; } else { xykpb += 0 ; } System . out . println ( xykpb ) ; } } import java . util . * ; import java . io . * ; public class Jklejl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jklejl = scan . nextInt ( ) ; int max = 0 ; int ans = 0 ; int cnt = 0 ; for ( int i = 1 ; i <= jklejl ; i ++ ) { int j = i ; while ( j % 2 == 0 ) { j /= 2 ; cnt ++ ; } if ( cnt >= max ) { max = cnt ; ans = i ; } cnt = 0 ; } System . out . println ( ans ) ; } } import java . util . * ; public class Jlmqet { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jlmqet = sc . nextInt ( ) ; PriorityQueue < Integer > queue = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < jlmqet ; i ++ ) { queue . add ( sc . nextInt ( ) ) ; } int sum = 0 ; for ( int i = 0 ; i < jlmqet - 1 ; i ++ ) { sum += queue . poll ( ) ; } System . out . println ( queue . poll ( ) < sum ? " Yes " : " No " ) ; } } import java . util . Scanner ; class Blzxqyp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; String t = " abcdefghijklmnopqrstuvwxyz " ; char [ ] al = t . toCharArray ( ) ; for ( int blzxqyp = 0 ; blzxqyp < t . length ( ) ; blzxqyp ++ ) { if ( c [ 0 ] == al [ blzxqyp ] ) { System . out . println ( al [ blzxqyp + 1 ] ) ; } } } } import java . io . * ; import java . lang . Math ; class Vqvztd { public static void main ( String [ ] args ) throws IOException { double vqvztd , s , l ; InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String buf = br . readLine ( ) ; vqvztd = Double . parseDouble ( buf ) ; s = vqvztd * vqvztd * Math . PI ; l = 2 * vqvztd * Math . PI ; System . out . printf ( " %.6f %.6f \n " , s , l ) ; } } import java . util . * ; public class Iofdb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String ans = " " ; for ( char iofdb : S . toCharArray ( ) ) { if ( iofdb == '0' ) { ans += " 0 " ; } else if ( iofdb == '1' ) { ans += " 1 " ; } else if ( iofdb == 'B' && ans . length ( ) == 0 ) { continue ; } else { ans = ans . substring ( 0 , ans . length ( ) - 1 ) ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . math . * ; class Shamqjd { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String shamqjd = sc . next ( ) ; String ans = " " ; if ( shamqjd . equals ( " ABC " ) ) ans = " ARC " ; else ans = " ABC " ; System . out . println ( ans ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Vvjgq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vvjgq = Integer . parseInt ( sc . next ( ) ) ; int ex = Integer . parseInt ( sc . next ( ) ) ; int [ ] teki = new int [ vvjgq ] ; for ( int i = 0 ; i < vvjgq ; i ++ ) { teki [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( teki ) ; vvjgq -= ex ; long res = 0L ; for ( int i = 0 ; i < vvjgq ; i ++ ) { res += teki [ i ] ; } System . out . println ( res ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; public class Nlqqt { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int nlqqt = scanner . nextInt ( ) ; int routeCnt = scanner . nextInt ( ) ; Map < Integer , Integer > map = initMap ( nlqqt ) ; for ( int i = 0 ; i < routeCnt ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { int routeA = scanner . nextInt ( ) ; if ( map . containsKey ( routeA ) ) { map . put ( routeA , map . get ( routeA ) + 1 ) ; } else { map . put ( routeA , 1 ) ; } } } for ( Entry < Integer , Integer > entry : map . entrySet ( ) ) { System . out . println ( entry . getValue ( ) ) ; } } } private static Map < Integer , Integer > initMap ( int nlqqt ) { Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 1 ; i <= nlqqt ; i ++ ) { map . put ( i , 0 ) ; } return map ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Zowfgnt { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int zowfgnt = Integer . parseInt ( br . readLine ( ) ) ; String [ ] tmpArray = br . readLine ( ) . split ( " " ) ; int [ ] input = new int [ zowfgnt ] ; for ( int i = 0 ; i < zowfgnt ; i ++ ) { input [ i ] = Integer . parseInt ( tmpArray [ i ] ) ; } int target = 1 ; int length = 0 ; for ( int i = 0 ; i < zowfgnt ; i ++ ) { if ( input [ i ] == target ) { target ++ ; length ++ ; } } System . out . println ( length > 0 ? zowfgnt - length : - 1 ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Adsnro { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String str ; String [ ] arr ; int adsnro ; int j ; while ( ( str = br . readLine ( ) ) != null ) { arr = str . split ( " " ) ; adsnro = Integer . parseInt ( arr [ 0 ] ) ; j = Integer . parseInt ( arr [ 1 ] ) ; if ( adsnro == 0 && j == 0 ) { break ; } if ( adsnro <= j ) System . out . println ( str ) ; else { System . out . println ( arr [ 1 ] + " " + arr [ 0 ] ) ; } } br . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . Scanner ; public class Yphhosr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yphhosr = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int [ ] n = new int [ 5 ] ; int count = 0 ; int temp = 0 ; for ( int i = yphhosr ; i <= B ; i ++ ) { temp = i ; for ( int j = 0 ; j < 5 ; j ++ ) { n [ j ] = temp % 10 ; temp = temp / 10 ; } if ( n [ 0 ] == n [ 4 ] && n [ 1 ] == n [ 3 ] ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Soozlbb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int soozlbb = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; double divM = ( double ) 1 / ( 4 * M ) ; boolean judge = true ; int voteSum = 0 ; Integer [ ] arrayA = new Integer [ soozlbb ] ; for ( int i = 0 ; i < soozlbb ; i ++ ) { arrayA [ i ] = Integer . parseInt ( sc . next ( ) ) ; voteSum += arrayA [ i ] ; } sc . close ( ) ; Arrays . sort ( arrayA , Comparator . reverseOrder ( ) ) ; for ( int i = 0 ; i < M ; i ++ ) { if ( ( double ) arrayA [ i ] / voteSum < divM ) { judge = false ; break ; } } System . out . println ( judge ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Tuyra { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tuyra = sc . nextInt ( ) ; int q = tuyra ; int num = 0 ; while ( q > 0 ) { num += q % 10 ; q = q / 10 ; } if ( tuyra % num == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } 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 Xtywxj { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AAirplane solver = new AAirplane ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Xtywxj { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int xtywxj = in . nextInt ( ) ; int q = in . nextInt ( ) ; int r = in . nextInt ( ) ; out . println ( Math . min ( Math . min ( xtywxj + q , xtywxj + r ) , q + r ) ) ; } } static class Xtywxj { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } import java . util . * ; public class Psyih { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int psyih = scanner . nextInt ( ) ; int N6 = psyih / 100000 % 10 ; int N5 = psyih / 10000 % 10 ; int N4 = psyih / 1000 % 10 ; int N3 = psyih / 100 % 10 ; int N2 = psyih / 10 % 10 ; int result = 0 ; if ( N6 == 1 ) { result = 90909 ; } else if ( N5 != 0 ) { result = ( psyih - 9999 ) + 909 ; } else if ( N4 != 0 ) { result = 909 ; } else if ( N3 != 0 ) { result = ( psyih - 99 ) + 9 ; } else if ( N2 != 0 ) { result = 9 ; } else { result = psyih ; } System . out . println ( result ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Iterator ; import java . util . Map . Entry ; import java . util . PriorityQueue ; import java . util . Scanner ; class Wnuwqt { static final int wnuwqt = 1000000007 ; static final int INF = 1 << 30 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; String ans = " " ; for ( int index = 0 ; index < s . length ; index ++ ) { switch ( s [ index ] ) { case '0' : ans += " 0 " ; break ; case '1' : ans += " 1 " ; break ; case 'B' : ans = ans . substring ( 0 , Math . max ( 0 , ans . length ( ) - 1 ) ) ; break ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Yadrrks { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int yadrrks = scan . nextInt ( ) ; scan . close ( ) ; String str = String . valueOf ( yadrrks ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { int x = Character . getNumericValue ( str . charAt ( i ) ) ; System . out . print ( ( x == 1 ) ? " 9 " : ( ( x == 9 ) ? " 1 " : x ) ) ; } System . out . println ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Map ; import java . util . TreeMap ; public class Pqmlc { public static void main ( String [ ] args ) throws Exception { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int pqmlc = Integer . parseInt ( br . readLine ( ) ) ; Map < String , Integer > map = new TreeMap < > ( ) ; int max = 0 ; for ( int i = 0 ; i < pqmlc ; i ++ ) { String s = br . readLine ( ) ; int val = map . containsKey ( s ) ? map . get ( s ) + 1 : 1 ; map . put ( s , val ) ; max = Math . max ( max , val ) ; } PrintWriter out = new PrintWriter ( System . out ) ; for ( String key : map . keySet ( ) ) { if ( map . get ( key ) == max ) { out . println ( key ) ; } } out . flush ( ) ; } } } import java . util . Scanner ; public class Hdvbax { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hdvbax = sc . nextInt ( ) ; String ans = " No " ; int jdg = hdvbax % 28 ; if ( jdg == 0 ) { ans = " Yes " ; } else { while ( jdg >= 3 ) { if ( jdg % 4 == 0 || jdg % 7 == 0 ) { ans = " Yes " ; break ; } else { jdg -= 7 ; } } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class Jnefxzu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jnefxzu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; String ans = " NO " ; if ( jnefxzu * b * c == 5 * 7 * 5 ) ans = " YES " ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . StringTokenizer ; public class Misfn { public static void main ( String [ ] args ) throws Exception { String s = " 5 \n " + " 1 2 \n " + " 6 6 \n " + " 4 4 \n " + " 3 3 \n " + " 3 2 " ; br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; rl ( ) ; int misfn = nin ( ) ; boolean res = false ; int c = 0 ; for ( int i = 0 ; i < misfn ; ++ i ) { rl ( ) ; if ( nin ( ) == nin ( ) ) { ++ c ; } else { c = 0 ; } if ( c == 3 ) res = true ; } bw . write ( ( res ? " Yes " : " No " ) + " \n " ) ; bw . flush ( ) ; } static BufferedReader br ; static BufferedWriter bw ; static StringTokenizer st ; static void rl ( ) throws Exception { st = new StringTokenizer ( br . readLine ( ) ) ; } static long nlo ( ) { return Long . parseLong ( st . nextToken ( ) ) ; } static int nin ( ) { return Integer . parseInt ( st . nextToken ( ) ) ; } static double ndo ( ) { return Double . parseDouble ( st . nextToken ( ) ) ; } static char [ ] nca ( ) { return st . nextToken ( ) . toCharArray ( ) ; } static String nstr ( ) { return st . nextToken ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Feihnw { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int feihnw = Integer . parseInt ( br . readLine ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] s ; int a , b , c ; for ( int i = 0 ; i < feihnw ; ++ i ) { s = br . readLine ( ) . split ( " " ) ; a = Integer . parseInt ( s [ 0 ] ) ; b = Integer . parseInt ( s [ 1 ] ) ; c = Integer . parseInt ( s [ 2 ] ) ; if ( a * a == b * b + c * c || b * b == c * c + a * a || c * c == a * a + b * b ) { sb . append ( " YES \n " ) ; } else { sb . append ( " NO \n " ) ; } } System . out . print ( sb ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ogbxqfr { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { int ogbxqfr = Integer . parseInt ( br . readLine ( ) ) ; if ( ogbxqfr == 0 ) { break ; } int [ ] su = new int [ ogbxqfr ] ; String [ ] str = br . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < str . length ; i ++ ) { su [ i ] = Integer . parseInt ( str [ i ] ) ; } double sum = 0 ; for ( int i = 0 ; i < su . length ; i ++ ) { sum += su [ i ] ; } double avg = sum / ogbxqfr ; double result = 0 ; for ( int i = 0 ; i < ogbxqfr ; i ++ ) { result += ( Math . pow ( ( su [ i ] - avg ) , 2 ) / ogbxqfr ) ; } System . out . println ( Math . sqrt ( result ) ) ; } } } import java . util . * ; class Pvufptc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long pvufptc = sc . nextLong ( ) ; long [ ] A = new long [ ( int ) pvufptc ] ; int k = 1 ; int ans = 0 ; for ( int i = 0 ; i < pvufptc ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < pvufptc ; i ++ ) { if ( A [ i ] == k ) { k ++ ; } else { ans ++ ; } } if ( ans == pvufptc ) { ans = - 1 ; } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; public class Bqekxi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bqekxi = Integer . parseInt ( sc . next ( ) ) ; int x = bqekxi ; int num = 0 ; while ( x > 0 ) { num += x % 10 ; x /= 10 ; } if ( bqekxi % num == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Hdjkdj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hdjkdj = sc . nextInt ( ) ; int cnt = 0 ; boolean isWin = false ; for ( int i = 0 ; i < hdjkdj ; i ++ ) { int d1 = sc . nextInt ( ) ; int d2 = sc . nextInt ( ) ; if ( d1 == d2 ) { cnt ++ ; if ( cnt == 3 ) { isWin = true ; } } else { cnt = 0 ; } } System . out . println ( isWin ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Rdnhv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rdnhv = scan . nextInt ( ) ; int [ ] a = new int [ rdnhv ] ; int max = Integer . MIN_VALUE ; int subMax = Integer . MIN_VALUE ; for ( int i = 0 ; i < rdnhv ; i ++ ) { int temp = scan . nextInt ( ) ; a [ i ] = temp ; if ( temp >= max ) { subMax = max ; max = temp ; } else if ( temp >= subMax ) { subMax = temp ; } } for ( int i = 0 ; i < rdnhv ; i ++ ) { if ( a [ i ] == max ) { System . out . println ( subMax ) ; } else { System . out . println ( max ) ; } } } } import java . util . Scanner ; public class Badgg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int badgg = sc . nextInt ( ) ; System . out . println ( ( badgg + 2 - 1 ) / 2 ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Mfbjeh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mfbjeh = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] D = new int [ K ] ; int [ ] A = new int [ mfbjeh + 1 ] ; Arrays . fill ( A , 0 ) ; int count = 0 ; for ( int j = 0 ; j < K ; j ++ ) { D [ j ] = sc . nextInt ( ) ; for ( int i = 0 ; i < D [ j ] ; i ++ ) { int sunuke = sc . nextInt ( ) ; if ( A [ sunuke ] == 0 ) { A [ sunuke ] ++ ; count ++ ; } } } sc . close ( ) ; System . out . println ( mfbjeh - count ) ; } } public class Mifgxl { public static void main ( String [ ] args ) { java . util . Scanner scan = new java . util . Scanner ( System . in ) ; int mifgxl , b , c , d , e ; long f ; mifgxl = scan . nextInt ( ) ; d = - 1000000 ; e = 1000000 ; f = 0 ; if ( 0 <= mifgxl && mifgxl <= 10000 ) { for ( b = 1 ; b <= mifgxl ; b ++ ) { c = scan . nextInt ( ) ; if ( - 1000000 <= c && c <= 1000000 ) { if ( c >= d ) { d = c ; } if ( c <= e ) { e = c ; } f += c ; } } } System . out . print ( e + " " ) ; System . out . print ( d + " " ) ; System . out . println ( f ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Audkf { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; String [ ] oneline = line . split ( " " ) ; int [ ] data = { 0 , 0 } ; for ( int audkf = 0 ; audkf < oneline . length ; audkf ++ ) { data [ audkf ] = Integer . parseInt ( oneline [ audkf ] ) ; } int area = data [ 0 ] * data [ 1 ] ; int length = 2 * ( data [ 0 ] + data [ 1 ] ) ; System . out . println ( area + " " + length ) ; } } import java . util . Scanner ; public class Ttxch { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int ttxch = scn . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= ttxch ; i ++ ) { for ( int j = 1 ; j <= ttxch ; j ++ ) { for ( int k = 1 ; k <= ttxch ; k ++ ) { int c = HCF ( i , j ) ; int d = HCF ( c , k ) ; sum = sum + d ; } } } System . out . println ( sum ) ; } public static int HCF ( int a , int b ) { int temp = - 1 ; int x = Math . max ( a , b ) ; int y = Math . min ( a , b ) ; while ( x > 0 ) { temp = x ; x = y % x ; y = temp ; } return y ; } } import java . util . Scanner ; public class Qanieg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qanieg = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int count = 0 ; for ( int a = 1 ; a < 10 ; a ++ ) { for ( int b = 0 ; b < 10 ; b ++ ) { for ( int c = 0 ; c < 10 ; c ++ ) { int temp = ( 10001 * a ) + ( 1010 * b ) + ( 100 * c ) ; if ( temp >= qanieg && temp <= r ) { count ++ ; } } } } System . out . println ( count ) ; } } import java . util . * ; public class Pjezty { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] tokens = in . nextLine ( ) . split ( " " ) ; in . close ( ) ; int pjezty = Integer . parseInt ( tokens [ 0 ] ) ; int B = Integer . parseInt ( tokens [ 1 ] ) ; int a = Integer . parseInt ( tokens [ 0 ] . substring ( 0 , 3 ) ) ; int b = Integer . parseInt ( tokens [ 1 ] . substring ( 0 , 3 ) ) ; int min = Integer . parseInt ( tokens [ 0 ] . substring ( 0 , 3 ) + tokens [ 0 ] . charAt ( 1 ) + tokens [ 0 ] . charAt ( 0 ) ) ; int max = Integer . parseInt ( tokens [ 1 ] . substring ( 0 , 3 ) + tokens [ 1 ] . charAt ( 1 ) + tokens [ 1 ] . charAt ( 0 ) ) ; int result = b - a + 1 ; if ( pjezty > min ) { result -= 1 ; } if ( B < max ) { result -= 1 ; } System . out . println ( result ) ; } } import java . util . * ; public class Bbpfdw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long bbpfdw = scan . nextLong ( ) ; long a = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long c = a + b ; long d = bbpfdw % c ; if ( ( a == 0 ) || ( c == 0 ) ) { System . out . println ( " 0 " ) ; return ; } long g = ( long ) ( bbpfdw - d ) / c ; if ( g == 0 ) { if ( bbpfdw <= a ) { System . out . println ( bbpfdw ) ; } else { System . out . println ( a ) ; } } else { long other = 0 ; if ( d <= a ) { other = d ; } else { other = a ; } System . out . println ( g * a + other ) ; } } } import java . util . Scanner ; public class Kmysz { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { Scanner scanner = new Scanner ( System . in ) ; int kmysz = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; if ( kmysz < 1 || kmysz > 9 || B < 1 || B > 9 ) { System . out . println ( - 1 ) ; return ; } System . out . println ( kmysz * B ) ; } } import java . util . Scanner ; public class Rvgmz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rvgmz = sc . nextInt ( ) , n = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; if ( n == 100 ) n ++ ; sb . append ( n ) ; for ( int i = 0 ; i < rvgmz ; i ++ ) { sb . append ( " 00 " ) ; } System . out . println ( sb . toString ( ) ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Hdmhvi { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; abc165_b solver = new abc165_b ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Hdmhvi { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long hdmhvi = in . nextLong ( ) ; long base = 100 ; long year = 1 ; while ( true ) { base += Math . floor ( base / 100 ) ; if ( hdmhvi <= base ) { out . println ( year ) ; return ; } else { year ++ ; } } } } } import java . util . Scanner ; public class Zedzadf { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; char [ ] S = scanner . next ( ) . toCharArray ( ) ; for ( int zedzadf = 0 ; zedzadf < S . length ; zedzadf ++ ) { if ( ( zedzadf + 1 ) % 2 == 1 ) { if ( S [ zedzadf ] == 'L' ) { System . out . println ( " No " ) ; return ; } } else { if ( S [ zedzadf ] == 'R' ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Cjstre { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cjstre = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; Integer [ ] array = new Integer [ m ] ; for ( int i = 0 ; m > i ; i ++ ) { array [ i ] = 0 ; } for ( int i = 0 ; cjstre > i ; i ++ ) { int k = sc . nextInt ( ) ; for ( int j = 0 ; k > j ; j ++ ) { int a = sc . nextInt ( ) ; array [ a - 1 ] = array [ a - 1 ] + 1 ; } } int count = 0 ; for ( int i = 0 ; m > i ; i ++ ) { if ( array [ i ] > cjstre - 1 ) count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Qnrwrkx { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int qnrwrkx = s . nextInt ( ) ; System . out . println ( ( double ) qnrwrkx * qnrwrkx * qnrwrkx / 27 ) ; s . close ( ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Yhucfcb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yhucfcb = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < yhucfcb ; i ++ ) { map . put ( i , sc . nextInt ( ) ) ; } int cnt = 0 ; cnt += map . get ( 0 ) ; for ( int i = 1 ; i < yhucfcb ; i ++ ) { if ( map . get ( i - 1 ) < map . get ( i ) ) { cnt += map . get ( i ) - map . get ( i - 1 ) ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Ucnfbed { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ucnfbed = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; String s = sc . next ( ) ; int [ ] l = new int [ q ] ; int [ ] r = new int [ q ] ; for ( int i = 0 ; i < q ; i ++ ) { l [ i ] = sc . nextInt ( ) ; r [ i ] = sc . nextInt ( ) ; } int [ ] at = new int [ ucnfbed ] ; int t = 0 ; for ( int i = 1 ; i < ucnfbed ; ++ i ) { if ( s . charAt ( i - 1 ) == 'A' & s . charAt ( i ) == 'C' ) ++ t ; at [ i ] = t ; } for ( int i = 0 ; i < q ; ++ i ) { System . out . println ( at [ r [ i ] - 1 ] - at [ l [ i ] - 1 ] ) ; } } } import java . util . * ; public class Slzhpr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int slzhpr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( slzhpr > 9 || b > 9 ? " -1 " : slzhpr * b ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class Wtsnlx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String wtsnlx = sc . nextLine ( ) ; System . out . println ( " 2018 " + wtsnlx . substring ( 4 ) ) ; } } import java . util . Scanner ; public class Lofxwme { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int lofxwme = sc . nextInt ( ) ; int [ ] a = new int [ lofxwme ] ; for ( int i = 0 ; i < lofxwme ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } printArray ( a ) ; for ( int i = 1 ; i < lofxwme ; i ++ ) { int key = a [ i ] ; int j = i - 1 ; while ( j >= 0 && a [ j ] > key ) { a [ j + 1 ] = a [ j ] ; j -- ; } a [ j + 1 ] = key ; printArray ( a ) ; } } public static void printArray ( int [ ] a ) { for ( int i = 0 ; i < a . length - 1 ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } System . out . println ( a [ a . length - 1 ] ) ; } } import java . util . Scanner ; public class Ajuem { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ajuem = sc . next ( ) ; if ( ajuem . equals ( " SSS " ) ) { System . out . println ( 0 ) ; return ; } if ( ajuem . equals ( " RRR " ) ) { System . out . println ( 3 ) ; return ; } if ( ajuem . equals ( " RRS " ) || ajuem . equals ( " SRR " ) ) { System . out . println ( 2 ) ; return ; } System . out . println ( 1 ) ; } } import java . util . * ; public class Iyyuti { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iyyuti = sc . nextInt ( ) ; PriorityQueue < Double > q = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < iyyuti ; i ++ ) { q . add ( ( double ) sc . nextInt ( ) ) ; } while ( q . size ( ) > 1 ) { double x = q . poll ( ) ; double y = q . poll ( ) ; q . add ( ( x + y ) / 2 ) ; } System . out . println ( q . poll ( ) ) ; } } import java . util . * ; public class Izkpj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int izkpj = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; int ans = 0 ; for ( int i = 0 ; i < izkpj ; i ++ ) { String s = sc . next ( ) ; if ( ! set . contains ( s ) ) { set . add ( s ) ; ans ++ ; } } System . out . print ( ans ) ; } } import java . util . Scanner ; public class Ipqtdla { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double ipqtdla = sc . nextInt ( ) ; double b = sc . nextInt ( ) ; double c = sc . nextInt ( ) ; double d = sc . nextInt ( ) ; double tturn = Math . ceil ( c / b ) ; double aturn = Math . ceil ( ipqtdla / d ) ; if ( tturn <= aturn ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . File ; import java . io . IOException ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Deque ; import java . util . Scanner ; public class Abyza { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int abyza = sc . nextInt ( ) ; int H = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; System . out . println ( ( x - r >= 0 && x + r <= abyza && y - r >= 0 && y + r <= H ) ? " Yes " : " No " ) ; } } import java . util . * ; public class Xkvqu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xkvqu = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; double ans = 100001.0 ; double bef ; int answer = 0 ; for ( int i = 0 ; i < xkvqu ; i ++ ) { bef = ans ; ans = Math . min ( ans , Math . abs ( a - ( t - sc . nextInt ( ) * 0.006 ) ) ) ; if ( bef != ans ) answer = i + 1 ; } System . out . println ( answer ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Zhzuggt { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int zhzuggt = Integer . parseInt ( sc . next ( ) ) ; List < Integer > a = new ArrayList < > ( ) ; a . add ( zhzuggt ) ; int ans = 0 ; for ( int i = 0 ; i < 1000000 ; i ++ ) { int ai = a . get ( i ) % 2 == 0 ? a . get ( i ) / 2 : 3 * a . get ( i ) + 1 ; if ( a . contains ( ai ) ) { ans = i + 2 ; break ; } a . add ( ai ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class Jktie { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jktie = sc . nextInt ( ) ; int [ ] d = new int [ jktie ] ; for ( int i = 0 ; i < jktie ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; int ans = 1 ; for ( int i = 1 ; i < jktie ; i ++ ) { if ( d [ i - 1 ] != d [ i ] ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Mkdey { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String line1 = sc . nextLine ( ) ; String line2 = sc . nextLine ( ) ; String [ ] array1 = line1 . split ( " " ) ; String [ ] array2 = line2 . split ( " " ) ; int mkdey = Integer . parseInt ( array1 [ 0 ] ) ; int n = Integer . parseInt ( array1 [ 1 ] ) ; long sum = 0 ; String result = " No " ; for ( int i = 0 ; i < n ; i ++ ) { int buf = Integer . parseInt ( array2 [ i ] ) ; sum += buf ; if ( sum >= mkdey ) { result = " Yes " ; break ; } } System . out . println ( result ) ; } } import java . io . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . util . * ; public class Wxahxrp { static class Wxahxrp { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { 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 wxahxrp = " " ; try { wxahxrp = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return wxahxrp ; } public Character charAt ( int i ) { return null ; } } public static void main ( String [ ] args ) throws IOException { FastReader s = new FastReader ( ) ; String n = s . next ( ) ; if ( n . charAt ( 0 ) >= 65 && n . charAt ( 0 ) <= 90 ) System . out . println ( " A " ) ; else System . out . println ( " a " ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; public class Aefaf { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int aefaf = sc . nextInt ( ) ; String [ ] str = new String [ aefaf ] ; for ( int i = 0 ; i < aefaf ; i ++ ) { str [ i ] = sc . next ( ) ; } List < String > listA = new ArrayList < String > ( Arrays . asList ( str ) ) ; List < String > listB = new ArrayList < String > ( new HashSet < > ( listA ) ) ; if ( listA . size ( ) == listB . size ( ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Apgzjar { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; a [ 0 ] = sc . nextInt ( ) ; a [ 1 ] = sc . nextInt ( ) ; a [ 2 ] = sc . nextInt ( ) ; int apgzjar ; for ( int i = 0 ; i < a . length ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( a [ i ] < a [ j ] ) { apgzjar = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = apgzjar ; } } } apgzjar = a [ 1 ] - a [ 0 ] ; apgzjar += a [ 2 ] - a [ 1 ] ; System . out . println ( apgzjar ) ; } } import java . util . Scanner ; public class Bxwuyu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bxwuyu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int count = 0 ; if ( bxwuyu == b ) { count ++ ; } if ( b == c ) { count ++ ; } if ( c == bxwuyu ) { count ++ ; } System . out . println ( count == 1 ? " Yes " : " No " ) ; } } import java . util . * ; public class Biiyw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Integer n = Integer . valueOf ( sc . nextLine ( ) ) ; String biiyw = sc . nextLine ( ) ; Map < Integer , Integer > vList = str2List ( biiyw ) ; String cStr = sc . nextLine ( ) ; Map < Integer , Integer > cList = str2List ( cStr ) ; Integer max = 0 ; for ( Integer i = 0 ; i < n ; i ++ ) { Integer profit = vList . get ( i ) - cList . get ( i ) ; if ( profit > 0 ) { max += profit ; } } System . out . println ( max ) ; } static Map < Integer , Integer > str2List ( String str ) { String [ ] vArrStr = str . split ( " " ) ; Map < Integer , Integer > ret = new HashMap < > ( ) ; Integer key = 0 ; for ( String val : vArrStr ) { ret . put ( key , Integer . valueOf ( val ) ) ; key ++ ; } return ret ; } } import java . io . IOException ; import java . util . Scanner ; public class Tgrcw { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int tgrcw = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] m = new int [ tgrcw ] ; int minCost = Integer . MAX_VALUE ; int total = 0 ; for ( int i = 0 ; i < tgrcw ; i ++ ) { m [ i ] = sc . nextInt ( ) ; minCost = Math . min ( minCost , m [ i ] ) ; total += m [ i ] ; } System . out . println ( ( x - total ) / minCost + tgrcw ) ; } } import java . util . Scanner ; public class Nihfph { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; int nihfph = Integer . parseInt ( String . join ( " " , S . split ( " / " ) ) ) ; System . out . println ( nihfph <= 20190430 ? " Heisei " : " TBD " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Omreqsy { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Solver solver = new Solver ( ) ; solver . init ( ) ; solver . readHead ( in . readLine ( ) ) ; } } class Omreqsy { int omreqsy ; int cnt ; public void init ( ) { omreqsy = 0 ; cnt = 0 ; } public void readHead ( String str ) { String [ ] strArr = str . split ( " " ) ; omreqsy = Integer . parseInt ( strArr [ 0 ] ) ; int a = Integer . parseInt ( strArr [ 0 ] ) ; int b = Integer . parseInt ( strArr [ 1 ] ) ; int k = Integer . parseInt ( strArr [ 2 ] ) ; for ( int ans = Integer . min ( a , b ) ; ; ans -- ) { if ( a % ans == 0 && b % ans == 0 ) k -- ; if ( k <= 0 ) { System . out . println ( ans ) ; return ; } } } public boolean hasNext ( ) { return cnt < omreqsy ; } public void readBody ( String str ) { cnt ++ ; } public void solve ( ) { } } import java . util . ArrayList ; import java . util . Scanner ; class Ivayh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ivayh = sc . nextInt ( ) ; int firstPoint = sc . nextInt ( ) ; ArrayList < Integer > playerPoint = new ArrayList < > ( ) ; for ( int i = 0 ; i < ivayh ; i ++ ) { playerPoint . add ( 0 ) ; } int cnt = sc . nextInt ( ) ; for ( int i = 0 ; i < cnt ; i ++ ) { int p = sc . nextInt ( ) ; playerPoint . set ( p - 1 , playerPoint . get ( p - 1 ) + 1 ) ; } for ( int i = 0 ; i < ivayh ; i ++ ) { System . out . println ( firstPoint - cnt + playerPoint . get ( i ) > 0 ? " Yes " : " No " ) ; } } } import java . math . BigDecimal ; import java . util . Scanner ; public class Uynbiw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long uynbiw = sc . nextLong ( ) ; BigDecimal ans = new BigDecimal ( 1 ) ; BigDecimal over = new BigDecimal ( 1000000000000000000L ) ; boolean ov = false ; boolean ze = false ; for ( int i = 0 ; i < uynbiw ; i ++ ) { long Ai = sc . nextLong ( ) ; if ( ! ze ) { if ( Ai == 0 ) { ze = true ; } if ( ! ov ) { BigDecimal bd = new BigDecimal ( Ai ) ; ans = ans . multiply ( bd ) ; int ju = ans . compareTo ( over ) ; if ( ju == 1 ) { ov = true ; } } } } if ( ze ) { System . out . println ( 0 ) ; } else if ( ov ) { System . out . println ( - 1 ) ; } else { System . out . println ( ans ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; import java . util . Scanner ; class Vkfrafj { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] chars = s . toCharArray ( ) ; for ( char vkfrafj : chars ) { if ( vkfrafj == '1' ) { System . out . print ( 9 ) ; } else { System . out . print ( 1 ) ; } } } } import java . util . Scanner ; class Pnijnvj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pnijnvj = sc . nextInt ( ) ; String temp = String . valueOf ( pnijnvj / 100 ) ; int tem = Integer . parseInt ( temp + temp + temp ) ; if ( pnijnvj <= tem ) { System . out . println ( tem ) ; } else { System . out . println ( tem + 111 ) ; } } } import java . util . Scanner ; public class Eapegwz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int eapegwz = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int f = 0 ; for ( int price = B * 10 ; price < ( B + 1 ) * 10 ; price ++ ) { if ( ( int ) ( ( double ) price * 0.08 + 0.01 ) == eapegwz ) { System . out . println ( price ) ; f ++ ; break ; } } if ( f == 0 ) { System . out . println ( - 1 ) ; } } } import java . util . * ; public class Bygpaz { public static void main ( String [ ] args ) { Scanner read = new Scanner ( System . in ) ; int bygpaz = read . nextInt ( ) ; int [ ] d = new int [ bygpaz ] ; d [ 0 ] = read . nextInt ( ) - 1 ; boolean ban = true ; for ( int i = 1 ; i < bygpaz ; i ++ ) { d [ i ] = read . nextInt ( ) ; if ( d [ i - 1 ] > d [ i ] ) { ban = false ; break ; } if ( d [ i - 1 ] < d [ i ] ) -- d [ i ] ; } if ( ban ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . * ; class Bgombyj { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = buf . readLine ( ) ; char [ ] a = str . toCharArray ( ) ; for ( int bgombyj = 0 ; bgombyj < a . length ; bgombyj ++ ) { if ( Character . isLowerCase ( a [ bgombyj ] ) ) System . out . print ( Character . toUpperCase ( a [ bgombyj ] ) ) ; else if ( Character . isUpperCase ( a [ bgombyj ] ) ) System . out . print ( Character . toLowerCase ( a [ bgombyj ] ) ) ; else System . out . print ( a [ bgombyj ] ) ; if ( bgombyj == a . length - 1 ) System . out . println ( ) ; } } } import java . util . Scanner ; public class Talekk { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner scan = new Scanner ( System . in ) ; String W = scan . nextLine ( ) . toLowerCase ( ) ; int talekk = 0 ; while ( scan . hasNext ( ) ) { String t = scan . next ( ) ; if ( t . equals ( " END_OF_TEXT " ) ) break ; t = t . toLowerCase ( ) ; if ( t . equals ( W ) ) talekk ++ ; } System . out . println ( talekk ) ; System . exit ( 0 ) ; } } import java . util . * ; public class Ubfqwe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ubfqwe = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < ubfqwe ; i ++ ) { int x = sc . nextInt ( ) ; while ( x > 0 && x % 2 == 0 ) { count ++ ; x /= 2 ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Tlajb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long tlajb , b , g , l ; while ( sc . hasNext ( ) ) { tlajb = sc . nextLong ( ) ; b = sc . nextLong ( ) ; g = gcd ( tlajb , b ) ; l = ( tlajb * b ) / g ; System . out . println ( g + " " + l ) ; } } private static long gcd ( long tlajb , long b ) { if ( tlajb == 0 ) return b ; else if ( b == 0 ) return tlajb ; return gcd ( b , tlajb % b ) ; } } import java . io . * ; import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Yjamo { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] s = br . readLine ( ) . split ( " " ) ; String S = s [ 0 ] ; String T = s [ 1 ] ; s = br . readLine ( ) . split ( " " ) ; int yjamo = Integer . parseInt ( s [ 0 ] ) ; int B = Integer . parseInt ( s [ 1 ] ) ; String U = br . readLine ( ) ; if ( U . equals ( S ) ) out . println ( ( yjamo - 1 ) + " " + B ) ; else out . println ( yjamo + " " + ( B - 1 ) ) ; } } import java . util . Scanner ; class Vsalk { public static void main ( String [ ] a ) { Scanner scan = new Scanner ( System . in ) ; int vsalk = scan . nextInt ( ) ; int debt = 100000 ; for ( int i = 0 ; i < vsalk ; i ++ ) { debt += debt / 20 ; debt = up ( debt ) ; } System . out . println ( debt ) ; } static int up ( int money ) { money += 999 ; money -= money % 1000 ; return money ; } } import java . util . Scanner ; public class Sevnlrr { static int sevnlrr ; static int [ ] a ; private static void init ( ) { Scanner scanner = new Scanner ( System . in ) ; sevnlrr = scanner . nextInt ( ) ; a = new int [ sevnlrr ] ; for ( int i = 0 ; i < sevnlrr ; i ++ ) a [ i ] = scanner . nextInt ( ) ; scanner . close ( ) ; } private static boolean check ( ) { boolean ok = true ; for ( int i = 0 ; i < sevnlrr ; i ++ ) { if ( a [ i ] % 2 != 0 ) { ok = false ; break ; } } return ok ; } public static void main ( String [ ] args ) { init ( ) ; int count = 0 ; while ( true ) { if ( check ( ) ) { count ++ ; for ( int j = 0 ; j < sevnlrr ; j ++ ) { a [ j ] = a [ j ] / 2 ; } } else { break ; } } System . out . println ( count ) ; } } import java . util . Scanner ; class Nhati { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; double nhati = Double . parseDouble ( s1 ) ; double s = Math . PI * nhati * nhati ; double l = Math . PI * ( nhati + nhati ) ; System . out . println ( String . format ( " %1$3f " , s ) + " " + String . format ( " %1$3f " , l ) ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Khhelyq { public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( ( System . in ) ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int khhelyq = Integer . parseInt ( st . nextToken ( ) ) ; int y = Integer . parseInt ( st . nextToken ( ) ) ; int z = Integer . parseInt ( st . nextToken ( ) ) ; int temp = khhelyq ; khhelyq = y ; y = temp ; temp = khhelyq ; khhelyq = z ; z = temp ; System . out . println ( khhelyq + " " + y + " " + z ) ; } } import java . util . * ; public class Ccxcavo { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; int ccxcavo = keyboard . nextInt ( ) ; int Y = keyboard . nextInt ( ) ; int turu = 2 ; int kame = 4 ; String ans = " No " ; for ( int i = 0 ; i < ccxcavo + 1 ; i ++ ) { if ( i * turu + ( ccxcavo - i ) * kame == Y ) { ans = " Yes " ; } } System . out . println ( ans ) ; keyboard . close ( ) ; } } import java . util . Scanner ; public class Wzqbot { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String t ; String h ; int wzqbot = 0 ; int h_point = 0 ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { t = sc . next ( ) ; h = sc . next ( ) ; if ( t . compareTo ( h ) > 0 ) { wzqbot += 3 ; } else if ( t . compareTo ( h ) < 0 ) { h_point += 3 ; } else { wzqbot += 1 ; h_point += 1 ; } } System . out . println ( wzqbot + " " + h_point ) ; } } import java . util . Scanner ; public class Etfmenr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String line = sc . next ( ) ; if ( line . equals ( " - " ) ) { break ; } ; int etfmenr = line . length ( ) ; char [ ] str = new char [ etfmenr ] ; for ( int i = 0 ; i < etfmenr ; i ++ ) { str [ i ] = line . charAt ( i ) ; } int m = sc . nextInt ( ) ; for ( int i = 0 ; i < m ; i ++ ) { int h = sc . nextInt ( ) ; char [ ] hoge = new char [ etfmenr ] ; System . arraycopy ( str , 0 , hoge , 0 , etfmenr ) ; for ( int j = 0 ; j < etfmenr ; j ++ ) { str [ j ] = hoge [ ( j + h ) % etfmenr ] ; } } for ( int k = 0 ; k < etfmenr ; k ++ ) { System . out . print ( str [ k ] ) ; } System . out . println ( " " ) ; } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Dyejd { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BBounding solver = new BBounding ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Dyejd { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int dyejd = in . nextInt ( ) ; int x = in . nextInt ( ) ; int d = 0 ; int best = 1 ; for ( int i = 0 ; i < dyejd ; i ++ ) { d += in . nextInt ( ) ; if ( d > x ) { best = i + 1 ; break ; } if ( i == dyejd - 1 ) best = dyejd + 1 ; } out . println ( best ) ; } } } import java . util . Scanner ; public class Rqtui { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int rqtui = in . nextInt ( ) ; int i = 1000 ; while ( i < rqtui ) { i += 1000 ; } System . out . println ( i - rqtui ) ; } } import java . util . * ; public class Cbefz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cbefz = sc . nextInt ( ) ; int [ ] a = new int [ cbefz ] ; for ( int i = 0 ; i < cbefz ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; boolean is_odd = false ; while ( ! is_odd ) { for ( int i = 0 ; i < cbefz ; i ++ ) { if ( ( a [ i ] & 1 ) == 0 ) { a [ i ] >>= 1 ; } else { is_odd = true ; break ; } } if ( ! is_odd ) cnt ++ ; } System . out . println ( cnt ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ekypkrv { public static void main ( String [ ] args ) throws IOException { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String ekypkrv = br . readLine ( ) ; StringBuffer sb = new StringBuffer ( ekypkrv ) ; System . out . println ( sb . reverse ( ) ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class Ahmkww { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ahmkww = scanner . nextInt ( ) ; String s ; HashSet < String > list = new HashSet < String > ( ahmkww ) ; for ( int i = 0 ; i < ahmkww ; i ++ ) { s = scanner . next ( ) ; list . add ( s ) ; } System . out . println ( list . size ( ) ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class Mggcoc { public static void main ( String [ ] args ) { Scanner f = new Scanner ( System . in ) ; while ( true ) { int mggcoc = f . nextInt ( ) ; if ( mggcoc == 0 ) break ; BigDecimal [ ] entries = new BigDecimal [ mggcoc ] ; BigDecimal sum = new BigDecimal ( 0 ) ; BigDecimal std = new BigDecimal ( 0 ) ; for ( int i = 0 ; i < mggcoc ; i ++ ) { BigDecimal temp = new BigDecimal ( f . nextInt ( ) ) ; entries [ i ] = temp ; sum = sum . add ( temp ) ; } BigDecimal average = sum . divide ( new BigDecimal ( mggcoc ) , 6 , BigDecimal . ROUND_HALF_UP ) ; for ( int i = 0 ; i < mggcoc ; i ++ ) { std = std . add ( entries [ i ] . subtract ( average ) . pow ( 2 ) ) ; } System . out . println ( Math . sqrt ( std . divide ( new BigDecimal ( mggcoc ) , 6 , BigDecimal . ROUND_HALF_UP ) . doubleValue ( ) ) ) ; } } } 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 Ueyhqd { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Ueyhqd { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String ueyhqd = in . nextString ( ) ; out . println ( ueyhqd . replaceAll ( " 1 " , " 2 " ) . replaceAll ( " 9 " , " 1 " ) . replaceAll ( " 2 " , " 9 " ) ) ; } } static class Ueyhqd { private BufferedReader br ; private StringTokenizer st ; public InputReader ( InputStream inputStream ) { br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; st = new StringTokenizer ( " " ) ; } public String nextString ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) , " " ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } } return st . nextToken ( ) ; } } } import java . util . Scanner ; import java . util . Arrays ; public class Wmmzt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] num = new int [ 3 ] ; for ( int wmmzt = 0 ; wmmzt < 3 ; wmmzt ++ ) { num [ wmmzt ] = scan . nextInt ( ) ; } int k = scan . nextInt ( ) ; Arrays . sort ( num ) ; for ( int wmmzt = 1 ; wmmzt <= k ; wmmzt ++ ) { num [ 2 ] *= 2 ; } int sum = 0 ; for ( int wmmzt = 0 ; wmmzt < 3 ; wmmzt ++ ) { sum += num [ wmmzt ] ; } System . out . println ( sum ) ; } } import java . lang . reflect . Array ; import java . util . * ; public class Mshhig { static int mshhig ; static int K ; static long Q ; static int A ; static int B ; static long C ; static double min = 9999999 ; static long ans = 0 ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int T = scanner . nextInt ( ) ; System . out . println ( ( T / A ) * B ) ; } } import java . util . Scanner ; public class Mlasoa { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mlasoa = scan . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= mlasoa ; i ++ ) { if ( i % 3 == 0 || i % 5 == 0 ) { continue ; } else { ans = ans + i ; } } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Lmyynh { public static void main ( String [ ] arges ) { List < String > klist = new ArrayList < String > ( ) ; int lmyynh = 0 ; Scanner sc = new Scanner ( System . in ) ; while ( lmyynh < 1 ) { String line = sc . nextLine ( ) ; klist . add ( line ) ; if ( line . equals ( " 0 0 " ) ) { break ; } } for ( String string : klist ) { if ( string . equals ( " 0 0 " ) ) { break ; } String [ ] k = string . split ( " " ) ; int v = Integer . parseInt ( k [ 0 ] ) ; int v2 = Integer . parseInt ( k [ 1 ] ) ; for ( int j = 0 ; j < v ; j ++ ) { int count = 0 ; if ( ( j + 1 ) % 2 == 1 ) { while ( count < v2 ) { if ( ( count + 1 ) % 2 == 1 ) { System . out . print ( " # " ) ; count ++ ; } else { System . out . print ( " . " ) ; count ++ ; } } } else { while ( count < v2 ) { if ( ( count + 1 ) % 2 == 1 ) { System . out . print ( " . " ) ; count ++ ; } else { System . out . print ( " # " ) ; count ++ ; } } } System . out . println ( " " ) ; } System . out . println ( " " ) ; } } } import java . util . Scanner ; public class Nztsj { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long nztsj = scanner . nextLong ( ) ; String S = scanner . next ( ) ; scanner . close ( ) ; long ans = 1 ; for ( int i = 0 ; i < nztsj - 1 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( i + 1 ) ) ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; class Hokxl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hokxl = Integer . parseInt ( sc . next ( ) ) ; int W = Integer . parseInt ( sc . next ( ) ) ; while ( hokxl != 0 && W != 0 ) { if ( hokxl > 300 || W > 300 ) break ; for ( int i = 0 ; i < hokxl ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; hokxl = Integer . parseInt ( sc . next ( ) ) ; W = Integer . parseInt ( sc . next ( ) ) ; } } } import java . util . Scanner ; class Juodb { public static void main ( String [ ] args ) { int juodb , H , x , y , r ; Scanner sc = new Scanner ( System . in ) ; juodb = sc . nextInt ( ) ; H = sc . nextInt ( ) ; x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; r = sc . nextInt ( ) ; if ( x + r > juodb || x - r < 0 ) { System . out . println ( " No " ) ; } else if ( y + r > H || y - r < 0 ) { System . out . println ( " No " ) ; } else if ( x > juodb || y > H ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; public class Yiiquv { public static void main ( String [ ] args ) { Scanner sc1 = new Scanner ( System . in ) ; int yiiquv = sc1 . nextInt ( ) ; int b = sc1 . nextInt ( ) ; int max = yiiquv + b ; if ( max < yiiquv - b ) { max = yiiquv - b ; } if ( max < yiiquv * b ) { max = yiiquv * b ; } System . out . print ( max ) ; } } import java . util . Scanner ; public class Dgjrh { void run ( ) { Scanner s = new Scanner ( System . in ) ; String W = s . next ( ) ; int dgjrh = 0 ; while ( true ) { String T = s . next ( ) ; if ( T . equals ( " END_OF_TEXT " ) ) break ; if ( W . compareToIgnoreCase ( T ) == 0 ) { dgjrh ++ ; } } System . out . println ( dgjrh ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; class Iuwqy { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int iuwqy = sc . nextInt ( ) ; int [ ] ar = new int [ iuwqy ] ; for ( int i = 0 ; i < iuwqy ; i ++ ) { ar [ i ] = 0 ; } int k = sc . nextInt ( ) ; for ( int i = 1 ; i <= k ; i ++ ) { int d = sc . nextInt ( ) ; for ( int j = 1 ; j <= d ; j ++ ) { int in = sc . nextInt ( ) ; ar [ in - 1 ] ++ ; } } int s = 0 ; for ( int i = 0 ; i < iuwqy ; i ++ ) { if ( ar [ i ] == 0 ) s ++ ; } System . out . println ( s ) ; } catch ( Exception e ) { } } } import java . util . * ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . TreeMap ; import java . util . ArrayDeque ; import java . awt . Point ; class Hpazidf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hpazidf = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] P = new int [ hpazidf ] ; for ( int i = 0 ; i < hpazidf ; i ++ ) { P [ i ] = sc . nextInt ( ) ; } Arrays . sort ( P ) ; int min = 0 ; for ( int i = 0 ; i < K ; i ++ ) { min += P [ i ] ; } System . out . println ( min ) ; } } import java . util . Scanner ; public class Wgmaqqq { void reverse ( ) { Scanner s = new Scanner ( System . in ) ; int wgmaqqq = s . nextInt ( ) ; int [ ] a = new int [ wgmaqqq ] ; for ( int i = 0 ; i < wgmaqqq ; i ++ ) { a [ i ] = s . nextInt ( ) ; } for ( int i = wgmaqqq - 1 ; i >= 0 ; i -- ) { System . out . print ( a [ i ] ) ; if ( i > 0 ) { System . out . print ( " " ) ; } else { System . out . print ( " \n " ) ; } } } public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . reverse ( ) ; } } import java . util . Scanner ; public class Pnxlt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pnxlt = sc . nextInt ( ) ; int [ ] n = new int [ pnxlt ] ; int [ ] m = new int [ pnxlt ] ; for ( int i = 0 ; i < pnxlt ; i ++ ) { n [ i ] = sc . nextInt ( ) ; m [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; for ( int i = 0 ; i < pnxlt ; i ++ ) { if ( n [ i ] == m [ i ] ) { cnt ++ ; } else if ( n [ i ] != m [ i ] ) { cnt = 0 ; } if ( cnt == 3 ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . * ; class Bffghzd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] a = sc . next ( ) . toCharArray ( ) ; int bffghzd = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( a [ i ] == '1' ) { bffghzd += 1 ; } } System . out . print ( bffghzd ) ; } } import java . util . * ; public class Jynoaxe { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int jynoaxe = 0 ; char p = '.' ; for ( char ch : sc . next ( ) . toCharArray ( ) ) { jynoaxe = ( ( p == '.' || p == 'S' ) && ch == 'R' ) ? 1 : jynoaxe ; if ( ch == 'R' && p == 'R' ) jynoaxe ++ ; p = ch ; } System . out . println ( jynoaxe ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { solve ( ) ; } } import java . util . Scanner ; public class Spnapci { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String spnapci = sc . next ( ) ; if ( spnapci . equals ( " AAA " ) || spnapci . equals ( " BBB " ) ) { System . out . print ( " No " ) ; } else { System . out . print ( " Yes " ) ; } } } import java . util . Scanner ; public class Akksmkm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int akksmkm ; int b ; akksmkm = scan . nextInt ( ) ; b = scan . nextInt ( ) ; sizeComparison ( akksmkm , b ) ; } public static void sizeComparison ( int akksmkm , int b ) { String i = " == " ; if ( akksmkm < b ) { i = " < " ; } else if ( akksmkm > b ) { i = " > " ; } System . out . println ( " a " + i + " b " ) ; } } import java . util . Scanner ; public class Fcudoej { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long fcudoej = Integer . parseInt ( sc . next ( ) ) ; long B = Integer . parseInt ( sc . next ( ) ) ; System . out . print ( fcudoej * B / gcd ( fcudoej , B ) ) ; return ; } static long gcd ( long a , long b ) { long max = Math . max ( a , b ) ; long min = Math . min ( a , b ) ; if ( max % min == 0 ) { return min ; } else { return gcd ( max % min , min ) ; } } } import java . util . Scanner ; public class Mtwkwps { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String word ; String [ ] sen = new String [ 1000 ] ; int mtwkwps = 0 ; word = scan . next ( ) ; while ( true ) { sen [ mtwkwps ] = scan . next ( ) ; if ( sen [ mtwkwps ] . equals ( " END_OF_TEXT " ) ) break ; mtwkwps ++ ; } int ans = 0 ; int num = word . length ( ) ; ; for ( int j = 0 ; j < mtwkwps + 1 ; j ++ ) { if ( sen [ j ] . equalsIgnoreCase ( word ) ) ans ++ ; } System . out . println ( ans ) ; return ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class Jnrdaip { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] numberArray = br . readLine ( ) . split ( " " ) ; int jnrdaip = Integer . parseInt ( numberArray [ 0 ] ) ; int K = Integer . parseInt ( numberArray [ 1 ] ) ; String [ ] inputArray = br . readLine ( ) . split ( " " ) ; int [ ] priceArray = new int [ jnrdaip ] ; for ( int i = 0 ; i < jnrdaip ; i ++ ) { priceArray [ i ] = Integer . parseInt ( inputArray [ i ] ) ; } Arrays . sort ( priceArray ) ; int result = 0 ; for ( int j = 0 ; j < K ; j ++ ) { result += priceArray [ j ] ; } System . out . println ( result ) ; } } import java . util . * ; public class Jeojep { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jeojep = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int i = 0 ; int a_tax = ( int ) ( i * 0.08 ) ; int b_tax = ( int ) ( i * 0.1 ) ; int ans = - 1 ; while ( i < 1000 ) { i ++ ; a_tax = ( int ) ( i * 0.08 ) ; b_tax = ( int ) ( i * 0.1 ) ; if ( a_tax == jeojep && b_tax == B ) { ans = i ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Xcxgimg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int xcxgimg = Integer . parseInt ( sc . nextLine ( ) ) ; String line = sc . nextLine ( ) ; String [ ] line1 = line . split ( " " ) ; int [ ] ary = new int [ xcxgimg ] ; for ( int i = 0 ; i < xcxgimg ; i ++ ) ary [ i ] = Integer . parseInt ( line1 [ i ] ) ; int [ ] ary1 = new int [ xcxgimg ] ; for ( int i = 0 ; i < xcxgimg ; i ++ ) ary1 [ ary [ i ] - 1 ] = i + 1 ; for ( int i = 0 ; i < xcxgimg ; i ++ ) System . out . print ( ary1 [ i ] + " " ) ; } } import java . util . * ; import java . io . * ; public class Iwpip { static StringTokenizer st ; static BufferedReader br ; static PrintWriter out ; public static void main ( String [ ] args ) throws IOException { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String iwpip = " " + nextInt ( ) ; if ( iwpip . contains ( " 7 " ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public static long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } public static double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } static String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) . trim ( ) ) ; return st . nextToken ( ) ; } } import java . util . * ; public class Lsfkr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String answer = " Heisei " ; int lsfkr , month , day ; lsfkr = Integer . parseInt ( s . substring ( 0 , 4 ) ) ; month = Integer . parseInt ( s . substring ( 5 , 7 ) ) ; if ( lsfkr > 2019 ) answer = " TBD " ; if ( lsfkr == 2019 && month >= 5 ) answer = " TBD " ; System . out . println ( answer ) ; } } import java . io . PrintStream ; import java . util . Scanner ; public class Ninqn { private static final PrintStream so = System . out ; private static final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int ninqn = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x <= ninqn ; x ++ ) { for ( int y = 0 ; y <= ninqn ; y ++ ) { int z = S - ( x + y ) ; if ( 0 <= z && z <= ninqn ) { count ++ ; } } } so . println ( count ) ; } } import java . util . Scanner ; class Ylkkiv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int [ ] A = new int [ str . length ( ) ] ; for ( int ylkkiv = 0 ; ylkkiv < str . length ( ) ; ylkkiv ++ ) { A [ ylkkiv ] = str . charAt ( ylkkiv ) ; } if ( A [ 0 ] == A [ 1 ] || A [ 1 ] == A [ 2 ] || A [ 2 ] == A [ 3 ] ) { System . out . println ( " Bad " ) ; } else { System . out . println ( " Good " ) ; } } } import java . util . Scanner ; public class Azayb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int azayb = sc . nextInt ( ) ; int h = 0 ; int m = 0 ; int s = 0 ; while ( azayb >= 3600 ) { azayb = azayb - 3600 ; h ++ ; } while ( azayb >= 60 ) { azayb = azayb - 60 ; m ++ ; } s = azayb ; System . out . println ( h + " : " + m + " : " + s ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Gkxbbi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gkxbbi = sc . nextInt ( ) ; int [ ] arr = new int [ gkxbbi ] ; for ( int i = 0 ; i < gkxbbi ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; boolean isDistinct = true ; for ( int i = 1 ; i < gkxbbi ; i ++ ) { if ( arr [ i ] == arr [ i - 1 ] ) { isDistinct = false ; break ; } } if ( isDistinct ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . Scanner ; public class Kjjzb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kjjzb = Integer . parseInt ( sc . next ( ) ) ; int [ ] numList = new int [ kjjzb ] ; for ( int i = 0 ; i < kjjzb ; i ++ ) { numList [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int r = 0 ; for ( int i = 0 ; i < kjjzb ; i ++ ) { for ( int j = i + 1 ; j < kjjzb ; j ++ ) { r += numList [ i ] * numList [ j ] ; } } System . out . println ( r ) ; } } import java . util . * ; class Yebrcig { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int yebrcig = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = - 1 ; for ( int i = 12 ; i <= 1000 ; i ++ ) { if ( i * 8 / 100 == yebrcig && i / 10 == B ) { ans = i ; break ; } } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; public class Sumbgz { private static final String sumbgz = " Sunny " ; private static final String WATHER_CLOUDY = " Cloudy " ; private static final String WATHER_RAINY = " Rainy " ; public static void main ( String [ ] args ) { String today = scanTodayWeather ( System . in ) ; String tomorrow = predictTomorrowWeather ( today ) ; System . out . println ( tomorrow ) ; } private static String scanTodayWeather ( InputStream in ) { String today = null ; try { InputStreamReader isr = new InputStreamReader ( in ) ; BufferedReader br = new BufferedReader ( isr ) ; today = br . readLine ( ) ; br . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return today ; } private static String predictTomorrowWeather ( String today ) { String tomorrow = null ; if ( today . equals ( sumbgz ) ) { tomorrow = WATHER_CLOUDY ; } else if ( today . equals ( WATHER_CLOUDY ) ) { tomorrow = WATHER_RAINY ; } else if ( today . equals ( WATHER_RAINY ) ) { tomorrow = sumbgz ; } return tomorrow ; } } import java . io . BufferedReader ; import java . io . * ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . math . * ; public class Yiiagtd { static class Yiiagtd { 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 ; } } public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int yiiagtd = 1 ; while ( yiiagtd -- > 0 ) { String [ ] s = sc . next ( ) . split ( " S " ) ; int max = 0 ; for ( String w : s ) { max = Math . max ( w . length ( ) , max ) ; } pw . println ( max ) ; } pw . close ( ) ; } } import java . util . Scanner ; public class Rnkrlk { private final static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int rnkrlk = sc . nextInt ( ) ; long K = sc . nextInt ( ) ; long Q = sc . nextInt ( ) ; long [ ] array = new long [ rnkrlk ] ; for ( int i = 0 ; i < Q ; i ++ ) { array [ sc . nextInt ( ) - 1 ] ++ ; } for ( int i = 0 ; i < rnkrlk ; i ++ ) { if ( ( K + array [ i ] - Q ) > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; public class Uhlih { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uhlih = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; char [ ] p = { 'A' , 'B' , 'C' } ; int idx = 0 ; int count = 0 ; for ( int i = 0 ; i < uhlih ; i ++ ) { if ( s . charAt ( i ) != p [ idx ] ) { idx = s . charAt ( i ) == p [ 0 ] ? 1 : 0 ; } else idx ++ ; if ( idx == 3 ) { idx = 0 ; count ++ ; } } System . out . println ( count ) ; } } import java . io . * ; import java . util . StringTokenizer ; class Kabik { public static void main ( String [ ] args ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String buf ; try { while ( ( buf = br . readLine ( ) ) != null ) { StringTokenizer st = new StringTokenizer ( buf ) ; long kabik = Integer . parseInt ( st . nextToken ( ) ) ; long m = Integer . parseInt ( st . nextToken ( ) ) ; long gcd ; long lcm = kabik * m ; while ( kabik % m != 0 ) { long t = m ; m = kabik % m ; kabik = t ; } gcd = m ; lcm = lcm / gcd ; System . out . println ( gcd + " " + lcm ) ; } } catch ( Exception e ) { System . out . println ( " Exception! " ) ; } } } import java . util . Scanner ; public class Wusfqcc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wusfqcc = sc . nextInt ( ) ; int a , b , c ; for ( int i = 0 ; i < wusfqcc ; i ++ ) { a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; if ( judgeTriangle ( a , b , c ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } sc . close ( ) ; } static boolean judgeTriangle ( int a , int b , int c ) { int da = a * a ; int db = b * b ; int dc = c * c ; if ( da + db == dc ) return true ; else if ( db + dc == da ) return true ; else if ( dc + da == db ) return true ; else return false ; } } import java . util . Scanner ; public class Elakq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String elakq = sc . next ( ) ; StringBuilder sb = new StringBuilder ( elakq ) ; String ans = elakq . replace ( " eraser " , " " ) . replace ( " erase " , " " ) . replace ( " dreamer " , " " ) . replace ( " dream " , " " ) ; System . out . println ( ans . equals ( " " ) ? " YES " : " NO " ) ; } } import java . util . Scanner ; class Cnzaaxz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cnzaaxz = sc . nextInt ( ) ; int [ ] height = new int [ cnzaaxz ] ; for ( int i = 0 ; i < cnzaaxz ; i ++ ) { height [ i ] = Integer . parseInt ( sc . next ( ) ) ; } boolean pos = true ; for ( int i = 0 ; i < cnzaaxz - 1 ; i ++ ) { if ( height [ cnzaaxz - i - 2 ] - height [ cnzaaxz - i - 1 ] <= 0 ) { continue ; } else if ( height [ cnzaaxz - i - 2 ] - height [ cnzaaxz - i - 1 ] == 1 ) { height [ cnzaaxz - i - 2 ] -- ; } else { pos = false ; break ; } } if ( pos ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . PrintWriter ; import java . util . Scanner ; public class Bkgfiq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bkgfiq = Integer . parseInt ( sc . next ( ) ) ; int Y = Integer . parseInt ( sc . next ( ) ) ; int k = 0 ; PrintWriter out = new PrintWriter ( System . out ) ; for ( int i = 0 ; i <= bkgfiq ; i ++ ) { for ( int j = 0 ; j <= bkgfiq - i ; j ++ ) { k = bkgfiq - i - j ; if ( 10000 * i + 5000 * j + 1000 * k == Y ) { out . println ( i + " " + j + " " + k ) ; sc . close ( ) ; out . flush ( ) ; return ; } } } out . println ( " -1 -1 -1 " ) ; sc . close ( ) ; out . flush ( ) ; } } import java . util . Scanner ; public class Nrrqt { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { solve ( sc ) ; } } public static void solve ( Scanner sc ) { char [ ] x = sc . next ( ) . toCharArray ( ) ; x [ 3 ] = '8' ; System . out . println ( x ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; public class Ykeccu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ykeccu = sc . nextInt ( ) ; HashMap < String , Long > map = new HashMap < > ( ) ; for ( int i = 0 ; i < ykeccu ; i ++ ) { String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; Arrays . sort ( c ) ; s = new String ( c ) ; Long cnt = ( map . containsKey ( s ) ? map . get ( s ) + 1 : 1 ) ; map . put ( s , cnt ) ; } long count = 0 ; for ( Long l : map . values ( ) ) { count = count + ( l * ( l - 1 ) / 2 ) ; } System . out . print ( count ) ; } } import java . util . Scanner ; public class Kjuli { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int kjuli = in . nextInt ( ) ; int [ ] d = new int [ kjuli ] ; for ( int i = 0 ; i < kjuli ; i ++ ) { d [ i ] = in . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < kjuli ; i ++ ) { for ( int j = i + 1 ; j < kjuli ; j ++ ) { sum += d [ i ] * d [ j ] ; } } System . out . println ( sum ) ; } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Arfvg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int arfvg = sc . nextInt ( ) ; Set < String > used = new HashSet < String > ( ) ; String s = sc . next ( ) ; used . add ( s ) ; for ( int i = 1 ; i < arfvg ; i ++ ) { String t = sc . next ( ) ; if ( used . contains ( t ) ) { System . out . println ( " No " ) ; break ; } else { used . add ( t ) ; } if ( s . charAt ( s . length ( ) - 1 ) != t . charAt ( 0 ) ) { System . out . println ( " No " ) ; break ; } if ( i == arfvg - 1 ) { System . out . println ( " Yes " ) ; } s = t ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Pjgqgn { public static void main ( String [ ] args ) throws Exception { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String [ ] array = reader . readLine ( ) . split ( " " ) ; int pjgqgn = Integer . parseInt ( array [ 0 ] ) ; int B = Integer . parseInt ( array [ 1 ] ) ; int C = Integer . parseInt ( array [ 2 ] ) ; System . out . println ( Math . max ( B + C - pjgqgn , 0 ) ) ; } } } import java . util . * ; public class Rukwoa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String word = sc . next ( ) ; String mae = " " ; String usiro = " " ; while ( ! word . equals ( " - " ) ) { int rukwoa = sc . nextInt ( ) ; for ( int i = 0 ; i < rukwoa ; i ++ ) { int a = sc . nextInt ( ) ; usiro = word . substring ( a ) ; mae = word . substring ( 0 , a ) ; word = usiro + mae ; } System . out . println ( word ) ; word = sc . next ( ) ; } sc . close ( ) ; } } import java . util . * ; class Xglane { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xglane = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { int button = 0 ; if ( xglane > B ) { sum += xglane ; xglane -= 1 ; } else { sum += B ; B -= 1 ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Vsnzdy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int vsnzdy = Integer . parseInt ( str ) ; str = scan . next ( ) ; int b = Integer . parseInt ( str ) ; if ( vsnzdy < b ) System . out . println ( " a < b " ) ; else if ( vsnzdy > b ) System . out . println ( " a > b " ) ; else if ( vsnzdy == b ) System . out . println ( " a == b " ) ; } } import java . util . Scanner ; public class Dlxrgc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] result = new int [ 26 ] ; for ( int dlxrgc = 0 ; dlxrgc < result . length ; dlxrgc ++ ) { result [ dlxrgc ] = 0 ; } while ( sc . hasNext ( ) ) { String input = sc . nextLine ( ) ; for ( int dlxrgc = 0 ; dlxrgc < input . length ( ) ; dlxrgc ++ ) { char ch = input . charAt ( dlxrgc ) ; String str = String . valueOf ( ch ) ; str = str . toLowerCase ( ) ; ch = str . charAt ( 0 ) ; for ( char c = 'a' ; c <= 'z' ; c ++ ) { int index = c - 'a' ; if ( ch == c ) { result [ index ] ++ ; } } } } for ( int dlxrgc = 0 ; dlxrgc < result . length ; dlxrgc ++ ) { char alphabet = ( char ) ( dlxrgc + 'a' ) ; System . out . println ( alphabet + " : " + result [ dlxrgc ] ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Iuqrcr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iuqrcr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; while ( iuqrcr > 0 || c > 0 ) { c -= b ; if ( c <= 0 ) break ; iuqrcr -= d ; } if ( iuqrcr > 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . * ; import java . util . * ; public class Myhaa { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; System . out . println ( 4 - in . nextLine ( ) . replace ( " + " , " " ) . length ( ) * 2 ) ; } } import java . util . * ; public class Pgyel { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int pgyel = stdIn . nextInt ( ) ; int [ ] d = new int [ pgyel ] ; for ( int i = 0 ; i < pgyel ; i ++ ) { d [ i ] = stdIn . nextInt ( ) ; } Arrays . sort ( d ) ; int count = 0 ; for ( int i = 0 ; i < pgyel ; i ++ ) { if ( i >= 1 && d [ i ] != d [ i - 1 ] ) { count ++ ; } else if ( i == 0 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . ArrayList ; class Pojzqpv { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int pojzqpv = scn . nextInt ( ) ; ArrayList < Integer > element = new ArrayList < Integer > ( ) ; for ( int i = 1 ; ; ) { if ( i == 1 ) { element . add ( pojzqpv ) ; } else { if ( pojzqpv % 2 == 1 ) { pojzqpv = odd ( pojzqpv ) ; } else { pojzqpv = even ( pojzqpv ) ; } if ( element . indexOf ( pojzqpv ) == - 1 ) { element . add ( pojzqpv ) ; } else { System . out . println ( i ) ; break ; } } i ++ ; } } public static int even ( int n ) { return n / 2 ; } public static int odd ( int n ) { return 3 * n + 1 ; } } import java . math . BigInteger ; import java . util . * ; import java . io . * ; public class Czhaocs { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int czhaocs = in . nextInt ( ) ; double side = ( double ) czhaocs / 3 ; System . out . println ( side * side * side ) ; } } import java . util . * ; public class Taurwqw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int taurwqw = sc . nextInt ( ) ; int [ ] value = new int [ taurwqw ] ; for ( int i = 0 ; i < taurwqw ; i ++ ) { value [ i ] = sc . nextInt ( ) ; } solve ( value ) ; } public static void solve ( int [ ] value ) { double result = 0 ; for ( int an : value ) { result += ( double ) 1 / an ; } result = 1 / result ; System . out . println ( result ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Fozhai { public static void main ( String [ ] args ) { int fozhai ; int M ; int temp ; int sum = 0 ; int P ; ArrayList < Integer > A = new ArrayList < Integer > ( ) ; Scanner sc = new Scanner ( System . in ) ; fozhai = sc . nextInt ( ) ; M = sc . nextInt ( ) ; int i ; for ( i = 0 ; i < fozhai ; i ++ ) { temp = sc . nextInt ( ) ; A . add ( temp ) ; sum += temp ; } Collections . sort ( A , Collections . reverseOrder ( ) ) ; P = A . get ( M - 1 ) ; if ( ( double ) sum / 4 / M > P ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Cojrrh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Integer int1 = scanner . nextInt ( ) ; Integer int2 = scanner . nextInt ( ) ; int cojrrh = int1 * int2 ; System . out . println ( cojrrh ) ; } } import java . util . * ; class Emwzei { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int emwzei = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < emwzei ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } List < Integer > listB = new ArrayList < Integer > ( new HashSet < > ( list ) ) ; System . out . print ( listB . size ( ) ) ; } } import java . util . Scanner ; public class Mirluac { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int mirluac = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String u = sc . next ( ) ; if ( s . equals ( u ) ) mirluac -- ; if ( t . equals ( u ) ) b -- ; System . out . println ( mirluac + " " + b ) ; } } import java . util . * ; public class Vabydy { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int vabydy = scn . nextInt ( ) ; int k = scn . nextInt ( ) ; int [ ] a = new int [ vabydy ] ; for ( int i = 0 ; i < a . length ; ++ i ) { a [ i ] = scn . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < a . length ; ++ i ) { if ( k <= a [ i ] ) { count = count + 1 ; } } System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . Arrays ; class Bcelh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String str = sc . nextLine ( ) ; String [ ] str2 = str . split ( " " ) ; int [ ] x = new int [ 2 ] ; for ( int bcelh = 0 ; bcelh < 2 ; bcelh ++ ) { x [ bcelh ] = Integer . parseInt ( str2 [ bcelh ] ) ; } if ( x [ 0 ] == 0 && x [ 1 ] == 0 ) { break ; } Arrays . sort ( x ) ; System . out . println ( x [ 0 ] + " " + x [ 1 ] ) ; } } } import java . util . Scanner ; import java . lang . Math ; class Lkmfi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double lkmfi = scan . nextDouble ( ) ; double area = lkmfi * lkmfi * Math . PI ; double circumference = 2 * lkmfi * Math . PI ; System . out . printf ( " %f %f \n " , area , circumference ) ; } } import java . util . Scanner ; import java . lang . Math ; class Adjcr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] alp = s . toCharArray ( ) ; int adjcr = ( int ) ( alp [ 0 ] ) ; alp [ 0 ] = ( char ) ( adjcr + 1 ) ; System . out . print ( alp [ 0 ] ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; class Gynxvpb { public static void main ( String [ ] args ) throws Exception { int [ ] antenna = new int [ 5 ] ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; for ( int gynxvpb = 0 ; gynxvpb < antenna . length ; gynxvpb ++ ) { antenna [ gynxvpb ] = Integer . parseInt ( br . readLine ( ) ) ; } int k = Integer . parseInt ( br . readLine ( ) ) ; if ( antenna [ 4 ] - antenna [ 0 ] > k ) { System . out . println ( " :( " ) ; } else { System . out . println ( " Yay! " ) ; } } } import java . util . Scanner ; public class Mupaqxp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int mupaqxp = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( mupaqxp == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < W ; i ++ ) { System . out . printf ( " # " ) ; } System . out . printf ( " %n " ) ; for ( int i = 0 ; i < mupaqxp - 2 ; i ++ ) { System . out . printf ( " # " ) ; for ( int j = 0 ; j < W - 2 ; j ++ ) { System . out . printf ( " . " ) ; } System . out . printf ( " #%n " ) ; } for ( int i = 0 ; i < W ; i ++ ) { System . out . printf ( " # " ) ; } System . out . printf ( " %n%n " ) ; } } } import java . util . Scanner ; public class Qlxwx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qlxwx = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int ans = 0 ; if ( b <= c || d <= qlxwx ) { ans = 0 ; } else if ( c <= qlxwx && b <= d ) { ans = b - qlxwx ; } else if ( qlxwx <= c && d <= b ) { ans = d - c ; } else if ( qlxwx <= c && c <= b && b <= d ) { ans = b - c ; } else if ( c <= qlxwx && qlxwx <= d && d <= b ) { ans = d - qlxwx ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Ulxlqu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ulxlqu = sc . nextInt ( ) ; int [ ] t = new int [ ulxlqu + 1 ] ; int [ ] x = new int [ ulxlqu + 1 ] ; int [ ] y = new int [ ulxlqu + 1 ] ; t [ 0 ] = 0 ; x [ 0 ] = 0 ; y [ 0 ] = 0 ; boolean result = true ; for ( int i = 1 ; i <= ulxlqu ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; int tempx = Math . abs ( x [ i ] - x [ i - 1 ] ) ; int tempy = Math . abs ( y [ i ] - y [ i - 1 ] ) ; int tempt = Math . abs ( t [ i ] - t [ i - 1 ] ) ; if ( ( tempx + tempy ) > tempt ) { result = false ; break ; } if ( ( tempx + tempy ) % 2 != tempt % 2 ) { result = false ; break ; } } sc . close ( ) ; if ( result ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Albccdx { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int albccdx = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] a = new int [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = scan . nextInt ( ) ; b [ i ] = scan . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < albccdx ; i ++ ) { count = 0 ; for ( int j = 0 ; j < a . length ; j ++ ) { if ( a [ j ] == i + 1 ) { count ++ ; } if ( b [ j ] == i + 1 ) { count ++ ; } } System . out . println ( count ) ; } } } import java . util . * ; import java . io . * ; public class Hjhzx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; int [ ] rx = new int [ 3 ] ; int [ ] ry = new int [ 3 ] ; boolean hjhzx = true ; for ( int i = 0 ; i < 3 ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { c [ i ] [ j ] = scan . nextInt ( ) ; } } ry [ 0 ] = 0 ; for ( int j = 0 ; j < 3 ; j ++ ) { rx [ j ] = c [ 0 ] [ j ] - ry [ 0 ] ; } for ( int j = 1 ; j < 3 ; j ++ ) { ry [ j ] = c [ j ] [ 0 ] - rx [ 0 ] ; } outside : for ( int i = 0 ; i < 3 ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { if ( rx [ j ] + ry [ i ] != c [ i ] [ j ] ) { hjhzx = false ; System . out . println ( " No " ) ; break outside ; } } } if ( hjhzx ) { System . out . println ( " Yes " ) ; } } } import java . util . * ; public class Wcivl { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s ; int wcivl ; int i ; Deck d = new Deck ( ) ; while ( ! ( s = sc . next ( ) ) . equals ( " - " ) ) { d . setDeck ( s ) ; wcivl = sc . nextInt ( ) ; for ( i = 0 ; i < wcivl ; i ++ ) { d . shuffle ( sc . nextInt ( ) ) ; } d . printDeck ( ) ; } } } class Wcivl { private String str ; Deck ( ) { } void setDeck ( String s ) { this . str = s ; } void shuffle ( int h ) { this . str = this . str . substring ( h , this . str . length ( ) ) + this . str . substring ( 0 , h ) ; } void printDeck ( ) { System . out . println ( this . str ) ; } } import java . util . Scanner ; public class Eugaftk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] an = new int [ 5 ] ; for ( int eugaftk = 0 ; eugaftk < 5 ; eugaftk ++ ) { an [ eugaftk ] = sc . nextInt ( ) ; } int k = sc . nextInt ( ) ; String ans = " :( " ; sc . close ( ) ; if ( an [ 4 ] - an [ 0 ] <= k ) { ans = " Yay! " ; } System . out . println ( ans ) ; } } import java . util . * ; class Auppt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int auppt = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( auppt > b ) { System . out . println ( 2 * auppt - 1 ) ; } else if ( auppt == b ) { System . out . println ( 2 * auppt ) ; } else { System . out . println ( 2 * b - 1 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Pfcubt { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int pfcubt = fs . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= pfcubt ; ++ i ) { if ( i % 3 != 0 && i % 5 != 0 ) ans += i ; } System . out . println ( ans ) ; } static class Pfcubt { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] readArray ( int pfcubt ) { int [ ] a = new int [ pfcubt ] ; for ( int i = 0 ; i < pfcubt ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . io . * ; import java . util . * ; class Hqzsdup { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int hqzsdup = s . nextInt ( ) ; int n = s . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = s . nextInt ( ) ; } int maxdiff = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( maxdiff < arr [ i ] - arr [ i - 1 ] ) maxdiff = arr [ i ] - arr [ i - 1 ] ; } if ( maxdiff < hqzsdup - arr [ n - 1 ] + arr [ 0 ] ) { System . out . println ( hqzsdup - ( hqzsdup - arr [ n - 1 ] + arr [ 0 ] ) ) ; } else { System . out . println ( hqzsdup - maxdiff ) ; } } } import java . io . IOException ; import java . util . ArrayList ; import java . util . Scanner ; class Gtuerpa { public static void main ( String [ ] args ) throws NumberFormatException , IOException { Scanner scan = new Scanner ( System . in ) ; ArrayList < Integer > NN = new ArrayList < Integer > ( ) ; ArrayList < Integer > XX = new ArrayList < Integer > ( ) ; int gtuerpa = 1 ; int x = 1 ; int kumi = 0 ; while ( gtuerpa != 0 || x != 0 ) { gtuerpa = scan . nextInt ( ) ; x = scan . nextInt ( ) ; NN . add ( gtuerpa ) ; XX . add ( x ) ; } for ( int i = 0 ; i < NN . size ( ) - 1 ; i ++ ) { kumi = 0 ; for ( int i1 = 0 ; i1 < NN . get ( i ) ; i1 ++ ) { for ( int i2 = 0 ; i2 < NN . get ( i ) ; i2 ++ ) { for ( int i3 = 0 ; i3 < NN . get ( i ) ; i3 ++ ) { int N1 = i1 + 1 ; int N2 = i2 + 1 ; int N3 = i3 + 1 ; if ( N1 == N2 || N2 == N3 || N3 == N1 ) { } else { if ( N1 + N2 + N3 == XX . get ( i ) ) { kumi += 1 ; } } } } } System . out . println ( kumi / 6 ) ; } } } import java . util . * ; public class Ssqsifk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ssqsifk = Integer . parseInt ( scanner . next ( ) ) ; double x ; x = ( double ) ssqsifk / 3.0 ; System . out . println ( Math . pow ( x , 3 ) ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Idhqrw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int idhqrw = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; List < Integer > cList = new ArrayList < > ( ) ; List < Integer > tList = new ArrayList < > ( ) ; for ( int i = 0 ; i < idhqrw ; i ++ ) { cList . add ( sc . nextInt ( ) ) ; tList . add ( sc . nextInt ( ) ) ; } Integer minCost = null ; for ( int i = 0 ; i < idhqrw ; i ++ ) { if ( tList . get ( i ) > t ) { continue ; } int cost = cList . get ( i ) ; if ( minCost == null || cost < minCost ) { minCost = cost ; } } if ( minCost == null ) { System . out . println ( " TLE " ) ; return ; } System . out . println ( minCost ) ; } } import java . util . Scanner ; public class Vinxzuk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vinxzuk = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int c = 0 ; for ( int i = 0 ; i < vinxzuk ; i ++ ) { int b = sc . nextInt ( ) ; if ( a <= b ) c ++ ; } System . out . println ( c ) ; } } import java . util . Scanner ; public class Trmmrc { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int trmmrc = stdIn . nextInt ( ) ; int Q = stdIn . nextInt ( ) ; int [ ] ans = new int [ trmmrc ] ; int [ ] kota = new int [ Q ] ; String S = stdIn . next ( ) ; int z = 1 , y = 0 , l = 0 , r = 0 , num = 0 ; while ( z < trmmrc ) { if ( S . substring ( z , z + 1 ) . equals ( " C " ) && S . substring ( z - 1 , z ) . equals ( " A " ) ) { y ++ ; } ans [ z ] = y ; z ++ ; } z = 0 ; y = 0 ; while ( z < Q ) { l = stdIn . nextInt ( ) ; r = stdIn . nextInt ( ) ; kota [ z ] = ans [ r - 1 ] - ans [ l - 1 ] ; z ++ ; } z = 0 ; while ( z < Q ) { System . out . println ( kota [ z ] ) ; z ++ ; } } } import java . util . * ; import java . io . * ; import java . math . * ; public class Rwkft { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int rwkft = sc . nextInt ( ) ; if ( rwkft == 2 ) { System . out . println ( rwkft ) ; return ; } ArrayList < Integer > list = getPrime ( rwkft ) ; while ( true ) { if ( check ( rwkft , list ) ) { System . out . println ( rwkft ) ; return ; } rwkft ++ ; } } static ArrayList < Integer > getPrime ( int x ) { ArrayList < Integer > list = new ArrayList < Integer > ( ) ; list . add ( 2 ) ; int max = ( int ) Math . pow ( x * 2 , 0.5 ) ; for ( int i = 3 ; i < max ; i += 2 ) { boolean chk = true ; for ( int j : list ) { if ( i % j == 0 ) { chk = false ; break ; } } if ( chk ) { list . add ( i ) ; } } return list ; } static boolean check ( int x , List < Integer > list ) { for ( int j : list ) { if ( x % j == 0 ) { return false ; } } return true ; } } import java . util . * ; public class Nwuyaoj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nwuyaoj = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ nwuyaoj ] ; int [ ] B = new int [ nwuyaoj - 1 ] ; for ( int i = 0 ; i < nwuyaoj - 1 ; i ++ ) { B [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int sum = 0 ; if ( B . length == 1 ) { System . out . println ( B [ 0 ] * 2 ) ; return ; } else { sum = B [ 0 ] ; for ( int i = 1 ; i < nwuyaoj - 1 ; i ++ ) { sum += Math . min ( B [ i ] , B [ i - 1 ] ) ; } } sum += B [ nwuyaoj - 2 ] ; System . out . println ( sum ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Qksdbfz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qksdbfz = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < qksdbfz ; i ++ ) { int p = sc . nextInt ( ) ; list . add ( p ) ; } Collections . sort ( list ) ; int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { sum += list . get ( i ) ; } System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Leewzq { public static void main ( String [ ] args ) { new Main ( ) ; } public Main ( ) { Scanner sc = new Scanner ( System . in ) ; int leewzq = Integer . parseInt ( sc . next ( ) ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int remainder = leewzq % A ; int n = leewzq / A ; System . out . println ( remainder > 0 ? n + 1 : n ) ; } } import java . io . * ; import java . util . Scanner ; public class Umflvpu { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] s = br . readLine ( ) . split ( " " ) ; long umflvpu = Long . parseLong ( s [ 0 ] ) ; long a = Long . parseLong ( s [ 1 ] ) ; long b = Long . parseLong ( s [ 2 ] ) ; if ( a == 0 && b == 0 ) { System . out . println ( 0 ) ; } else { long sum = a + b ; sum = umflvpu % sum ; if ( sum > a ) sum = a ; long x = umflvpu / ( a + b ) ; System . out . println ( x * a + sum ) ; } } } import java . util . * ; public class Palcvz { public static void main ( String [ ] args ) throws Exception { final Integer [ ] HonPT = new Integer [ ] { 2 , 4 , 5 , 7 , 9 } ; final Integer [ ] PonPT = new Integer [ ] { 0 , 1 , 6 , 8 } ; Scanner scan = new Scanner ( System . in ) ; char [ ] n = scan . nextLine ( ) . toCharArray ( ) ; Integer num = Integer . parseInt ( String . valueOf ( n [ n . length - 1 ] ) ) ; if ( Arrays . asList ( HonPT ) . contains ( num ) ) { System . out . println ( " hon " ) ; } else if ( Arrays . asList ( PonPT ) . contains ( num ) ) { System . out . println ( " pon " ) ; } else { System . out . println ( " bon " ) ; } scan . close ( ) ; } } import java . util . Scanner ; class Rascszr { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( System . in ) ; long rascszr = sc . nextLong ( ) ; long f = rascszr / 500 , f2 = ( rascszr % 500 ) / 5 ; System . out . println ( f * 1000 + f2 * 5 ) ; } } import java . util . * ; import java . io . * ; import java . math . BigInteger ; public class Esnyu { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; StringTokenizer st1 = new StringTokenizer ( br . readLine ( ) ) ; int esnyu = Integer . parseInt ( st1 . nextToken ( ) ) ; int k = Integer . parseInt ( st1 . nextToken ( ) ) ; int q = Integer . parseInt ( st1 . nextToken ( ) ) ; int [ ] arr = new int [ esnyu ] ; for ( int i = 0 ; i < q ; i ++ ) { arr [ Integer . parseInt ( br . readLine ( ) ) - 1 ] ++ ; } for ( int i = 0 ; i < esnyu ; i ++ ) { if ( k - ( q - arr [ i ] ) > 0 ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } } out . flush ( ) ; out . close ( ) ; } } import java . util . Scanner ; public class Rgxzt { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int rgxzt = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( rgxzt > b ) { ans += rgxzt ; rgxzt -- ; } else { ans += b ; b -- ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; public class Fpwuzo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fpwuzo = sc . nextInt ( ) ; String s = sc . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int start = ( int ) s . charAt ( i ) ; int ans = start + fpwuzo ; if ( ans < 91 ) { System . out . print ( ( char ) ans ) ; } else { System . out . print ( ( char ) ( ans - 26 ) ) ; } } System . out . println ( ) ; } } import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Yrjvs { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { final String s = reader . readLine ( ) ; boolean yrjvs = false ; if ( s . charAt ( 0 ) == 'A' ) { int cnt = 0 ; int at = 0 ; for ( int i = 2 ; i <= s . length ( ) - 2 ; i ++ ) { if ( s . charAt ( i ) == 'C' ) { cnt ++ ; at = i ; } } if ( cnt == 1 ) { yrjvs = true ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( i == at ) continue ; if ( s . charAt ( i ) < 'a' || 'z' < s . charAt ( i ) ) { yrjvs = false ; break ; } } } } System . out . println ( yrjvs ? " AC " : " WA " ) ; } } } import java . util . Scanner ; public class Rjwbv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rjwbv = sc . nextInt ( ) ; int [ ] P = new int [ rjwbv + 1 ] ; for ( int i = 1 ; i <= rjwbv ; i ++ ) { P [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int ans = 1 ; int min = P [ 1 ] ; for ( int i = 2 ; i <= rjwbv ; i ++ ) { min = Math . min ( min , P [ i ] ) ; if ( P [ i ] <= min ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; class Tvdso { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tvdso = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; boolean flag = true ; long aa = tvdso , bb = b ; while ( flag ) { if ( aa < bb ) { aa += tvdso ; } else if ( bb < aa ) { bb += b ; } else if ( aa == bb ) { flag = false ; } } System . out . println ( aa ) ; } } import java . util . Scanner ; public class Itagp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int itagp = sc . nextInt ( ) + sc . nextInt ( ) ; int [ ] nums = { 1 , 2 , 3 } ; switch ( itagp ) { case 3 : System . out . println ( 3 ) ; break ; case 4 : System . out . println ( 2 ) ; break ; case 5 : System . out . println ( 1 ) ; break ; default : return ; } } } import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; class Gihth { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; int gihth = 1 ; while ( ! str . equals ( " 0 " ) ) { System . out . println ( " Case " + gihth + " : " + str ) ; gihth ++ ; str = br . readLine ( ) ; } } } import java . util . HashMap ; import java . util . Scanner ; class Sbxjoo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sbxjoo = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( ( long ) sbxjoo * b / gcd ( sbxjoo , b ) ) ; } public static int gcd ( int sbxjoo , int b ) { if ( sbxjoo % b == 0 ) { return b ; } return gcd ( b , sbxjoo % b ) ; } } import java . io . * ; public class Lcozfez { public static void main ( String [ ] args ) { int lcozfez = 0 , f = 0 , r = 0 ; try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String [ ] strAry = br . readLine ( ) . split ( " " ) ; lcozfez = Integer . parseInt ( strAry [ 0 ] ) ; f = Integer . parseInt ( strAry [ 1 ] ) ; r = Integer . parseInt ( strAry [ 2 ] ) ; if ( lcozfez == - 1 && f == - 1 && r == - 1 ) break ; System . out . printf ( " %s \n " , judge ( lcozfez , f , r ) ) ; } } catch ( Exception e ) { System . err . println ( e ) ; } } private static String judge ( int lcozfez , int f , int r ) { if ( ( lcozfez == - 1 || f == - 1 ) || lcozfez + f < 30 ) return " F " ; else if ( lcozfez + f < 50 ) { if ( r >= 50 ) return " C " ; else return " D " ; } else if ( lcozfez + f < 65 ) return " C " ; else if ( lcozfez + f < 80 ) return " B " ; else return " A " ; } } import java . util . * ; class Ggaeg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ggaeg = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; System . out . println ( ggaeg <= f * t ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Styais { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int styais = scan . nextInt ( ) ; int n1 = styais + 1 ; long [ ] m = new long [ n1 ] ; long [ ] h = new long [ styais ] ; for ( int i = 0 ; i < n1 ; i ++ ) { m [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < styais ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } long result = 0 ; for ( int i = 0 ; i < styais ; i ++ ) { long xh = h [ i ] ; if ( xh >= m [ i ] ) { result += m [ i ] ; xh -= m [ i ] ; if ( xh >= m [ i + 1 ] ) { result += m [ i + 1 ] ; m [ i + 1 ] = 0 ; } else { result += xh ; m [ i + 1 ] -= xh ; } } else { m [ i ] -= xh ; result += xh ; } } System . out . println ( result ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Vyytuh { public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] nANDmStr = input . readLine ( ) . split ( " " ) ; int [ ] nANDm = new int [ nANDmStr . length ] ; for ( int vyytuh = 0 ; vyytuh < nANDmStr . length ; vyytuh ++ ) { nANDm [ vyytuh ] = Integer . parseInt ( nANDmStr [ vyytuh ] ) ; } int [ ] [ ] matrix = new int [ nANDm [ 0 ] ] [ nANDm [ 1 ] ] ; for ( int row = 0 ; row < matrix . length ; row ++ ) { String [ ] matrixStr = input . readLine ( ) . split ( " " ) ; for ( int column = 0 ; column < matrixStr . length ; column ++ ) { matrix [ row ] [ column ] = Integer . parseInt ( matrixStr [ column ] ) ; } } String [ ] vectorStr = new String [ nANDm [ 1 ] ] ; int [ ] vector = new int [ vectorStr . length ] ; for ( int vyytuh = 0 ; vyytuh < vector . length ; vyytuh ++ ) { vectorStr [ vyytuh ] = input . readLine ( ) ; vector [ vyytuh ] = Integer . parseInt ( vectorStr [ vyytuh ] ) ; } for ( int row = 0 ; row < nANDm [ 0 ] ; row ++ ) { int solution = 0 ; for ( int column = 0 ; column < nANDm [ 1 ] ; column ++ ) { solution = matrix [ row ] [ column ] * vector [ column ] + solution ; } System . out . println ( solution ) ; } } } import java . util . Scanner ; public class Gjdtnkz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int gjdtnkz = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; if ( gjdtnkz == 0 ) break ; int count = 0 ; for ( int i = 1 ; i <= gjdtnkz - 2 ; i ++ ) { for ( int j = i + 1 ; j <= gjdtnkz - 1 ; j ++ ) { int check_number = x - i - j ; if ( check_number <= gjdtnkz && check_number > j ) { count ++ ; } } } System . out . println ( count ) ; } } } import java . util . Scanner ; public class Ivrdoti { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final String S = sc . next ( ) ; int ivrdoti ; if ( " RRR " . equals ( S ) ) { ivrdoti = 3 ; } else if ( " RRS " . equals ( S ) || " SRR " . equals ( S ) ) { ivrdoti = 2 ; } else if ( S . contains ( " R " ) ) { ivrdoti = 1 ; } else { ivrdoti = 0 ; } System . out . println ( ivrdoti ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Qnzll { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qnzll = scan . nextInt ( ) ; String [ ] s = new String [ qnzll ] ; int [ ] cnt = new int [ qnzll ] ; String [ ] scheck = new String [ qnzll ] ; for ( int i = 0 ; i < qnzll ; i ++ ) { s [ i ] = scan . next ( ) ; cnt [ i ] = 0 ; scheck [ i ] = " " ; } scan . close ( ) ; Arrays . sort ( s ) ; int suffix = 0 ; int max = 0 ; for ( int i = 0 ; i < qnzll ; i ++ ) { if ( i != 0 && s [ i ] . equals ( s [ i - 1 ] ) == false ) { scheck [ suffix ] = s [ i - 1 ] ; suffix += 1 ; } if ( i == qnzll - 1 ) scheck [ suffix ] = s [ i ] ; if ( i == qnzll - 1 && s [ i ] . equals ( s [ i - 1 ] ) == false ) scheck [ suffix ] = s [ i ] ; cnt [ suffix ] += 1 ; if ( max < cnt [ suffix ] ) max = cnt [ suffix ] ; } for ( int i = 0 ; i <= suffix ; i ++ ) { if ( cnt [ i ] == max ) System . out . println ( scheck [ i ] ) ; } } } import java . util . * ; public class Fnsmm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fnsmm = sc . nextInt ( ) ; int i = 0 ; for ( i = fnsmm ; i > 0 ; i -- ) { if ( judge ( i ) ) { break ; } } System . out . println ( i ) ; } private static boolean judge ( int n ) { boolean re = false ; if ( n == 1 ) { re = true ; } else { for ( int i = 2 ; i < n ; i ++ ) { for ( int j = 1 ; j < n ; j ++ ) { int m = ( int ) Math . pow ( i , j ) ; if ( m == n ) { re = true ; break ; } } } } return re ; } } import java . util . * ; public class Gycml { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gycml = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int a = - 1 ; int b = - 1 ; int c = - 1 ; for ( int i = 0 ; i <= gycml ; i ++ ) { for ( int j = 0 ; j <= gycml - i ; j ++ ) { if ( Y == ( 10000 * i + 5000 * j + 1000 * ( gycml - i - j ) ) ) { a = i ; b = j ; c = gycml - i - j ; } } } System . out . print ( a + " " ) ; System . out . print ( b + " " ) ; System . out . print ( c ) ; } } import java . util . Scanner ; class Gqenc { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) , t ; int gqenc = 0 , countEven = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) t = " 0 " ; else t = " 1 " ; if ( ! s . substring ( i , i + 1 ) . equals ( t ) ) gqenc ++ ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) t = " 1 " ; else t = " 0 " ; if ( ! s . substring ( i , i + 1 ) . equals ( t ) ) countEven ++ ; } System . out . println ( ( int ) Math . min ( gqenc , countEven ) ) ; } } import java . util . * ; public class Btzpvs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int btzpvs = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] allList = new int [ 2 * btzpvs ] ; for ( int i = 0 ; i < 2 * btzpvs ; i ++ ) { allList [ i ] = sc . nextInt ( ) ; } int cost = 10001 ; for ( int i = 1 ; i < 2 * btzpvs ; i += 2 ) { if ( allList [ i ] <= T && allList [ i - 1 ] < cost ) { cost = allList [ i - 1 ] ; } } if ( cost == 10001 ) { System . out . println ( " TLE " ) ; } else { System . out . println ( cost ) ; } } } import java . util . * ; class Wgogcx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int wgogcx = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( wgogcx == 0 && b == 0 ) break ; if ( wgogcx < b ) System . out . println ( wgogcx + " " + b ) ; else System . out . println ( b + " " + wgogcx ) ; } } } import java . util . Scanner ; public class Kxcpcv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long kxcpcv = sc . nextLong ( ) ; if ( kxcpcv < 10 ) { System . out . println ( kxcpcv ) ; } else if ( kxcpcv < 100 ) { System . out . println ( 9 ) ; } else if ( kxcpcv < 1000 ) { System . out . println ( 9 + kxcpcv - 99 ) ; } else if ( kxcpcv < 10000 ) { System . out . println ( 909 ) ; } else if ( kxcpcv < 100000 ) { System . out . println ( 909 + kxcpcv - 9999 ) ; } else { System . out . println ( 90909 ) ; } sc . close ( ) ; } } import java . util . * ; public class Iepzas { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int iepzas = s . nextInt ( ) ; int k = s . nextInt ( ) ; long [ ] h = new long [ iepzas ] ; for ( int i = 0 ; i < iepzas ; i ++ ) { h [ i ] = s . nextLong ( ) ; } long [ ] dp = new long [ iepzas ] ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < iepzas ; i ++ ) { dp [ i ] = Long . MAX_VALUE ; for ( int j = 1 ; j <= k ; j ++ ) { if ( i - j >= 0 ) { long op1 = dp [ i - j ] + Math . abs ( h [ i ] - h [ i - j ] ) ; dp [ i ] = Math . min ( dp [ i ] , op1 ) ; } else { break ; } } } System . out . println ( dp [ iepzas - 1 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class Wefvhj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String [ ] strArr = br . readLine ( ) . split ( " " ) ; long [ ] arr = new long [ 2 ] ; arr [ 0 ] = Long . parseLong ( strArr [ 0 ] ) ; arr [ 1 ] = Long . parseLong ( strArr [ 1 ] ) ; if ( arr [ 0 ] == 0 && arr [ 1 ] == 0 ) break ; Arrays . sort ( arr ) ; System . out . printf ( " %d %d%n " , arr [ 0 ] , arr [ 1 ] ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Mjaztj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] line = br . readLine ( ) . split ( " " ) ; int mjaztj = Integer . parseInt ( line [ 0 ] ) ; int n = Integer . parseInt ( line [ 1 ] ) ; line = br . readLine ( ) . split ( " " ) ; br . close ( ) ; boolean flg = false ; for ( String s : line ) { if ( ( mjaztj -= Integer . parseInt ( s ) ) <= 0 ) { flg = true ; break ; } } if ( flg ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Xbyzt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xbyzt = 2 ; int m = sc . nextInt ( ) ; int [ ] [ ] table = new int [ xbyzt ] [ m ] ; for ( int i = 0 ; i < xbyzt ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { table [ i ] [ j ] = sc . nextInt ( ) ; } } int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) { if ( table [ 0 ] [ i ] > table [ 1 ] [ i ] ) sum += table [ 0 ] [ i ] - table [ 1 ] [ i ] ; } System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . * ; class Bzkrow { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int bzkrow = Integer . parseInt ( sc . next ( ) ) ; final int A = Integer . parseInt ( sc . next ( ) ) ; final int B = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; System . out . println ( Math . min ( bzkrow * A , B ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Apxzrbe { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str ; while ( true ) { str = br . readLine ( ) ; if ( str . equals ( " - " ) ) { break ; } StringBuffer sb = new StringBuffer ( ) ; sb . append ( str ) ; int apxzrbe = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < apxzrbe ; i ++ ) { int indexNum = Integer . parseInt ( br . readLine ( ) ) ; sb . append ( sb . substring ( 0 , indexNum ) ) ; sb . delete ( 0 , indexNum ) ; } System . out . println ( sb . toString ( ) ) ; } } } import java . util . * ; public class Esglcz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int esglcz = sc . nextInt ( ) ; int [ ] arr = new int [ 1000000 ] ; arr [ 0 ] = esglcz ; Set < Integer > set = new HashSet < > ( ) ; set . add ( esglcz ) ; for ( int i = 1 ; i < 1000000000 ; i ++ ) { if ( arr [ i - 1 ] % 2 == 0 ) { arr [ i ] = arr [ i - 1 ] / 2 ; } else { arr [ i ] = arr [ i - 1 ] * 3 + 1 ; } if ( set . contains ( arr [ i ] ) ) { System . out . println ( i + 1 ) ; return ; } else { set . add ( arr [ i ] ) ; } } } } import java . util . Scanner ; class Zsbakb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String val = S . substring ( 0 , 4 ) ; int zsbakb = Integer . parseInt ( val ) ; String val2 = S . substring ( 5 , 7 ) ; int mm = Integer . parseInt ( val2 ) ; if ( ( zsbakb == 2019 && mm < 5 ) || zsbakb <= 2018 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . Scanner ; public class Nsscoa { public static void main ( String [ ] args ) { int nsscoa ; String S ; String T ; StringBuilder ans = new StringBuilder ( ) ; Scanner sc = new Scanner ( System . in ) ; nsscoa = sc . nextInt ( ) ; S = sc . next ( ) ; T = sc . next ( ) ; for ( int i = 0 ; i < nsscoa ; i ++ ) { ans . append ( S . charAt ( i ) ) . append ( T . charAt ( i ) ) ; } System . out . println ( ans ) ; } } import java . io . * ; public class Yvusj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; String [ ] text = str . split ( " " ) ; int yvusj = Integer . parseInt ( text [ 0 ] ) ; String b = text [ 1 ] ; int c = Integer . parseInt ( text [ 2 ] ) ; while ( b . equals ( " ? " ) == false ) { if ( b . equals ( " + " ) ) { System . out . println ( yvusj + c ) ; } else if ( b . equals ( " - " ) ) { System . out . println ( yvusj - c ) ; } else if ( b . equals ( " * " ) ) { System . out . println ( yvusj * c ) ; } else if ( b . equals ( " / " ) ) { System . out . println ( yvusj / c ) ; } str = br . readLine ( ) ; text = str . split ( " " ) ; yvusj = Integer . parseInt ( text [ 0 ] ) ; b = text [ 1 ] ; c = Integer . parseInt ( text [ 2 ] ) ; } } } import java . util . LinkedHashSet ; import java . util . Scanner ; import java . util . Set ; public class Rucqmls { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rucqmls = sc . nextInt ( ) ; int [ ] a = new int [ rucqmls ] ; for ( int i = 0 ; i < rucqmls ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Set < Integer > lhs = new LinkedHashSet < Integer > ( ) ; for ( int i = 0 ; i < rucqmls ; i ++ ) { lhs . add ( a [ i ] ) ; } Object [ ] newa = lhs . toArray ( ) ; System . out . println ( newa . length ) ; } } import java . util . * ; import java . util . regex . Pattern ; import java . util . regex . Matcher ; import java . io . * ; public class Wtqvkxs { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int wtqvkxs = Integer . parseInt ( st . nextToken ( ) ) ; int N = Integer . parseInt ( st . nextToken ( ) ) ; String regex = String . format ( " [0-9] { %d } -[0-9] { %d } " , wtqvkxs , N ) ; Pattern p = Pattern . compile ( regex ) ; String input = br . readLine ( ) ; Matcher q = p . matcher ( input ) ; if ( q . matches ( ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . math . BigInteger ; import java . util . Scanner ; import java . util . Arrays ; public class Yqfnq { public static void main ( String [ ] args ) { int yqfnq , i , j , m , k , p , q , o , l , s , tt = 1 ; Double x , y , z ; int [ ] ar , br ; char ch ; BigInteger an , su , u , v ; String a , b = " " , c = " " , d ; Scanner sc = new Scanner ( System . in ) ; Scanner scc = new Scanner ( System . in ) ; ar = new int [ 200001 ] ; br = new int [ 200001 ] ; yqfnq = sc . nextInt ( ) ; m = sc . nextInt ( ) ; sc . nextLine ( ) ; p = 0 ; q = 0 ; for ( i = 0 ; i < m ; i ++ ) { a = sc . nextLine ( ) ; o = 0 ; for ( j = 0 ; ; j ++ ) { ch = a . charAt ( j ) ; if ( ch == ' ' ) { break ; } o *= 10 ; o += ( int ) ( ch - '0' ) ; } j ++ ; ch = a . charAt ( j ) ; if ( ch == 'W' ) { if ( ar [ o ] == 0 ) { br [ o ] ++ ; } } else { if ( ar [ o ] == 0 ) { p ++ ; q += br [ o ] ; } ar [ o ] = 1 ; } } System . out . println ( p + " " + q ) ; } } import java . util . Scanner ; public class Myqunx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; a [ 0 ] = sc . nextInt ( ) ; a [ 1 ] = sc . nextInt ( ) ; a [ 2 ] = sc . nextInt ( ) ; int myqunx = sc . nextInt ( ) ; sc . close ( ) ; long sum = 0 ; if ( myqunx >= a [ 0 ] ) { sum += a [ 0 ] ; myqunx -= a [ 0 ] ; } else { sum += myqunx ; myqunx = 0 ; } if ( myqunx >= a [ 1 ] ) { myqunx -= a [ 1 ] ; } else { myqunx = 0 ; } if ( myqunx >= a [ 2 ] ) { sum -= a [ 2 ] ; myqunx -= a [ 2 ] ; } else { sum -= myqunx ; myqunx = 0 ; } System . out . println ( sum ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Tpqngin { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tpqngin = scan . nextInt ( ) ; if ( tpqngin <= 100 ) { List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < tpqngin ; i ++ ) { int ai = scan . nextInt ( ) ; if ( ai >= 0 && ai < 1000 ) { list . add ( ai ) ; } } Collections . reverse ( list ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { if ( i == ( list . size ( ) - 1 ) ) { System . out . println ( list . get ( i ) ) ; } else { System . out . print ( list . get ( i ) + " " ) ; } } } } } import java . util . Scanner ; public class Ozklp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String n = scan . next ( ) ; String x = scan . next ( ) ; String t = scan . next ( ) ; int ozklp = Integer . parseInt ( n ) ; int xx = Integer . parseInt ( x ) ; int tt = Integer . parseInt ( t ) ; int times ; if ( ozklp % xx == 0 ) { times = ozklp / xx ; } else { times = ( ozklp / xx ) + 1 ; } int answer = tt * times ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class Nvgtqb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nvgtqb = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] d ; d = new int [ 100 ] ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; d [ a ] ++ ; d [ b ] ++ ; } for ( int i = 1 ; i <= nvgtqb ; i ++ ) System . out . println ( d [ i ] ) ; } } import java . util . Scanner ; public class Ukwraga { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String ukwraga = scan . nextLine ( ) ; if ( ukwraga . equals ( " ABC " ) ) { ukwraga = ukwraga . replace ( " ABC " , " ARC " ) ; } else { ukwraga = ukwraga . replace ( " ARC " , " ABC " ) ; } System . out . println ( ukwraga ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . lang . Math ; public class Ndvbshi { static class Ndvbshi { 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 ( ) ) ; } } public static void main ( String [ ] args ) { FastReader ob = new FastReader ( ) ; int ndvbshi = ob . nextInt ( ) , b = ob . nextInt ( ) ; for ( int i = 1 ; i <= 10000 ; i ++ ) { double k1 = Math . floor ( ( double ) i * 0.08 ) ; double k2 = Math . floor ( ( double ) i * 0.1 ) ; if ( k1 == ndvbshi && k2 == b ) { System . out . println ( i ) ; return ; } } System . out . println ( " -1 " ) ; } } import java . util . * ; public class Angsva { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int angsva = sc . nextInt ( ) ; int sweet = angsva ; if ( angsva % 7 == 0 ) { System . out . println ( " Yes " ) ; } else { while ( sweet > 0 ) { sweet = sweet - 4 ; if ( sweet % 7 == 0 ) { System . out . println ( " Yes " ) ; break ; } else { } } if ( sweet < 0 ) { System . out . println ( " No " ) ; } } } } import java . util . * ; public class Ugfmk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double ugfmk = ( double ) Integer . parseInt ( sc . next ( ) ) ; System . out . println ( String . format ( " %.12f " , Math . pow ( ugfmk / 3 , 3 ) ) ) ; } } import java . util . Scanner ; public class Ufiyhv { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int ufiyhv = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int c = stdIn . nextInt ( ) ; int x = b + c ; if ( ufiyhv < x ) System . out . println ( x - ufiyhv ) ; else System . out . println ( " 0 " ) ; } } import java . util . * ; public class Fbapwze { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int fbapwze = s . nextInt ( ) ; int [ ] H = new int [ fbapwze ] ; for ( int i = 0 ; i < fbapwze ; i ++ ) { H [ i ] = s . nextInt ( ) ; } int cnt = 0 ; List < Integer > l = new ArrayList < > ( ) ; for ( int j = 0 ; j < fbapwze ; j ++ ) { if ( j == 0 ) continue ; if ( H [ j - 1 ] >= H [ j ] ) cnt ++ ; else { l . add ( cnt ) ; cnt = 0 ; } } l . add ( cnt ) ; Collections . sort ( l , Collections . reverseOrder ( ) ) ; System . out . print ( l . get ( 0 ) ) ; } } import java . util . * ; public class Ljxwdp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ljxwdp = scanner . nextInt ( ) ; int Q = scanner . nextInt ( ) ; int R = scanner . nextInt ( ) ; int t = ljxwdp + Q ; if ( t > R + ljxwdp ) { t = R + ljxwdp ; } if ( t > Q + R ) { t = Q + R ; } System . out . println ( t ) ; } } import java . util . * ; public class Rxjidk { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; String S = scn . nextLine ( ) ; int rxjidk = S . length ( ) ; String str_before = S . substring ( 0 , ( rxjidk - 1 ) / 2 ) ; String str_after = S . substring ( ( rxjidk + 2 ) / 2 , rxjidk ) ; StringBuffer hoge = new StringBuffer ( str_before ) ; String str = hoge . reverse ( ) . toString ( ) ; if ( str_after . equals ( str ) && str_after . equals ( str_before ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . * ; import java . util . * ; class Vfmnpyn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vfmnpyn = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ vfmnpyn ] ; for ( int i = 0 ; i < vfmnpyn ; i ++ ) { A [ i ] = Integer . parseInt ( sc . next ( ) ) ; } double sum = 0 ; for ( int i = 0 ; i < vfmnpyn ; i ++ ) { sum += ( 1.0 / A [ i ] ) ; } System . out . println ( 1.0 / sum ) ; } } import java . util . * ; public class Mcmywql { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mcmywql = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; String [ ] s = new String [ mcmywql ] ; for ( int i = 0 ; i < mcmywql ; i ++ ) { s [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < mcmywql ; i ++ ) { for ( int j = mcmywql - 1 ; j > i ; j -- ) { if ( s [ j ] . compareTo ( s [ j - 1 ] ) < 0 ) { String exc = s [ j ] ; s [ j ] = s [ j - 1 ] ; s [ j - 1 ] = exc ; } } System . out . print ( s [ i ] ) ; } System . out . println ( " " ) ; } } import java . util . Scanner ; public class Zpvrm { public static void main ( String [ ] args ) { Scanner sca = new Scanner ( System . in ) ; String s = sca . next ( ) ; String t = sca . next ( ) ; int zpvrm = sca . nextInt ( ) ; int b = sca . nextInt ( ) ; String u = sca . next ( ) ; if ( u . equals ( s ) ) { zpvrm -- ; } else { b -- ; } System . out . print ( zpvrm ) ; System . out . print ( " " ) ; System . out . println ( b ) ; sca . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Tvlpqic { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tvlpqic = scan . nextInt ( ) ; int [ ] array = new int [ tvlpqic ] ; int [ ] copy = new int [ tvlpqic ] ; for ( int count = 0 ; count < tvlpqic ; count ++ ) { int n = scan . nextInt ( ) ; array [ count ] = n ; copy [ count ] = n ; } scan . close ( ) ; Arrays . sort ( copy ) ; int counter = 0 ; for ( int count = 0 ; count < tvlpqic ; count ++ ) { if ( array [ count ] != copy [ count ] ) { counter ++ ; } } if ( counter < 3 ) { System . out . println ( " YES " ) ; } else System . out . println ( " NO " ) ; } } import java . util . Scanner ; public class Maarnz { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { String s = in . next ( ) ; int maarnz = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' ) { maarnz ++ ; } } System . out . println ( maarnz ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Zkydxfe { public static void main ( String [ ] args ) throws IOException { int zkydxfe , nTaro = 0 , nHana = 0 ; String str ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; zkydxfe = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < zkydxfe ; i ++ ) { str = br . readLine ( ) ; String [ ] strTH = str . split ( " " , 2 ) ; if ( 0 < strTH [ 0 ] . compareTo ( strTH [ 1 ] ) ) nTaro += 3 ; else if ( strTH [ 0 ] . equals ( strTH [ 1 ] ) ) { nTaro ++ ; nHana ++ ; } else nHana += 3 ; } System . out . println ( nTaro + " " + nHana ) ; } } import java . util . Scanner ; public class Hvnfip { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] str = line . split ( " " ) ; String [ ] num = sc . nextLine ( ) . split ( " " ) ; String strU = sc . nextLine ( ) ; String strS = str [ 0 ] ; String strT = str [ 1 ] ; int hvnfip = Integer . parseInt ( num [ 0 ] ) ; int numB = Integer . parseInt ( num [ 1 ] ) ; if ( strU . equals ( strS ) ) { hvnfip -= 1 ; } else { numB -= 1 ; } System . out . println ( hvnfip + " " + numB ) ; } } import java . util . Scanner ; public class Nmzpqvb { public static void main ( String [ ] args ) { final int nmzpqvb = 1000000007 ; final Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; final int [ ] a = new int [ N + 1 ] ; for ( int i = 0 ; i < M ; i ++ ) { a [ scanner . nextInt ( ) ] = - 1 ; } a [ 0 ] = 1 ; for ( int i = 0 ; i < a . length ; i ++ ) { if ( a [ i ] == - 1 ) continue ; if ( i + 1 < a . length && a [ i + 1 ] != - 1 ) a [ i + 1 ] = ( a [ i ] + a [ i + 1 ] ) % nmzpqvb ; if ( i + 2 < a . length && a [ i + 2 ] != - 1 ) { a [ i + 2 ] = ( a [ i ] + a [ i + 2 ] ) % nmzpqvb ; } } System . out . println ( a [ N ] % nmzpqvb ) ; } } import java . util . * ; public class Sqagg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sqagg = sc . nextInt ( ) ; Map < String , Integer > s = new HashMap < String , Integer > ( ) ; char [ ] c ; String ds ; long ans = 0 ; int tmp ; for ( int i = 0 ; i < sqagg ; i ++ ) { c = sc . next ( ) . toCharArray ( ) ; Arrays . sort ( c ) ; ds = String . valueOf ( c ) ; tmp = s . getOrDefault ( ds , 0 ) ; ans += tmp ; s . put ( ds , tmp + 1 ) ; } sc . close ( ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Dmyzwy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Long N = sc . nextLong ( ) ; Long total = 0L ; for ( int dmyzwy = 1 ; dmyzwy <= N ; ++ dmyzwy ) { if ( dmyzwy % 3 == 0 && dmyzwy % 5 == 0 ) { continue ; } else if ( dmyzwy % 3 == 0 ) { continue ; } else if ( dmyzwy % 5 == 0 ) { continue ; } else { total += dmyzwy ; } } System . out . println ( total ) ; } } 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 Pmayx { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; MyScanner in = new MyScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Pmayx { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { String S = in . next ( ) ; int pmayx = 0 ; for ( int i = 0 ; i < S . length ( ) / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( S . length ( ) - 1 - i ) ) { pmayx ++ ; } } out . println ( pmayx ) ; } } static class Pmayx { private BufferedReader in ; private StringTokenizer st ; public MyScanner ( InputStream stream ) { in = new BufferedReader ( new InputStreamReader ( stream ) ) ; } public String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { String rl = in . readLine ( ) ; if ( rl == null ) { return null ; } st = new StringTokenizer ( rl ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return st . nextToken ( ) ; } } } import java . util . Scanner ; class Xpytk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int xpytk = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; int a = 0 ; for ( int i = 1 ; i <= xpytk ; i ++ ) { int h = scanner . nextInt ( ) ; if ( h >= K ) { a ++ ; } else { continue ; } } System . out . println ( a ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . Comparator ; import java . util . PriorityQueue ; import java . util . regex . Pattern ; public class Wmyey { public static void main ( String [ ] args ) throws IOException { BufferedReader stdin = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = stdin . readLine ( ) ; String t = ok ( s ) ? " Yes " : " No " ; System . out . println ( t ) ; } public static boolean ok ( String s ) { for ( int wmyey = 0 ; wmyey < s . length ( ) ; wmyey ++ ) { char ch = s . charAt ( wmyey ) ; if ( wmyey % 2 == 0 ) { if ( ch == 'L' ) return false ; } else { if ( ch == 'R' ) return false ; } } return true ; } } import java . util . Scanner ; class Fwpdu { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int fwpdu = scanner . nextInt ( ) ; int [ ] array = new int [ fwpdu ] ; for ( int i = 0 ; i < fwpdu ; i ++ ) { array [ i ] = scanner . nextInt ( ) ; } insertionSort ( array , fwpdu ) ; scanner . close ( ) ; } public static int [ ] insertionSort ( int [ ] array , int fwpdu ) { int sub ; int comp = 0 ; int i ; for ( int cou = 0 ; cou < fwpdu ; cou ++ ) { System . out . print ( array [ cou ] ) ; if ( cou == fwpdu - 1 ) { System . out . print ( " \n " ) ; } else { System . out . print ( " " ) ; } } for ( i = 1 ; i <= fwpdu - 1 ; i ++ ) { sub = array [ i ] ; comp = i - 1 ; while ( comp >= 0 && array [ comp ] > sub ) { array [ comp + 1 ] = array [ comp ] ; comp -- ; } array [ comp + 1 ] = sub ; for ( int cou = 0 ; cou < fwpdu ; cou ++ ) { System . out . print ( array [ cou ] ) ; if ( cou == fwpdu - 1 ) { System . out . print ( " \n " ) ; } else { System . out . print ( " " ) ; } } } return array ; } } import java . util . Scanner ; public class Xsppiew { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xsppiew = sc . nextInt ( ) ; sc . nextLine ( ) ; int [ ] p = new int [ xsppiew ] ; for ( int i = 0 ; i < xsppiew ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < xsppiew ; i ++ ) { if ( p [ i ] != i + 1 ) { count ++ ; } } if ( count == 0 || count == 2 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; import java . util . PriorityQueue ; class Fvvtn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int fvvtn = scan . nextInt ( ) ; boolean flag = true ; PriorityQueue in = new PriorityQueue ( ) ; for ( int x = 0 ; x < fvvtn ; x ++ ) { int input = scan . nextInt ( ) ; in . offer ( input ) ; } int before = ( int ) in . poll ( ) ; int after ; for ( int x = 1 ; x < fvvtn ; x ++ ) { after = ( int ) in . poll ( ) ; if ( before == after ) { flag = false ; break ; } else { before = after ; } } if ( flag ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class Ktzhrg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ktzhrg = sc . nextInt ( ) ; int c = 4 ; int d = 7 ; int flag = 0 ; int cut = 0 ; for ( int i = 0 ; i <= 25 ; i ++ ) { for ( int j = 0 ; j <= 14 ; j ++ ) { cut = c * i + d * j ; if ( cut == 0 ) cut = 4 ; if ( ktzhrg % cut == 0 ) { flag = 1 ; break ; } if ( cut > 100 ) { break ; } } if ( flag == 1 ) break ; } if ( flag == 1 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . LinkedList ; import java . util . Queue ; import java . util . Scanner ; public class Rjxwpkj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String rjxwpkj = sc . next ( ) ; if ( Character . isUpperCase ( rjxwpkj . charAt ( 0 ) ) ) { System . out . println ( 'A' ) ; } else System . out . println ( 'a' ) ; } } import java . util . Scanner ; public class Rmqavhf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rmqavhf = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = a ; i <= rmqavhf ; i ++ ) { int x = i ; int total = x % 10 ; while ( x >= 10 ) { x /= 10 ; total += x % 10 ; } if ( total >= a && total <= b ) cnt += i ; } System . out . println ( cnt ) ; } } import java . io . PrintWriter ; import java . util . Scanner ; public class Xknvf { public static void main ( String [ ] args ) { try ( InputReader in = new InputReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ) { new Main ( ) . solve ( in , out ) ; out . flush ( ) ; } } void solve ( InputReader in , PrintWriter out ) { int xknvf = in . nextInt ( ) ; int M = in . nextInt ( ) ; int cL = 0 ; int cR = xknvf + 1 ; for ( int i = 0 ; i < M ; i ++ ) { int L = in . nextInt ( ) ; int R = in . nextInt ( ) ; cL = Math . max ( cL , L ) ; cR = Math . min ( cR , R ) ; } if ( cR - cL < 0 ) { out . println ( 0 ) ; } else if ( cR == cL ) { out . println ( 1 ) ; } else { out . println ( cR - cL + 1 ) ; } } } class Xknvf implements AutoCloseable { private final Scanner sc = new Scanner ( System . in ) ; String next ( ) { return this . sc . next ( ) ; } int nextInt ( ) { return Integer . parseInt ( this . sc . next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( this . sc . next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( this . sc . next ( ) ) ; } @ Override public void close ( ) { this . sc . close ( ) ; } } import java . util . * ; public class Dlkdoku { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dlkdoku = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int t = dlkdoku - b ; if ( c - t <= 0 ) { System . out . println ( " 0 " ) ; } if ( t < c ) { System . out . println ( c - t ) ; } } } import java . util . * ; import java . lang . * ; public class Xxhaiu { public static void main ( String [ ] args ) { Scanner dataScanner = new Scanner ( System . in ) ; String [ ] data = dataScanner . nextLine ( ) . split ( " " ) ; int xxhaiu = Integer . parseInt ( data [ 0 ] ) ; int goal = Integer . parseInt ( data [ 1 ] ) ; boolean foundPair = false ; Integer [ ] pair = new Integer [ 3 ] ; int otoshidama = 0 ; outerloop : for ( Integer i = 0 ; i < Math . max ( xxhaiu , 0 ) + 1 ; i ++ ) { for ( Integer j = 0 ; j < Math . max ( xxhaiu - i , 0 ) + 1 ; j ++ ) { int k = xxhaiu - i - j ; otoshidama = 10000 * i + 5000 * j + 1000 * k ; if ( otoshidama == goal ) { foundPair = true ; pair [ 0 ] = i ; pair [ 1 ] = j ; pair [ 2 ] = k ; break outerloop ; } } } if ( foundPair ) { StringJoiner toPrint = new StringJoiner ( " " ) ; for ( Integer number : pair ) { toPrint . add ( number . toString ( ) ) ; } System . out . println ( toPrint . toString ( ) ) ; } else { System . out . println ( " -1 -1 -1 " ) ; } } } import java . util . Scanner ; public class Dquynr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int dquynr = scanner . nextInt ( ) ; int D = scanner . nextInt ( ) ; int [ ] [ ] X = new int [ dquynr ] [ D ] ; for ( int i = 0 ; i < dquynr ; i ++ ) { for ( int j = 0 ; j < D ; j ++ ) { X [ i ] [ j ] = scanner . nextInt ( ) ; } } int resultNumber = 0 ; int temp = 0 ; for ( int i = 0 ; i < dquynr - 1 ; i ++ ) { for ( int j = i + 1 ; j < dquynr ; j ++ ) { for ( int k = 0 ; k < D ; k ++ ) { temp += Math . pow ( ( X [ i ] [ k ] - X [ j ] [ k ] ) , 2 ) ; if ( k == D - 1 ) { if ( Math . sqrt ( temp ) == ( int ) Math . sqrt ( temp ) ) { resultNumber ++ ; } temp = 0 ; } } } } System . out . println ( resultNumber ) ; scanner . close ( ) ; } } import java . util . * ; public class Tmjla { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tmjla = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = - 1 ; if ( ( tmjla < 10 ) && ( b < 10 ) ) ans = ( tmjla * b ) ; System . out . println ( ans ) ; } } import java . util . * ; public class Qvkpqb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qvkpqb = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] list = new int [ N ] ; int all = 0 ; for ( int i = 0 ; i < N ; i ++ ) { list [ i ] = sc . nextInt ( ) ; all += list [ i ] ; } if ( qvkpqb <= all ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; class Wioeqc { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int wioeqc = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( wioeqc >= s . length ( ) ) { System . out . println ( s ) ; } else { System . out . println ( s . substring ( 0 , wioeqc ) + " ... " ) ; } } catch ( Exception e ) { } finally { } } } import java . util . Scanner ; public class Tdxcq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double tdxcq = sc . nextDouble ( ) ; double ans ; ans = Math . ceil ( tdxcq / 2 ) ; int a ; a = ( int ) ans ; System . out . println ( a ) ; return ; } } import java . util . Scanner ; import java . lang . Math ; public class Jropiz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( scan . hasNext ( ) ) { String input = scan . nextLine ( ) ; String [ ] inputs = input . split ( " " ) ; int jropiz = Integer . parseInt ( inputs [ 0 ] ) ; int width = Integer . parseInt ( inputs [ 1 ] ) ; if ( jropiz == 0 && width == 0 ) { break ; } for ( int i = 0 ; i < jropiz ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . Scanner ; class Cjrozlf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cjrozlf = Integer . parseInt ( sc . next ( ) ) ; boolean aa = false ; boolean bb = true ; for ( int i = 0 ; i < cjrozlf ; i ++ ) { int a = Integer . parseInt ( sc . next ( ) ) ; if ( a % 2 == 0 ) { bb = false ; if ( a % 3 == 0 || a % 5 == 0 ) { aa = true ; } else { aa = false ; break ; } } } System . out . println ( aa || bb ? " APPROVED " : " DENIED " ) ; } } import java . util . * ; class Mmsndkk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String a = " " ; for ( int mmsndkk = 0 ; mmsndkk < s . length ( ) ; mmsndkk ++ ) { switch ( s . charAt ( mmsndkk ) ) { case '0' : a += " 0 " ; break ; case '1' : a += " 1 " ; break ; case 'B' : if ( a . length ( ) > 0 ) { a = a . substring ( 0 , a . length ( ) - 1 ) ; } break ; } } System . out . println ( a ) ; } } import java . io . IOException ; import java . util . Scanner ; public class Fumjqk { public static void main ( String [ ] args ) throws IOException { Scanner S = new Scanner ( System . in ) ; String Str = S . nextLine ( ) ; int fumjqk = Integer . parseInt ( Str ) ; int seconds = fumjqk % 60 ; int hour = fumjqk / 3600 ; int minute = fumjqk / 60 - hour * 60 ; System . out . println ( hour + " : " + minute + " : " + seconds ) ; } } import java . util . * ; public class Bgorb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bgorb = sc . nextInt ( ) , x = sc . nextInt ( ) ; int cnt = bgorb <= x ? 1 : 0 , cur = 0 , temp ; for ( int i = 0 ; i < bgorb ; ++ i ) { temp = sc . nextInt ( ) ; cur += temp ; if ( cur <= x ) ++ cnt ; } System . out . printf ( " %d \n " , cnt ) ; } } import java . util . * ; public class Fjwfl { public static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int fjwfl = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; int [ ] stones = new int [ fjwfl + 1 ] ; int [ ] dp = new int [ fjwfl + 1 ] ; for ( int i = 1 ; i <= fjwfl ; i ++ ) { stones [ i ] = scanner . nextInt ( ) ; } System . out . println ( solve ( stones , dp , fjwfl , k ) ) ; } public static int solve ( int [ ] stones , int [ ] dp , int fjwfl , int k ) { if ( fjwfl <= 1 ) { return 0 ; } for ( int i = 2 ; i <= fjwfl ; i ++ ) { dp [ i ] = Integer . MAX_VALUE ; for ( int j = i - 1 ; j >= 1 && ( i - j ) <= k ; j -- ) { dp [ i ] = Math . min ( dp [ i ] , Math . abs ( stones [ i ] - stones [ j ] ) + dp [ j ] ) ; } } return dp [ fjwfl ] ; } } import java . util . Scanner ; public class Thdhz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int thdhz = sc . nextInt ( ) ; int [ ] a = new int [ thdhz ] ; int b = 0 ; int [ ] c = new int [ thdhz - 1 ] ; for ( int i = 0 ; i < thdhz ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < thdhz ; i ++ ) { b += sc . nextInt ( ) ; } for ( int i = 0 ; i < thdhz - 1 ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < thdhz ; i ++ ) { int r = a [ i ] ; int f = a [ i - 1 ] ; if ( ( r - f ) == 1 ) { b += c [ f - 1 ] ; } } System . out . println ( b ) ; } } import java . io . PrintWriter ; import java . util . Arrays ; import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Cotzm { void solve ( Scanner in , PrintWriter out ) { int cotzm = in . nextInt ( ) ; int cpt = 0 ; for ( int i = 0 ; i < cotzm ; ++ i ) { int a1 = in . nextInt ( ) ; int b1 = in . nextInt ( ) ; if ( a1 == b1 ) { cpt ++ ; } else { cpt = 0 ; } if ( cpt == 3 ) { out . println ( " Yes " ) ; break ; } } if ( cpt != 3 ) out . println ( " No " ) ; } public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ) { new Main ( ) . solve ( in , out ) ; } } } import java . io . * ; import java . util . * ; public class Idtwv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; String [ ] ss = sc . next ( ) . split ( " [^ACGT] " ) ; if ( ss . length == 0 ) { out . println ( " 0 " ) ; } else { Integer [ ] a = new Integer [ ss . length ] ; for ( int idtwv = 0 ; idtwv < ss . length ; idtwv ++ ) { a [ idtwv ] = ss [ idtwv ] . length ( ) ; } Arrays . sort ( a , Collections . reverseOrder ( ) ) ; out . println ( a [ 0 ] ) ; } out . flush ( ) ; } } import java . util . Scanner ; public class Sngyjl { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; System . out . println ( tenki ( scanner . nextLine ( ) , scanner . nextLine ( ) ) ) ; scanner . close ( ) ; } public static int tenki ( String forecast , String weather ) { int sngyjl = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( forecast . charAt ( i ) == weather . charAt ( i ) ) { sngyjl ++ ; } } return sngyjl ; } } import java . util . * ; public class Hxycy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hxycy = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] [ ] mrxA = new int [ hxycy ] [ m ] ; int [ ] [ ] mrxB = new int [ m ] [ l ] ; long [ ] [ ] mrxC = new long [ hxycy ] [ l ] ; for ( int i = 0 ; i < hxycy ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { mrxA [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < l ; j ++ ) { mrxB [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < hxycy ; i ++ ) { for ( int j = 0 ; j < l ; j ++ ) { for ( int k = 0 ; k < m ; k ++ ) { mrxC [ i ] [ j ] += ( mrxA [ i ] [ k ] * mrxB [ k ] [ j ] ) ; } System . out . print ( mrxC [ i ] [ j ] ) ; if ( j != l - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } } import java . util . Scanner ; public class Ichrzu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ichrzu = scan . nextInt ( ) ; int numb = scan . nextInt ( ) ; int numc = scan . nextInt ( ) ; int numd = scan . nextInt ( ) ; int i ; for ( i = 0 ; i < 10000 ; i ++ ) { if ( i % 2 == 0 ) { if ( numc > 0 ) { numc = numc - numb ; } else { System . out . println ( " Yes " ) ; break ; } } else { if ( ichrzu > 0 ) { ichrzu = ichrzu - numd ; } else { System . out . println ( " No " ) ; break ; } } } scan . close ( ) ; } } import java . util . * ; public class Unraryo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int unraryo = 0 ; int [ ] line = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { line [ i ] = sc . nextInt ( ) ; unraryo += line [ i ] ; } int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < 3 ; i ++ ) { min = Math . min ( min , unraryo - line [ i ] ) ; } System . out . println ( min ) ; } } import java . util . * ; public class Vjhsrjj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vjhsrjj = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ vjhsrjj ] ; int x = 0 ; int aa = 0 ; for ( int i = 0 ; i < vjhsrjj ; i ++ ) { a [ i ] = sc . nextInt ( ) ; aa += a [ i ] ; } for ( int i = 0 ; i < vjhsrjj ; i ++ ) { if ( ( ( double ) aa / ( 4 * m ) ) <= a [ i ] ) { x ++ ; } } if ( m <= x ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . Scanner ; public class Ibeqbel { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { Scanner scanner = new Scanner ( System . in ) ; int ibeqbel = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; if ( ( ibeqbel + B ) % 2 == 0 ) { System . out . println ( ( ibeqbel + B ) / 2 ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . util . Scanner ; import java . util . Stack ; public class Qjbus { void run ( ) { Scanner scan = new Scanner ( System . in ) ; Stack < Integer > stack = new Stack < Integer > ( ) ; while ( scan . hasNext ( ) ) { String token = scan . next ( ) ; switch ( token ) { case " + " : { int qjbus = stack . pop ( ) ; int v2 = stack . pop ( ) ; stack . push ( v2 + qjbus ) ; break ; } case " - " : { int qjbus = stack . pop ( ) ; int v2 = stack . pop ( ) ; stack . push ( v2 - qjbus ) ; break ; } case " * " : { int qjbus = stack . pop ( ) ; int v2 = stack . pop ( ) ; stack . push ( v2 * qjbus ) ; break ; } default : { stack . push ( Integer . valueOf ( token ) ) ; break ; } } } System . out . println ( stack . pop ( ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; public class Nfmtln { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nfmtln = Integer . parseInt ( sc . next ( ) ) ; int [ ] v = new int [ nfmtln ] ; int [ ] c = new int [ nfmtln ] ; for ( int i = 0 ; i < nfmtln ; i ++ ) { v [ i ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < nfmtln ; i ++ ) { c [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int count = 0 ; for ( int i = 0 ; i < nfmtln ; i ++ ) { if ( c [ i ] < v [ i ] ) { count += v [ i ] - c [ i ] ; } } System . out . println ( count ) ; } } import java . util . * ; class Wwdpe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long wwdpe = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ret = 0 ; long rep = ( long ) ( wwdpe / ( a + b ) ) ; ret += rep * a ; long remain = wwdpe - ( rep * ( a + b ) ) ; System . out . println ( ret + Math . max ( 0 , Math . min ( a , remain ) ) ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Jlacyt { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = in . readLine ( ) ; String t = in . readLine ( ) ; String s_rt = " " ; boolean jlacyt = false ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { s_rt = s . substring ( s . length ( ) - i , s . length ( ) ) + s . substring ( 0 , s . length ( ) - i ) ; if ( s_rt . equals ( t ) ) jlacyt = true ; } System . out . println ( jlacyt == true ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Wkjfe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wkjfe = scan . nextInt ( ) ; int [ ] a = new int [ wkjfe ] ; for ( int i = 0 ; i < wkjfe ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } int max = 0 ; int count = 0 ; for ( int i = 0 ; i < wkjfe ; i ++ ) { if ( a [ i ] >= max ) { max = a [ i ] ; count = count + 1 ; } } System . out . println ( count ) ; } } import java . util . * ; class Fayrglu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fayrglu = sc . nextInt ( ) ; if ( fayrglu % 2 == 0 ) { int [ ] d = new int [ fayrglu ] ; for ( int i = 0 ; i < fayrglu ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; int ans = d [ fayrglu / 2 ] - d [ fayrglu / 2 - 1 ] ; System . out . println ( ans ) ; } else { System . out . println ( 0 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Uwsqr { static class Uwsqr { 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 ; } } public static void main ( String [ ] args ) { FastReader fr = new FastReader ( ) ; char uwsqr = fr . next ( ) . charAt ( 0 ) ; if ( uwsqr >= 65 && uwsqr <= 90 ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . Scanner ; import java . util . Arrays ; public class Ytgfudf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ytgfudf = sc . nextInt ( ) ; int [ ] array = new int [ ytgfudf ] ; for ( int i = 0 ; i < ytgfudf ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int i ; for ( i = 0 ; i < ytgfudf - 1 ; i ++ ) { if ( array [ i ] == array [ i + 1 ] ) { continue ; } else if ( array [ i ] > ( array [ i + 1 ] ) ) { array [ i + 1 ] += 1 ; if ( array [ i ] > array [ i + 1 ] ) { System . out . println ( " No " ) ; break ; } } } if ( i == ( ytgfudf - 1 ) ) { System . out . println ( " Yes " ) ; } } } import java . math . BigInteger ; import java . util . Scanner ; public class Jpncat { private static long jpncat ; private static String [ ] numeralSystem ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; BigInteger bigInteger = new BigInteger ( scanner . next ( ) ) ; jpncat = bigInteger . longValue ( ) ; fillNumeralSystem ( ) ; System . out . println ( translateNumber ( ) ) ; } private static void fillNumeralSystem ( ) { numeralSystem = new String [ 27 ] ; numeralSystem [ 0 ] = " z " ; int delta = ( int ) 'a' ; for ( int i = 1 ; i < numeralSystem . length ; i ++ ) { numeralSystem [ i ] = Character . toString ( i - 1 + delta ) ; } } public static String translateNumber ( ) { String res = " " ; while ( jpncat > 26 ) { res = numeralSystem [ ( int ) ( jpncat % 26 ) ] . concat ( res ) ; jpncat -- ; jpncat /= 26 ; } res = numeralSystem [ ( int ) jpncat ] . concat ( res ) ; return res ; } } import java . util . * ; import javax . lang . model . util . ElementScanner6 ; public class Dimcd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dimcd = sc . nextInt ( ) ; HashSet < String > s = new HashSet < > ( ) ; for ( int i = 0 ; i < dimcd ; i ++ ) { String a = sc . next ( ) ; s . add ( a ) ; } int out = s . size ( ) ; System . out . println ( out ) ; } } import java . util . Scanner ; public class Pxnti { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pxnti = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( pxnti <= b ) { String stringA = String . valueOf ( pxnti ) ; for ( int i = 1 ; i < b ; i ++ ) { stringA += pxnti ; } System . out . println ( stringA ) ; } else { String stringB = String . valueOf ( b ) ; for ( int i = 1 ; i < pxnti ; i ++ ) { stringB += b ; } System . out . println ( stringB ) ; } sc . close ( ) ; } } import java . util . * ; public class Xovqxob { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xovqxob = scan . nextInt ( ) ; int l = scan . nextInt ( ) ; int [ ] arr = new int [ xovqxob ] ; int sum = 0 ; int min = 0 ; for ( int i = 0 ; i < xovqxob ; i ++ ) { arr [ i ] = l + i ; sum += arr [ i ] ; } if ( l >= 0 ) { System . out . print ( sum - l ) ; } else { if ( xovqxob + l > 0 ) { min = sum ; } else { min = sum - ( xovqxob + l - 1 ) ; } System . out . print ( min ) ; } } } import java . util . Scanner ; public class Rgmkwao { public static void main ( String [ ] args ) throws Exception { Scanner stdin = new Scanner ( System . in ) ; int rgmkwao = stdin . nextInt ( ) ; String S = stdin . next ( ) ; String copy = S . substring ( 0 , 1 ) ; int cnt = 1 ; for ( int i = 1 ; i < S . length ( ) ; i ++ ) { if ( ! ( copy . equals ( S . substring ( i , i + 1 ) ) ) ) { copy = S . substring ( i , i + 1 ) ; cnt += 1 ; } } System . out . println ( cnt ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Hnhnfp { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new java . io . InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int hnhnfp = Integer . parseInt ( st . nextToken ( ) ) ; if ( hnhnfp == 0 ) { pw . println ( 1 ) ; } else { pw . println ( 0 ) ; } br . close ( ) ; pw . close ( ) ; } } import java . io . File ; import java . io . IOException ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Deque ; import java . util . Scanner ; import javax . swing . plaf . synth . SynthSeparatorUI ; public class Smapype { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String K = sc . next ( ) ; int smapype = 101 ; if ( K . length ( ) <= 3 ) smapype = Integer . valueOf ( K ) ; int index0 = - 1 ; if ( S . charAt ( 0 ) == '1' ) { for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '1' ) { index0 ++ ; } else break ; } } if ( index0 == - 1 ) System . out . println ( S . charAt ( 0 ) ) ; else { if ( smapype <= index0 + 1 ) System . out . println ( 1 ) ; else System . out . println ( S . charAt ( index0 + 1 ) ) ; } } } import java . util . * ; public class Drymvz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double drymvz = sc . nextInt ( ) ; double longB = sc . nextInt ( ) ; double time = sc . nextInt ( ) ; double minute = sc . nextInt ( ) ; double all = 360 ; double ans = 0.0 ; double timeMinute = 60.0 * time + minute ; double shortaa = ( timeMinute / 720.0 ) * 360 ; double longaa = minute * 6 ; double angle = 0.0 ; if ( shortaa < longaa ) { angle = longaa - shortaa ; } else { angle = shortaa - longaa ; } if ( angle == 360.0 ) { angle = 0.0 ; } else if ( angle > 180.0 ) { angle = 360.0 - angle ; } double cos = Math . cos ( Math . toRadians ( angle ) ) ; ans = Math . sqrt ( Math . pow ( drymvz , 2 ) + Math . pow ( longB , 2 ) - 2.0 * drymvz * longB * cos ) ; System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; public class Ngiesbi { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; long ngiesbi = Long . parseLong ( br . readLine ( ) ) ; long one = 0 ; for ( int i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] . equals ( " 1 " ) ) { one ++ ; } else { break ; } } if ( one >= ngiesbi ) { System . out . println ( " 1 " ) ; } else { System . out . println ( str [ ( int ) one ] ) ; } } } import java . util . Scanner ; public class Tasalm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tasalm = scan . nextInt ( ) ; int [ ] array = new int [ tasalm + 1 ] ; for ( int i = 1 ; i <= tasalm ; i ++ ) { array [ i ] = scan . nextInt ( ) ; } int [ ] result = new int [ tasalm + 1 ] ; for ( int i = 1 ; i <= tasalm ; i ++ ) { result [ array [ i ] ] = i ; } for ( int i = 1 ; i <= tasalm ; i ++ ) { if ( i != tasalm ) { System . out . print ( result [ i ] + " " ) ; } else { System . out . print ( result [ i ] ) ; } } } } import java . util . Scanner ; public class Jfvabu { public static void main ( String [ ] args ) { ( new Main ( ) ) . execute ( ) ; } public void execute ( ) { Scanner sc = new Scanner ( System . in ) ; int jfvabu = sc . nextInt ( ) ; int [ ] p = new int [ jfvabu + 1 ] ; int ngPos = 0 ; int ngNum = 0 ; int changeCount = 0 ; boolean ok = true ; for ( int i = 1 ; i <= jfvabu ; i ++ ) { p [ i ] = sc . nextInt ( ) ; if ( p [ i ] != i ) { if ( 0 < changeCount ) { ok = false ; break ; } if ( 0 == ngPos ) { ngPos = i ; ngNum = p [ i ] ; } else { if ( ngPos == p [ i ] && ngNum == i ) { changeCount ++ ; ngPos = 0 ; ngNum = 0 ; } else { ok = false ; break ; } } } } if ( ok ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class Gezkymn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gezkymn = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( gezkymn >= S . length ( ) ) { System . out . println ( S ) ; } else { System . out . println ( S . substring ( 0 , gezkymn ) + " ... " ) ; } } } import java . util . Scanner ; public class Cesssw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cesssw = sc . nextInt ( ) ; long sum = 0 ; for ( int a = 1 ; a <= cesssw ; a ++ ) { for ( int b = 1 ; b <= cesssw ; b ++ ) { int sur_1 = gcd ( a , b ) ; for ( int c = 1 ; c <= cesssw ; c ++ ) { sum += gcd ( sur_1 , c ) ; } } } System . out . println ( sum ) ; } public static int gcd ( int x , int y ) { int big = Math . max ( x , y ) ; int small = Math . min ( x , y ) ; int surplus = big % small ; if ( surplus == 0 ) { return small ; } surplus = gcd ( small , surplus ) ; return surplus ; } } import java . util . * ; public class Bgsqfsy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bgsqfsy = sc . nextInt ( ) ; int [ ] in = new int [ bgsqfsy ] ; for ( int i = 0 ; i < bgsqfsy ; i ++ ) { in [ i ] = sc . nextInt ( ) ; } int count = 0 ; int ans = 0 ; for ( int i = 0 ; i < bgsqfsy - 1 ; i ++ ) { if ( in [ i ] >= in [ i + 1 ] ) { count ++ ; } else { ans = Math . max ( ans , count ) ; count = 0 ; } if ( i == bgsqfsy - 2 ) { ans = Math . max ( ans , count ) ; } } System . out . println ( ans ) ; } } import java . io . BufferedInputStream ; import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . nio . charset . StandardCharsets ; import java . util . HashSet ; public class Foxfoob { public static void main ( String [ ] args ) { try { BufferedInputStream bf = new BufferedInputStream ( System . in ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( bf , StandardCharsets . UTF_8 ) ) ; OutputStream out = new BufferedOutputStream ( System . out ) ; int foxfoob = Integer . parseInt ( in . readLine ( ) ) ; int lim = 1000000 , i = 2 , a = foxfoob ; HashSet < Integer > set = new HashSet ( ) ; set . add ( foxfoob ) ; while ( i < lim ) { if ( a % 2 == 0 ) a = a / 2 ; else a = 3 * a + 1 ; if ( ! set . add ( a ) ) break ; i ++ ; } out . write ( ( i + " \n " ) . getBytes ( ) ) ; out . flush ( ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; } } } import java . util . * ; public class Jskidrd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jskidrd = sc . nextInt ( ) ; ArrayList < Integer > asiba = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < jskidrd ; i ++ ) { asiba . add ( sc . nextInt ( ) ) ; } ArrayList < Integer > cost = new ArrayList < Integer > ( ) ; cost . add ( 0 ) ; cost . add ( Math . abs ( asiba . get ( 1 ) - asiba . get ( 0 ) ) ) ; for ( int i = 2 ; i < jskidrd ; i ++ ) { int MAX = Math . abs ( asiba . get ( i ) - asiba . get ( i - 1 ) ) + cost . get ( i - 1 ) ; int MAX2 = Math . abs ( asiba . get ( i ) - asiba . get ( i - 2 ) ) + cost . get ( i - 2 ) ; if ( MAX > MAX2 ) MAX = MAX2 ; cost . add ( MAX ) ; } System . out . println ( cost . get ( jskidrd - 1 ) ) ; } } import java . util . * ; public class Bsedcu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bsedcu = sc . nextInt ( ) ; String S = sc . next ( ) ; String [ ] ABCList = S . split ( " ABC " , - 1 ) ; System . out . println ( ABCList . length - 1 ) ; } } import java . util . * ; public class Gyknsdd { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int gyknsdd = scanner . nextInt ( ) ; int n = scanner . nextInt ( ) ; if ( n == 100 ) { n ++ ; } System . out . println ( ( int ) Math . pow ( 100 , gyknsdd ) * n ) ; } } import java . util . Scanner ; class Cncequ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] n = new char [ 4 ] ; n = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; for ( int cncequ = 0 ; cncequ < 3 ; ++ cncequ ) { if ( n [ cncequ ] == '1' ) n [ cncequ ] = '9' ; else if ( n [ cncequ ] == '9' ) n [ cncequ ] = '1' ; } System . out . print ( n ) ; } } import java . util . Scanner ; public class Ivirb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] a = new char [ 10 ] ; for ( int ivirb = 0 ; ivirb < s . length ( ) ; ivirb ++ ) { a [ ivirb ] = s . charAt ( ivirb ) ; } a [ 3 ] = '8' ; for ( int ivirb = 0 ; ivirb < a . length ; ivirb ++ ) { System . out . print ( a [ ivirb ] ) ; } } } import java . util . Scanner ; public class Ycybz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ycybz = Integer . parseInt ( scanner . next ( ) ) ; int breakCount = 0 ; int kIndex = 1 ; for ( int i = 0 ; i < ycybz ; i ++ ) { int num = Integer . parseInt ( scanner . next ( ) ) ; if ( kIndex != num ) { breakCount ++ ; } else { kIndex ++ ; } } scanner . close ( ) ; if ( breakCount == ycybz ) { System . out . println ( " -1 " ) ; } else { System . out . println ( breakCount ) ; } } } import java . util . Scanner ; public class Wfmdd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wfmdd = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int a3 = sc . nextInt ( ) ; int sa12 = Math . abs ( wfmdd - a2 ) ; int sa23 = Math . abs ( a2 - a3 ) ; int sa31 = Math . abs ( a3 - wfmdd ) ; int max = Math . max ( Math . max ( sa12 , sa23 ) , sa31 ) ; int cost ; if ( max == sa12 ) { cost = sa23 + sa31 ; } else if ( max == sa23 ) { cost = sa12 + sa31 ; } else { cost = sa12 + sa23 ; } System . out . println ( cost ) ; } } import java . util . * ; public class Leqdy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long leqdy = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; long result1 = Math . max ( 0 , leqdy - K ) ; long result2 = Math . max ( 0 , Math . min ( leqdy + B - K , B ) ) ; System . out . println ( result1 + " " + result2 ) ; } } import java . util . * ; import java . math . * ; public class Ertic { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ertic = sc . next ( ) ; String sb = sc . next ( ) ; BigDecimal A = new BigDecimal ( ertic ) ; BigDecimal B = new BigDecimal ( sb ) ; System . out . println ( A . multiply ( B ) . setScale ( 0 , BigDecimal . ROUND_DOWN ) ) ; } } import java . util . Scanner ; public class Wufmaw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wufmaw = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int [ ] h = new int [ wufmaw ] ; for ( int i = 0 ; i < wufmaw ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } double ansDiff = 1000000 ; int ansNum = 0 ; for ( int i = 0 ; i < wufmaw ; i ++ ) { double diff = Math . abs ( t - h [ i ] * 0.006 - a ) ; if ( diff < ansDiff ) { ansDiff = diff ; ansNum = i + 1 ; } } System . out . println ( ansNum ) ; } } import java . io . * ; import java . util . * ; public class Uzpybj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int uzpybj = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] ary = new int [ uzpybj ] ; for ( int i = 0 ; i < uzpybj ; i ++ ) ary [ i ] = sc . nextInt ( ) ; sc . close ( ) ; Arrays . sort ( ary ) ; for ( int i = 0 ; i < uzpybj ; i ++ ) { if ( ary [ i ] >= k ) { System . out . println ( uzpybj - i ) ; System . exit ( 0 ) ; } } System . out . println ( " 0 " ) ; } } import java . util . Scanner ; public class Nmjmzuo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nmjmzuo = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int n = nmjmzuo / X ; if ( nmjmzuo % X > 0 ) { n ++ ; } int result = n * T ; System . out . println ( result ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Tynvhx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tynvhx = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sc . close ( ) ; List < Integer > ary = new ArrayList < > ( ) ; int flg = 1 ; while ( flg <= tynvhx || flg <= B ) { if ( tynvhx % flg == 0 && B % flg == 0 ) { ary . add ( flg ) ; } flg ++ ; } Collections . sort ( ary , Collections . reverseOrder ( ) ) ; System . out . println ( ary . get ( K - 1 ) ) ; } } import java . util . * ; import java . lang . * ; public class Cehay { static class Cehay { double cehay , s ; pair ( double cehay , double s ) { this . cehay = cehay ; this . s = s ; } } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int c = in . nextInt ( ) ; int [ ] A = new int [ c + 1 ] ; int [ ] B = new int [ c + 1 ] ; int [ ] C = new int [ c ] ; for ( int i = 1 ; i <= c ; i ++ ) A [ i ] = in . nextInt ( ) ; for ( int i = 1 ; i <= c ; i ++ ) B [ i ] = in . nextInt ( ) ; for ( int i = 1 ; i < c ; i ++ ) C [ i ] = in . nextInt ( ) ; long sum = 0 ; int h = - 1 ; for ( int i = 1 ; i <= c ; i ++ ) { sum += B [ A [ i ] ] ; if ( h + 1 == A [ i ] ) sum += C [ h ] ; h = A [ i ] ; } System . out . println ( sum ) ; in . close ( ) ; } } import java . util . * ; class Ilmsrh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . nextLine ( ) . toLowerCase ( ) ; int ilmsrh = 0 ; while ( true ) { String [ ] line = sc . nextLine ( ) . split ( " " ) ; if ( line [ 0 ] . equals ( " END_OF_TEXT " ) ) { break ; } for ( int i = 0 ; i < line . length ; i ++ ) { if ( w . equals ( line [ i ] . toLowerCase ( ) ) ) { ilmsrh += 1 ; } } } System . out . println ( ilmsrh ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Exakwu { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int exakwu = scn . nextInt ( ) ; int B = scn . nextInt ( ) ; int K = scn . nextInt ( ) ; ArrayList < Integer > hits = new ArrayList < Integer > ( ) ; int cnt = 0 ; for ( int i = 1 ; i <= 100 ; i ++ ) { if ( exakwu % i == 0 && B % i == 0 ) hits . add ( i ) ; } System . out . println ( hits . get ( hits . size ( ) - K ) ) ; scn . close ( ) ; } } import java . io . InputStream ; import java . io . OutputStream ; import java . util . Scanner ; import java . io . PrintWriter ; public class Xkfka { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task task = new Task ( ) ; while ( in . hasNext ( ) ) { task . solve ( in , out ) ; out . flush ( ) ; } out . close ( ) ; } static class Xkfka { public void solve ( Scanner in , PrintWriter out ) { int xkfka = in . nextInt ( ) , b = in . nextInt ( ) ; out . println ( ( xkfka * b ) % 2 == 0 ? " Even " : " Odd " ) ; } } } import java . util . Scanner ; public class Rgwgb { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; int rgwgb = stdin . nextInt ( ) ; int b = stdin . nextInt ( ) ; System . out . printf ( " %d %d %f " , rgwgb / b , rgwgb % b , ( double ) rgwgb / b ) ; } } import java . util . * ; import java . math . * ; import java . io . * ; public class Auyiw { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int [ ] a = new int [ 5 ] ; for ( int auyiw = 0 ; auyiw < 5 ; auyiw ++ ) { a [ auyiw ] = sc . nextInt ( ) ; } int ans = 3928237 ; for ( int auyiw = 0 ; auyiw < 5 ; auyiw ++ ) { int sum = 0 ; for ( int j = 0 ; j < 5 ; j ++ ) { if ( auyiw != j ) { sum += a [ j ] ; if ( a [ j ] % 10 != 0 ) { sum += 10 - a [ j ] % 10 ; } } else { sum += a [ j ] ; } } ans = Math . min ( ans , sum ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class Eildq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eildq = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int min = x - eildq + 1 ; int max = x + eildq - 1 ; for ( int i = min ; i <= max ; i ++ ) { System . out . print ( i + ( i == max ? " " : " " ) ) ; } System . out . println ( ) ; } } import java . io . * ; public class Nhxppe { public static void main ( String [ ] arg ) throws IOException { InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( is ) ; String nhxppe = br . readLine ( ) ; String [ ] spl = nhxppe . split ( " " ) ; if ( Integer . parseInt ( spl [ 0 ] ) > Integer . parseInt ( spl [ 1 ] ) ) { System . out . println ( " a > b " ) ; } else if ( Integer . parseInt ( spl [ 0 ] ) == Integer . parseInt ( spl [ 1 ] ) ) { System . out . println ( " a == b " ) ; } else { System . out . println ( " a < b " ) ; } } } import java . io . * ; public class Ixknmzn { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = reader . readLine ( ) ; char ixknmzn = line . charAt ( 0 ) ; ixknmzn ++ ; System . out . println ( ixknmzn ) ; } } import java . util . * ; public class Bhaxjnx { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String bhaxjnx = in . next ( ) ; String res ; if ( bhaxjnx . equals ( " Sunny " ) ) { res = " Cloudy " ; } else if ( bhaxjnx . equals ( " Cloudy " ) ) { res = " Rainy " ; } else { res = " Sunny " ; } System . out . println ( res ) ; in . close ( ) ; } } import java . util . Scanner ; class Qcrbvmm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qcrbvmm = 0 ; int b = 0 ; int c = 0 ; qcrbvmm = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; if ( qcrbvmm < b && b < c && qcrbvmm < c ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Nbjjfa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nbjjfa = Integer . parseInt ( sc . next ( ) ) ; switch ( nbjjfa % 10 ) { case 3 : System . out . println ( " bon " ) ; return ; case 0 : case 1 : case 6 : case 8 : System . out . println ( " pon " ) ; return ; default : System . out . println ( " hon " ) ; return ; } } } import java . util . Scanner ; public class Qkuviev { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int qkuviev = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int T = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( ( T / qkuviev ) * B ) ; } } } import java . util . Scanner ; public class Rxufhk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 100 ] ; int rxufhk = 0 ; for ( int i = 0 ; i < 100 ; i ++ ) { a [ i ] = 0 ; } int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; for ( int i = A ; i < B ; i ++ ) { a [ i ] ++ ; } for ( int i = C ; i < D ; i ++ ) { a [ i ] ++ ; } for ( int i = 0 ; i < 100 ; i ++ ) { if ( a [ i ] == 2 ) { rxufhk ++ ; } } System . out . println ( rxufhk ) ; } } import java . io . * ; import java . util . * ; import java . util . function . * ; final class Mwcit { static final Solver INSTANCE = new Solver ( ) ; void solve ( Supplier < String > sc ) { String S = sc . get ( ) ; int mwcit = Integer . parseInt ( S . substring ( 0 , 2 ) , 10 ) ; int right = Integer . parseInt ( S . substring ( 2 ) , 10 ) ; if ( isYear ( mwcit ) && isYear ( right ) ) { System . out . println ( " NA " ) ; } else if ( isYear ( mwcit ) ) { System . out . println ( " YYMM " ) ; } else if ( isYear ( right ) ) { System . out . println ( " MMYY " ) ; } else { System . out . println ( " AMBIGUOUS " ) ; } } boolean isYear ( int n ) { return n > 12 || n <= 0 ; } } class Mwcit { public static void main ( String ... args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Solver . INSTANCE . solve ( new Supplier < String > ( ) { StringTokenizer line ; public String get ( ) { try { return ( line = line != null && line . hasMoreTokens ( ) ? line : new StringTokenizer ( reader . readLine ( ) ) ) . nextToken ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } ) ; } } import java . util . * ; class Txrystg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int txrystg = sc . nextInt ( ) ; int [ ] len = new int [ txrystg ] ; int sum = 0 ; int max = 0 ; for ( int i = 0 ; i < txrystg ; i ++ ) { int temp = sc . nextInt ( ) ; if ( temp > max ) { max = temp ; } sum += temp ; } System . out . println ( max < sum - max ? " Yes " : " No " ) ; } } import java . util . * ; class Iaflick { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iaflick = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; Integer [ ] h = new Integer [ iaflick ] ; long ans = 0 ; for ( int i = 0 ; i < iaflick ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } if ( k >= iaflick ) { System . out . println ( ans ) ; } else { Arrays . sort ( h , Collections . reverseOrder ( ) ) ; for ( int i = 0 ; i < k ; i ++ ) { h [ i ] = 0 ; } for ( int i = 0 ; i < iaflick ; i ++ ) { ans += h [ i ] ; } System . out . println ( ans ) ; } } } import java . util . * ; public class Rqaflv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rqaflv = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] cities = new int [ rqaflv ] ; for ( int i = 0 ; i < m ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; cities [ l - 1 ] ++ ; cities [ r - 1 ] ++ ; } for ( int j = 0 ; j < rqaflv ; j ++ ) { System . out . println ( cities [ j ] ) ; } } } import java . util . * ; public class Dgfsf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dgfsf = sc . nextInt ( ) ; Integer [ ] dArr = new Integer [ dgfsf ] ; for ( int i = 0 ; i < dgfsf ; i ++ ) { dArr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( dArr , Collections . reverseOrder ( ) ) ; int count = 1 ; for ( int i = 1 ; i < dgfsf ; i ++ ) { if ( dArr [ i - 1 ] == dArr [ i ] ) continue ; if ( dArr [ i - 1 ] > dArr [ i ] ) { count ++ ; } else { break ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Bpakns { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int bpakns = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int H = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; double sita = ( ( double ) H / 12 + ( double ) M / 12 / 60 - ( double ) M / 60 ) * 2 * Math . PI ; sita = sita < 0 ? - ( double ) sita : sita ; double answer = Math . sqrt ( ( double ) ( Math . pow ( bpakns , 2 ) + Math . pow ( B , 2 ) - ( double ) ( ( double ) ( 2 * bpakns * B ) * Math . cos ( sita ) ) ) ) ; System . out . print ( answer ) ; } } } import java . util . Scanner ; public class Mujzpw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mujzpw = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; long [ ] x = new long [ mujzpw ] ; long [ ] y = new long [ mujzpw ] ; int count = 0 ; for ( int i = 0 ; i < mujzpw ; i ++ ) { x [ i ] = sc . nextLong ( ) ; y [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < mujzpw ; i ++ ) { if ( Math . sqrt ( x [ i ] * x [ i ] + y [ i ] * y [ i ] ) <= d ) { count += 1 ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Thyobhp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int thyobhp = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; sc . close ( ) ; int answer = 0 ; answer += ( thyobhp * ( thyobhp - 1 ) ) / 2 ; answer += ( m * ( m - 1 ) ) / 2 ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class Rmwwlhl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rmwwlhl = sc . nextInt ( ) ; int yoke = 0 ; int count = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { count += rmwwlhl % 10 ; rmwwlhl -= rmwwlhl % 10 ; rmwwlhl /= 10 ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Pjdefs { public static int total ( int t ) { int pjdefs = 0 ; while ( t != 0 ) { pjdefs += t % 10 ; t /= 10 ; } return pjdefs ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int result = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( A <= total ( i ) && total ( i ) <= B ) result += i ; } System . out . println ( result ) ; } } import java . util . Scanner ; public class Jsefwet { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jsefwet = sc . nextInt ( ) ; int [ ] B = new int [ jsefwet ] ; for ( int i = 0 ; i < jsefwet - 1 ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } int total = 0 ; for ( int i = 0 ; i < jsefwet ; i ++ ) { if ( i == 0 ) total += B [ i ] ; else if ( i == jsefwet - 1 ) total += B [ i - 1 ] ; else { if ( B [ i ] > B [ i - 1 ] ) total += B [ i - 1 ] ; else total += B [ i ] ; } } System . out . println ( total ) ; } } import java . util . * ; class Ualzcki { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ualzcki = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; System . out . println ( t / ualzcki * b ) ; } } import java . util . * ; public class Sttvzt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sttvzt = sc . nextInt ( ) ; int [ ] arr = new int [ sttvzt + 1 ] ; arr [ 0 ] = - 1 ; for ( int i = 1 ; i < sttvzt + 1 ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } String ans = " Yes " ; for ( int i = 1 ; i < sttvzt ; i ++ ) { if ( arr [ i ] <= arr [ i + 1 ] - 1 ) { arr [ i + 1 ] -- ; } else if ( arr [ i ] <= arr [ i + 1 ] ) { continue ; } else { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Nhhgati { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nhhgati = sc . nextInt ( ) ; int x_500 = nhhgati / 500 ; nhhgati = nhhgati - nhhgati / 500 * 500 ; int x_5 = nhhgati / 5 ; int ans = x_500 * 1000 + x_5 * 5 ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class Vearewc { private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; private static StringTokenizer st ; private static int readInt ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return Integer . parseInt ( st . nextToken ( ) ) ; } public static void main ( String [ ] args ) throws IOException { int vearewc = readInt ( ) ; if ( vearewc % 1000 == 0 ) pw . println ( 0 ) ; else pw . println ( 1000 - vearewc % 1000 ) ; pw . close ( ) ; } } import java . util . * ; import java . lang . * ; public class Sfwbsoh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String sfwbsoh = scan . next ( ) ; if ( sfwbsoh . equals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } if ( sfwbsoh . equals ( " ARC " ) ) { System . out . println ( " ABC " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Hzovd { public static void main ( String [ ] args ) throws IOException { int [ ] data = new int [ 10 ] ; final String BR = System . getProperty ( " line.separator " ) ; int hzovd = 0 , second = 0 , third = 0 ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; for ( int i = 0 ; i < 10 ; i ++ ) { data [ i ] = Integer . parseInt ( in . readLine ( ) ) ; } for ( int datum : data ) { int temp1 = 0 , temp2 = 0 ; if ( hzovd < datum ) { temp1 = hzovd ; temp2 = second ; hzovd = datum ; second = temp1 ; third = temp2 ; } else if ( second < datum ) { temp2 = second ; second = datum ; third = temp2 ; } else if ( third < datum ) { third = datum ; } } System . out . println ( hzovd + BR + second + BR + third ) ; } } import java . util . Scanner ; public class Jogtla { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] menu = new int [ 5 ] ; int jogtla = 0 ; int max = 0 ; int idx = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { menu [ i ] = sc . nextInt ( ) ; if ( max < ( 10 - ( menu [ i ] % 10 ) ) && ( 10 - ( menu [ i ] % 10 ) ) != 10 ) { max = 10 - ( menu [ i ] % 10 ) ; idx = i ; } } sc . close ( ) ; for ( int i = 0 ; i < 5 ; i ++ ) { if ( idx != i ) { if ( ( 10 - ( menu [ i ] % 10 ) ) == 10 ) { jogtla += menu [ i ] ; } else { jogtla += menu [ i ] + ( 10 - ( menu [ i ] % 10 ) ) ; } } } jogtla += menu [ idx ] ; System . out . println ( jogtla ) ; } } import java . util . * ; public class Jnfvm { public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . exec ( ) ; } private void exec ( ) { Scanner scan = new Scanner ( System . in ) ; int jnfvm = 0 ; int count7 = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { switch ( scan . nextInt ( ) ) { case 5 : jnfvm ++ ; break ; case 7 : count7 ++ ; break ; default : } } if ( jnfvm == 2 && count7 == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } scan . close ( ) ; } } import java . util . * ; public class Fcnhkxs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fcnhkxs = 0 ; int count7 = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { switch ( sc . nextInt ( ) ) { case 5 : fcnhkxs ++ ; break ; case 7 : count7 ++ ; break ; } } if ( fcnhkxs == 2 && count7 == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; import java . util . Stack ; class Zcflh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zcflh = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; String [ ] name = new String [ zcflh ] ; String [ ] queue = new String [ 1000000 ] ; int head = 0 , tail = 0 ; int totaltime = 0 ; int now = 0 ; Map < String , Integer > time = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < zcflh ; ++ i ) { name [ i ] = sc . next ( ) ; time . put ( name [ i ] , sc . nextInt ( ) ) ; totaltime += time . get ( name [ i ] ) ; queue [ tail ] = name [ i ] ; ++ tail ; } while ( now != totaltime ) { if ( time . get ( queue [ head ] ) > q ) { time . put ( queue [ head ] , time . get ( queue [ head ] ) - q ) ; queue [ tail ] = queue [ head ] ; ++ head ; ++ tail ; now += q ; } else { now += time . get ( queue [ head ] ) ; System . out . println ( queue [ head ] + " " + now ) ; ++ head ; } } } } import java . util . * ; class Wtnbisy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wtnbisy = sc . nextInt ( ) ; int c0 = 0 ; int c1 = 0 ; int c2 = 0 ; int c3 = 0 ; for ( int i = 0 ; i < wtnbisy + 1 ; i ++ ) { String s = sc . nextLine ( ) ; if ( s . equals ( " AC " ) ) { ++ c0 ; } else if ( s . equals ( " WA " ) ) { ++ c1 ; } else if ( s . equals ( " TLE " ) ) { ++ c2 ; } else if ( s . equals ( " RE " ) ) { ++ c3 ; } } System . out . println ( " AC x " + c0 ) ; System . out . println ( " WA x " + c1 ) ; System . out . println ( " TLE x " + c2 ) ; System . out . println ( " RE x " + c3 ) ; } } import java . util . * ; import java . math . BigInteger ; public class Dlvqy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dlvqy = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; boolean [ ] sunukes = new boolean [ dlvqy ] ; for ( int i = 0 ; i < k ; i ++ ) { int d = sc . nextInt ( ) ; for ( int j = 0 ; j < d ; j ++ ) { sunukes [ sc . nextInt ( ) - 1 ] = true ; } } int ans = 0 ; for ( boolean hasSweets : sunukes ) { if ( hasSweets ) continue ; ans ++ ; } System . out . println ( ans ) ; } } import java . io . * ; class Izruuf { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int izruuf = Integer . parseInt ( br . readLine ( ) ) ; String buf = br . readLine ( ) ; String [ ] line = buf . split ( " " ) ; int a = Integer . parseInt ( line [ 0 ] ) ; long max = a ; long min = a ; long total = a ; for ( int i = 1 ; i < izruuf ; i ++ ) { int b = Integer . parseInt ( line [ i ] ) ; if ( max < b ) max = b ; if ( min > b ) min = b ; total = total + b ; } System . out . print ( min + " " + max + " " + total ) ; System . out . print ( " \n " ) ; } catch ( Exception e ) { } } } import java . util . * ; public class Wgxadc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wgxadc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] surp = new int [ Math . min ( wgxadc , b ) + 1 ] ; for ( int i = 1 ; i <= Math . min ( wgxadc , b ) ; i ++ ) { if ( wgxadc % i == 0 && b % i == 0 ) { surp [ i ] = i ; } } Arrays . sort ( surp ) ; System . out . println ( surp [ Math . min ( wgxadc , b ) - k + 1 ] ) ; } } import java . util . * ; import java . io . * ; class Wboftlu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out , true ) ; String str = sc . nextLine ( ) ; int wboftlu = 0 ; int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == 'R' ) { count ++ ; wboftlu = Math . wboftlu ( count , wboftlu ) ; } else { count = 0 ; } } out . println ( wboftlu ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Whpzbr { public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; boolean whpzbr = false ; int num = in . nextInt ( ) ; int max = in . nextInt ( ) ; int cost = Integer . MAX_VALUE ; for ( int i = 0 ; i < num ; i ++ ) { int c = in . nextInt ( ) ; int t = in . nextInt ( ) ; if ( c < cost && t <= max ) { cost = c ; whpzbr = true ; } } if ( whpzbr ) System . out . println ( cost ) ; else System . out . println ( " TLE " ) ; } static class Whpzbr { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Wurmjn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int wurmjn = 0 ; while ( wurmjn == 0 ) { String line = sc . nextLine ( ) ; String [ ] x = line . split ( " " ) ; int a = Integer . parseInt ( x [ 0 ] ) ; int b = Integer . parseInt ( x [ 2 ] ) ; String op = x [ 1 ] ; if ( op . equals ( " + " ) ) { list . add ( a + b ) ; } if ( op . equals ( " - " ) ) { list . add ( a - b ) ; } if ( op . equals ( " * " ) ) { list . add ( a * b ) ; } if ( op . equals ( " / " ) ) { list . add ( a / b ) ; } if ( op . equals ( " ? " ) ) { break ; } } for ( Integer integer : list ) { System . out . println ( integer ) ; } } } import java . util . Scanner ; public class Dabffpr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dabffpr = scan . nextInt ( ) ; int [ ] h = new int [ dabffpr + 1 ] ; for ( int i = 1 ; i <= dabffpr ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } h [ 0 ] = 0 ; for ( int i = 1 ; i <= dabffpr ; i ++ ) { if ( h [ i ] > h [ i - 1 ] ) { h [ i ] -- ; } } for ( int i = 1 ; i <= dabffpr ; i ++ ) { if ( h [ i ] >= h [ i - 1 ] ) { } else { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; class Rtaofnl { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; double rtaofnl = cin . nextDouble ( ) ; System . out . printf ( " %.6f %.6f \n " , cal_area ( rtaofnl ) , cal_cirum ( rtaofnl ) ) ; } private static double cal_cirum ( double rtaofnl ) { return ( rtaofnl * 2 * Math . PI ) ; } private static double cal_area ( double rtaofnl ) { return ( rtaofnl * rtaofnl * Math . PI ) ; } } import java . util . Scanner ; public class Avmff { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int avmff = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] ary = new int [ avmff ] ; long sum = 0 ; for ( int i = 0 ; i < avmff ; i ++ ) { ary [ i ] = sc . nextInt ( ) ; sum += ary [ i ] ; } sc . close ( ) ; int m2 = 0 ; for ( int i = 0 ; i < avmff ; i ++ ) { if ( ary [ i ] * ( 4 * m ) >= sum ) { m2 ++ ; } } System . out . println ( m2 >= m ? " Yes " : " No " ) ; } } import java . util . ArrayList ; import java . util . Comparator ; import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; public class Yqxiky { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long yqxiky = scanner . nextLong ( ) ; long count = 0 ; while ( yqxiky > 1 ) { yqxiky = yqxiky / 2 ; count ++ ; } long answer = 0 ; for ( int i = 0 ; i <= count ; i ++ ) { answer += Math . pow ( 2 , i ) ; } System . out . println ( answer ) ; } } import java . util . * ; import java . io . * ; public class Spaeoih { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int spaeoih = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] r = new int [ 2 * m ] ; int [ ] rr = new int [ spaeoih + 1 ] ; for ( int i = 0 ; i < 2 * m ; i ++ ) { r [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < spaeoih + 1 ; i ++ ) { rr [ i ] = 0 ; } for ( int i = 0 ; i < 2 * m ; i ++ ) { rr [ r [ i ] ] ++ ; } for ( int i = 1 ; i <= spaeoih ; i ++ ) { System . out . println ( rr [ i ] ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Wzywf { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder builder = new StringBuilder ( ) ; while ( true ) { String [ ] data = reader . readLine ( ) . split ( " " ) ; int wzywf = Integer . parseInt ( data [ 0 ] ) ; int b = Integer . parseInt ( data [ 1 ] ) ; if ( wzywf == 0 && b == 0 ) break ; for ( int y = 0 ; y < wzywf ; y ++ ) { for ( int x = 0 ; x < b ; x ++ ) { builder . append ( " # " ) ; } builder . append ( " \n " ) ; } builder . append ( " \n " ) ; } System . out . print ( builder ) ; } } import java . util . Scanner ; public class Flsyzhp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int flsyzhp = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; sc . close ( ) ; if ( Y % 2 == 1 ) { System . out . println ( " No " ) ; return ; } double ans = Y / 2 - flsyzhp ; if ( ans < 0 || ans > flsyzhp || ans % 1 != 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class Jplgzi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jplgzi , m , l ; jplgzi = sc . nextInt ( ) ; m = sc . nextInt ( ) ; l = sc . nextInt ( ) ; long [ ] [ ] A = new long [ jplgzi ] [ m ] ; long [ ] [ ] B = new long [ m ] [ l ] ; for ( int i = 0 ; i < jplgzi ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { A [ i ] [ j ] = sc . nextLong ( ) ; } } for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < l ; j ++ ) { B [ i ] [ j ] = sc . nextLong ( ) ; } } for ( int i = 0 ; i < jplgzi ; i ++ ) { for ( int j = 0 ; j < l ; j ++ ) { long sum = 0 ; for ( int k = 0 ; k < m ; k ++ ) { sum = sum + A [ i ] [ k ] * B [ k ] [ j ] ; } if ( j != l - 1 ) { System . out . print ( sum + " " ) ; } else System . out . println ( sum ) ; } } } } import java . util . Scanner ; public class Atiwgav { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int atiwgav = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int res10000 = - 1 , res5000 = - 1 , res1000 = - 1 ; sc . close ( ) ; for ( int a = 0 ; a <= atiwgav ; a ++ ) { for ( int b = 0 ; b + a <= atiwgav ; b ++ ) { int c = atiwgav - a - b ; int total = 10000 * a + 5000 * b + 1000 * c ; if ( total == y ) { res10000 = a ; res5000 = b ; res1000 = c ; } } } System . out . println ( res10000 + " " + res5000 + " " + res1000 ) ; } } import java . text . DecimalFormat ; import java . util . Scanner ; public class Btcqkt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = sc . nextLine ( ) . split ( " " ) ; int btcqkt = Integer . parseInt ( s [ 0 ] ) ; int b = Integer . parseInt ( s [ 1 ] ) ; int d = btcqkt / b ; int r = btcqkt % b ; double af = ( double ) btcqkt ; double bf = ( double ) b ; double f = af / bf ; System . out . println ( d + " " + r + " " + new DecimalFormat ( " 0000000000.0000000000 " ) . format ( f ) ) ; } } import java . util . Scanner ; public class Yfdweq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yfdweq = sc . nextInt ( ) ; int [ ] A = new int [ yfdweq + 1 ] ; int [ ] B = new int [ yfdweq ] ; for ( int i = 0 ; i < yfdweq + 1 ; i ++ ) A [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < yfdweq ; i ++ ) B [ i ] = sc . nextInt ( ) ; long res = 0 ; for ( int i = 0 ; i < yfdweq ; i ++ ) { int d = Math . min ( A [ i ] , B [ i ] ) ; res += d ; A [ i ] -= d ; B [ i ] -= d ; d = Math . min ( B [ i ] , A [ i + 1 ] ) ; res += d ; A [ i + 1 ] -= d ; } System . out . println ( res ) ; } } import java . util . Scanner ; public class Tgdgfnn { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String tgdgfnn = sc . next ( ) ; String t = sc . next ( ) ; if ( tgdgfnn . equals ( t . substring ( 0 , tgdgfnn . length ( ) ) ) && ( t . length ( ) - tgdgfnn . length ( ) == 1 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Hnbsbn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int hnbsbn = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; int [ ] [ ] a = new int [ hnbsbn ] [ m ] ; int [ ] b = new int [ m ] ; for ( int y = 0 ; y < hnbsbn ; y ++ ) { for ( int x = 0 ; x < m ; x ++ ) { a [ y ] [ x ] = scanner . nextInt ( ) ; } } for ( int y = 0 ; y < m ; y ++ ) { b [ y ] = scanner . nextInt ( ) ; } for ( int y = 0 ; y < hnbsbn ; y ++ ) { int ans = 0 ; for ( int x = 0 ; x < m ; x ++ ) { ans += a [ y ] [ x ] * b [ x ] ; } System . out . println ( ans ) ; } scanner . close ( ) ; } } import java . util . Scanner ; public class Ziohf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ziohf = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; true ; i ++ ) { ziohf -= m ; ans ++ ; if ( ziohf <= 0 ) { break ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; public class Ijzaz { public static void main ( String [ ] hi ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; int ijzaz = Integer . parseInt ( st . nextToken ( ) ) ; int X = Integer . parseInt ( st . nextToken ( ) ) ; int T = Integer . parseInt ( st . nextToken ( ) ) ; int time = ijzaz / X ; time *= T ; if ( ijzaz % X > 0 ) time += T ; System . out . println ( time ) ; } } import java . util . * ; import java . math . BigDecimal ; import java . math . RoundingMode ; public class Eufjh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eufjh = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; double a1 = 0.08 ; double b1 = 0.1 ; double s = 0 ; int ans = - 1 ; int s1 = 0 ; double t = 0 ; double t1 = 0 ; for ( int i = 1 ; i < 10000 ; i ++ ) { s = i * 0.08 ; s1 = ( int ) s ; t = i * 0.1 ; t1 = ( int ) t ; if ( s1 == eufjh && t1 == B ) { ans = i ; break ; } } System . out . print ( ans ) ; } } import java . util . * ; public class Bieze { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String result = " " ; for ( int bieze = 0 ; bieze < s . length ( ) ; bieze ++ ) { switch ( s . charAt ( bieze ) ) { case '0' : result += 0 ; break ; case '1' : result += 1 ; break ; case 'B' : if ( ! result . isEmpty ( ) ) { result = result . substring ( 0 , result . length ( ) - 1 ) ; } break ; } } System . out . println ( result ) ; } } import java . util . * ; public class Dsxnoij { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int dsxnoij = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int powD = 1 ; for ( int i = 0 ; i < dsxnoij ; i ++ ) { powD *= 100 ; } int ans = N * powD ; if ( ( ans == 100 && powD == 1 ) || ( ans == 10000 && powD == 100 ) || ( ans == 1000000 && powD == 10000 ) ) { System . out . println ( ans + 1 * powD ) ; } else { System . out . println ( ans ) ; } } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; class Qzgrrc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int qzgrrc = Integer . parseInt ( s . substring ( 0 , 2 ) ) ; int b = Integer . parseInt ( s . substring ( 2 ) ) ; String ans = " NA " ; if ( ( qzgrrc >= 1 && qzgrrc <= 12 ) && ( b >= 1 && b <= 12 ) ) { ans = " AMBIGUOUS " ; } else if ( qzgrrc >= 1 && qzgrrc <= 12 ) { ans = " MMYY " ; } else if ( b >= 1 && b <= 12 ) { ans = " YYMM " ; } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; class Rxtgxzt { static int rxtgxzt , arr [ ] , k ; static long [ ] dp ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = 1 ; StringBuilder printans = new StringBuilder ( ) ; while ( t -- > 0 ) { StringTokenizer tok = new StringTokenizer ( br . readLine ( ) , " " ) ; rxtgxzt = Integer . parseInt ( tok . nextToken ( ) ) ; k = Integer . parseInt ( tok . nextToken ( ) ) ; arr = new int [ rxtgxzt ] ; tok = new StringTokenizer ( br . readLine ( ) , " " ) ; for ( int i = 0 ; i < rxtgxzt ; i ++ ) { arr [ i ] = Integer . parseInt ( tok . nextToken ( ) ) ; } dp = new long [ rxtgxzt ] ; printans . append ( call ( ) ) ; } System . out . println ( printans ) ; } static long call ( ) { dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( arr [ 1 ] - arr [ 0 ] ) ; for ( int i = 2 ; i < rxtgxzt ; i ++ ) { long temp = Integer . MAX_VALUE ; for ( int j = i - k ; j < i ; j ++ ) { if ( j >= 0 ) { temp = Math . min ( temp , dp [ j ] + Math . abs ( arr [ i ] - arr [ j ] ) ) ; } } dp [ i ] = temp ; } return dp [ dp . length - 1 ] ; } } import java . util . Arrays ; import java . util . Scanner ; public class Jodwjzb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jodwjzb = sc . nextInt ( ) ; int [ ] H = new int [ jodwjzb ] ; for ( int i = 0 ; i < jodwjzb ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < jodwjzb ; i ++ ) { if ( i == 1 ) { H [ 0 ] -- ; } else { if ( H [ i - 1 ] - 1 >= H [ i - 2 ] ) { H [ i - 1 ] -- ; } } } int [ ] H1 = H . clone ( ) ; Arrays . sort ( H ) ; if ( Arrays . equals ( H , H1 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Yixql { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int yixql = gi ( ) ; int [ ] A = new int [ yixql ] ; for ( int i = 0 ; i < yixql ; i ++ ) { A [ i ] = gi ( ) ; } Arrays . parallelSort ( A ) ; System . out . println ( A [ A . length - 1 ] - A [ 0 ] ) ; } public static int s ( int yixql ) { String S = String . valueOf ( yixql ) ; int c = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { int k = Integer . parseInt ( S . substring ( i , i + 1 ) ) ; c += k ; } return c ; } public static long d ( long yixql ) { String a = String . valueOf ( yixql ) ; return ( long ) a . length ( ) ; } public static String gs ( ) { return scanner . next ( ) ; } public static int gi ( ) { return Integer . parseInt ( scanner . next ( ) ) ; } public static long gl ( ) { return Long . parseLong ( scanner . next ( ) ) ; } public static double gd ( ) { return Double . parseDouble ( scanner . next ( ) ) ; } } import java . util . * ; class Chqebv { public static void main ( String [ ] args ) { int chqebv ; int i , j ; int v ; Scanner scan = new Scanner ( System . in ) ; String str = new String ( ) ; chqebv = scan . nextInt ( ) ; int [ ] A = new int [ chqebv ] ; for ( i = 0 ; i < chqebv ; i ++ ) A [ i ] = scan . nextInt ( ) ; for ( i = 0 ; i < chqebv ; i ++ ) { v = A [ i ] ; j = i - 1 ; while ( j >= 0 && A [ j ] > v ) { A [ j + 1 ] = A [ j ] ; j -- ; } A [ j + 1 ] = v ; str = Arrays . toString ( A ) ; str = str . replaceAll ( " \\ [| \\ ]|, " , " " ) ; System . out . println ( str ) ; } return ; } } import java . util . Scanner ; public class Tkavku { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int tkavku = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] p = new int [ m ] ; String [ ] s = new String [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { p [ i ] = sc . nextInt ( ) - 1 ; s [ i ] = sc . next ( ) ; } int [ ] [ ] a = new int [ 2 ] [ tkavku ] ; for ( int i = 0 ; i < m ; i ++ ) { if ( s [ i ] . equals ( " WA " ) && a [ 1 ] [ p [ i ] ] == 0 ) { a [ 0 ] [ p [ i ] ] ++ ; } if ( s [ i ] . equals ( " AC " ) && a [ 1 ] [ p [ i ] ] == 0 ) { a [ 1 ] [ p [ i ] ] ++ ; } } int ac = 0 ; int wa = 0 ; for ( int i = 0 ; i < tkavku ; i ++ ) { ac += a [ 1 ] [ i ] ; if ( a [ 1 ] [ i ] == 1 ) { wa += a [ 0 ] [ i ] ; } } System . out . println ( ac + " " + wa ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Vuioe { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; long vuioe = sc . nextLong ( ) ; int m = sc . nextInt ( ) ; long sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) sum += sc . nextLong ( ) ; System . out . println ( ( sum <= vuioe ) ? vuioe - sum : " -1 " ) ; } static class Vuioe { 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 . Scanner ; public class Awtbez { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int awtbez = scanner . nextInt ( ) ; int result = 0 ; int max = 0 ; for ( int i = 0 ; i < awtbez ; i ++ ) { int a = scanner . nextInt ( ) ; if ( a >= max ) { max = a ; result ++ ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class Esyuiuq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String N = sc . nextLine ( ) ; sc . close ( ) ; String [ ] a = new String [ 3 ] ; a [ 0 ] = N . substring ( 0 , 1 ) ; a [ 1 ] = N . substring ( 1 , 2 ) ; a [ 2 ] = N . substring ( 2 , 3 ) ; for ( int esyuiuq = 0 ; esyuiuq < 3 ; esyuiuq ++ ) { if ( a [ esyuiuq ] . equals ( " 1 " ) ) { a [ esyuiuq ] = " 9 " ; } else if ( a [ esyuiuq ] . equals ( " 9 " ) ) { a [ esyuiuq ] = " 1 " ; } } System . out . println ( a [ 0 ] + a [ 1 ] + a [ 2 ] ) ; } } import java . util . Scanner ; public class Tmeri { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tmeri = sc . nextInt ( ) ; int [ ] nums = new int [ tmeri ] ; for ( int i = 0 ; i < tmeri ; i ++ ) { nums [ i ] = sc . nextInt ( ) ; } boolean result = true ; for ( int i = 0 ; i < tmeri ; i ++ ) { int before = 0 ; if ( i != 0 ) { before = nums [ i - 1 ] ; } if ( nums [ i ] < before ) { result = false ; break ; } if ( nums [ i ] != before ) { nums [ i ] -- ; } } if ( result ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Slqej { public static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } public static int gcd_roop ( int a , int b ) { while ( true ) { if ( b == 0 ) return a ; int slqej ; slqej = a ; a = b ; b = slqej % b ; } } public static void main ( String [ ] args ) { int a , b ; Scanner scan = new Scanner ( System . in ) ; a = scan . nextInt ( ) ; b = scan . nextInt ( ) ; System . out . println ( gcd_roop ( a , b ) ) ; scan . close ( ) ; } } import java . util . Scanner ; public class Brwsl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int brwsl = sc . nextInt ( ) ; int [ ] [ ] a = new int [ 2 ] [ brwsl ] ; for ( int i = 0 ; i < brwsl ; i ++ ) { a [ 0 ] [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < brwsl ; i ++ ) { a [ 1 ] [ i ] = sc . nextInt ( ) ; } int max = 0 ; int first = 0 ; for ( int i = 0 ; i < brwsl ; i ++ ) { first += a [ 0 ] [ i ] ; int second = 0 ; for ( int j = i ; j < brwsl ; j ++ ) { second += a [ 1 ] [ j ] ; } max = Math . max ( max , first + second ) ; } System . out . println ( max ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Lykmli { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long lykmli = sc . nextLong ( ) ; long A = 1 ; for ( long i = 1 ; i * i <= lykmli ; i ++ ) { if ( lykmli % i == 0 && i > A ) { A = i ; } } long B = lykmli / A ; System . out . println ( A + B - 2 ) ; sc . close ( ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class Zdkdwa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigDecimal a = sc . nextBigDecimal ( ) ; BigDecimal b = sc . nextBigDecimal ( ) ; BigDecimal c = sc . nextBigDecimal ( ) ; BigDecimal d = sc . nextBigDecimal ( ) ; BigDecimal e = a . multiply ( c ) ; if ( e . compareTo ( a . multiply ( d ) ) < 0 ) { e = a . multiply ( d ) ; } if ( e . compareTo ( b . multiply ( c ) ) < 0 ) { e = b . multiply ( c ) ; } if ( e . compareTo ( b . multiply ( d ) ) < 0 ) { e = b . multiply ( d ) ; } System . out . println ( e ) ; } } import java . util . Scanner ; public class Oglxs { public static void main ( String [ ] args ) { try ( Scanner cs = new Scanner ( System . in ) ) { String line = cs . nextLine ( ) ; String answer = " " ; int oglxs = line . oglxs ( ) ; for ( int i = 0 ; i < oglxs ; i ++ ) { char ch = line . charAt ( i ) ; if ( Character . isLowerCase ( ch ) ) { System . out . print ( Character . toUpperCase ( ch ) ) ; } else { System . out . print ( Character . toLowerCase ( ch ) ) ; } } System . out . printf ( " \n " ) ; } } } import java . util . * ; public class Cgodk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cgodk = scan . nextInt ( ) ; int [ ] a = new int [ cgodk ] ; for ( int i = 0 ; i < cgodk ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } long sum = 0 ; while ( true ) { boolean flag = true ; for ( int i = 0 ; i < cgodk ; i ++ ) { if ( a [ i ] == 0 ) { if ( flag == false ) { break ; } } else { a [ i ] -= 1 ; flag = false ; } } if ( flag == true ) { System . out . println ( sum ) ; return ; } sum += 1 ; } } } import java . util . Scanner ; public class Ixezr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String ixezr = scan . next ( ) ; String b = scan . next ( ) ; if ( ixezr . equals ( b . substring ( 0 , b . length ( ) - 1 ) ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; } } import java . util . * ; class Mkotq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mkotq = sc . nextLong ( ) ; long r = sc . nextLong ( ) ; long min = mkotq * ( mkotq + 1 ) % 2019 ; if ( ( r - mkotq ) >= 2018 ) { System . out . println ( 0 ) ; } else if ( ( r - mkotq ) < ( 2019 - mkotq % 2019 ) ) { for ( long e = mkotq ; e < r ; e ++ ) { for ( long f = e + 1 ; f <= r ; f ++ ) { min = Math . min ( min , e * f % 2019 ) ; } if ( min == 0 ) { break ; } } System . out . println ( min ) ; } else { System . out . println ( 0 ) ; } } } import java . util . * ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Alejff { public static void main ( String [ ] a ) { Scanner scan = new Scanner ( System . in ) ; int alejff = scan . nextInt ( ) ; Map < Integer , Integer > numMap = new HashMap < > ( ) ; for ( int i = 1 ; i < alejff + 1 ; i ++ ) { int s = scan . nextInt ( ) ; int dis = alejff - s ; numMap . put ( alejff - dis , i ) ; } for ( int j = 1 ; j < numMap . size ( ) + 1 ; j ++ ) { System . out . printf ( " %d " , numMap . get ( j ) ) ; } } } import java . util . * ; public class Xnwgmu { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final String xnwgmu = sc . next ( ) ; final String t = sc . next ( ) ; sc . close ( ) ; String result = " No " ; if ( t . length ( ) == xnwgmu . length ( ) + 1 && t . substring ( 0 , xnwgmu . length ( ) ) . equals ( xnwgmu ) ) { result = " Yes " ; } System . out . println ( result ) ; } } import java . util . * ; public class Nahco { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nahco = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int base = 1 ; for ( int i = 0 ; i < nahco ; i ++ ) { base *= 100 ; } if ( N % 100 == 0 ) { System . out . println ( base * ( N + 1 ) ) ; } else { System . out . println ( base * N ) ; } } } import java . util . * ; public class Newqc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int newqc = sc . nextInt ( ) ; Set < Integer > visited = new HashSet < > ( ) ; int cnt = 0 ; while ( newqc > 0 ) { newqc -- ; int num = sc . nextInt ( ) ; if ( visited . contains ( num ) ) continue ; visited . add ( num ) ; cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . * ; public class Okgln { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String t = sc . nextLine ( ) ; String [ ] sArray = s . split ( " " ) ; String [ ] tArray = t . split ( " " ) ; int okgln = sArray . length - tArray . length + 1 ; String part = new String ( ) ; int count = 9999 ; for ( int i = 0 ; i < okgln ; i ++ ) { StringBuilder sb = new StringBuilder ( ) ; for ( int j = i ; j < i + tArray . length ; j ++ ) { sb . append ( sArray [ j ] ) ; } part = sb . toString ( ) ; String [ ] partArray = part . split ( " " ) ; int currentCount = 0 ; for ( int k = 0 ; k < tArray . length ; k ++ ) { if ( ! partArray [ k ] . equals ( tArray [ k ] ) ) { currentCount ++ ; } } count = currentCount < count ? currentCount : count ; } System . out . println ( count ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Egfnvv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int egfnvv = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] arr = new int [ egfnvv ] ; int totalVotes = 0 ; for ( int i = 0 ; i < egfnvv ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; totalVotes += arr [ i ] ; } double popular = totalVotes / ( 4 * m ) ; int ans = 0 ; for ( int i = 0 ; i < egfnvv ; i ++ ) { if ( totalVotes <= arr [ i ] * 4 * m ) ans ++ ; } if ( ans >= m ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class Fgkmw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fgkmw = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < fgkmw ; ++ i ) { int high = sc . nextInt ( ) ; if ( high >= K ) { count ++ ; } } System . out . println ( count ) ; } } import java . io . * ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Hmvmmg { static String a ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int hmvmmg = stdIn . nextInt ( ) ; int count = 0 ; IN : for ( int i = 0 ; i < hmvmmg ; i ++ ) { int x = stdIn . nextInt ( ) ; for ( int j = 2 ; j * j <= x ; j ++ ) { if ( x % j == 0 ) continue IN ; } count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . stream . IntStream ; public class Noexp { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int noexp = sc . nextInt ( ) ; int sum = 0 ; int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < noexp ; i ++ ) { final int L = sc . nextInt ( ) ; max = Math . max ( max , L ) ; sum += L ; } System . out . println ( max * 2 < sum ? " Yes " : " No " ) ; } } import java . util . * ; import java . io . * ; class Kiuqsou { void solve ( ) { char [ ] a = incharar ( ) ; int kiuqsou = 0 ; for ( int i = 0 ; i < a . length / 2 ; i ++ ) { if ( a [ i ] != a [ a . length - i - 1 ] ) kiuqsou ++ ; } out . println ( kiuqsou ) ; } public static Scanner in = new Scanner ( System . in ) ; public static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; out . flush ( ) ; } public int inint ( ) { return in . nextInt ( ) ; } public long inlong ( ) { return in . nextLong ( ) ; } public String instr ( ) { return in . next ( ) ; } public int [ ] inintar ( int num ) { int [ ] a = new int [ num ] ; for ( int i = 0 ; i < num ; i ++ ) { a [ i ] = in . nextInt ( ) ; } return a ; } public char [ ] incharar ( ) { return in . next ( ) . toCharArray ( ) ; } } import java . util . * ; class Fhxyu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fhxyu = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ fhxyu ] ; for ( int i = 0 ; i < fhxyu ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int count = 0 ; uncode : while ( true ) { for ( int i = 0 ; i < fhxyu ; i ++ ) { if ( a [ i ] % 2 != 0 ) { break uncode ; } a [ i ] = a [ i ] / 2 ; } count ++ ; } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; class Dfojmn { public static void main ( String [ ] args ) throws IOException { PrintWriter out = new PrintWriter ( System . out ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int dfojmn = Integer . parseInt ( br . readLine ( ) ) ; int answer = ( int ) ( Math . ceil ( dfojmn / 1000.0 ) ) ; out . println ( answer * 1000 - dfojmn ) ; out . flush ( ) ; out . close ( ) ; } static class Dfojmn { long x1 ; long x2 ; public pair ( long x1 , long x2 ) { this . x1 = x1 ; this . x2 = x2 ; } } } import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; import java . util . function . Function ; import java . util . stream . Collectors ; public class Nfsviz { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; List < Long > s = stdin . nextLine ( ) . chars ( ) . boxed ( ) . collect ( Collectors . groupingBy ( Function . identity ( ) , Collectors . counting ( ) ) ) . values ( ) . stream ( ) . collect ( Collectors . toList ( ) ) ; String nfsviz = s . equals ( Arrays . asList ( 2L , 2L ) ) ? " Yes " : " No " ; System . out . println ( nfsviz ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; class Vbfclw { public static void main ( String [ ] args ) throws Exception { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; List < String > firstRow = Arrays . asList ( br . readLine ( ) . split ( " " ) ) ; List < String > secondRow = Arrays . asList ( br . readLine ( ) . split ( " " ) ) ; String thirdRow = br . readLine ( ) ; List < Integer > ballsCount = new ArrayList < > ( ) ; for ( String s : secondRow ) { ballsCount . add ( Integer . parseInt ( s ) ) ; } Map < String , Integer > ballsCountAndColor = new HashMap < > ( ) ; for ( int vbfclw = 0 ; vbfclw < firstRow . size ( ) ; vbfclw ++ ) { ballsCountAndColor . put ( firstRow . get ( vbfclw ) , ballsCount . get ( vbfclw ) ) ; } ballsCountAndColor . put ( thirdRow , ballsCountAndColor . get ( thirdRow ) . intValue ( ) - 1 ) ; System . out . print ( ballsCountAndColor . get ( firstRow . get ( 0 ) ) . intValue ( ) + " " + ballsCountAndColor . get ( firstRow . get ( 1 ) ) . intValue ( ) ) ; } catch ( IOException | NumberFormatException e ) { e . printStackTrace ( ) ; System . exit ( 0 ) ; } catch ( final Exception e ) { e . printStackTrace ( ) ; System . exit ( 0 ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class Asurfij { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int asurfij = sc . nextInt ( ) ; int a ; ArrayList < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; i < asurfij ; i ++ ) { a = sc . nextInt ( ) ; list . add ( String . valueOf ( a ) ) ; list . add ( " " ) ; } list . remove ( list . size ( ) - 1 ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { System . out . print ( list . get ( list . size ( ) - 1 - i ) ) ; } System . out . println ( ) ; } } import java . util . * ; public class Fqcwdw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fqcwdw = sc . nextInt ( ) ; int [ ] youso1 = new int [ fqcwdw ] ; for ( int i = 0 ; i < fqcwdw ; i ++ ) { youso1 [ i ] = sc . nextInt ( ) ; } int [ ] youso2 = youso1 . clone ( ) ; Arrays . sort ( youso2 ) ; for ( int i = 0 ; i < fqcwdw ; i ++ ) { if ( youso1 [ i ] < youso2 [ fqcwdw - 1 ] ) { System . out . println ( youso2 [ fqcwdw - 1 ] ) ; } else { System . out . println ( youso2 [ fqcwdw - 2 ] ) ; } } } } import java . util . ArrayList ; import java . util . Iterator ; import java . util . Scanner ; public class Rqhmv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long rqhmv = sc . nextLong ( ) ; long result = 0 ; long num = sc . nextLong ( ) ; for ( int i = 1 ; i < rqhmv ; i ++ ) { long a = sc . nextInt ( ) ; if ( a >= num ) { num = a ; } else { result = result + num - a ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class Dbddmkv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dbddmkv = scan . nextInt ( ) ; boolean f = false ; for ( int i = 0 ; i < dbddmkv ; i ++ ) { for ( int j = 0 ; j < dbddmkv ; j ++ ) { if ( ( 4 * i ) + ( 7 * j ) == dbddmkv ) { f = true ; System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } } import java . io . * ; import java . util . * ; public class Cghbhne { static PrintWriter out = new PrintWriter ( ( System . out ) ) ; public static void main ( String [ ] args ) throws IOException { Kioken sc = new Kioken ( ) ; char cghbhne = sc . next ( ) . charAt ( 0 ) ; if ( Character . isUpperCase ( cghbhne ) ) { out . println ( " A " ) ; } else { out . println ( " a " ) ; } out . close ( ) ; } public static void kamehameha ( ) { } static class Cghbhne { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; public String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return br . readLine ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ; } public boolean hasNext ( ) { String next = null ; try { next = br . readLine ( ) ; } catch ( Exception e ) { } if ( next == null ) { return false ; } st = new StringTokenizer ( next ) ; return true ; } } } import java . util . Scanner ; public class Vkhgs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vkhgs = sc . nextInt ( ) ; int [ ] color = new int [ 9 ] ; int ans = 0 ; for ( int i = 0 ; i < vkhgs ; i ++ ) { int a = sc . nextInt ( ) ; color [ Math . min ( a / 400 , 8 ) ] ++ ; } for ( int i = 0 ; i < 8 ; i ++ ) { if ( color [ i ] > 0 ) ans ++ ; } int ans2 = ans + color [ 8 ] ; if ( ans == 0 && color [ 8 ] > 0 ) ans = 1 ; System . out . printf ( " %d %d " , ans , ans2 ) ; sc . close ( ) ; } } import java . util . * ; public class Mvzecr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] a = sc . nextLine ( ) . split ( " " ) ; int mvzecr = a . length ; String answer = " " ; for ( int i = 0 ; i < mvzecr ; i ++ ) { if ( a [ i ] . equals ( " 0 " ) ) { answer += " 0 " ; } if ( a [ i ] . equals ( " 1 " ) ) { answer += " 1 " ; } if ( a [ i ] . equals ( " B " ) ) { if ( answer != null && answer . length ( ) > 0 ) { answer = answer . substring ( 0 , answer . length ( ) - 1 ) ; } } } System . out . println ( answer ) ; } } import java . util . * ; public class Dpccz { long dpccz = Long . MAX_VALUE ; long [ ] [ ] dp ; public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( N * A < B ? N * A : B ) ; } } import java . util . Scanner ; public class Ocyxmqr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; for ( int ocyxmqr = 1 ; ; ocyxmqr ++ ) { int x = sc . nextInt ( ) ; if ( x == 0 ) { break ; } System . out . printf ( " Case %d: %d \n " , ocyxmqr , x ) ; } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Durnon { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; C solver = new C ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Durnon { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int durnon = Integer . parseInt ( in . next ( ) ) ; int preT = 0 ; int preX = 0 ; int preY = 0 ; for ( int i = 0 ; i < durnon ; i ++ ) { int postT = Integer . parseInt ( in . next ( ) ) ; int postX = Integer . parseInt ( in . next ( ) ) ; int postY = Integer . parseInt ( in . next ( ) ) ; int dt = postT - preT ; int dist = Math . abs ( postX - preX ) + Math . abs ( postY - preY ) ; if ( ( dt < dist ) || ( ( ( dist - dt ) & 1 ) != 0 ) ) { out . println ( " No " ) ; return ; } preT = postT ; preX = postX ; preY = postY ; } out . println ( " Yes " ) ; } } } import java . util . Scanner ; class Okuvo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; StringBuilder output = new StringBuilder ( ) ; for ( int okuvo = 0 ; okuvo < input . length ( ) ; ++ okuvo ) { if ( input . charAt ( okuvo ) != 'B' ) { output . append ( input . charAt ( okuvo ) ) ; } else { int len = output . length ( ) ; if ( len > 0 ) { output . deleteCharAt ( len - 1 ) ; } } } sc . close ( ) ; System . out . println ( output ) ; } } import java . util . Scanner ; public class Hiyufh { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int hiyufh = in . nextInt ( ) ; int lim = in . nextInt ( ) ; int pos = 0 ; int ans = 0 ; for ( int i = 0 ; i < hiyufh ; i ++ ) { pos += in . nextInt ( ) ; if ( lim < pos ) { ans = i + 1 ; break ; } else if ( lim == pos ) { ans = i + 2 ; break ; } else if ( i == hiyufh - 1 ) { ans = hiyufh + 1 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Ypxyuz { public static void main ( String [ ] args ) { int ypxyuz = 0 ; Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; sc . close ( ) ; for ( int i = 0 ; i < x ; i ++ ) { ypxyuz += 2 ; if ( ( i + 1 ) == x ) { if ( ypxyuz == y ) { System . out . println ( " Yes " ) ; } else { for ( int j = i ; j >= 0 ; j -- ) { ypxyuz -= 2 ; ypxyuz += 4 ; if ( ypxyuz == y ) { System . out . println ( " Yes " ) ; break ; } if ( j == 0 ) { System . out . println ( " No " ) ; } } } } } } } import java . util . * ; public class Plhobdg { void solve ( ) { Scanner scan = new Scanner ( System . in ) ; int plhobdg = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int [ ] h = new int [ plhobdg ] ; for ( int i = 0 ; i < plhobdg ; i ++ ) h [ i ] = scan . nextInt ( ) ; int [ ] dp = new int [ plhobdg ] ; for ( int i = 0 ; i < plhobdg ; i ++ ) dp [ i ] = Integer . MAX_VALUE ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 0 ; i < plhobdg ; i ++ ) { for ( int j = 1 ; j <= k ; j ++ ) { if ( i - j >= 0 ) dp [ i ] = Math . min ( dp [ i ] , dp [ i - j ] + Math . abs ( h [ i - j ] - h [ i ] ) ) ; } } System . out . println ( dp [ plhobdg - 1 ] ) ; scan . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class Agfkys { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int agfkys = sc . nextInt ( ) ; int [ ] a1 = new int [ agfkys + 2 ] ; int [ ] a2 = new int [ agfkys + 1 ] ; a1 [ 0 ] = 0 ; a2 [ 0 ] = 0 ; int sum = 0 ; int subsum = 0 ; int sum1 = 0 ; int sum2 = 0 ; for ( int i = 1 ; i <= agfkys ; i ++ ) { a1 [ i ] = sc . nextInt ( ) ; } sum1 = a1 [ 1 ] ; a1 [ agfkys + 1 ] = 0 ; for ( int i = 1 ; i <= agfkys ; i ++ ) { a2 [ i ] = sc . nextInt ( ) ; sum2 += a2 [ i ] ; } for ( int i = 1 ; i <= agfkys ; i ++ ) { subsum = sum1 + sum2 ; if ( subsum > sum ) { sum = subsum ; } sum1 += a1 [ i + 1 ] ; sum2 -= a2 [ i ] ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Phbjlt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int phbjlt = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; long min = Long . MAX_VALUE ; for ( int i = 0 ; i <= 100000 ; i ++ ) { long amount = 0 ; amount = i * 2 * C + Math . max ( 0 , X - i ) * phbjlt + Math . max ( 0 , Y - i ) * B ; min = Math . min ( min , amount ) ; } System . out . println ( min ) ; } } import java . util . Scanner ; public class Luvpz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int luvpz = scanner . nextInt ( ) ; System . out . println ( 2 * luvpz * Math . PI ) ; } } import java . util . Scanner ; public class Jyxxchd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long jyxxchd = sc . nextLong ( ) ; System . out . println ( hit ( jyxxchd ) ) ; } private static long hit ( long jyxxchd ) { return jyxxchd == 1 ? 1 : hit ( jyxxchd / 2 ) * 2 + 1 ; } } import java . util . Scanner ; class Wqpdwjq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str1 = scan . next ( ) ; String str2 = scan . next ( ) ; int wqpdwjq = Integer . parseInt ( str1 ) ; int b = Integer . parseInt ( str2 ) ; System . out . println ( wqpdwjq * b + " " + ( wqpdwjq * 2 + b * 2 ) ) ; } } import java . util . * ; public class Rswpph { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rswpph = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; String [ ] nums = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { nums [ i ] = sc . next ( ) ; } sc . close ( ) ; for ( int count = 0 ; ; count ++ ) { if ( ! ( Arrays . asList ( nums ) . contains ( String . valueOf ( rswpph - count ) ) ) ) { System . out . println ( rswpph - count ) ; break ; } if ( ! ( Arrays . asList ( nums ) . contains ( String . valueOf ( rswpph + count ) ) ) ) { System . out . println ( rswpph + count ) ; break ; } } } } import java . util . Scanner ; public class Wazvau { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wazvau = sc . nextInt ( ) ; int c = 0 ; while ( wazvau > c ) { c = c + 1000 ; } c = c - wazvau ; System . out . println ( c ) ; } } import java . util . Scanner ; public class Wygmnyp { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int wygmnyp = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( k <= wygmnyp ) { System . out . println ( k ) ; return ; } if ( k <= wygmnyp + b ) { System . out . println ( wygmnyp ) ; return ; } System . out . println ( wygmnyp - ( k - wygmnyp - b ) ) ; } } import java . util . Scanner ; public class Yeukx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] lines = line . split ( " " ) ; int yeukx = Integer . parseInt ( lines [ 0 ] ) ; int B = Integer . parseInt ( lines [ 1 ] ) ; System . out . println ( yeukx * B ) ; } } import java . util . Arrays ; import java . util . Scanner ; class Ughjh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ughjh = sc . nextInt ( ) ; int [ ] a = new int [ ughjh ] ; for ( int i = 0 ; i < ughjh ; i ++ ) a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; int ans = a [ ughjh / 2 ] - a [ ughjh / 2 - 1 ] ; System . out . println ( ans ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Mxajgv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mxajgv = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; if ( mxajgv <= m ) { System . out . println ( " unsafe " ) ; } else { System . out . println ( " safe " ) ; } } } import java . util . Scanner ; public class Bnguvb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] list = sc . next ( ) . toCharArray ( ) ; boolean bnguvb = false ; int max = 0 ; int tmp = 0 ; for ( int i = 0 ; i < list . length ; i ++ ) { if ( list [ i ] == 'A' || list [ i ] == 'T' || list [ i ] == 'C' || list [ i ] == 'G' ) { if ( ! bnguvb ) { bnguvb = true ; tmp = 0 ; } tmp ++ ; } else { if ( bnguvb ) { bnguvb = false ; max = Math . max ( max , tmp ) ; } } } System . out . println ( Math . max ( max , tmp ) ) ; } } import java . util . * ; import java . io . * ; class Yregeg { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String [ ] input = br . readLine ( ) . split ( " " ) ; int yregeg = Integer . parseInt ( input [ 0 ] ) ; int M = Integer . parseInt ( input [ 1 ] ) ; int result = 0 ; if ( yregeg > 1 ) { result += ( yregeg * ( yregeg - 1 ) ) / 2 ; } if ( M > 1 ) { result += ( M * ( M - 1 ) ) / 2 ; } System . out . println ( result ) ; } } } import java . util . Scanner ; public class Eaiucvd { public static void main ( String [ ] args ) { Scanner nine = new Scanner ( System . in ) ; int eaiucvd = nine . nextInt ( ) ; int number2 = nine . nextInt ( ) ; if ( 1 <= eaiucvd && eaiucvd <= 9 && 1 <= number2 && number2 <= 9 ) { int answer = eaiucvd * number2 ; System . out . println ( answer ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . * ; public class Amomqyw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long amomqyw = sc . nextLong ( ) ; long num = 2 ; while ( num <= amomqyw ) num *= 2 ; System . out . println ( num - 1 ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Tiqewn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tiqewn = sc . nextInt ( ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < tiqewn ; i ++ ) { a . add ( sc . nextInt ( ) ) ; } sc . close ( ) ; long cnt = 0 ; int flg = 1 ; if ( a . indexOf ( 1 ) == - 1 ) { System . out . println ( - 1 ) ; return ; } else { cnt += a . indexOf ( 1 ) ; for ( int i = a . indexOf ( 1 ) ; i < tiqewn - 1 ; i ++ ) { if ( a . get ( i + 1 ) == flg + 1 ) { flg ++ ; } else { cnt ++ ; } } } System . out . println ( cnt ) ; } } import java . util . * ; public class Rcxpbb { public static void main ( String [ ] args ) throws java . io . IOException { int rcxpbb , h , m , s ; Scanner in = new Scanner ( System . in ) ; rcxpbb = in . nextInt ( ) ; h = rcxpbb / 3600 ; rcxpbb = rcxpbb % 3600 ; m = rcxpbb / 60 ; s = rcxpbb % 60 ; System . out . println ( h + " : " + m + " : " + s ) ; } } import java . lang . reflect . Array ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Sqxbe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int sqxbe = scan . nextInt ( ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; List < Integer > totalList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i <= sqxbe ; i ++ ) { int sum = gettotal ( i ) ; if ( a <= sum && b >= sum ) { totalList . add ( i ) ; } } int res = 0 ; for ( int i = 0 ; i < totalList . size ( ) ; i ++ ) { res = res + totalList . get ( i ) ; } System . out . print ( res ) ; } private static int gettotal ( int i ) { int sum = 0 ; while ( i != 0 ) { sum += i % 10 ; i /= 10 ; } return sum ; } } import java . util . * ; public class Otlheh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long otlheh = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( k <= otlheh ) { otlheh = otlheh - k ; k = 0 ; } else { k = k - otlheh ; otlheh = 0 ; } if ( k <= b ) { b = b - k ; k = 0 ; } else { k = k - b ; b = 0 ; } System . out . println ( otlheh + " " + b ) ; } } import java . util . Scanner ; public class Qemxnf { public static void main ( String [ ] args ) { int qemxnf , n , q , tail , head , hz , notime = 0 ; String hzn ; Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; q = sc . nextInt ( ) ; tail = n ; head = 0 ; String [ ] name = new String [ n + 1 ] ; int [ ] time = new int [ n + 1 ] ; for ( qemxnf = 0 ; qemxnf < n ; qemxnf ++ ) { name [ qemxnf ] = sc . next ( ) ; time [ qemxnf ] = sc . nextInt ( ) ; } while ( true ) { if ( tail == head ) break ; if ( q <= time [ head ] ) { hz = time [ head ] - q ; notime += q ; } else { hz = 0 ; notime += time [ head ] ; } hzn = name [ head ] ; if ( head + 1 == n + 1 ) { head = 0 ; } else { head ++ ; } if ( hz == 0 ) { System . out . println ( hzn + " " + notime ) ; continue ; } time [ tail ] = hz ; name [ tail ] = hzn ; if ( tail + 1 == n + 1 ) { tail = 0 ; } else { tail ++ ; } } } } import java . util . Scanner ; class Snwmdg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int snwmdg = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int [ ] [ ] table = new int [ snwmdg + 1 ] [ y + 1 ] ; for ( int i = 0 ; i < snwmdg ; i ++ ) { for ( int j = 0 ; j < y ; j ++ ) { table [ i ] [ j ] = sc . nextInt ( ) ; table [ i ] [ y ] += table [ i ] [ j ] ; table [ snwmdg ] [ j ] += table [ i ] [ j ] ; table [ snwmdg ] [ y ] += table [ i ] [ j ] ; } } for ( int i = 0 ; i < snwmdg + 1 ; i ++ ) { for ( int j = 0 ; j < y + 1 ; j ++ ) { System . out . print ( table [ i ] [ j ] ) ; if ( j != y ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } } import java . io . * ; import java . util . * ; import java . math . * ; import java . util . regex . Pattern ; class Inmyge { public static void main ( String [ ] args ) { int inmyge , b , i , small , sum = 0 ; String s = " " ; Scanner sc = new Scanner ( System . in ) ; inmyge = sc . nextInt ( ) ; b = sc . nextInt ( ) ; if ( inmyge < b ) { small = inmyge ; for ( i = b - 1 ; i >= 0 ; i -- ) { sum = sum + ( int ) Math . pow ( 10 , i ) ; } small = inmyge * sum ; s = " " + small ; } else { small = b ; for ( i = inmyge - 1 ; i >= 0 ; i -- ) { sum = sum + ( int ) Math . pow ( 10 , i ) ; } small = b * sum ; s = " " + small ; } System . out . println ( s ) ; } } import java . util . Scanner ; public class Qkhry { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; long qkhry = scn . nextInt ( ) ; System . out . println ( ( long ) ( qkhry + Math . pow ( qkhry , 2 ) + Math . pow ( qkhry , 3 ) ) ) ; } } import java . util . Scanner ; public class Wnqua { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wnqua = sc . nextInt ( ) ; int [ ] A = new int [ wnqua ] ; for ( int i = 0 ; i < wnqua ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < wnqua ; i ++ ) { int minj = i ; for ( int j = i ; j < wnqua ; j ++ ) { if ( A [ j ] < A [ minj ] ) { minj = j ; } } if ( i != minj ) { count ++ ; } int x = A [ i ] ; A [ i ] = A [ minj ] ; A [ minj ] = x ; } for ( int i = 0 ; i < wnqua - 1 ; i ++ ) { System . out . print ( A [ i ] + " " ) ; } System . out . println ( A [ wnqua - 1 ] ) ; System . out . print ( count ) ; System . out . printf ( " \n " ) ; } } import java . io . * ; import java . util . StringTokenizer ; public class Aaydrac { public static void main ( String [ ] args ) throws Exception { StringTokenizer st ; BufferedReader read = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter prnt = new PrintWriter ( System . out ) ; String aaydrac = read . readLine ( ) ; if ( aaydrac . charAt ( 0 ) == '7' ) { prnt . println ( " Yes " ) ; } else if ( aaydrac . charAt ( 1 ) == '7' ) { prnt . println ( " Yes " ) ; } else if ( aaydrac . charAt ( 2 ) == '7' ) { prnt . println ( " Yes " ) ; } else { prnt . println ( " No " ) ; } prnt . close ( ) ; } } import java . util . * ; public class Pexsmok { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long pexsmok = sc . nextLong ( ) ; long ans = 100 ; long sum = 0 ; while ( ans < pexsmok ) { ans = ans + ( long ) ( ans / 100 ) ; sum ++ ; } System . out . println ( sum ) ; } } import java . util . * ; public class Ggcqshv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ggcqshv = sc . nextInt ( ) ; sc . close ( ) ; int sum = 0 ; int count = 0 ; while ( sum <= ggcqshv ) { count ++ ; sum = ( int ) Math . pow ( 2 , count ) ; } System . out . println ( ( int ) Math . pow ( 2 , count - 1 ) ) ; } } import java . util . * ; class Ncnalc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ncnalc = sc . nextInt ( ) ; int count = 1 ; int Answer = 0 ; for ( int i = 0 ; i < ncnalc ; i ++ ) { if ( sc . nextInt ( ) == count ) { count ++ ; } else { Answer ++ ; } } if ( Answer == ncnalc ) { Answer = - 1 ; } System . out . println ( Answer ) ; } } import java . util . Scanner ; class Tsxmkky { public static void main ( String [ ] ag ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; int tsxmkky = 0 ; int gl = a . length ( ) - 1 ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) == 'A' ) { tsxmkky = i + 1 ; break ; } } for ( int i = a . length ( ) - 1 ; i >= 0 ; i -- ) { if ( a . charAt ( i ) == 'Z' ) { gl = i + 1 ; break ; } } System . out . println ( gl - tsxmkky + 1 ) ; } } import java . util . Scanner ; public class Esqak { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String inputId = sc . nextLine ( ) ; String inputAddId = sc . nextLine ( ) ; int esqak = 0 ; for ( int i = 0 ; i < inputId . length ( ) ; i ++ ) { if ( inputId . charAt ( i ) != inputAddId . charAt ( i ) ) { esqak ++ ; } } if ( esqak == 0 && ( inputAddId . length ( ) - inputId . length ( ) == 1 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Clgzw { public static void main ( String [ ] args ) { final Scanner cin = new Scanner ( System . in ) ; int clgzw = cin . nextInt ( ) ; long [ ] arr = new long [ clgzw ] ; for ( int i = 0 ; i < clgzw ; i ++ ) { arr [ i ] = cin . nextLong ( ) ; } Arrays . parallelSort ( arr ) ; if ( arr [ 0 ] == 0 ) { System . out . print ( 0 ) ; return ; } long mul = 1L ; for ( long a : arr ) { if ( mul * 1.0 * a > ( long ) 1e18 ) { System . out . print ( - 1 ) ; System . exit ( 0 ) ; } mul = mul * a ; } System . out . print ( mul > ( long ) 1e18 ? - 1 : mul ) ; } } import java . util . * ; public class Oyunf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oyunf = sc . nextInt ( ) ; int [ ] arr = new int [ oyunf ] ; for ( int i = 0 ; i < oyunf ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int [ ] dp = new int [ oyunf ] ; if ( oyunf == 1 ) System . out . println ( arr [ 0 ] ) ; for ( int i = 1 ; i < oyunf ; i ++ ) { int abs1 = Math . abs ( arr [ i ] - arr [ i - 1 ] ) ; if ( i == 1 ) { int abs = abs1 ; dp [ i ] = abs ; } else { dp [ i ] = Math . min ( abs1 + dp [ i - 1 ] , Math . abs ( arr [ i ] - arr [ i - 2 ] ) + dp [ i - 2 ] ) ; } } System . out . println ( dp [ oyunf - 1 ] ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class Fgjgon { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int fgjgon = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int ans = 1 ; int D = 0 ; for ( int i = 0 ; i < fgjgon ; i ++ ) { D += sc . nextInt ( ) ; if ( D <= X ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Mnycg { public static void main ( String [ ] args ) throws Exception { String [ ] lines = getStdin ( ) ; String str1 = lines [ 0 ] ; int mnycg = Integer . parseInt ( str1 ) ; String str2 = lines [ 1 ] ; String [ ] str21 = str2 . split ( " " ) ; int from = Integer . parseInt ( str21 [ 0 ] ) ; int till = Integer . parseInt ( str21 [ 1 ] ) ; for ( int i = 1 ; i <= 1000 ; i ++ ) { int multiple = mnycg * i ; if ( multiple >= from && multiple <= till ) { System . out . println ( " OK " ) ; return ; } else { multiple = mnycg ; } } System . out . println ( " NG " ) ; } private static String [ ] getStdin ( ) { Scanner scanner = new Scanner ( System . in ) ; ArrayList < String > lines = new ArrayList < > ( ) ; while ( scanner . hasNext ( ) ) { lines . add ( scanner . nextLine ( ) ) ; } return lines . toArray ( new String [ lines . size ( ) ] ) ; } } import java . util . * ; import static java . lang . Math . * ; import java . math . BigInteger ; public class Zuxsm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zuxsm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int result = 0 ; for ( int i = zuxsm ; i < b + 1 ; i ++ ) { String s = String . valueOf ( i ) ; boolean chk = true ; for ( int j = 0 ; j < s . length ( ) / 2 ; j ++ ) { if ( s . charAt ( j ) != s . charAt ( s . length ( ) - j - 1 ) ) { chk = false ; break ; } } if ( chk ) result ++ ; } System . out . println ( result ) ; } } import java . util . Scanner ; public class Mrucs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mrucs = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double ans = 0 ; int times = 0 ; for ( int i = mrucs ; i > 0 ; -- i ) { while ( i * Math . pow ( 2 , times ) < k ) ++ times ; ans = ans + ( 1 / ( double ) mrucs ) * Math . pow ( 0.5 , times ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class Axkmaj { public static void main ( String [ ] arg ) { Scanner scan = new Scanner ( System . in ) ; int axkmaj = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int K = 0 ; int check = 0 ; if ( ( axkmaj + B ) % 2 == 0 ) { K = ( Math . abs ( axkmaj ) + Math . abs ( B ) ) / 2 ; check ++ ; } if ( check == 0 ) { System . out . println ( " IMPOSSIBLE " ) ; } else { System . out . println ( K ) ; } } } import java . io . * ; public class Xocfpu { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; int xocfpu = Integer . parseInt ( line ) ; int sec = 0 , min = 0 , hour = 0 ; if ( xocfpu >= 3600 ) { hour = xocfpu / 3600 ; xocfpu = xocfpu % 3600 ; min = xocfpu / 60 ; sec = xocfpu % 60 ; System . out . println ( hour + " : " + min + " : " + sec ) ; } else if ( xocfpu >= 60 ) { min = xocfpu / 60 ; sec = xocfpu % 60 ; System . out . println ( hour + " : " + min + " : " + sec ) ; } else { System . out . println ( hour + " : " + min + " : " + sec ) ; } } } import java . util . Scanner ; public class Soaohsd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int soaohsd = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; for ( int turtle = 0 ; turtle <= soaohsd ; ++ turtle ) { int crane = soaohsd - turtle ; int feet = 4 * turtle + 2 * crane ; if ( feet == y ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . HashMap ; import java . util . HashSet ; import java . util . Map ; import java . util . Scanner ; import java . util . Set ; import java . util . TreeSet ; public class Jiizq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jiizq = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; String [ ] s = new String [ jiizq ] ; for ( int i = 0 ; i < jiizq ; i ++ ) { s [ i ] = sc . next ( ) ; set . add ( s [ i ] ) ; map . put ( s [ i ] , 0 ) ; } for ( int i = 0 ; i < jiizq ; i ++ ) { int v = map . get ( s [ i ] ) ; map . put ( s [ i ] , ++ v ) ; } int max = 1 ; for ( String key : map . keySet ( ) ) { if ( map . get ( key ) > max ) { max = map . get ( key ) ; } } Set < String > tSet = new TreeSet < > ( ) ; for ( String key : map . keySet ( ) ) { if ( map . get ( key ) == max ) { tSet . add ( key ) ; } } StringBuilder sb = new StringBuilder ( ) ; for ( String string : tSet ) { sb . append ( string ) ; sb . append ( '\n' ) ; } System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; import java . io . * ; class Uitdp { int uitdp , B , len ; String S ; char [ ] cS ; boolean flg ; public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . input ( ) ; m . solve ( ) ; m . out ( ) ; } public void input ( ) { Scanner sc = new Scanner ( System . in ) ; uitdp = sc . nextInt ( ) ; B = sc . nextInt ( ) ; S = sc . next ( ) ; cS = S . toCharArray ( ) ; len = cS . length ; } public void solve ( ) { if ( len == uitdp + B + 1 ) { if ( cS [ uitdp ] == '-' ) { for ( int i = 0 ; i < uitdp ; i ++ ) { if ( cS [ i ] >= '0' && cS [ i ] <= '9' ) { flg = true ; } else { flg = false ; break ; } } if ( flg == true ) { for ( int i = uitdp + 1 ; i < len ; i ++ ) { if ( cS [ i ] >= '0' && cS [ i ] <= '9' ) { flg = true ; } else { flg = false ; break ; } } } } else { flg = false ; } } else { flg = false ; } } public void out ( ) { if ( flg == true ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Fnqeyw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fnqeyw = sc . nextInt ( ) ; int a = 1 ; for ( int i = 2 ; i <= 32 ; i ++ ) { for ( int j = 2 ; j <= 10 ; j ++ ) { double b = Math . pow ( i , j ) ; if ( b <= fnqeyw ) { if ( fnqeyw - a >= fnqeyw - b ) { a = ( int ) b ; } } else { break ; } } } if ( fnqeyw < 4 ) { System . out . println ( fnqeyw ) ; } else { System . out . println ( a ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Vjjctoe { public static void main ( String [ ] arges ) { Scanner sc = new Scanner ( System . in ) ; List < String > k = new ArrayList < String > ( ) ; while ( true ) { String line = sc . nextLine ( ) ; k . add ( line ) ; if ( line . equals ( " 0 " ) ) { break ; } } for ( String string : k ) { if ( string . equals ( " 0 " ) ) { break ; } String [ ] lig = new String [ string . length ( ) ] ; for ( int vjjctoe = 0 ; vjjctoe < string . length ( ) ; vjjctoe ++ ) { lig [ vjjctoe ] = string . substring ( vjjctoe , vjjctoe + 1 ) ; } int sum = 0 ; int [ ] v = new int [ lig . length ] ; for ( int vjjctoe = 0 ; vjjctoe < lig . length ; vjjctoe ++ ) { v [ vjjctoe ] = Integer . parseInt ( lig [ vjjctoe ] ) ; sum += v [ vjjctoe ] ; } System . out . println ( sum ) ; } } } import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Imilu { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int imilu = Integer . parseInt ( st . nextToken ( ) ) ; int K = Integer . parseInt ( st . nextToken ( ) ) ; int [ ] prices = new int [ imilu ] ; st = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < prices . length ; i ++ ) prices [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; Arrays . sort ( prices ) ; int sum = 0 ; for ( int i = 0 ; i < K ; i ++ ) sum += prices [ i ] ; bw . write ( sum + " \n " ) ; bw . flush ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . HashSet ; import java . util . Set ; public class Tgnqc { public static void main ( String [ ] args ) { Set < Integer > set = new HashSet ( ) ; int tgnqc = getInput ( ) ; do { set . add ( tgnqc ) ; tgnqc = f ( tgnqc ) ; } while ( ! set . contains ( tgnqc ) ) ; System . out . println ( set . size ( ) + 1 ) ; return ; } private static int f ( int n ) { if ( n % 2 == 0 ) { return n / 2 ; } else { return 3 * n + 1 ; } } private static int getInput ( ) { int ret = 0 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { ret = Integer . parseInt ( br . readLine ( ) . trim ( ) ) ; } catch ( IOException e ) { System . err . println ( e . getMessage ( ) ) ; } return ret ; } } import java . util . Scanner ; public class Nkxlynk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nkxlynk = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int point = 0 ; int res = 1 ; for ( int i = 0 ; i < nkxlynk ; i ++ ) { point += Integer . parseInt ( sc . next ( ) ) ; if ( x < point ) break ; res ++ ; } System . out . println ( res ) ; } } import java . io . * ; public class Ozcgy { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int ozcgy = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 1 ] ) ; int d = ozcgy / b ; int e = ozcgy % b ; double f = ( double ) ozcgy / b ; System . out . printf ( " %d %d %.5f \n " , d , e , f ) ; } } import java . util . Scanner ; import java . lang . * ; public class Leykhlm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String input = scanner . nextLine ( ) ; String [ ] inputs = input . split ( " " ) ; int leykhlm = Integer . parseInt ( inputs [ 0 ] ) ; int Q = Integer . parseInt ( inputs [ 1 ] ) ; int R = Integer . parseInt ( inputs [ 2 ] ) ; int min1 = Math . min ( leykhlm , Q ) ; int max1 = Math . max ( leykhlm , Q ) ; if ( max1 <= R ) { System . out . println ( min1 + max1 ) ; } else { System . out . println ( min1 + R ) ; } scanner . close ( ) ; } } import java . util . HashMap ; import java . util . Scanner ; public class Vymdhkk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Result result = execute ( sc . nextLine ( ) ) ; System . out . println ( result ) ; } public static Result execute ( String str ) { if ( ! isPalindrone ( str ) ) { return Result . No ; } int vymdhkk = str . vymdhkk ( ) ; String firstHalf = str . substring ( 0 , ( vymdhkk - 1 ) / 2 ) ; if ( ! isPalindrone ( firstHalf ) ) { return Result . No ; } String lastHalf = str . substring ( ( vymdhkk + 1 ) / 2 ) ; if ( ! isPalindrone ( lastHalf ) ) { return Result . No ; } return Result . Yes ; } private static boolean isPalindrone ( String str ) { int vymdhkk = str . vymdhkk ( ) ; if ( vymdhkk == 1 ) { return true ; } for ( int i = 0 ; i < ( vymdhkk + 1 ) / 2 ; i ++ ) { if ( str . charAt ( i ) != str . charAt ( vymdhkk - i - 1 ) ) { return false ; } } return true ; } public static enum Result { Yes , No } } import java . util . Scanner ; public class Ywphd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ywphd = sc . nextInt ( ) ; int [ ] A = new int [ ywphd + 1 ] ; int [ ] B = new int [ ywphd ] ; long jizenSum = 0 ; for ( int i = 0 ; i < ywphd + 1 ; i ++ ) { A [ i ] = sc . nextInt ( ) ; jizenSum += A [ i ] ; } for ( int i = 0 ; i < ywphd ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } int tmp = 0 ; for ( int i = 0 ; i < ywphd ; i ++ ) { tmp = A [ i ] - B [ i ] ; if ( tmp < 0 ) { if ( B [ i ] - A [ i ] > A [ i + 1 ] ) { A [ i + 1 ] = 0 ; } else { A [ i + 1 ] = A [ i + 1 ] - ( B [ i ] - A [ i ] ) ; } A [ i ] = 0 ; } else { A [ i ] = tmp ; } } long sum = 0 ; for ( int i = 0 ; i < ywphd + 1 ; i ++ ) { sum += A [ i ] ; } System . out . println ( jizenSum - sum ) ; } } import java . util . Scanner ; public class Vvsjho { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int vvsjho = scanner . nextInt ( ) ; int hissatsuwazashurui = scanner . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < hissatsuwazashurui ; i ++ ) { sum += scanner . nextInt ( ) ; } if ( vvsjho > sum ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; class Tsqxb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String strs = sc . next ( ) ; String strp = sc . next ( ) ; int tsqxb = strs . length ( ) ; int psum = strp . length ( ) ; for ( int p = 0 ; p < tsqxb ; p ++ ) { String str1 = " " ; String str2 = " " ; String str3 = " " ; for ( int q = p ; q < tsqxb ; q ++ ) { char c1 = strs . charAt ( q ) ; str1 += c1 ; } for ( int r = 0 ; r < p ; r ++ ) { char c2 = strs . charAt ( r ) ; str2 += c2 ; } for ( int s = 0 ; s < psum ; s ++ ) { char c3 = ( str1 + str2 ) . charAt ( s ) ; str3 += c3 ; } if ( str3 . equals ( strp ) ) { System . out . println ( " Yes " ) ; break ; } else if ( p == tsqxb - 1 ) { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class Yrthhp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String yrthhp = sc . nextLine ( ) ; yrthhp = yrthhp . replace ( " eraser " , " " ) . replace ( " erase " , " " ) . replace ( " dreamer " , " " ) . replace ( " dream " , " " ) ; if ( yrthhp . equals ( " " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; class Oaznerr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oaznerr = sc . nextInt ( ) ; int [ ] [ ] [ ] bill = new int [ 4 ] [ 3 ] [ 10 ] ; int b ; int f ; int r ; int v = 0 ; for ( int i = 0 ; i < oaznerr ; i ++ ) { b = sc . nextInt ( ) ; f = sc . nextInt ( ) ; r = sc . nextInt ( ) ; v = sc . nextInt ( ) ; bill [ b - 1 ] [ f - 1 ] [ r - 1 ] = bill [ b - 1 ] [ f - 1 ] [ r - 1 ] + ( v ) ; } for ( int j = 0 ; j < 4 ; j ++ ) { for ( int k = 0 ; k < 3 ; k ++ ) { for ( int l = 0 ; l < 10 ; l ++ ) { System . out . print ( " " + bill [ j ] [ k ] [ l ] ) ; } System . out . println ( ) ; } if ( j != 3 ) { System . out . println ( " #################### " ) ; } } } } import java . util . * ; public class Ngiohfc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ngiohfc = sc . nextLong ( ) ; long ans = Long . MAX_VALUE ; long j = 0 ; for ( long i = 1 ; i * i <= ngiohfc ; i ++ ) { if ( ngiohfc % i != 0 ) { continue ; } j = ngiohfc / i ; ans = Math . min ( ans , i + j - 2 ) ; } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ktyciyf { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String info = br . readLine ( ) ; String [ ] fight = info . split ( " " ) ; int ktyciyf = ( int ) Math . ceil ( ( Double . parseDouble ( fight [ 0 ] ) / Double . parseDouble ( fight [ 1 ] ) ) ) ; System . out . println ( ktyciyf ) ; } } import java . util . Scanner ; public class Azvbd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int azvbd = sc . nextInt ( ) ; sc . nextLine ( ) ; String str = sc . nextLine ( ) ; if ( str . length ( ) <= azvbd ) { System . out . println ( str ) ; return ; } String str2 = str . substring ( 0 , azvbd ) + " ... " ; System . out . println ( str2 ) ; } } import java . util . * ; import java . util . Arrays ; public class Wsyhnrv { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; int wsyhnrv = scanner . nextInt ( ) ; int S = scanner . nextInt ( ) ; int sub = 0 ; int count = 0 ; for ( int i = 0 ; i <= wsyhnrv ; i ++ ) { if ( i != S ) { for ( int j = 0 ; j <= wsyhnrv ; j ++ ) { if ( i + j != S ) { sub = S - ( i + j ) ; if ( sub >= 0 && sub <= wsyhnrv ) { count ++ ; } } else if ( i + j == S ) { count ++ ; break ; } } } else if ( i == S ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Rovseb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rovseb = 0 ; String str1 = sc . nextLine ( ) ; String str2 = sc . nextLine ( ) ; String [ ] strArray1 = str1 . split ( " " ) ; String [ ] strArray2 = str2 . split ( " " ) ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { if ( ! strArray1 [ i ] . equals ( strArray2 [ i ] ) ) { rovseb ++ ; } } System . out . println ( rovseb ) ; } } import java . util . * ; class Dzisjn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dzisjn = sc . nextInt ( ) ; Integer [ ] num = new Integer [ dzisjn ] ; int alice = 0 ; int bob = 0 ; for ( int i = 0 ; i < dzisjn ; i ++ ) { num [ i ] = sc . nextInt ( ) ; } Arrays . sort ( num ) ; for ( int i = dzisjn - 1 ; i != - 1 ; i -- ) { if ( i % 2 == 0 ) { alice += num [ i ] ; } else { bob += num [ i ] ; } } System . out . println ( Math . abs ( alice - bob ) ) ; } } import java . util . Scanner ; class Nbkdgwi { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int nbkdgwi = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] [ ] h = new int [ nbkdgwi + 1 ] [ c + 1 ] ; StringBuilder sb1 = new StringBuilder ( ) ; StringBuilder sb2 = new StringBuilder ( ) ; String b = " " , n = " \n " ; for ( int i = 0 ; i < nbkdgwi ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { h [ i ] [ j ] = sc . nextInt ( ) ; h [ i ] [ c ] += h [ i ] [ j ] ; h [ nbkdgwi ] [ j ] += h [ i ] [ j ] ; h [ nbkdgwi ] [ c ] += h [ i ] [ j ] ; sb1 . append ( h [ i ] [ j ] + b ) ; if ( i == nbkdgwi - 1 ) sb2 . append ( h [ nbkdgwi ] [ j ] + b ) ; } sb1 . append ( h [ i ] [ c ] + n ) ; } sb2 . append ( h [ nbkdgwi ] [ c ] ) ; System . out . print ( sb1 ) ; System . out . println ( sb2 ) ; } } import static java . lang . Integer . parseInt ; public class Okfbd { public static void main ( String [ ] args ) { String okfbd = new java . util . Scanner ( System . in ) . nextLine ( ) ; String [ ] number = okfbd . split ( " " , 0 ) ; String answer = Compare ( parseInt ( number [ 0 ] ) , parseInt ( number [ 1 ] ) ) ; System . out . println ( answer ) ; } public static String Compare ( int x , int y ) { if ( x < y ) { return " a < b " ; } if ( x > y ) { return " a > b " ; } if ( x == y ) { return " a == b " ; } return null ; } } import java . util . * ; public class Yzlbazh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Set < String > set = new HashSet < > ( ) ; set . add ( scanner . next ( ) ) ; set . add ( scanner . next ( ) ) ; set . add ( scanner . next ( ) ) ; System . out . println ( set . size ( ) == 2 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Fmsmwn { String s ; public Main ( String str ) { s = str ; } public int searchA ( ) { return s . indexOf ( " A " ) ; } public int searchZ ( ) { return s . lastIndexOf ( " Z " ) + 1 ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . nextLine ( ) ; Main m = new Main ( str ) ; int fmsmwn = m . searchA ( ) ; int end = m . searchZ ( ) ; System . out . println ( end - fmsmwn ) ; } } import java . util . Scanner ; public class Inelwlg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . nextLine ( ) ; String [ ] strAry = str . split ( " " ) ; int inelwlg = Integer . parseInt ( strAry [ 0 ] ) ; int int2 = Integer . valueOf ( strAry [ 1 ] ) . intValue ( ) ; int i = 0 ; boolean b = true ; while ( b ) { if ( inelwlg < Math . pow ( int2 , i ) ) { System . out . println ( i ) ; b = false ; } i ++ ; scan . close ( ) ; } } } import java . util . * ; public class Rbabi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rbabi = getInputInteger ( sc ) ; int b = getInputInteger ( sc ) ; if ( rbabi % 2 == 0 || b % 2 == 0 ) { output ( " Even " ) ; } else { output ( " Odd " ) ; } } public static String getInputString ( Scanner sc ) { return sc . next ( ) ; } public static int getInputInteger ( Scanner sc ) { return Integer . parseInt ( sc . next ( ) ) ; } public static void output ( String ... params ) { boolean isInit = true ; String str = " " ; for ( String s : params ) { if ( ! isInit ) { str += " " ; } str += s ; isInit = false ; } System . out . println ( str ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Lhycbh { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; abc134_b solver = new abc134_b ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Lhycbh { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int lhycbh = in . nextInt ( ) ; int D = in . nextInt ( ) ; int mans = ( int ) Math . ceil ( lhycbh / ( ( D * 2 ) + 1 ) ) ; if ( lhycbh % ( ( D * 2 ) + 1 ) != 0 ) { mans ++ ; } out . println ( mans ) ; } } } import java . util . * ; public class Aldvhm { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int aldvhm = sc . nextInt ( ) ; String po = sc . next ( ) ; String po2 = po . substring ( 0 , aldvhm / 2 ) ; String po3 = po . substring ( aldvhm / 2 ) ; System . out . println ( ( po2 . equals ( po3 ) ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Dgucr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dgucr = sc . nextInt ( ) ; int [ ] array = new int [ dgucr ] ; for ( int i = 0 ; i < array . length ; i ++ ) array [ i ] = sc . nextInt ( ) ; int count = 0 ; int max = array [ 0 ] ; for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] >= max ) count ++ ; max = Math . max ( max , array [ i ] ) ; } System . out . println ( count ) ; } } import java . util . * ; public class Ljoupt { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] str = new String [ 2 ] ; int ljoupt = 0 ; while ( in . hasNext ( ) ) { String buf = in . nextLine ( ) ; str [ ljoupt ] = buf ; } String [ ] split = str [ 0 ] . split ( " " ) ; int [ ] facter ; facter = new int [ split . length ] ; for ( int i = 0 ; i < split . length ; i ++ ) { facter [ i ] = Integer . parseInt ( split [ i ] ) ; } if ( facter [ 0 ] < facter [ 1 ] ) { int temp = facter [ 0 ] ; facter [ 0 ] = facter [ 1 ] ; facter [ 1 ] = temp ; } int r = 0 ; int x = facter [ 0 ] ; int y = facter [ 1 ] ; while ( y > 0 ) { r = x % y ; x = y ; y = r ; } System . out . println ( x ) ; } } import java . util . Scanner ; public class Ucctt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ucctt = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { ucctt += sc . nextInt ( ) ; } if ( ucctt >= 22 ) { System . out . println ( " bust " ) ; return ; } System . out . println ( " win " ) ; } } import java . util . * ; class Tavxkku { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { StringBuilder str = new StringBuilder ( s . next ( ) . replaceAll ( " eraser " , " " ) . replaceAll ( " dream " , " D " ) . replaceAll ( " er " , " R " ) . replaceAll ( " as " , " A " ) ) ; String [ ] m = { " RAe " , " DR " , " D " } ; String b , st ; boolean tavxkku ; do { tavxkku = false ; for ( int i = 0 ; i < m . length ; i ++ ) { b = m [ i ] ; st = str . toString ( ) ; if ( st . endsWith ( b ) ) { str . delete ( str . length ( ) - b . length ( ) , str . length ( ) ) ; tavxkku = true ; break ; } } } while ( tavxkku ) ; System . out . println ( ( str . toString ( ) . equals ( " " ) ) ? " YES " : " NO " ) ; } } import java . util . * ; public class Ofhycdf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ofhycdf = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] A = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { A [ i ] = sc . nextInt ( ) ; ofhycdf -= A [ i ] ; } if ( ofhycdf <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Huypjk { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int huypjk = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int empty = huypjk - b ; if ( c - empty < 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( c - empty ) ; } } } import java . util . Scanner ; public class Hubyi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hubyi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String result = ( hubyi == b ) ? " a == b " : ( hubyi > b ) ? " a > b " : " a < b " ; System . out . println ( result ) ; } } import java . util . Scanner ; public class Qvasd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; Boolean bool = true ; for ( int qvasd = 0 ; qvasd < S . length ( ) ; qvasd ++ ) { if ( qvasd % 2 == 0 ) { if ( ! ( ( S . charAt ( qvasd ) == 'R' ) || ( S . charAt ( qvasd ) == 'U' ) || ( S . charAt ( qvasd ) == 'D' ) ) ) { bool = false ; } } if ( qvasd % 2 == 1 ) { if ( ! ( ( S . charAt ( qvasd ) == 'L' ) || ( S . charAt ( qvasd ) == 'U' ) || ( S . charAt ( qvasd ) == 'D' ) ) ) { bool = false ; } } } if ( bool == true ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } sc . close ( ) ; } } import java . util . * ; public class Whwfz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String whwfz = in . next ( ) ; if ( whwfz . compareTo ( " ABC " ) == 0 ) { System . out . println ( " ARC " ) ; } else { System . out . println ( " ABC " ) ; } } } import java . util . * ; public class Xzlssp { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int xzlssp = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int z ; int count = 0 ; for ( int x = 0 ; x <= xzlssp ; x ++ ) { for ( int y = 0 ; y <= xzlssp ; y ++ ) { z = s - x - y ; if ( 0 <= z && z <= xzlssp ) { count += 1 ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Buvaqy { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scanner = new Scanner ( System . in ) ; int buvaqy = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; System . out . println ( buvaqy * b ) ; } } import java . util . Scanner ; public class Szzfzxg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int szzfzxg = scan . nextInt ( ) , b = scan . nextInt ( ) , c = scan . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= c ; i ++ ) { if ( szzfzxg <= i && i <= b ) { if ( c % i == 0 ) { count ++ ; } } } System . out . println ( count ) ; } } 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 Nahzf { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastReader in = new FastReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ASheepAndWolves solver = new ASheepAndWolves ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Nahzf { public void solve ( int testNumber , FastReader in , PrintWriter out ) { out . println ( in . nextInt ( ) > in . nextInt ( ) ? " safe " : " unsafe " ) ; } } static class Nahzf { BufferedReader br ; StringTokenizer st ; public FastReader ( InputStream inputStream ) { br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } import java . util . Scanner ; public class Zawro { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zawro = sc . nextInt ( ) ; int [ ] H = new int [ zawro ] ; int [ ] Hmax = new int [ zawro ] ; for ( int i = 0 ; i < zawro ; i ++ ) { H [ i ] = sc . nextInt ( ) ; if ( i >= 1 ) { Hmax [ i ] = Math . max ( H [ i ] , Hmax [ i - 1 ] ) ; } else { Hmax [ i ] = H [ i ] ; } } int sum = 0 ; for ( int i = 0 ; i < zawro ; i ++ ) { if ( H [ i ] >= Hmax [ i ] ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; class Ixvhoq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ixvhoq = scan . nextInt ( ) ; int [ ] r = new int [ ixvhoq ] ; int ans ; for ( int i = 0 ; i < ixvhoq ; i ++ ) { r [ i ] = scan . nextInt ( ) ; } int maxv = r [ 1 ] - r [ 0 ] ; int minv = r [ 0 ] ; for ( int i = 1 ; i < ixvhoq ; i ++ ) { maxv = Math . max ( maxv , r [ i ] - minv ) ; minv = Math . min ( minv , r [ i ] ) ; } System . out . println ( maxv ) ; } } import java . util . Scanner ; public class Xyrln { public static void main ( String [ ] args ) { int xyrln , y , z , a , b , c ; Scanner sc = new Scanner ( System . in ) ; a = 0 ; xyrln = sc . nextInt ( ) ; y = sc . nextInt ( ) ; y = y / 1000 ; if ( y < xyrln ) { System . out . println ( " -1 -1 -1 " ) ; } else if ( y == xyrln ) { System . out . println ( " 0 0 " + y ) ; } else { z = y - xyrln ; while ( z % 9 != 0 ) { z = z - 4 ; a ++ ; } b = z / 9 ; c = xyrln - a - b ; if ( a < 0 || b < 0 || c < 0 ) { System . out . println ( " -1 -1 -1 " ) ; } else { System . out . println ( b + " " + a + " " + c ) ; } } } } import java . util . Scanner ; public class Jnydiu { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int jnydiu = scanner . nextInt ( ) ; int [ ] b = new int [ jnydiu ] ; int c = Integer . MAX_VALUE ; int d = Integer . MIN_VALUE ; long e = 0 ; for ( int i = 0 ; i < jnydiu ; i ++ ) { int f = scanner . nextInt ( ) ; c = Math . min ( c , f ) ; d = Math . max ( d , f ) ; e += f ; } System . out . println ( String . format ( " %d %d %d " , c , d , e ) ) ; } } import java . util . * ; import java . text . * ; class Nadingj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; double nadingj = sc . nextDouble ( ) ; double a = 3.14159265358979323846 * nadingj * nadingj ; double l = 3.14159265358979323846 * nadingj * 2 ; NumberFormat format = NumberFormat . getInstance ( ) ; format . setMaximumFractionDigits ( 5 ) ; format . setMinimumFractionDigits ( 5 ) ; format . setGroupingUsed ( false ) ; System . out . println ( " " + format . format ( a ) + " " + format . format ( l ) ) ; } } import java . util . * ; import java . util . ArrayList ; import java . util . List ; public class Xxvoz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Double > list = new ArrayList < > ( ) ; Double n = sc . nextDouble ( ) ; for ( int xxvoz = 0 ; xxvoz < n ; xxvoz ++ ) { list . add ( sc . nextDouble ( ) ) ; } Collections . sort ( list ) ; System . out . println ( ( int ) ( list . get ( list . size ( ) - 1 ) - list . get ( 0 ) ) ) ; return ; } } import java . util . * ; import java . util . ArrayList ; import java . util . List ; public class Jsripo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jsripo = sc . nextInt ( ) ; int [ ] d = new int [ jsripo ] ; int ans = 0 ; for ( int i = 0 ; i < jsripo ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < jsripo ; i ++ ) { for ( int j = i + 1 ; j < jsripo ; j ++ ) { ans = ans + d [ i ] * d [ j ] ; } } System . out . println ( ans ) ; } } import java . io . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . util . * ; public class Ibelil { static class Ibelil { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { 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 ; } public Character charAt ( int i ) { return null ; } } public static void main ( String [ ] args ) throws IOException { FastReader s = new FastReader ( ) ; int ibelil = s . nextInt ( ) ; int v = ( int ) ( ibelil + Math . pow ( ibelil , 2 ) + Math . pow ( ibelil , 3 ) ) ; System . out . println ( v ) ; } } import java . util . * ; public class Vajga { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vajga = sc . nextInt ( ) ; int a2 = vajga * vajga ; int a3 = vajga * vajga * vajga ; int ans = vajga + a2 + a3 ; System . out . println ( ans ) ; } } import java . util . Scanner ; class Nbjmw { int nbjmw , m , x , y ; public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; sc . useDelimiter ( " \\ s " ) ; nbjmw = sc . nextInt ( ) ; m = sc . nextInt ( ) ; int [ ] [ ] A = new int [ nbjmw ] [ m ] ; int [ ] b = new int [ m ] ; int [ ] c = new int [ nbjmw ] ; for ( x = 0 ; x < nbjmw ; x ++ ) { c [ x ] = 0 ; for ( y = 0 ; y < m ; y ++ ) { A [ x ] [ y ] = sc . nextInt ( ) ; } } for ( y = 0 ; y < m ; y ++ ) { b [ y ] = sc . nextInt ( ) ; } for ( x = 0 ; x < nbjmw ; x ++ ) { for ( y = 0 ; y < m ; y ++ ) { c [ x ] = c [ x ] + A [ x ] [ y ] * b [ y ] ; } } for ( x = 0 ; x < nbjmw ; x ++ ) { System . out . println ( c [ x ] ) ; } } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . * ; public class Twkztn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int twkztn = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; long at = 0 ; for ( int i = 0 ; i < n ; i ++ ) at += sc . nextInt ( ) ; if ( twkztn <= at ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; class Mwegjo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mwegjo = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] x = new int [ b ] ; for ( int i = 0 ; i < mwegjo ; i ++ ) { int c = sc . nextInt ( ) ; for ( int j = 0 ; j < c ; j ++ ) { int d = sc . nextInt ( ) ; x [ d - 1 ] = x [ d - 1 ] + 1 ; } } int ret = 0 ; for ( int k = 0 ; k < b ; k ++ ) { if ( mwegjo == x [ k ] ) ret = ret + 1 ; } System . out . println ( ret ) ; } } import java . util . Scanner ; public class Zantdej { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zantdej = sc . nextInt ( ) ; int [ ] monsters = new int [ zantdej + 1 ] ; int [ ] heroes = new int [ zantdej ] ; for ( int i = 0 ; i < zantdej + 1 ; i ++ ) monsters [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < zantdej ; i ++ ) heroes [ i ] = sc . nextInt ( ) ; int rem = 0 ; long totalKilled = 0 ; for ( int i = 0 ; i < zantdej ; i ++ ) { int killedPrev = Math . min ( rem , monsters [ i ] ) ; int killedNow = Math . min ( monsters [ i ] - killedPrev , heroes [ i ] ) ; totalKilled += killedPrev + killedNow ; rem = Math . max ( heroes [ i ] - killedNow , 0 ) ; } totalKilled += Math . min ( rem , monsters [ zantdej ] ) ; System . out . println ( totalKilled ) ; } } import java . util . * ; public class Mdiqreg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] s = S . toCharArray ( ) ; int mdiqreg = S . length ( ) ; boolean OK = true ; int i = 0 ; int j = ( mdiqreg - 1 ) / 2 - 1 ; while ( j - i >= 1 ) { if ( s [ i ] == s [ j ] && s [ mdiqreg - 1 - i ] == s [ mdiqreg - 1 - j ] ) { i ++ ; j -- ; } else { OK = false ; break ; } } for ( int k = 0 ; k < mdiqreg / 2 ; k ++ ) { if ( s [ k ] != s [ mdiqreg - 1 - k ] ) { OK = false ; break ; } } System . out . println ( OK ? " Yes " : " No " ) ; } } import java . util . * ; class Mexcyd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mexcyd = sc . nextLong ( ) ; long r = sc . nextLong ( ) ; long min = Long . MAX_VALUE ; int cnt = 0 ; if ( r - mexcyd >= 2018 ) { System . out . println ( 0 ) ; return ; } for ( long i = mexcyd ; i < r ; i ++ ) { for ( long j = i + 1 ; j <= r ; j ++ ) { cnt ++ ; min = Math . min ( ( i * j ) % 2019 , min ) ; } if ( min == 0 ) break ; } System . out . println ( min ) ; } } import java . util . * ; import java . util . stream . * ; public class Osntgrr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int osntgrr = sc . nextInt ( ) ; List < Integer > numList = new ArrayList < > ( ) ; while ( sc . hasNextInt ( ) ) { numList . add ( sc . nextInt ( ) ) ; } System . out . println ( new HashSet < > ( numList ) . size ( ) ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Jcdbf { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA_147 solver = new TaskA_147 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Jcdbf { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int jcdbf = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; out . println ( jcdbf + b + c >= 22 ? " bust " : " win " ) ; } } } import java . math . * ; import java . util . * ; public class Tsqmsk { public static void main ( String [ ] args ) { BigDecimal pi = new BigDecimal ( " 3.14159265359 " ) ; Scanner sc = new Scanner ( System . in ) ; BigDecimal m = sc . nextBigDecimal ( ) ; System . out . println ( m . multiply ( pi ) . multiply ( new BigDecimal ( 2 ) ) ) ; } } import java . util . * ; class Qbuhyjg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int qbuhyjg = t . length ( ) ; for ( int i = 0 ; i <= s . length ( ) - t . length ( ) ; i ++ ) { int count = 0 ; int k = i ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( k ) != t . charAt ( j ) ) { count ++ ; } k ++ ; } qbuhyjg = Math . min ( count , qbuhyjg ) ; } System . out . println ( qbuhyjg ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Oueaqdl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oueaqdl = getInt ( sc ) ; int [ ] d = getIntArray ( sc ) ; Arrays . sort ( d ) ; int ARCMax = d [ oueaqdl / 2 - 1 ] ; int ABCMin = d [ oueaqdl / 2 ] ; System . out . println ( ABCMin - ARCMax ) ; } public static long getLong ( Scanner sc ) { return Long . parseLong ( sc . next ( ) ) ; } public static int getInt ( Scanner sc ) { return Integer . parseInt ( sc . next ( ) ) ; } public static String getString ( Scanner sc ) { return sc . next ( ) ; } public static int [ ] getIntArray ( Scanner sc ) { String line = " " ; while ( line . equals ( " " ) ) { line = sc . nextLine ( ) ; } String [ ] strArray = line . split ( " " ) ; int [ ] intArray = new int [ strArray . length ] ; for ( int i = 0 ; i < strArray . length ; i ++ ) { intArray [ i ] = Integer . parseInt ( strArray [ i ] ) ; } return intArray ; } } import java . util . Scanner ; public class Spleeev { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = { " AC " , " WA " , " TLE " , " RE " } ; int [ ] ans = new int [ 4 ] ; for ( int spleeev = sc . nextInt ( ) ; spleeev > 0 ; spleeev -- ) { String t = sc . next ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( t . charAt ( 0 ) == s [ i ] . charAt ( 0 ) ) ans [ i ] ++ ; } } for ( int i = 0 ; i < 4 ; i ++ ) { System . out . println ( s [ i ] + " x " + ans [ i ] ) ; } } } import java . util . Scanner ; public class Euxfb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int euxfb = sc . nextInt ( ) ; int [ ] value = new int [ euxfb ] ; for ( int i = 0 ; i < euxfb ; i ++ ) { value [ i ] = sc . nextInt ( ) ; } solve ( value ) ; } public static void solve ( int [ ] height ) { int result = 0 ; int now = 0 ; for ( int i = 1 ; i < height . length ; i ++ ) { if ( height [ i - 1 ] >= height [ i ] ) { now ++ ; } else { if ( result < now ) result = now ; now = 0 ; } } if ( result < now ) result = now ; System . out . println ( result ) ; } } import java . util . * ; public class Wmqba { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wmqba = sc . nextInt ( ) ; int a = wmqba / 100 ; int b = ( wmqba - a * 100 ) / 10 ; int c = ( wmqba - a * 100 - b * 10 ) / 1 ; System . out . println ( a + b + c ) ; } } import java . util . * ; public class Jmrdo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jmrdo = sc . nextInt ( ) ; double b = sc . nextDouble ( ) ; long ans = ( long ) ( jmrdo * ( b * 100 ) ) / 100 ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . Scanner ; public class Reota { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int reota = sc . nextInt ( ) ; int [ ] w = new int [ reota ] ; for ( int i = 0 ; i < reota ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } int ans = 100000000 ; for ( int i = 0 ; i < reota ; i ++ ) { int sum1 = 0 ; int sum2 = 0 ; for ( int j = 0 ; j < i ; j ++ ) { sum1 += w [ j ] ; } for ( int k = i ; k < reota ; k ++ ) { sum2 += w [ k ] ; } ans = Math . min ( ans , ( int ) Math . abs ( sum1 - sum2 ) ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Ruqskc { void run ( ) { Scanner s = new Scanner ( System . in ) ; while ( true ) { int ruqskc = s . nextInt ( ) ; int x = s . nextInt ( ) ; if ( ruqskc == 0 && x == 0 ) break ; int sum = 0 ; int count = 0 ; int a = 0 ; int [ ] num = new int [ ruqskc ] ; for ( int i = 0 ; i < ruqskc ; i ++ ) num [ i ] = i + 1 ; for ( int i = a ; i < ruqskc ; i ++ ) { for ( int j = i + 1 ; j < ruqskc ; j ++ ) { for ( int k = j + 1 ; k < ruqskc ; k ++ ) { sum = num [ i ] + num [ j ] + num [ k ] ; if ( sum == x ) { count ++ ; } a ++ ; } } } System . out . println ( count ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; public class Qtdjx { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int qtdjx , m , ans ; qtdjx = sc . nextInt ( ) ; m = sc . nextInt ( ) ; ans = ( ( qtdjx + m ) * ( qtdjx + m - 1 ) ) / 2 - ( qtdjx * m ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Ssird { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ssird = sc . nextLong ( ) , K = sc . nextLong ( ) ; double ch = Math . log ( ssird ) / Math . log ( K ) ; int ans = ( int ) Math . ceil ( ch ) ; if ( ans == ch ) { System . out . println ( ans + 1 ) ; } else { System . out . println ( ans ) ; } } } import java . util . Scanner ; public class Twpidt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int twpidt = sc . nextInt ( ) ; int sum = sc . nextInt ( ) ; int ct = 0 ; for ( int i = 0 ; i <= twpidt ; i ++ ) { for ( int j = 0 ; j <= twpidt ; j ++ ) { int tmp = sum - i - j ; if ( tmp <= twpidt && tmp >= 0 ) ct ++ ; } } System . out . println ( ct ) ; } } import java . util . Scanner ; public class Dmauik { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int dmauik = in . nextInt ( ) ; int T = in . nextInt ( ) ; int A = in . nextInt ( ) ; int [ ] h = new int [ dmauik ] ; double [ ] t = new double [ dmauik ] ; for ( int i = 0 ; i < dmauik ; i ++ ) { h [ i ] = in . nextInt ( ) ; t [ i ] = Math . abs ( ( T - h [ i ] * 0.006 ) - A ) ; } int minn = 10000 ; double min = 10000000 ; for ( int i = 0 ; i < dmauik ; i ++ ) { if ( min > t [ i ] ) { min = t [ i ] ; minn = i ; } } System . out . println ( minn + 1 ) ; } } import java . util . Scanner ; public class Yzlsk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yzlsk = sc . nextInt ( ) ; boolean ok = false ; LOOP : for ( int i = 0 ; i <= yzlsk ; i += 4 ) { for ( int j = 0 ; i + j <= yzlsk ; j += 7 ) { if ( i + j == yzlsk ) { ok = true ; break LOOP ; } } } if ( ok ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Uvmsfu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] pizza = new int [ 5 ] ; int uvmsfu = 1000000000 ; for ( int i = 0 ; i < 5 ; i ++ ) { pizza [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < 2 * ( pizza [ 3 ] + pizza [ 4 ] ) + 1 ; i ++ ) { int a = Math . max ( 0 , ( pizza [ 3 ] - i / 2 ) ) ; int b = Math . max ( 0 , ( pizza [ 4 ] - i / 2 ) ) ; int c = i ; uvmsfu = Math . min ( uvmsfu , pizza [ 0 ] * a + pizza [ 1 ] * b + pizza [ 2 ] * c ) ; } System . out . println ( uvmsfu ) ; } } import java . util . * ; public class Mpqseca { private final static int mpqseca = 1_000_000_007 ; public static int gcd ( int a , int b ) { if ( a == 0 ) return b ; if ( b == 0 ) return a ; if ( a == b ) return a ; if ( a > b ) return gcd ( a - b , b ) ; return gcd ( a , b - a ) ; } public static long mod ( long a , long b ) { return ( ( a % b ) + b ) % b ; } public static int mod ( int a , int b ) { return ( ( a % b ) + b ) % b ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . nextLine ( ) ; String t = in . nextLine ( ) ; int res = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != t . charAt ( i ) ) res ++ ; } System . out . println ( res ) ; in . close ( ) ; } } import java . util . * ; public class Kiktar { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kiktar = sc . nextInt ( ) ; int [ ] c = new int [ 9 ] ; for ( int i = 0 ; i < kiktar ; i ++ ) { int tmp = sc . nextInt ( ) / 400 ; if ( tmp > 8 ) tmp = 8 ; c [ tmp ] ++ ; } int max , min = 0 ; for ( int i = 0 ; i < 8 ; i ++ ) { if ( c [ i ] != 0 ) min ++ ; } if ( min == 0 ) { min = 1 ; max = c [ 8 ] ; } else { max = min + c [ 8 ] ; } System . out . println ( min + " " + max ) ; } } import java . util . Scanner ; public class Ggrhre { final static long ggrhre = 2019 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long L = sc . nextLong ( ) ; long R = sc . nextLong ( ) ; sc . close ( ) ; if ( L / ggrhre != R / ggrhre ) { System . out . println ( 0 ) ; return ; } long min = Long . MAX_VALUE ; for ( long i = L ; i <= R - 1 ; i ++ ) { for ( long j = i + 1 ; j <= R ; j ++ ) { long r = ( i * j ) % ggrhre ; min = Math . min ( min , r ) ; } } System . out . println ( min ) ; } } import java . util . Scanner ; public class Eyuqs { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; String eyuqs = scanner . next ( ) ; String b = scanner . next ( ) ; if ( ( eyuqs . length ( ) + 1 == b . length ( ) ) && b . startsWith ( eyuqs ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class Qavwkq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qavwkq = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; if ( qavwkq <= 5 ) System . out . println ( " 0 " ) ; else if ( qavwkq <= 12 ) System . out . println ( b / 2 ) ; else System . out . println ( b ) ; } } import java . io . * ; class Jaufx { int [ ] s ; int jaufx ; Sta ( ) { s = new int [ 1000 ] ; jaufx = 0 ; } void push ( int x ) { jaufx ++ ; s [ jaufx ] = x ; } int pop ( ) { jaufx -- ; return s [ jaufx + 1 ] ; } } public class Jaufx { public static void main ( String [ ] args ) throws IOException { BufferedReader din = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = din . readLine ( ) ; String [ ] tokens = line . split ( " " ) ; Sta stack = new Sta ( ) ; for ( int i = 0 ; i < tokens . length ; i ++ ) { String x = tokens [ i ] ; if ( x . equals ( " + " ) ) { stack . push ( stack . pop ( ) + stack . pop ( ) ) ; } else if ( x . equals ( " - " ) ) { stack . push ( - stack . pop ( ) + stack . pop ( ) ) ; } else if ( x . equals ( " * " ) ) { stack . push ( stack . pop ( ) * stack . pop ( ) ) ; } else { int t = Integer . parseInt ( x ) ; stack . push ( t ) ; } } System . out . println ( stack . pop ( ) ) ; } } import java . util . * ; public class Lojgrds { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lojgrds = sc . nextInt ( ) ; int lowPos = sc . nextInt ( ) ; String str = sc . next ( ) ; String [ ] ary = str . split ( " " , 0 ) ; for ( int i = 0 ; i < lojgrds ; i ++ ) { if ( i == lowPos - 1 ) ary [ i ] = ary [ i ] . toLowerCase ( ) ; System . out . print ( ary [ i ] ) ; } } } import java . util . Scanner ; class Wwxezi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wwxezi = sc . nextInt ( ) ; int [ ] sequence = new int [ wwxezi ] ; double denominator = 0 ; for ( int i = 0 ; i < wwxezi ; i ++ ) { sequence [ i ] = sc . nextInt ( ) ; denominator += 1.0 / sequence [ i ] ; } System . out . println ( 1 / denominator ) ; } } import java . util . * ; public class Ippsw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; String T = sc . nextLine ( ) ; sc . close ( ) ; boolean ippsw = true ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { char sVal = S . charAt ( i ) ; char tVal = T . charAt ( i ) ; if ( sVal != tVal ) { ippsw = false ; break ; } } if ( ippsw ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Xgraw { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int xgraw = in . nextInt ( ) ; int [ ] hills = new int [ xgraw ] ; for ( int i = 0 ; i < xgraw ; i ++ ) { hills [ i ] = in . nextInt ( ) ; } int counter = 1 ; int cur = hills [ 0 ] ; for ( int i = 1 ; i < xgraw ; i ++ ) { if ( hills [ i ] >= cur ) { counter ++ ; cur = hills [ i ] ; } } System . out . println ( counter ) ; } } import java . util . * ; public class Ffdpwt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ffdpwt = sc . nextInt ( ) , d = sc . nextInt ( ) ; sc . close ( ) ; int tmp = 2 * d + 1 ; int r = ffdpwt % tmp ; int ans = ffdpwt / tmp ; if ( r != 0 ) ans ++ ; System . out . println ( ans ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Wsnwc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Set < Integer > arrays = new HashSet < > ( ) ; int wsnwc = 1 ; int s = sc . nextInt ( ) ; arrays . add ( s ) ; while ( true ) { wsnwc ++ ; s = result ( s ) ; if ( arrays . contains ( s ) ) { System . out . println ( wsnwc ) ; break ; } arrays . add ( s ) ; } } public static int result ( int a ) { if ( a % 2 == 0 ) { return a / 2 ; } return 3 * a + 1 ; } } import java . util . * ; class Oidcn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; char oidcn = scan . next ( ) . charAt ( 0 ) ; System . out . println ( ++ oidcn ) ; } } import java . util . * ; public class Hupyv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hupyv = sc . nextInt ( ) ; int a = hupyv % 500 ; int b = ( a - ( a % 5 ) ) ; int c = ( hupyv - a ) * 2 ; System . out . println ( b + c ) ; } } import java . util . * ; public class Mfwcmhc { public static void main ( String [ ] args ) { Scanner sc = null ; sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; String before = " " ; int mfwcmhc = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( i == 0 ) { if ( s . substring ( 0 , 1 ) . equals ( " R " ) ) { mfwcmhc = 1 ; } before = s . substring ( 0 , 1 ) ; } else { if ( s . substring ( i , i + 1 ) . equals ( " R " ) && before . equals ( " R " ) ) { mfwcmhc += 1 ; } else if ( s . substring ( i , i + 1 ) . equals ( " R " ) && before . equals ( " S " ) ) { mfwcmhc = 1 ; } before = s . substring ( i , i + 1 ) ; } } System . out . println ( mfwcmhc ) ; } } import java . util . Arrays ; import java . util . Collection ; import java . util . Collections ; import java . util . Scanner ; public class Etvnrb { public static void main ( String [ ] args ) { int etvnrb = 0 ; Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; char a = n . charAt ( 0 ) ; char b = n . charAt ( 1 ) ; char c = n . charAt ( 2 ) ; char d = n . charAt ( 3 ) ; if ( a == '+' ) { etvnrb ++ ; } else { etvnrb -- ; } if ( b == '+' ) { etvnrb ++ ; } else { etvnrb -- ; } if ( c == '+' ) { etvnrb ++ ; } else { etvnrb -- ; } if ( d == '+' ) { etvnrb ++ ; } else { etvnrb -- ; } System . out . println ( etvnrb ) ; } } import java . util . * ; public class Peruu { public static void main ( String [ ] args ) { boolean peruu = true ; Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; String [ ] strArray = s . split ( " " ) ; if ( strArray . length != a + b + 1 ) peruu = false ; if ( strArray [ a ] . equals ( " - " ) ) { for ( int i = 0 ; i < strArray . length ; i ++ ) { if ( i != a ) { if ( ! ( strArray [ i ] . equals ( " - " ) ) ) { int x = Integer . parseInt ( strArray [ i ] ) ; if ( x >= 10 && x < 0 ) peruu = false ; } else peruu = false ; } } } else peruu = false ; if ( peruu ) System . out . println ( " Yes " ) ; else if ( ! peruu ) System . out . println ( " No " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Hzllez { static long hzllez = 1000000000 + 7 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; n = n % 10 ; if ( n == 2 || n == 4 || n == 5 || n == 7 || n == 9 ) { System . out . println ( " hon " ) ; } if ( n == 0 || n == 1 || n == 6 || n == 8 ) { System . out . println ( " pon " ) ; } if ( n == 3 ) { System . out . println ( " bon " ) ; } } static long divn ( int target , int times ) { int sqtimes = ( int ) Math . sqrt ( times ) ; long ans = 1 ; for ( int i = 0 ; i < sqtimes ; i ++ ) { ans = ( ans * target ) % ( 1000000000 + 7 ) ; } long holder = ans ; ans = 1 ; for ( int i = 0 ; i < sqtimes ; i ++ ) { ans = ( ans * holder ) % ( 1000000000 + 7 ) ; } for ( int i = 0 ; i < times - sqtimes * sqtimes ; i ++ ) { ans = ( ans * target ) % ( 1000000000 + 7 ) ; } return ans ; } static long div ( long a ) { if ( a < 0 ) a += 1000000000 + 7 ; return a % ( 1000000000 + 7 ) ; } } import java . util . Scanner ; public class Mrklvna { public static void main ( String [ ] args ) { Scanner inp = new Scanner ( System . in ) ; int mrklvna = inp . nextInt ( ) ; int cols = inp . nextInt ( ) ; int [ ] [ ] aMatrix = new int [ mrklvna ] [ cols ] ; int [ ] [ ] bMatrix = new int [ cols ] [ 1 ] ; for ( int k = 0 ; k < mrklvna ; k ++ ) { for ( int j = 0 ; j < cols ; j ++ ) { aMatrix [ k ] [ j ] = inp . nextInt ( ) ; } } for ( int j = 0 ; j < cols ; j ++ ) { bMatrix [ j ] [ 0 ] = inp . nextInt ( ) ; } int [ ] [ ] total = matrixCalc ( aMatrix , bMatrix , mrklvna , cols ) ; for ( int [ ] item : total ) { for ( int secondItem : item ) { System . out . println ( secondItem ) ; } } } public static int [ ] [ ] matrixCalc ( int [ ] [ ] aMatrix , int [ ] [ ] bMatrix , int mrklvna , int cols ) { int [ ] [ ] totals = new int [ mrklvna ] [ 1 ] ; for ( int k = 0 ; k < mrklvna ; k ++ ) { int total = 0 ; for ( int j = 0 ; j < cols ; j ++ ) { total += aMatrix [ k ] [ j ] * bMatrix [ j ] [ 0 ] ; } totals [ k ] [ 0 ] = total ; } return totals ; } } import java . util . Scanner ; public class Bksnby { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int bksnby = scan . nextInt ( ) ; long sum = 0 ; for ( int i = 1 ; i <= bksnby ; i ++ ) { for ( int j = 1 ; j <= bksnby ; j ++ ) { for ( int l = 1 ; l <= bksnby ; l ++ ) { int first = gcd ( Math . max ( i , j ) , Math . min ( i , j ) ) ; int res = gcd ( Math . max ( first , l ) , Math . min ( first , l ) ) ; sum += res ; } } } System . out . println ( sum ) ; } private static int gcd ( int a , int b ) { int r = a % b ; if ( r == 0 ) { return b ; } else { return gcd ( b , r ) ; } } } import java . util . Scanner ; public class Oruqj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oruqj = sc . nextInt ( ) ; int a , b , c ; a = oruqj / 100 ; b = ( oruqj - a * 100 ) / 10 ; c = oruqj - a * 100 - b * 10 ; if ( a == 7 || b == 7 || c == 7 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Dssjhdf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; sc . close ( ) ; int dssjhdf = S . dssjhdf ( ) ; boolean flag = true ; for ( int i = 1 ; i <= dssjhdf ; i ++ ) { int index = i % 2 ; String firstS = S . substring ( 0 , 1 ) ; if ( index == 1 ) { if ( firstS . equals ( " L " ) ) { flag = false ; break ; } } else if ( index == 0 ) { if ( firstS . equals ( " R " ) ) { flag = false ; break ; } } S = S . substring ( 1 ) ; } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Jvjylct { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jvjylct = sc . nextInt ( ) ; int [ ] b = new int [ jvjylct - 1 ] ; int sum = 0 ; for ( int i = 0 ; i < jvjylct - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } sum += b [ 0 ] ; for ( int j = 0 ; j < jvjylct - 2 ; j ++ ) { if ( b [ j ] >= b [ j + 1 ] ) { sum += b [ j + 1 ] ; } else { sum += b [ j ] ; } } sum += b [ jvjylct - 2 ] ; System . out . println ( sum ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class Gsctmw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String gsctmw = sc . next ( ) ; if ( gsctmw . charAt ( 0 ) == gsctmw . charAt ( 1 ) && ( gsctmw . charAt ( 2 ) == gsctmw . charAt ( 3 ) ) && ( gsctmw . charAt ( 0 ) != gsctmw . charAt ( 2 ) ) ) System . out . println ( " Yes " ) ; else if ( gsctmw . charAt ( 0 ) == gsctmw . charAt ( 2 ) && ( gsctmw . charAt ( 1 ) == gsctmw . charAt ( 3 ) ) && ( gsctmw . charAt ( 0 ) != gsctmw . charAt ( 1 ) ) ) System . out . println ( " Yes " ) ; else if ( gsctmw . charAt ( 0 ) == gsctmw . charAt ( 3 ) && ( gsctmw . charAt ( 1 ) == gsctmw . charAt ( 2 ) ) && ( gsctmw . charAt ( 0 ) != gsctmw . charAt ( 1 ) ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Cnhwi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cnhwi = 0 ; long n = sc . nextLong ( ) ; String str = String . valueOf ( n ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char a = str . charAt ( i ) ; int b = a - '0' ; cnhwi = cnhwi + b ; } if ( n % cnhwi == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Ozlqzts { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ozlqzts = sc . next ( ) ; if ( ozlqzts . contains ( " 7 " ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; sc . close ( ) ; } } 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 Bukqen { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; MyScanner in = new MyScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; A solver = new A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Bukqen { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { int bukqen = in . Int ( ) ; out . println ( ( 1000 - ( bukqen % 1000 ) ) % 1000 ) ; } } static class Bukqen { private BufferedReader in ; private StringTokenizer st ; public MyScanner ( InputStream stream ) { in = new BufferedReader ( new InputStreamReader ( stream ) ) ; } public String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { String rl = in . readLine ( ) ; if ( rl == null ) { return null ; } st = new StringTokenizer ( rl ) ; } catch ( IOException e ) { return null ; } } return st . nextToken ( ) ; } public int Int ( ) { return Integer . parseInt ( next ( ) ) ; } } } import java . util . * ; public class Ijuud { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { while ( true ) { int ijuud = sc . nextInt ( ) , f = sc . nextInt ( ) , r = sc . nextInt ( ) ; if ( ijuud == - 1 && f == - 1 && r == - 1 ) { break ; } if ( ijuud == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } else if ( ijuud + f >= 80 ) { System . out . println ( " A " ) ; } else if ( ijuud + f >= 65 ) { System . out . println ( " B " ) ; } else if ( ijuud + f >= 50 ) { System . out . println ( " C " ) ; } else if ( ijuud + f >= 30 ) { if ( r >= 50 ) { System . out . println ( " C " ) ; } else { System . out . println ( " D " ) ; } } else { System . out . println ( " F " ) ; } } } } } import java . util . Arrays ; import java . util . Scanner ; public class Cjmwvv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cjmwvv = sc . nextInt ( ) ; String [ ] vote = new String [ cjmwvv ] ; int i = 0 ; while ( i < cjmwvv ) { vote [ i ] = sc . next ( ) ; i ++ ; } Arrays . sort ( vote ) ; int maxCounter = 0 ; int [ ] a = new int [ cjmwvv ] ; String [ ] b = new String [ cjmwvv ] ; int j = 0 ; a [ 0 ] = 1 ; b [ 0 ] = vote [ 0 ] ; for ( i = 1 ; i < cjmwvv ; i ++ ) { if ( vote [ i ] . equals ( b [ j ] ) ) { a [ j ] ++ ; } else { if ( maxCounter < a [ j ] ) { maxCounter = a [ j ] ; } j ++ ; a [ j ] = 1 ; b [ j ] = vote [ i ] ; } } if ( maxCounter < a [ j ] ) { maxCounter = a [ j ] ; } for ( i = 0 ; i < cjmwvv ; i ++ ) { if ( a [ i ] == maxCounter ) { System . out . println ( b [ i ] ) ; } } } } import java . util . * ; class Ulkoq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ulkoq = Integer . parseInt ( sc . next ( ) ) ; String s = Integer . toString ( ulkoq ) ; if ( s . charAt ( 0 ) == '7' || s . charAt ( 1 ) == '7' || s . charAt ( 2 ) == '7' ) { System . out . println ( " Yes " ) ; } else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Gjghubx { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String word = sc . nextLine ( ) ; int gjghubx = 0 ; while ( true ) { String text = sc . nextLine ( ) ; if ( text . equals ( " END_OF_TEXT " ) ) { break ; } String [ ] t = text . split ( " " ) ; for ( String t_word : t ) { if ( t_word . equalsIgnoreCase ( word ) ) { gjghubx ++ ; } } } System . out . println ( gjghubx ) ; } } import java . util . Scanner ; import java . util . Arrays ; import java . lang . Math ; public class Yeqywn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Integer a = Integer . parseInt ( scanner . next ( ) ) ; Integer b = Integer . parseInt ( scanner . next ( ) ) ; Integer result ; Integer total = Integer . sum ( a , b ) ; if ( total > 3 ) { result = Math . abs ( a - b ) ; } else { result = a + b ; } System . out . println ( result ) ; } } import java . util . * ; public class Ibczl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] in = sc . next ( ) . toCharArray ( ) ; List < String > out = new ArrayList < > ( ) ; String kotae = " " ; for ( int ibczl = 0 ; ibczl < in . length ; ibczl ++ ) { char b01 = in [ ibczl ] ; if ( b01 == '0' ) { out . add ( out . size ( ) , " 0 " ) ; } else if ( b01 == '1' ) { out . add ( out . size ( ) , " 1 " ) ; } else if ( b01 == 'B' ) { if ( out . size ( ) == 0 ) { } else { out . remove ( out . size ( ) - 1 ) ; } } } for ( int ibczl = 0 ; ibczl < out . size ( ) ; ibczl ++ ) { String s = out . get ( ibczl ) ; kotae = kotae + s ; } System . out . println ( kotae ) ; } } import java . io . * ; import java . util . * ; public class Csacwwf { public static void main ( final String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; int csacwwf = sc . nextInt ( ) ; String S = sc . next ( ) ; final Solver solver = new Solver ( ) ; solver . solve ( csacwwf , S ) ; } } class Csacwwf { public void solve ( int csacwwf , String S ) { int ans = 0 ; int cur = 'A' ; for ( int i = 0 ; i < csacwwf ; i ++ ) { char c = S . charAt ( i ) ; if ( cur == c ) { cur ++ ; if ( cur > 'C' ) { ans ++ ; cur = 'A' ; } } else { cur = ( c == 'A' ) ? 'B' : 'A' ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Pldpsuj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int pldpsuj = Integer . parseInt ( a + b ) ; for ( int i = 2 ; i * i <= pldpsuj ; i ++ ) { if ( i * i == pldpsuj ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Gaeujz { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String gaeujz = sc . nextLine ( ) ; String p = sc . nextLine ( ) ; gaeujz += gaeujz ; if ( gaeujz . contains ( p ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Mrobpve { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mrobpve = sc . nextInt ( ) ; int [ ] t = new int [ mrobpve ] ; int [ ] x = new int [ mrobpve ] ; int [ ] y = new int [ mrobpve ] ; for ( int i = 0 ; i < mrobpve ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } int tt = 0 ; int xx = 0 ; int yy = 0 ; for ( int i = 0 ; i < mrobpve ; i ++ ) { int tmpT = t [ i ] - tt ; int tmpX = Math . abs ( x [ i ] - xx ) ; int tmpY = Math . abs ( y [ i ] - yy ) ; if ( tmpX + tmpY > tmpT ) { System . out . println ( " No " ) ; return ; } if ( tmpT % 2 != ( tmpX + tmpY ) % 2 ) { System . out . println ( " No " ) ; return ; } tt = t [ i ] ; xx = x [ i ] ; yy = y [ i ] ; } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Qgohke { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; sc . next ( ) ; int qgohke = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; if ( c [ qgohke - 1 ] == 'A' ) { c [ qgohke - 1 ] = 'a' ; } else if ( c [ qgohke - 1 ] == 'B' ) { c [ qgohke - 1 ] = 'b' ; } else { c [ qgohke - 1 ] = 'c' ; } System . out . println ( c ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Frilupe { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; List < Integer > H = new ArrayList < Integer > ( ) ; List < Integer > W = new ArrayList < Integer > ( ) ; int frilupe = 0 ; int lastW = 0 ; do { frilupe = stdIn . nextInt ( ) ; lastW = stdIn . nextInt ( ) ; H . add ( frilupe ) ; W . add ( lastW ) ; } while ( frilupe != 0 || lastW != 0 ) ; for ( int i = 0 ; i < H . size ( ) - 1 ; i ++ ) { for ( int j = 0 ; j < H . get ( i ) ; j ++ ) { for ( int k = 0 ; k < W . get ( i ) ; k ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . Scanner ; import java . text . DecimalFormat ; public class Azkvex { public static void main ( String [ ] args ) { Scanner key = new Scanner ( System . in ) ; double azkvex = key . nextInt ( ) ; key . close ( ) ; System . out . println ( ( azkvex / 3 ) * ( azkvex / 3 ) * ( azkvex / 3 ) ) ; } } import java . util . Scanner ; public class Jdgilly { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String S = stdIn . next ( ) ; String [ ] s = S . split ( " S " ) ; int jdgilly = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { jdgilly = Math . max ( jdgilly , s [ i ] . length ( ) ) ; } System . out . println ( jdgilly ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Bxilkwy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bxilkwy = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] m = new int [ M + 1 ] ; Arrays . fill ( m , 0 ) ; int K = 0 ; int A = 0 ; int ans = 0 ; for ( int i = 0 ; i < bxilkwy ; i ++ ) { K = sc . nextInt ( ) ; for ( int j = 0 ; j < K ; j ++ ) { A = sc . nextInt ( ) ; m [ A ] ++ ; } } for ( int i = 0 ; i <= M ; i ++ ) { if ( m [ i ] == bxilkwy ) ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; class Vsfhe { private static Scanner sc ; public static void main ( final String [ ] args ) { sc = new Scanner ( System . in ) ; String vsfhe = sc . next ( ) ; if ( vsfhe . equals ( " ABC " ) ) System . out . println ( " ARC " ) ; else { System . out . println ( " ABC " ) ; } } } import java . util . * ; public class Myqniws { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int myqniws = s . length ( ) ; int sum1 = 0 ; int sum2 = 0 ; sum1 = 0 ; for ( int i = 0 ; i < myqniws ; i ++ ) { if ( s . charAt ( i ) == '0' ) { if ( i % 2 == 1 ) { sum1 += 1 ; } } else { if ( i % 2 == 0 ) { sum1 += 1 ; } } } sum2 = 0 ; for ( int i = 0 ; i < myqniws ; i ++ ) { if ( s . charAt ( i ) == '0' ) { if ( i % 2 == 0 ) { sum2 += 1 ; } } else { if ( i % 2 == 1 ) { sum2 += 1 ; } } } System . out . println ( Math . min ( sum1 , sum2 ) ) ; } } import java . math . * ; import java . util . * ; public class Fpozrlz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fpozrlz = sc . nextInt ( ) ; double a = fpozrlz / 3.0 ; double b = fpozrlz / 3.0 ; double v = a * b * ( fpozrlz - a - b ) ; System . out . println ( v ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Lgcfin { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; char [ ] s = br . readLine ( ) . toCharArray ( ) ; br . close ( ) ; if ( s [ 2 ] == s [ 3 ] && s [ 4 ] == s [ 5 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Zucjvm { public static void main ( String [ ] args ) { int zucjvm , b ; Scanner sc = new Scanner ( System . in ) ; do { zucjvm = sc . nextInt ( ) ; } while ( ! ( ( zucjvm >= 1 ) && ( zucjvm <= 20 ) ) ) ; do { b = sc . nextInt ( ) ; } while ( ! ( ( b >= 1 ) && ( b <= 20 ) ) ) ; if ( ( zucjvm >= 1 && zucjvm <= 9 ) && ( b >= 1 && b <= 9 ) ) { System . out . println ( zucjvm * b ) ; } else { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; public class Gsttxbz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int gsttxbz = Integer . parseInt ( scanner . nextLine ( ) ) ; String s = scanner . nextLine ( ) ; if ( gsttxbz % 2 == 1 || gsttxbz == 0 ) { System . out . println ( " No " ) ; return ; } String s1 = s . substring ( 0 , gsttxbz / 2 ) ; String s2 = s . substring ( gsttxbz / 2 , gsttxbz ) ; if ( s1 . startsWith ( s2 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scanner . close ( ) ; } } import java . util . Scanner ; public class Lcfsb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int lcfsb = scan . nextInt ( ) ; for ( int i = 1 ; i <= lcfsb ; i ++ ) { if ( i % 3 == 0 || Integer . toString ( i ) . indexOf ( " 3 " ) >= 0 ) { System . out . printf ( " %d " , i ) ; } } System . out . println ( " " ) ; scan . close ( ) ; } } import java . util . Scanner ; public class Ekcac { private static long ekcac = 1000000007 ; public static void main ( final String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int count = scanner . nextInt ( ) ; final int fallCount = scanner . nextInt ( ) ; final long [ ] steps = new long [ count + 1 ] ; for ( int i = 1 ; i < steps . length ; i ++ ) { steps [ i ] = 0 ; } steps [ 0 ] = 1 ; for ( int i = 0 ; i < fallCount ; i ++ ) { steps [ scanner . nextInt ( ) ] = - 1 ; } for ( int i = 0 ; i < count ; i ++ ) { if ( steps [ i ] == - 1 ) { continue ; } if ( i == count - 1 ) { steps [ i + 1 ] += steps [ i ] ; break ; } if ( steps [ i + 1 ] == - 1 && steps [ i + 2 ] == - 1 ) { System . out . println ( 0 ) ; return ; } if ( steps [ i + 2 ] != - 1 ) { steps [ i + 2 ] += steps [ i ] % ekcac ; } if ( steps [ i + 1 ] != - 1 ) { steps [ i + 1 ] += steps [ i ] % ekcac ; } } System . out . println ( steps [ count ] % ekcac ) ; } } import java . util . Scanner ; public class Sasimpx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sasimpx = sc . nextInt ( ) ; int maxCount = 0 ; int maxNum = 0 ; for ( int i = 0 ; i < sasimpx ; i ++ ) { int count = 0 ; int num = i + 1 ; while ( true ) { if ( num % 2 != 0 ) { break ; } num /= 2 ; count ++ ; } if ( i == 0 || count > maxCount ) { maxCount = count ; maxNum = i + 1 ; } } System . out . println ( maxNum ) ; } } import java . util . Scanner ; public class Jnwiepf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long jnwiepf = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( jnwiepf > k ) { jnwiepf -= k * ( jnwiepf / k ) ; if ( k - jnwiepf < jnwiepf ) { System . out . println ( k - jnwiepf ) ; } else { System . out . println ( jnwiepf ) ; } } else { if ( k - jnwiepf < jnwiepf ) { System . out . println ( k - jnwiepf ) ; } else { System . out . println ( jnwiepf ) ; } } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Skhtsb { public static void main ( String [ ] args ) throws Exception { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] natural = stdReader . readLine ( ) . split ( " " , 0 ) ; int skhtsb = Integer . parseInt ( natural [ 0 ] ) ; int y = Integer . parseInt ( natural [ 1 ] ) ; if ( skhtsb < y ) { skhtsb = skhtsb ^ y ; y = skhtsb ^ y ; skhtsb = skhtsb ^ y ; } while ( y > 0 ) { int r = skhtsb % y ; skhtsb = y ; y = r ; } System . out . println ( skhtsb ) ; } } import java . util . * ; public class Facxi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int facxi = 0 ; int z = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'A' ) { facxi = i ; break ; } } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'Z' ) { z = i + 1 ; } } System . out . println ( z - facxi ) ; } } import java . util . Scanner ; public class Yjwkcg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int yjwkcg = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; double d = 0 ; int ans = 0 ; double ans1 = 1000 ; int j = 0 ; for ( int i = 0 ; i != yjwkcg ; i ++ ) { d = scan . nextInt ( ) ; d = b - ( d * 0.006 ) ; d -= c ; if ( d < 0 ) { d *= - 1 ; } if ( d < ans1 ) { ans1 = d ; ans = i + 1 ; } } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Grhmxmi { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; String re = " " ; for ( int grhmxmi = line . length ( ) ; grhmxmi > 0 ; grhmxmi -- ) { re += line . charAt ( grhmxmi - 1 ) ; } System . out . println ( re ) ; } } import java . util . * ; import java . text . * ; class Xsidax { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; Comparator < String > cs = new Comparator < String > ( ) { public int compare ( String s1 , String s2 ) { int xsidax = s1 . length ( ) ; int l2 = s2 . length ( ) ; int l = Math . min ( xsidax , l2 ) ; for ( int i = 0 ; i < l ; i ++ ) { int d = s1 . charAt ( i ) - s2 . charAt ( i ) ; if ( d != 0 ) return d ; } return xsidax - l2 ; } public boolean equals ( Object o ) { return o == this ; } } ; int n = sc . nextInt ( ) ; int c1 = 0 , c2 = 0 ; while ( n -- > 0 ) { String x = sc . next ( ) ; String y = sc . next ( ) ; int c = cs . compare ( x , y ) ; if ( c < 0 ) { c2 += 3 ; } else if ( c > 0 ) { c1 += 3 ; } else { c2 ++ ; c1 ++ ; } } System . out . println ( " " + c1 + " " + c2 ) ; } } import java . io . * ; public class Owuinzi { public static void main ( String [ ] args ) throws IOException { long owuinzi = 0 ; int i = 0 ; long n = 100 ; double k = 0 ; BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) ) ; owuinzi = Long . parseLong ( r . readLine ( ) ) ; do { i ++ ; k = Math . ceil ( ( double ) ( n / 100 ) ) ; n += ( long ) k ; } while ( n < owuinzi ) ; System . out . println ( i ) ; } } import java . util . Scanner ; public class Hekvjy { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; double hekvjy , d , s ; d = sc . nextDouble ( ) ; hekvjy = sc . nextDouble ( ) ; s = sc . nextDouble ( ) ; if ( ( d / s ) <= hekvjy ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } catch ( Exception e ) { } } } import java . util . ArrayDeque ; import java . util . Queue ; import java . util . Scanner ; public class Ocimtf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ocimtf = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; Queue < Process > Q = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < ocimtf ; i ++ ) { Q . add ( new Process ( sc . next ( ) , sc . nextInt ( ) ) ) ; } int t = 0 ; while ( ! Q . isEmpty ( ) ) { Process p = Q . poll ( ) ; if ( p . time <= q ) { t += p . time ; System . out . println ( p . name + " " + t ) ; } else { t += q ; p . time -= q ; Q . add ( p ) ; } } sc . close ( ) ; } static class Ocimtf { String name ; int time ; public Process ( String name , int time ) { this . name = name ; this . time = time ; } } } import java . util . * ; import java . io . * ; import java . awt . geom . * ; public class Ezcgwlk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int ezcgwlk = Integer . parseInt ( br . readLine ( ) ) ; int [ ] arr = new int [ ezcgwlk - 1 ] ; String [ ] s = br . readLine ( ) . split ( " " ) ; int prev = 987654321 ; long sum = 0 ; for ( int i = 0 ; i < ezcgwlk - 1 ; i ++ ) { int curr = Integer . parseInt ( s [ i ] ) ; sum += ( long ) Math . min ( prev , curr ) ; prev = curr ; } sum += prev ; System . out . println ( sum ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Ezilxmk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ezilxmk = scan . nextInt ( ) ; int [ ] a = new int [ ezilxmk ] ; int i = 0 ; int Alice = 0 ; int Bob = 0 ; for ( i = 0 ; i < ezilxmk ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } Arrays . sort ( a ) ; for ( i = 1 ; i <= ezilxmk ; i ++ ) { if ( i % 2 == 1 ) { Alice = Alice + a [ ezilxmk - i ] ; } else { Bob = Bob + a [ ezilxmk - i ] ; } } System . out . println ( Alice - Bob ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Dsfotuy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dsfotuy = sc . nextInt ( ) ; List < Long > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < dsfotuy ; i ++ ) { list . add ( sc . nextLong ( ) ) ; } long max = Collections . max ( list ) ; long min = Collections . min ( list ) ; System . out . println ( max - min ) ; } } import java . util . Scanner ; public class Kbomi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kbomi = 0 ; int N = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; sc . close ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { int sum = sum ( i ) ; if ( A <= sum && sum <= B ) { kbomi += i ; } } System . out . println ( kbomi ) ; } private static int sum ( int i ) { int sumDigits = 0 ; while ( i != 0 ) { sumDigits += i % 10 ; i /= 10 ; } return sumDigits ; } } import java . util . * ; public class Aqnazu { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int aqnazu = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; System . out . println ( scanner . next ( ) . matches ( String . format ( " \\ d { %d } - \\ d { %d } " , aqnazu , b ) ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; class Mgvlpgi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int mgvlpgi = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int [ ] [ ] array ; array = new int [ mgvlpgi ] [ b ] ; int [ ] Vec = new int [ b ] ; int [ ] sum = new int [ mgvlpgi ] ; int x = 0 ; for ( int i = 0 ; i < mgvlpgi ; i ++ ) { for ( int j = 0 ; j < b ; j ++ ) { array [ i ] [ j ] = scanner . nextInt ( ) ; } } for ( int i = 0 ; i < b ; i ++ ) { Vec [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < mgvlpgi ; i ++ ) { for ( int j = 0 ; j < b ; j ++ ) { sum [ i ] = array [ i ] [ j ] * Vec [ j ] + x ; x = sum [ i ] ; } x = 0 ; } for ( int i = 0 ; i < mgvlpgi ; i ++ ) { System . out . println ( sum [ i ] ) ; } scanner . close ( ) ; } } import java . util . Scanner ; public class Cpjamrv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String buff = " " ; int cpjamrv = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double count = 1 , flag = 0 ; double count1 = 0 , count2 = 0 ; int count3 = 9999999 ; int [ ] [ ] array1 = new int [ cpjamrv ] [ k ] ; for ( int i = 0 ; i < cpjamrv ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { array1 [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < cpjamrv - 1 ; i ++ ) { for ( int j = i + 1 ; j < cpjamrv ; j ++ ) { for ( int g = 0 ; g < k ; g ++ ) { count2 += Math . pow ( ( array1 [ i ] [ g ] - array1 [ j ] [ g ] ) , 2 ) ; } count = Math . sqrt ( count2 ) ; count3 = ( int ) count ; if ( count - count3 == 0 ) { count1 ++ ; } count2 = 0 ; } } System . out . println ( ( int ) count1 ) ; } } import java . util . Scanner ; public class Vhjfvej { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vhjfvej = 0 ; int five = 0 ; while ( sc . hasNext ( ) ) { int num = sc . nextInt ( ) ; if ( num == 7 ) { vhjfvej ++ ; } else if ( num == 5 ) { five ++ ; } } if ( vhjfvej == 1 && five == 2 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; import java . lang . * ; import java . math . * ; public class Fojgz { Scanner sc = new Scanner ( System . in ) ; void run ( ) { int fojgz = sc . nextInt ( ) ; int b = 100 ; for ( int i = 0 ; i < fojgz ; i ++ ) { if ( ( double ) ( b * 0.05 ) - ( int ) ( b * 0.05 ) > 0 ) b = ( int ) ( b * 1.05 ) + 1 ; else b = ( int ) ( b * 1.05 ) ; } System . out . println ( b * 1000 ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . Scanner ; public class Aqthnxj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] ss = S . toCharArray ( ) ; String T = sc . next ( ) ; char [ ] t = T . toCharArray ( ) ; int aqthnxj = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { for ( int j = 0 ; j < T . length ( ) ; j ++ ) { if ( ss [ i ] == t [ j ] ) { if ( S . equals ( T . substring ( j , T . length ( ) ) + T . substring ( 0 , j ) ) ) { aqthnxj ++ ; } } } } if ( aqthnxj > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Lvtpmi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lvtpmi = 0 ; int S2 = 0 ; int S3 = 0 ; int N = sc . nextInt ( ) ; int [ ] arys ; arys = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arys [ i ] = sc . nextInt ( ) ; } int [ ] anss ; anss = new int [ N - 1 ] ; for ( int j = 0 ; j <= N - 2 ; j ++ ) { lvtpmi = 0 ; S2 = 0 ; S3 = 0 ; for ( int k = 0 ; k <= j ; k ++ ) { lvtpmi = lvtpmi + arys [ k ] ; } for ( int k = j + 1 ; k <= N - 1 ; k ++ ) { S2 = S2 + arys [ k ] ; } S3 = Math . abs ( lvtpmi - S2 ) ; anss [ j ] = S3 ; } int ans = anss [ 0 ] ; for ( int i = 0 ; i <= N - 2 ; i ++ ) { ans = Math . min ( ans , anss [ i ] ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Qcnmmg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qcnmmg = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] m = new int [ qcnmmg ] ; int sumG = 0 ; int minDonut = 1001 ; for ( int i = 0 ; i < qcnmmg ; i ++ ) { m [ i ] = sc . nextInt ( ) ; sumG += m [ i ] ; minDonut = Math . min ( minDonut , m [ i ] ) ; } int sumDonut = qcnmmg + ( x - sumG ) / minDonut ; System . out . println ( sumDonut ) ; } } import java . util . * ; public class Dxfcbe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dxfcbe = sc . nextInt ( ) ; double min = Math . pow ( 10 , 10 ) ; double max = 0 ; for ( int i = 0 ; i < dxfcbe ; i ++ ) { double target = sc . nextInt ( ) ; if ( min > target ) { min = target ; } if ( max < target ) { max = target ; } } System . out . println ( ( int ) ( max - min ) ) ; } } import java . util . * ; import java . io . * ; public class Uldok { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s1 = scanner . next ( ) ; char [ ] c = s1 . toCharArray ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int uldok = 0 ; uldok < s1 . length ( ) ; uldok ++ ) { if ( c [ uldok ] != 'B' ) list . add ( ( int ) c [ uldok ] - '0' ) ; else { if ( list . size ( ) > 0 ) list . remove ( list . size ( ) - 1 ) ; } } for ( int uldok = 0 ; uldok < list . size ( ) ; uldok ++ ) System . out . print ( list . get ( uldok ) ) ; } } import java . util . Scanner ; public class Mwybax { public static void main ( String [ ] av ) { Scanner s = new Scanner ( System . in ) ; int mwybax = s . nextInt ( ) ; int [ ] a = new int [ mwybax + 1 ] ; for ( int i = 0 ; i < mwybax ; i ++ ) { a [ i ] = s . nextInt ( ) ; } for ( int i = 1 ; i < mwybax ; i ++ ) { for ( int k = 0 ; k < mwybax ; k ++ ) { System . out . print ( a [ k ] ) ; if ( k != mwybax - 1 ) System . out . print ( " " ) ; } System . out . println ( " " ) ; int v = a [ i ] ; int j = i - 1 ; while ( j >= 0 && a [ j ] > v ) { a [ j + 1 ] = a [ j ] ; j -- ; } a [ j + 1 ] = v ; } for ( int k = 0 ; k < mwybax ; k ++ ) { System . out . print ( a [ k ] ) ; if ( k != mwybax - 1 ) System . out . print ( " " ) ; } System . out . println ( " " ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Bugcdce { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Bugcdce { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int bugcdce = Integer . parseInt ( in . next ( ) ) ; int d = Integer . parseInt ( in . next ( ) ) ; int ans = 0 ; if ( bugcdce % ( 2 * d + 1 ) == 0 ) { ans = bugcdce / ( 2 * d + 1 ) ; } else { ans = bugcdce / ( 2 * d + 1 ) + 1 ; } out . println ( ans ) ; } } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Kentrtz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long kentrtz = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; System . out . println ( solve ( b , c , d ) - solve ( kentrtz - 1 , c , d ) ) ; } static long gcd ( long kentrtz , long b ) { if ( b == 0 ) { return kentrtz ; } return gcd ( b , kentrtz % b ) ; } static long solve ( long b , long c , long d ) { long ret = b ; long other = c * d / gcd ( c , d ) ; ret -= b / c ; ret -= b / d ; ret += b / other ; return ret ; } } import java . util . * ; public class Saofl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int saofl = sc . nextInt ( ) ; saofl = saofl % 10 ; if ( saofl == 2 || saofl == 4 || saofl == 5 || saofl == 7 || saofl == 9 ) { System . out . println ( " hon " ) ; } else if ( saofl == 0 || saofl == 1 || saofl == 6 || saofl == 8 ) { System . out . println ( " pon " ) ; } else { System . out . println ( " bon " ) ; } } } import java . util . * ; public class Akwroe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int akwroe = sc . nextInt ( ) ; String ans = " APPROVED " ; for ( int i = 0 ; i < akwroe ; i ++ ) { int A = sc . nextInt ( ) ; if ( A % 2 == 0 && A % 3 != 0 && A % 5 != 0 ) ans = " DENIED " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Bopfz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; for ( int bopfz = 0 ; bopfz < s . length ( ) - 1 ; bopfz ++ ) { if ( s . charAt ( bopfz ) != s . charAt ( bopfz + 1 ) ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Grrsdr { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int grrsdr = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int ans = ( grrsdr + a - 1 ) / a ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class Hchykf { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Unstoppable solver = new Unstoppable ( ) ; solver . solve ( in , out ) ; out . close ( ) ; } static class Hchykf { public void solve ( InputReader in , PrintWriter out ) { int hchykf = in . nextInt ( ) ; int [ ] a = new int [ hchykf ] ; for ( int i = 0 ; i < hchykf ; i ++ ) a [ i ] = in . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < hchykf - 1 ; i ++ ) { for ( int j = i + 1 ; j < hchykf ; j ++ ) { int mul = a [ i ] * a [ j ] ; sum += mul ; } } out . println ( sum ) ; } } static class Hchykf { 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 Uoyay { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String p = sc . nextLine ( ) ; int uoyay = s . length ( ) ; int pLen = p . length ( ) ; boolean ok = false ; for ( int i = 0 ; i < uoyay ; i ++ ) { for ( int j = 0 ; j < pLen ; j ++ ) { if ( s . charAt ( ( i + j ) % uoyay ) != p . charAt ( j ) ) { break ; } if ( j == pLen - 1 ) ok = true ; } if ( ok ) break ; } System . out . println ( ok ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Wwqqgp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long wwqqgp = sc . nextLong ( ) ; long r = sc . nextLong ( ) ; long min = 9999 ; for ( long i = wwqqgp ; i < r ; i ++ ) { for ( long j = i + 1 ; j <= r ; j ++ ) { long mod = ( i * j ) % 2019 ; if ( mod == 0L ) { System . out . println ( mod ) ; System . exit ( 0 ) ; ; } if ( mod < min ) { min = mod ; } } } System . out . println ( min ) ; sc . close ( ) ; } } import java . util . * ; public class Kupulop { static public void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int kupulop = s . nextInt ( ) ; String c = s . next ( ) ; if ( kupulop % 2 == 1 ) { System . out . println ( " No " ) ; } else { boolean yes = true ; for ( int i = 0 ; i < kupulop / 2 && yes ; i ++ ) { if ( c . charAt ( i ) != c . charAt ( i + kupulop / 2 ) ) yes = false ; } if ( yes ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } } import java . util . * ; import java . io . * ; public class Poohv { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int poohv , x , t = 0 ; String [ ] brr = br . readLine ( ) . split ( " " ) ; poohv = Integer . parseInt ( brr [ 0 ] ) ; x = Integer . parseInt ( brr [ 1 ] ) ; t = Integer . parseInt ( brr [ 2 ] ) ; long ans = 0 ; while ( poohv > 0 ) { ans += t ; poohv -= x ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Lzkjmkz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long lzkjmkz = sc . nextLong ( ) , min = 11 ; String a = " " , b = " " ; for ( int i = 1 ; i <= Math . sqrt ( lzkjmkz ) ; i ++ ) { if ( lzkjmkz % i == 0 ) { a = String . valueOf ( i ) ; b = String . valueOf ( lzkjmkz / i ) ; min = Math . min ( min , Math . max ( a . length ( ) , b . length ( ) ) ) ; } } System . out . println ( min ) ; } public static List < Long > divisorEnum ( long lzkjmkz ) { List < Long > l = new ArrayList < > ( ) ; for ( long i = 1 ; i <= Math . sqrt ( lzkjmkz ) ; i ++ ) { if ( lzkjmkz % i == 0 ) { l . add ( i ) ; if ( i != Math . sqrt ( lzkjmkz ) ) l . add ( lzkjmkz / i ) ; } } l . sort ( null ) ; return l ; } } import java . util . Scanner ; public class Hqmysi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hqmysi = Integer . parseInt ( ( sc . next ( ) ) ) ; long [ ] aArr = new long [ hqmysi + 1 ] ; for ( int i = 0 ; i <= hqmysi ; i ++ ) { aArr [ i ] = Long . parseLong ( sc . next ( ) ) ; } long [ ] bArr = new long [ hqmysi ] ; for ( int i = 0 ; i < hqmysi ; i ++ ) { bArr [ i ] = Long . parseLong ( sc . next ( ) ) ; } sc . close ( ) ; long ans = 0 ; for ( int i = hqmysi - 1 ; i >= 0 ; i -- ) { long beated = Math . min ( aArr [ i + 1 ] , bArr [ i ] ) ; ans += beated ; aArr [ i + 1 ] -= beated ; bArr [ i ] -= beated ; beated = Math . min ( aArr [ i ] , bArr [ i ] ) ; ans += beated ; aArr [ i ] -= beated ; } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Wdzfq { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; char [ ] S = br . readLine ( ) . toCharArray ( ) ; char [ ] T = br . readLine ( ) . toCharArray ( ) ; int wdzfq = S . length - T . length + 1 ; int [ ] cnt = new int [ wdzfq ] ; int max = 0 ; for ( int i = 0 ; i < wdzfq ; i ++ ) { for ( int j = 0 ; j < T . length ; j ++ ) { if ( T [ j ] == S [ i + j ] ) { cnt [ i ] ++ ; } } } for ( int k = 0 ; k < cnt . length ; k ++ ) { if ( max < cnt [ k ] ) { max = cnt [ k ] ; } } System . out . println ( T . length - max ) ; } } import java . util . * ; public class Ysmubw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ysmubw = sc . nextInt ( ) ; int num2 = sc . nextInt ( ) ; int num3 = sc . nextInt ( ) ; System . out . println ( num3 ) ; System . out . println ( ysmubw ) ; System . out . println ( num2 ) ; } } import java . util . * ; public class Fevoqz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fevoqz = sc . nextInt ( ) ; int [ ] A = new int [ fevoqz + 1 ] ; int [ ] B = new int [ fevoqz ] ; for ( int i = 0 ; i < fevoqz + 1 ; i ++ ) A [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < fevoqz ; i ++ ) B [ i ] = sc . nextInt ( ) ; int [ ] AC = A . clone ( ) ; long cnt = 0 ; for ( int i = 0 ; i < fevoqz ; i ++ ) { if ( A [ i ] >= B [ i ] ) { A [ i ] -= B [ i ] ; B [ i ] = 0 ; } else { B [ i ] -= A [ i ] ; A [ i ] = 0 ; } if ( A [ i + 1 ] >= B [ i ] ) { A [ i + 1 ] -= B [ i ] ; B [ i ] = 0 ; } else { B [ i ] -= A [ i + 1 ] ; A [ i + 1 ] = 0 ; } } for ( int i = 0 ; i < fevoqz + 1 ; i ++ ) { cnt += AC [ i ] - A [ i ] ; } System . out . println ( cnt ) ; } } import java . util . * ; public class Winwt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String c = sc . next ( ) ; char [ ] sChar = new char [ 3 ] ; char [ ] cChar = new char [ 3 ] ; int winwt = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { sChar [ i ] = s . charAt ( i ) ; cChar [ i ] = c . charAt ( i ) ; if ( sChar [ i ] == cChar [ i ] ) { winwt ++ ; } } System . out . println ( winwt ) ; } } import java . util . * ; public class Rqryzh { static boolean [ ] targetNumbers ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long rqryzh = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long gcd = calcGcd ( rqryzh , B ) ; System . out . println ( rqryzh * B / gcd ) ; } public static long calcGcd ( long m , long n ) { if ( m < n ) { long tmp = m ; m = n ; n = tmp ; } long remainder = 0 ; while ( ( remainder = m % n ) != 0 ) { m = n ; n = remainder ; } return n ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Hpdevoj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String hpdevoj = br . readLine ( ) ; Integer witdh = Integer . parseInt ( hpdevoj . split ( " " ) [ 0 ] ) ; Integer height = Integer . parseInt ( hpdevoj . split ( " " ) [ 1 ] ) ; Integer x = Integer . parseInt ( hpdevoj . split ( " " ) [ 2 ] ) ; Integer y = Integer . parseInt ( hpdevoj . split ( " " ) [ 3 ] ) ; Integer r = Integer . parseInt ( hpdevoj . split ( " " ) [ 4 ] ) ; if ( witdh >= ( x + r ) && ( x - r ) >= 0 && height >= ( y + r ) && ( y - r ) >= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Zagffyj { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int zagffyj = scanner . nextInt ( ) ; int [ ] p = new int [ zagffyj ] ; for ( int i = 0 ; i < zagffyj ; i ++ ) { p [ i ] = scanner . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < zagffyj - 2 ; i ++ ) { if ( ( p [ i ] < p [ i + 1 ] && p [ i + 1 ] < p [ i + 2 ] ) || ( p [ i + 2 ] < p [ i + 1 ] && p [ i + 1 ] < p [ i ] ) ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; class Ergmfdh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ergmfdh = sc . nextInt ( ) ; int [ ] B = new int [ ergmfdh - 1 ] ; for ( int i = 0 ; i < ergmfdh - 1 ; i ++ ) B [ i ] = sc . nextInt ( ) ; int count = B [ 0 ] ; for ( int i = 0 ; i < ergmfdh - 2 ; i ++ ) { if ( B [ i ] < B [ i + 1 ] ) count += B [ i ] ; else count += B [ i + 1 ] ; } count += B [ ergmfdh - 2 ] ; System . out . println ( count ) ; } } import java . util . Scanner ; public class Wtfvn { public static void main ( String [ ] s ) { Scanner sc = new Scanner ( System . in ) ; int wtfvn = 0 ; if ( sc . hasNextInt ( ) ) wtfvn = sc . nextInt ( ) ; int cnt = 0 ; boolean res = false ; while ( wtfvn -- != 0 ) { byte x = sc . nextByte ( ) ; byte y = sc . nextByte ( ) ; if ( x == y ) cnt ++ ; else cnt = 0 ; if ( cnt == 3 ) res = true ; } if ( res ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Nwojwh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nwojwh = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] a = new int [ nwojwh ] ; int migi = 0 ; int hidari = 0 ; for ( int i = 0 ; i < M ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( a [ i ] < X ) { hidari ++ ; } else { migi ++ ; } } System . out . println ( Math . min ( migi , hidari ) ) ; } } import java . util . * ; import java . lang . * ; public class Ikedhfg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ikedhfg = sc . nextInt ( ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; String result = new String ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { result = result . concat ( String . valueOf ( s . charAt ( i ) ) ) ; result = result . concat ( String . valueOf ( t . charAt ( i ) ) ) ; } System . out . println ( result ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Dpshmtb { public static void main ( String [ ] arges ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] k = line . split ( " " ) ; int [ ] v = new int [ k . length ] ; for ( int dpshmtb = 0 ; dpshmtb < v . length ; dpshmtb ++ ) { v [ dpshmtb ] = Integer . parseInt ( k [ dpshmtb ] ) ; } int count = 0 ; for ( int dpshmtb = v [ 0 ] ; dpshmtb <= v [ 1 ] ; dpshmtb ++ ) { if ( v [ 2 ] % dpshmtb == 0 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class Xinad { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xinad = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; Boolean ans = true ; String [ ] strings = s . split ( " - " ) ; if ( strings . length != 2 ) ans = false ; else if ( strings [ 0 ] . length ( ) != xinad ) ans = false ; else if ( strings [ 1 ] . length ( ) != b ) ans = false ; if ( ans ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; sc . close ( ) ; return ; } } import java . util . * ; public class Jlkgwkm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int jlkgwkm = Integer . parseInt ( S . substring ( 0 , 2 ) ) ; int last2 = Integer . parseInt ( S . substring ( 2 , 4 ) ) ; String result = " " ; if ( 1 <= jlkgwkm && jlkgwkm <= 12 ) { if ( 1 <= last2 && last2 <= 12 ) { result = " AMBIGUOUS " ; } else { result = " MMYY " ; } } else { if ( 1 <= last2 && last2 <= 12 ) { result = " YYMM " ; } else { result = " NA " ; } } System . out . println ( result ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class Toqftzl { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String [ ] tmpArray = br . readLine ( ) . split ( " " ) ; int toqftzl = Integer . parseInt ( tmpArray [ 0 ] ) ; int b = Integer . parseInt ( tmpArray [ 1 ] ) ; if ( toqftzl == 0 && b == 0 ) { break ; } for ( int i = 0 ; i < toqftzl ; i ++ ) { for ( int j = 0 ; j < b ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . * ; import java . io . * ; public class Pozdsw { void solve ( InputReader in , PrintWriter out ) { out . println ( ( 1 + in . nextInt ( ) ) / 2 ) ; } public static void main ( String [ ] args ) throws Exception { InputReader in = new InputReader ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; Main solver = new Main ( ) ; solver . solve ( in , out ) ; out . close ( ) ; } static class Pozdsw { BufferedReader in ; StringTokenizer st ; public InputReader ( InputStream is ) { in = new BufferedReader ( new InputStreamReader ( is ) ) ; } public String next ( ) { try { while ( st == null || ! st . hasMoreTokens ( ) ) { st = new StringTokenizer ( in . readLine ( ) ) ; } return st . nextToken ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . HashMap ; public class Ktrlioj { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = " " ; HashMap < String , Integer > ans = new HashMap < String , Integer > ( ) ; while ( ( line = br . readLine ( ) ) != null ) { for ( int ktrlioj = 0 ; ktrlioj < line . length ( ) ; ktrlioj ++ ) { String str = Character . toString ( line . charAt ( ktrlioj ) ) . toLowerCase ( ) ; if ( ans . containsKey ( str ) ) { ans . put ( str , ans . get ( str ) + 1 ) ; } else { ans . put ( str , 1 ) ; } } } StringBuilder sb = new StringBuilder ( ) ; for ( char c = 'a' ; c <= 'z' ; c ++ ) { sb . append ( c ) . append ( " : " ) ; String keyChar = Character . toString ( c ) ; if ( ans . containsKey ( keyChar ) ) { sb . append ( ans . get ( keyChar ) ) ; } else { sb . append ( " 0 " ) ; } sb . append ( " \n " ) ; } System . out . print ( sb . toString ( ) ) ; } } import java . util . Scanner ; public class Ziovkbv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ziovkbv = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; String [ ] s = sc . next ( ) . split ( " " ) ; s [ k - 1 ] = s [ k - 1 ] . toLowerCase ( ) ; System . out . println ( String . join ( " " , s ) ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Hioaec { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] __ ) { while ( true ) { input ( ) ; if ( in . charAt ( 0 ) == '0' ) return ; solve ( ) ; } } static String in ; private static void input ( ) { in = s . next ( ) ; } private static void solve ( ) { int [ ] x = new int [ in . length ( ) ] ; for ( int hioaec = 0 ; hioaec < in . length ( ) ; hioaec ++ ) x [ hioaec ] = in . charAt ( hioaec ) - '0' ; System . out . println ( Arrays . stream ( x ) . parallel ( ) . sum ( ) ) ; } } import java . util . * ; public class Ypzry { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String N = sc . next ( ) ; sc . close ( ) ; String [ ] arr = N . split ( " " ) ; int ypzry = Integer . valueOf ( N ) ; int sn = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { sn += Integer . valueOf ( arr [ i ] ) ; } if ( ypzry % sn == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Ykjhno { private static int digitSum ( int input ) { int ykjhno = 0 ; int tmp = 1 ; while ( tmp <= input ) { ykjhno += ( input / tmp ) % 10 ; tmp *= 10 ; } return ykjhno ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int val = sc . nextInt ( ) ; String res = ( val % digitSum ( val ) == 0 ) ? " Yes " : " No " ; System . out . println ( res ) ; } } import java . util . Scanner ; public class Yvkgm { public static void main ( String [ ] args ) { int [ ] a ; int yvkgm = 0 , count = 1 ; a = new int [ 100000 ] ; a [ 0 ] = 1 ; Scanner n = new Scanner ( System . in ) ; while ( a [ yvkgm ] != 0 ) { yvkgm ++ ; a [ yvkgm ] = n . nextInt ( ) ; if ( a [ yvkgm ] != 0 ) { count += 1 ; } } yvkgm = 1 ; while ( count > yvkgm ) { System . out . println ( " Case " + yvkgm + " : " + a [ yvkgm ] ) ; yvkgm ++ ; } } } import java . util . * ; public class Lstajm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lstajm = sc . nextInt ( ) ; int num = 1 ; for ( int i = 0 ; i < 9 ; i ++ ) { if ( lstajm - 111 > 0 ) { lstajm -= 111 ; } else { num += i ; break ; } } System . out . println ( num * 111 ) ; } } import java . io . * ; import java . util . * ; public class Rrtrrys { public static void main ( String [ ] args ) { int rrtrrys , q , time = 0 ; Queue < String > queueName = new ArrayDeque < String > ( ) ; Queue < Integer > queueTime = new ArrayDeque < Integer > ( ) ; Scanner sc = new Scanner ( System . in ) ; rrtrrys = sc . nextInt ( ) ; q = sc . nextInt ( ) ; sc . nextLine ( ) ; for ( int i = 0 ; i < rrtrrys ; i ++ ) { String [ ] s = sc . nextLine ( ) . split ( " " ) ; queueName . add ( s [ 0 ] ) ; queueTime . add ( Integer . parseInt ( s [ 1 ] ) ) ; } while ( ! queueName . isEmpty ( ) ) { String qn = queueName . poll ( ) ; int t = queueTime . poll ( ) ; time += ( t > q ) ? q : t ; if ( t > q ) { queueTime . add ( t - q ) ; queueName . add ( qn ) ; } else { System . out . println ( qn + " " + time ) ; } } } } import java . util . Scanner ; public class Offjel { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int offjel ; String str ; while ( true ) { str = sc . next ( ) ; if ( str . equals ( " - " ) ) { break ; } String str1 ; String str2 ; int m ; m = sc . nextInt ( ) ; int h ; for ( offjel = 0 ; offjel < m ; offjel ++ ) { h = sc . nextInt ( ) ; str1 = str . substring ( 0 , h ) ; str2 = str . substring ( h ) ; str = str2 + str1 ; } System . out . println ( str ) ; } sc . close ( ) ; } } import java . util . * ; public class Sxujh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] S = sc . next ( ) . toCharArray ( ) ; String output = " Good " ; for ( int sxujh = 0 ; sxujh < S . length - 1 ; sxujh ++ ) { if ( S [ sxujh ] == S [ sxujh + 1 ] ) { output = " Bad " ; break ; } } System . out . println ( output ) ; } } import java . util . Scanner ; public class Wcsgo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) . toUpperCase ( ) ; String b = sc . next ( ) . toUpperCase ( ) ; String c = sc . next ( ) . toUpperCase ( ) ; int wcsgo = 0 ; int idxb = 0 ; int idxc = 0 ; char temp = 'A' ; while ( true ) { if ( temp == 'A' ) { if ( wcsgo >= a . length ( ) ) { break ; } temp = a . charAt ( wcsgo ) ; wcsgo ++ ; } else if ( temp == 'B' ) { if ( idxb >= b . length ( ) ) { break ; } temp = b . charAt ( idxb ) ; idxb ++ ; } else if ( temp == 'C' ) { if ( idxc >= c . length ( ) ) { break ; } temp = c . charAt ( idxc ) ; idxc ++ ; } } System . out . println ( temp ) ; } } import java . util . * ; public class Hhfevix { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long hhfevix = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; long ansA , ansB ; if ( hhfevix - k >= 0 ) { ansA = hhfevix - k ; } else { ansA = 0 ; } k -= hhfevix ; if ( k > 0 ) { if ( b - k >= 0 ) { ansB = b - k ; } else { ansB = 0 ; } } else { ansB = b ; } System . out . println ( ansA + " " + ansB ) ; } } import java . util . Scanner ; public class Owehl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int owehl = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( owehl == B ) { System . out . println ( " IMPOSSIBLE " ) ; } else if ( ( owehl + B ) % 2 == 0 ) { System . out . println ( ( owehl + B ) / 2 ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } sc . close ( ) ; } } import java . io . * ; public class Frmag { public static void main ( String ... args ) throws IOException { final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; final StringBuilder sb = new StringBuilder ( ) ; while ( true ) { final String line = br . readLine ( ) ; final int frmag = line . indexOf ( " " ) ; final int x = Integer . parseInt ( line . substring ( 0 , frmag ) ) ; final int y = Integer . parseInt ( line . substring ( frmag + 1 , line . length ( ) ) ) ; if ( x == 0 && y == 0 ) break ; sb . append ( x < y ? x + " " + y : y + " " + x ) . append ( " \n " ) ; } System . out . print ( sb ) ; } } import java . util . * ; class Jlbblmv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jlbblmv = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i <= jlbblmv ; i ++ ) { for ( int j = 0 ; j <= B ; j ++ ) { int k = ( X - i * 500 - j * 100 ) / 50 ; if ( k >= 0 && k <= C ) { cnt ++ ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Eqeyp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int eqeyp = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int q = scan . nextInt ( ) ; int [ ] a = new int [ eqeyp + 1 ] ; int i ; for ( i = 0 ; i < q ; i ++ ) a [ scan . nextInt ( ) ] ++ ; int border = q - k ; for ( i = 1 ; i <= eqeyp ; i ++ ) { if ( a [ i ] > border ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class Cvubu { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int cvubu = in . nextInt ( ) ; int [ ] value = new int [ cvubu ] ; int a = 0 ; int b = 0 ; for ( int i = 0 ; i < cvubu ; i ++ ) { value [ i ] = in . nextInt ( ) ; if ( a < value [ i ] ) { b = a ; a = value [ i ] ; } else if ( b < value [ i ] ) { b = value [ i ] ; } } in . close ( ) ; for ( int i = 0 ; i < cvubu ; i ++ ) { if ( a == value [ i ] ) { System . out . println ( b ) ; } else { System . out . println ( a ) ; } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; class Cgvwdpi { static Scanner sc = new Scanner ( ) ; public static void main ( final String [ ] args ) throws IOException { int cgvwdpi = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; char temp = c [ 0 ] ; int ans = 1 ; for ( int i = 1 ; i < cgvwdpi ; i ++ ) { if ( c [ i ] != temp ) { temp = c [ i ] ; ans ++ ; } } System . out . println ( ans ) ; } static class Cgvwdpi { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) , 1 << 15 ) ; StringTokenizer tokenizer ; String next ( ) throws IOException { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } } } import java . util . Scanner ; public class Dxboqjo { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String s = input . nextLine ( ) ; for ( int dxboqjo = 0 ; dxboqjo < s . length ( ) ; dxboqjo ++ ) { System . out . print ( " x " ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class Xrgswdx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xrgswdx = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int C = scan . nextInt ( ) ; ArrayList < Integer > times = new ArrayList ( ) ; ArrayList < Integer > number = new ArrayList ( ) ; int count = 0 ; for ( int i = 0 ; i < M ; i ++ ) { int B = scan . nextInt ( ) ; times . add ( B ) ; } for ( int i = 0 ; i < xrgswdx ; i ++ ) { int answer = 0 ; for ( int j = 0 ; j < times . size ( ) ; j ++ ) { int A = scan . nextInt ( ) ; number . add ( A ) ; answer += times . get ( j ) * number . get ( j ) ; } answer += C ; if ( answer > 0 ) { count ++ ; } number . clear ( ) ; } System . out . println ( count ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Ehkad { char ehkad ; void run ( ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String str = sc . next ( ) ; for ( int i = 0 ; i < a ; i ++ ) { ehkad = str . charAt ( i ) ; if ( '0' > ehkad || ehkad > '9' ) { System . out . println ( " No " ) ; return ; } } if ( str . charAt ( a ) != '-' ) { System . out . println ( " No " ) ; return ; } for ( int i = a + 1 ; i <= a + b ; i ++ ) { ehkad = str . charAt ( i ) ; if ( '0' > ehkad || ehkad > '9' ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; sc . close ( ) ; } void debug ( Object ... o ) { System . out . println ( Arrays . deepToString ( o ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . LinkedList ; import java . util . Queue ; import java . util . Scanner ; public class Nywgp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Queue < Character > [ ] queues = new Queue [ 3 ] ; for ( int nywgp = 0 ; nywgp < 3 ; nywgp ++ ) { queues [ nywgp ] = new LinkedList < > ( ) ; for ( char ch : scanner . next ( ) . toCharArray ( ) ) queues [ nywgp ] . add ( ch ) ; } int c = 0 ; while ( true ) { if ( queues [ c ] . isEmpty ( ) ) { System . out . println ( ( char ) ( 'A' + c ) ) ; return ; } char ch = queues [ c ] . remove ( ) ; c = ch - 'a' ; } } } import java . util . * ; public class Tvipuuy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tvipuuy = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < tvipuuy ; i ++ ) { int a = sc . nextInt ( ) ; int c = 0 ; while ( a % 2 == 0 ) { a /= 2 ; c ++ ; } if ( c < min ) min = c ; } System . out . println ( min ) ; } } import java . util . Scanner ; public class Venye { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int venye = scanner . nextInt ( ) ; int [ ] flowersHeight = new int [ venye ] ; int maxFlowerHeight = 0 ; for ( int i = 0 ; i < venye ; ++ i ) { flowersHeight [ i ] = scanner . nextInt ( ) ; maxFlowerHeight = Math . max ( maxFlowerHeight , flowersHeight [ i ] ) ; } int wateringTimes = 0 ; loop : while ( true ) { boolean start = false ; for ( int i = 0 , j = 0 ; i < venye ; ++ i ) { if ( ! start && ( flowersHeight [ i ] != 0 ) ) { -- flowersHeight [ i ] ; start = true ; } else if ( start && ( flowersHeight [ i ] != 0 ) ) { -- flowersHeight [ i ] ; } else if ( start && ( flowersHeight [ i ] == 0 ) ) { break ; } else { if ( ++ j == venye ) break loop ; } } ++ wateringTimes ; } System . out . print ( wateringTimes ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class Kpdzoy { public static void main ( String [ ] args ) throws FileNotFoundException , IOException { Scanner s = new Scanner ( System . in ) ; Map < String , Integer > map = new HashMap < > ( ) ; map . put ( " SUN " , 1 ) ; map . put ( " MON " , 2 ) ; map . put ( " TUE " , 3 ) ; map . put ( " WED " , 4 ) ; map . put ( " THU " , 5 ) ; map . put ( " FRI " , 6 ) ; map . put ( " SAT " , 7 ) ; String kpdzoy = s . nextLine ( ) ; System . out . println ( 8 - map . get ( kpdzoy ) ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class Yjykc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long yjykc = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; long c = ( b * b ) - ( yjykc * yjykc ) ; long d = 2 * b - 2 * yjykc ; if ( c % d == 0 ) System . out . println ( c / d ) ; else System . out . println ( " IMPOSSIBLE " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Atzxl { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int atzxl = s . nextInt ( ) ; ArrayList < Long > list = new ArrayList < > ( ) ; long num = 1 ; while ( num != atzxl + 1 ) { if ( num % 3 != 0 && num % 5 != 0 ) { list . add ( num ) ; num ++ ; } else { num ++ ; } } long sum = 0 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { sum = sum + list . get ( i ) ; } System . out . println ( sum ) ; } } import java . util . * ; public class Omtvc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int omtvc = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( lcm ( omtvc , B ) ) ; } public static long lcm ( int omtvc , int B ) { int temp ; long C = omtvc ; C *= B ; while ( ( temp = omtvc % B ) != 0 ) { omtvc = B ; B = temp ; } return ( C / B ) ; } } import java . util . Scanner ; public class Oqbvzq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( ( System . in ) ) ; int oqbvzq = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) , ans = " Yes " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i == ( oqbvzq ) ) { if ( ! s . substring ( i , i + 1 ) . equals ( " - " ) ) { ans = " No " ; break ; } } else { if ( ! s . substring ( i , i + 1 ) . matches ( " 1|2|3|4|5|6|7|8|9|0 " ) ) { ans = " No " ; break ; } } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; public class Ywljz { public static void main ( String [ ] x ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; short a = sc . nextShort ( ) ; System . out . println ( a + a * a + a * a * a ) ; } } import java . util . * ; public class Dmppc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long dmppc = sc . nextLong ( ) ; int k = 1 ; long z = 26L ; long d = 0L ; while ( z < dmppc ) { d = z ; k ++ ; z += ( long ) Math . pow ( 26 , k ) ; } long y = dmppc - d - 1L ; String alp = " abcdefghijklmnopqrstuvwxyz " ; String [ ] s = new String [ k ] ; for ( int i = k - 1 ; i >= 0 ; i -- ) { int c = ( int ) ( y % 26L ) ; s [ i ] = alp . substring ( c , c + 1 ) ; y = y / 26L ; } System . out . println ( String . join ( " " , s ) ) ; } } import java . util . Scanner ; public class Smluxnu { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int smluxnu = sc . nextInt ( ) ; int [ ] h = new int [ smluxnu ] ; for ( int i = 0 ; i < smluxnu ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int max = h [ 0 ] ; boolean b = true ; for ( int i = 0 ; i < smluxnu ; i ++ ) { if ( h [ i ] < max - 1 ) { b = false ; break ; } if ( h [ i ] > max ) { max = h [ i ] ; } } System . out . println ( b ? " Yes " : " No " ) ; } } import java . util . Scanner ; import java . util . Arrays ; import java . util . ArrayList ; import java . util . List ; import java . util . stream . Collectors ; class Yeike { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yeike = sc . nextInt ( ) ; int Sum = 0 ; List < String > listA = new ArrayList < String > ( ) ; for ( int i = 0 ; i < yeike ; i ++ ) { listA . add ( sc . next ( ) ) ; } List < String > listB = listA . stream ( ) . distinct ( ) . collect ( Collectors . toList ( ) ) ; System . out . println ( listB . size ( ) ) ; } } import java . util . Scanner ; public class Vcglqv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String vcglqv = scan . next ( ) ; String b = scan . next ( ) ; String c = scan . next ( ) ; String next = " a " ; while ( true ) { if ( next . equals ( " a " ) && vcglqv . length ( ) > 0 ) { next = vcglqv . substring ( 0 , 1 ) ; vcglqv = vcglqv . substring ( 1 ) ; } else if ( next . equals ( " b " ) && b . length ( ) > 0 ) { next = b . substring ( 0 , 1 ) ; b = b . substring ( 1 ) ; } else if ( c . length ( ) > 0 ) { next = c . substring ( 0 , 1 ) ; c = c . substring ( 1 ) ; } else { break ; } } System . out . println ( next . toUpperCase ( ) ) ; } } import java . util . Scanner ; public class Pfyjb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pfyjb = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int ans = 2000 ; for ( int i = 0 ; i < pfyjb ; i ++ ) { int c = sc . nextInt ( ) ; int t2 = sc . nextInt ( ) ; if ( t2 > t ) continue ; ans = Math . min ( ans , c ) ; } System . out . println ( ( ans != 2000 ) ? ans : " TLE " ) ; } } import java . util . Scanner ; public class Nhmjeiu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int nhmjeiu = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; if ( nhmjeiu == 0 && w == 0 ) break ; for ( int i = 0 ; i < nhmjeiu ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { boolean oddRow = ( i % 2 ) == 1 ; boolean oddColumn = ( j % 2 ) == 1 ; if ( ( oddRow && oddColumn ) || ( ! oddRow && ! oddColumn ) ) { System . out . print ( " # " ) ; } else { System . out . print ( " . " ) ; } } System . out . println ( " " ) ; } System . out . println ( " " ) ; } sc . close ( ) ; } } import java . util . * ; import java . lang . * ; class Ughnb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = " " ; while ( sc . hasNext ( ) ) { int ughnb = 0 ; s = sc . nextLine ( ) ; if ( s . equalsIgnoreCase ( " ssr " ) || s . equalsIgnoreCase ( " srs " ) || s . equalsIgnoreCase ( " rss " ) || s . equalsIgnoreCase ( " rsr " ) ) { ughnb = 1 ; } else if ( s . equalsIgnoreCase ( " rrs " ) || s . equalsIgnoreCase ( " srr " ) ) { ughnb = 2 ; } else if ( s . equalsIgnoreCase ( " rrr " ) ) { ughnb = 3 ; } else ughnb = 0 ; System . out . println ( ughnb ) ; } } } import java . util . Scanner ; public class Scjiixj { public static void main ( String [ ] args ) { int scjiixj , B , C , D ; Scanner scan = new Scanner ( System . in ) ; scjiixj = scan . nextInt ( ) ; B = scan . nextInt ( ) ; C = scan . nextInt ( ) ; D = scan . nextInt ( ) ; while ( true ) { if ( scjiixj <= 0 || C <= 0 ) break ; C -= B ; if ( scjiixj <= 0 || C <= 0 ) break ; scjiixj -= D ; } if ( C <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Jddkuy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jddkuy = sc . nextInt ( ) ; int [ ] h = new int [ jddkuy ] ; for ( int i = 0 ; i < jddkuy ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; while ( true ) { int l = jddkuy ; int r = jddkuy - 1 ; for ( int i = 0 ; i < jddkuy ; i ++ ) { if ( h [ i ] > 0 ) { l = Math . min ( l , i ) ; } else if ( l < i ) { r = i - 1 ; break ; } } if ( l == jddkuy ) break ; int min = 110 ; for ( int i = l ; i <= r ; i ++ ) { min = Math . min ( min , h [ i ] ) ; } for ( int i = l ; i <= r ; i ++ ) { h [ i ] -= min ; } cnt += min ; } System . out . println ( cnt ) ; } } import java . util . * ; public class Zyrier { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String str = s . next ( ) ; char [ ] alphabet = new char [ 26 ] ; char zyrier = 'a' ; for ( int i = 0 ; i < 26 ; i ++ ) { alphabet [ i ] = zyrier ++ ; long count = Main . split ( str , alphabet [ i ] ) ; if ( count % 2 != 0 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } public static int split ( String str , char target ) { int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == target ) count ++ ; } return count ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . util . Vector ; public class Mviprpu { public static void main ( String [ ] arg ) { Scanner ob = new Scanner ( System . in ) ; int mviprpu = ob . nextInt ( ) ; String s = ob . next ( ) ; int k = 0 ; for ( int i = 0 ; i <= s . length ( ) - 3 ; i ++ ) { if ( s . charAt ( i ) == 'A' && s . charAt ( i + 1 ) == 'B' && s . charAt ( i + 2 ) == 'C' ) { k ++ ; } } System . out . println ( k ) ; } } import java . util . * ; public class Viprk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int viprk = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] arr = new int [ viprk ] ; Arrays . fill ( arr , 0 ) ; for ( int i = 0 ; i < 2 * M ; i ++ ) { int a = sc . nextInt ( ) ; for ( int j = 1 ; j <= viprk ; j ++ ) { if ( a == j ) { arr [ j - 1 ] ++ ; } } } for ( int i = 0 ; i < viprk ; i ++ ) { System . out . println ( arr [ i ] ) ; } } } import java . util . Scanner ; public class Xhctcja { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xhctcja = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int y = 0 ; for ( int x = xhctcja ; x <= b ; x ++ ) { if ( c % x == 0 ) { y ++ ; } } System . out . println ( y ) ; } } import java . util . Scanner ; class Ewuld { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int ewuld = 0 ; int maxCount = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { String a = S . substring ( i , i + 1 ) ; if ( a . equals ( " A " ) || a . equals ( " C " ) || a . equals ( " G " ) || a . equals ( " T " ) ) { ewuld ++ ; } else { ewuld = 0 ; } if ( maxCount < ewuld ) { maxCount = ewuld ; } } System . out . println ( maxCount ) ; } } import java . io . * ; import java . util . * ; public class Eyvewek { public static void main ( final String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; long eyvewek ; eyvewek = sc . nextLong ( ) ; long B ; B = sc . nextLong ( ) ; final Solver solver = new Solver ( ) ; solver . solve ( eyvewek , B ) ; } } class Eyvewek { public void solve ( long eyvewek , long B ) { System . out . println ( eyvewek * B / lcd ( eyvewek , B ) ) ; } private long lcd ( long eyvewek , long B ) { if ( B == 0 ) { return eyvewek ; } return lcd ( B , eyvewek % B ) ; } } import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; import java . util . TreeMap ; public class Cusgtzg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cusgtzg = sc . nextInt ( ) ; Map < String , Integer > m = new TreeMap < String , Integer > ( ) ; int max = 0 ; for ( int i = 0 ; i < cusgtzg ; i ++ ) { String S = sc . next ( ) ; if ( m . containsKey ( S ) ) { m . put ( S , m . get ( S ) + 1 ) ; } else { m . put ( S , 1 ) ; } if ( max < m . get ( S ) ) { max = m . get ( S ) ; } } for ( Entry < String , Integer > s : m . entrySet ( ) ) { if ( s . getValue ( ) == max ) { System . out . println ( s . getKey ( ) ) ; } } } } import java . util . * ; public class Zapmr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int zapmr = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] lots = new int [ zapmr ] ; for ( int i = 1 ; i <= zapmr ; ++ i ) { lots [ i - 1 ] = i ; } while ( 0 < n -- ) { String [ ] horizontal_line = sc . next ( ) . split ( " , " ) ; swapVerticalLines ( lots , Integer . parseInt ( horizontal_line [ 0 ] ) - 1 , Integer . parseInt ( horizontal_line [ 1 ] ) - 1 ) ; } for ( int i = 0 ; i < zapmr ; ++ i ) { System . out . println ( String . valueOf ( lots [ i ] ) ) ; } } } private static void swapVerticalLines ( int [ ] lots , int line1 , int line2 ) { int tmp = lots [ line1 ] ; lots [ line1 ] = lots [ line2 ] ; lots [ line2 ] = tmp ; } } import java . util . Scanner ; public class Whvcdei { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int whvcdei = in . nextInt ( ) ; for ( int n = whvcdei ; n < 1000 ; n ++ ) { if ( n % 111 == 0 ) { System . out . println ( n ) ; return ; } } } } } import java . util . Scanner ; public class Ptmqk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ptmqk = scan . nextInt ( ) ; for ( int h = 0 ; h < 241 ; h ++ ) { if ( ptmqk >= 3600 ) { ptmqk = ptmqk - 3600 ; } else { System . out . print ( h + " : " ) ; break ; } } for ( int m = 0 ; m < 60 ; m ++ ) { if ( ptmqk >= 60 ) { ptmqk = ptmqk - 60 ; } else { System . out . println ( m + " : " + ptmqk ) ; break ; } } } } import java . io . * ; import java . util . StringTokenizer ; public class Dfdfg { public static void main ( String [ ] args ) { final FastScanner fs = new FastScanner ( ) ; final int [ ] arr = fs . nextIntArray ( ) ; int dfdfg = 0 ; for ( int i : arr ) { dfdfg += countDiv ( i ) ; } System . out . println ( dfdfg ) ; } static int countDiv ( int n ) { int i = 0 ; while ( n != 0 && n % 2 == 0 ) { n /= 2 ; i ++ ; } return i ; } public static class Dfdfg { BufferedReader br ; StringTokenizer st ; public FastScanner ( String s ) { try { br = new BufferedReader ( new FileReader ( s ) ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } } public FastScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String nextToken ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int [ ] nextIntArray ( ) { final int N = nextInt ( ) ; int [ ] arr = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = nextInt ( ) ; } return arr ; } int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; } long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( nextToken ( ) ) ; } } } import java . util . * ; class Owkvz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int owkvz = sc . nextInt ( ) ; long co = 0 ; HashMap < String , Long > l = new HashMap < String , Long > ( ) ; for ( int i = 0 ; i < owkvz ; i ++ ) { char [ ] c = sc . next ( ) . toCharArray ( ) ; Arrays . sort ( c ) ; String S = new String ( c ) ; if ( l . containsKey ( S ) ) { l . put ( S , l . get ( S ) + 1 ) ; co += l . get ( S ) ; } else { l . put ( S , ( long ) 0 ) ; } } sc . close ( ) ; System . out . println ( co ) ; } } import java . util . Scanner ; public class Eldsm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . nextLine ( ) ; String [ ] alp = { " a " , " b " , " c " , " d " , " e " , " f " , " g " , " h " , " i " , " j " , " k " , " l " , " m " , " n " , " o " , " p " , " q " , " r " , " s " , " t " , " u " , " v " , " w " , " x " , " y " , " z " } ; int eldsm ; for ( eldsm = 0 ; eldsm < 25 ; eldsm ++ ) { if ( alp [ eldsm ] . equals ( str ) ) { break ; } } System . out . println ( alp [ eldsm + 1 ] ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; class Yxhdmt { public static void main ( String [ ] args ) throws IOException { int yxhdmt , r ; double a , b , f ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String input = br . readLine ( ) ; String [ ] strArray = input . split ( " " ) ; a = Integer . parseInt ( strArray [ 0 ] ) ; b = Integer . parseInt ( strArray [ 1 ] ) ; yxhdmt = getD ( a , b ) ; r = getR ( a , b ) ; f = getF ( a , b ) ; System . out . printf ( " %d %d %.5f " , yxhdmt , r , f ) ; } static int getD ( double a , double b ) { return ( int ) ( a / b ) ; } static int getR ( double a , double b ) { return ( int ) ( a % b ) ; } static double getF ( double a , double b ) { return a / b ; } } import static java . lang . Integer . parseInt ; import static java . lang . Math . pow ; import static java . lang . System . out ; import java . io . File ; import java . util . Scanner ; public class Nmozsb { public static void main ( String [ ] args ) { new Main ( ) . right ( ) ; } public void right ( ) { try ( Scanner scan = new Scanner ( System . in ) ) { scanInData ( scan ) ; } catch ( Exception e ) { System . exit ( 0 ) ; } } public void right ( String inDataPath ) { try ( Scanner scan = new Scanner ( new File ( inDataPath ) ) ) { scanInData ( scan ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } public void scanInData ( Scanner scan ) { int nmozsb = parseInt ( scan . nextLine ( ) ) ; for ( int i = 0 ; i < nmozsb ; i ++ ) { String [ ] data = scan . nextLine ( ) . split ( " " ) ; printJudgeTriangle ( parseInt ( data [ 0 ] ) , parseInt ( data [ 1 ] ) , parseInt ( data [ 2 ] ) ) ; } } public void printJudgeTriangle ( int a , int b , int c ) { if ( judgeTriangle ( a , b , c ) || judgeTriangle ( b , c , a ) || judgeTriangle ( c , a , b ) ) { out . println ( " YES " ) ; } else { out . println ( " NO " ) ; } } public boolean judgeTriangle ( int x , int y , int z ) { return pow ( x , 2 ) + pow ( y , 2 ) == pow ( z , 2 ) ; } } import java . util . * ; class Krmlze { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int krmlze = Integer . parseInt ( sc . next ( ) ) ; int L = Integer . parseInt ( sc . next ( ) ) ; int [ ] data = new int [ krmlze ] ; int sum = 0 ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < krmlze ; i ++ ) { data [ i ] = L + i ; sum += data [ i ] ; if ( Math . abs ( min ) > Math . abs ( data [ i ] ) ) { min = data [ i ] ; } } System . out . println ( sum - min ) ; } } import java . util . Scanner ; public class Yhsmwc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long yhsmwc = scanner . nextLong ( ) ; long a = scanner . nextLong ( ) ; long b = scanner . nextLong ( ) ; if ( a == 0 ) { System . out . println ( " 0 " ) ; return ; } long d = a + b ; long q = yhsmwc / d ; long r = yhsmwc % d ; long blue = ( q * a ) + ( a < r ? a : r ) ; System . out . println ( blue ) ; } } import java . util . Scanner ; public class Cxwdc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cxwdc = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x <= cxwdc ; x ++ ) { for ( int y = 0 ; y <= cxwdc ; y ++ ) { int z = S - ( x + y ) ; if ( 0 <= z && z <= cxwdc ) { count ++ ; } } } System . out . print ( count ) ; } } import java . util . Scanner ; class Eqtdemf { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int eqtdemf = in . nextInt ( ) ; if ( eqtdemf == 0 ) break ; int [ ] numbers = new int [ eqtdemf ] ; long double_sum = 0 ; long sum_double = 0 ; for ( int i = 0 ; i < eqtdemf ; i ++ ) { numbers [ i ] = in . nextInt ( ) ; double_sum += numbers [ i ] ; } double_sum = double_sum * double_sum ; for ( int i = 0 ; i < eqtdemf ; i ++ ) sum_double += ( numbers [ i ] * numbers [ i ] ) ; double sd = Math . sqrt ( ( sum_double - double_sum / ( double ) eqtdemf ) / ( double ) eqtdemf ) ; System . out . printf ( " %5.8f " , sd ) ; System . out . println ( ) ; } } } import java . util . Scanner ; public class Gkaci { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int gkaci = sc . nextInt ( ) ; int tt = 0 ; int tx = 0 ; int ty = 0 ; for ( int i = 0 ; i < gkaci ; i ++ ) { int t = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int dt = Math . abs ( t - tt ) ; int dx = Math . abs ( x - tx ) ; int dy = Math . abs ( y - ty ) ; if ( dt < dx + dy || ( dt - dx - dy ) % 2 == 1 ) { System . out . println ( " No " ) ; sc . close ( ) ; return ; } } sc . close ( ) ; System . out . println ( " Yes " ) ; } } import java . util . * ; class Fogantv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fogantv = sc . nextInt ( ) ; long [ ] h = new long [ fogantv ] ; for ( int i = 0 ; i < fogantv ; i ++ ) { h [ i ] = sc . nextLong ( ) ; } long max = 0 , count = 0 ; for ( int i = 0 ; i < fogantv - 1 ; i ++ ) { if ( h [ i ] >= h [ i + 1 ] ) { count += 1 ; } else { count = 0 ; } if ( max < count ) { max = count ; } } System . out . println ( max ) ; } } import java . util . Scanner ; public class Rnlafgj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long rnlafgj = sc . nextLong ( ) ; String alphabet = " abcdefghijklmnopqrstuvwxyz " ; String name = " " ; while ( rnlafgj > 0 ) { rnlafgj -- ; long remain = rnlafgj % 26l ; name = alphabet . charAt ( ( int ) remain ) + name ; rnlafgj = rnlafgj / 26l ; } System . out . println ( name ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Tyogfq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int tyogfq = Integer . parseInt ( br . readLine ( ) ) ; int sum = ( int ) ( tyogfq + Math . pow ( ( double ) tyogfq , 2.0 ) + Math . pow ( ( double ) tyogfq , 3.0 ) ) ; System . out . println ( sum ) ; } } import java . io . * ; import java . util . * ; public class Xmvocdb { static Scanner sc = new Scanner ( System . in ) ; static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) throws IOException { String s = sc . next ( ) ; int xmvocdb = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '+' ) xmvocdb ++ ; else xmvocdb -- ; } out . println ( xmvocdb ) ; out . flush ( ) ; out . close ( ) ; } static class Xmvocdb { StringTokenizer st ; BufferedReader br ; public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; } public Scanner ( FileReader fileReader ) { br = new BufferedReader ( fileReader ) ; } public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } public String nextLine ( ) throws IOException { return br . readLine ( ) ; } public boolean ready ( ) throws IOException { return br . ready ( ) ; } } } import java . util . * ; public class Drzeh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long drzeh = sc . nextLong ( ) ; double b = sc . nextDouble ( ) ; int c = ( int ) Math . round ( 100 * b ) ; System . out . println ( ( long ) ( drzeh * c ) / 100 ) ; } } public class Ucgbdvy { public static void main ( String [ ] args ) { int ucgbdvy = new java . util . Scanner ( System . in ) . nextInt ( ) ; int pay = 0 ; while ( pay < ucgbdvy ) { pay += 1000 ; } System . out . println ( pay - ucgbdvy ) ; } } import java . util . * ; class Jayssm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jayssm = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int count = 0 ; for ( int ca = 0 ; ca < jayssm + 1 ; ++ ca ) { for ( int cb = 0 ; cb < B + 1 ; ++ cb ) { for ( int cc = 0 ; cc < C + 1 ; ++ cc ) { if ( ( ca * 500 + cb * 100 + cc * 50 ) == X ) { ++ count ; } } } } System . out . println ( count ) ; } } import java . util . * ; public class Npkwvgg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = " " ; String [ ] data = a . split ( " " ) ; for ( int npkwvgg = 0 ; data . length > npkwvgg ; npkwvgg ++ ) { if ( npkwvgg == 3 ) { data [ npkwvgg ] = " 8 " ; b = b + data [ npkwvgg ] ; } else { b = b + data [ npkwvgg ] ; } } System . out . println ( b ) ; } } import java . io . BufferedReader ; import java . io . * ; import java . util . * ; import java . util . ArrayList ; import java . util . Iterator ; import java . util . List ; import java . util . Collections ; import java . util . Arrays ; public class Xysxbm { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xysxbm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; int count = 0 ; if ( b + c - xysxbm <= 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( b + c - xysxbm ) ; } } } import java . util . Scanner ; public class Zxdkq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zxdkq = Integer . parseInt ( sc . next ( ) ) ; int N = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; if ( N != 100 ) { int answer = ( int ) ( N * Math . pow ( 100 , zxdkq ) ) ; System . out . println ( answer ) ; return ; } else { int answer = ( int ) ( 101 * Math . pow ( 100 , zxdkq ) ) ; System . out . println ( answer ) ; return ; } } } import java . util . Scanner ; class Hmydd { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int hmydd = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = ( int ) Math . log10 ( hmydd + b ) + 1 ; System . out . println ( c ) ; } } } import java . util . Scanner ; public class Kawpgl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kawpgl = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; for ( int i = 1 ; i <= kawpgl ; i ++ ) { if ( y == ( i * 2 ) + ( ( kawpgl - i ) * 4 ) ) { System . out . println ( " Yes " ) ; return ; } } for ( int i = 1 ; i <= kawpgl ; i ++ ) { if ( y == ( i * 4 ) + ( ( kawpgl - i ) * 2 ) ) { System . out . println ( " Yes " ) ; return ; } } for ( int i = 1 ; i <= kawpgl / 2 ; i ++ ) { if ( y == i * 2 ) { System . out . println ( " Yes " ) ; return ; } } for ( int i = 1 ; i <= kawpgl / 4 ; i ++ ) { if ( y == i * 4 ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Isoxvo { int isoxvo ; int ans ; public void shori ( ) { Scanner sc = new Scanner ( System . in ) ; isoxvo = sc . nextInt ( ) ; ans = isoxvo * isoxvo * isoxvo ; System . out . println ( ans ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { Main obj = new Main ( ) ; obj . shori ( ) ; } } import java . util . * ; public class Tnyvzc { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int tnyvzc = scn . nextInt ( ) ; int n = scn . nextInt ( ) ; String [ ] p = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { p [ i ] = scn . next ( ) ; } for ( int j = 0 ; j <= 51 ; j ++ ) { int min = tnyvzc - j ; int max = tnyvzc + j ; String mi = String . valueOf ( min ) ; String ma = String . valueOf ( max ) ; if ( ! Arrays . asList ( p ) . contains ( mi ) ) { System . out . println ( tnyvzc - j ) ; return ; } if ( ! Arrays . asList ( p ) . contains ( ma ) ) { System . out . println ( tnyvzc + j ) ; return ; } } scn . close ( ) ; } } import java . util . Scanner ; public class Pqrfn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int pqrfn = scan . nextInt ( ) ; int alpha = 0 ; int sum = 0 ; for ( int i = 1 ; i <= pqrfn ; i ++ ) { for ( int j = 1 ; j <= pqrfn ; j ++ ) { for ( int k = 1 ; k <= pqrfn ; k ++ ) { alpha = gcd ( i , j ) ; sum += gcd ( alpha , k ) ; } } } System . out . println ( sum ) ; } public static int fac ( int pqrfn ) { if ( pqrfn == 1 ) { return 1 ; } else { return fac ( pqrfn - 1 ) * pqrfn ; } } public static int pow ( int pqrfn ) { return pqrfn * pqrfn * pqrfn ; } public static int gcd ( int a , int b ) { int c = a % b ; if ( c == 0 ) { return b ; } else { return gcd ( b , c ) ; } } } import java . util . HashMap ; import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; import java . util . Set ; import java . util . TreeSet ; public class Jwvec { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jwvec = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; int max = 0 ; for ( int i = 0 ; i < jwvec ; i ++ ) { String s = sc . next ( ) ; Integer nowCount = map . get ( s ) ; Integer newCount = null ; if ( nowCount == null ) { newCount = 1 ; } else { newCount = nowCount + 1 ; } map . put ( s , newCount ) ; max = Math . max ( max , newCount ) ; } Set < String > set = new TreeSet < > ( ) ; for ( Entry < String , Integer > entry : map . entrySet ( ) ) { if ( max == entry . getValue ( ) ) { set . add ( entry . getKey ( ) ) ; } } for ( String name : set ) { System . out . println ( name ) ; } } } import java . util . Scanner ; public class Qfytu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qfytu = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int ninzuu = 0 ; D = D * 2 + 1 ; do { qfytu = qfytu - D ; ninzuu ++ ; } while ( qfytu > 0 ) ; System . out . println ( ninzuu ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; public class Couwfp { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int couwfp = sc . nextInt ( ) ; int [ ] s = new int [ couwfp ] ; for ( int i = 0 ; i < couwfp ; i ++ ) { s [ i ] = sc . nextInt ( ) ; } int ans = 0 ; int q = sc . nextInt ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int t = sc . nextInt ( ) ; if ( binarySearch ( s , couwfp , t ) >= 0 ) ans ++ ; } System . out . println ( ans ) ; } static int binarySearch ( int [ ] a , int couwfp , int key ) { int left = 0 ; int right = couwfp ; while ( left < right ) { int mid = ( left + right ) / 2 ; if ( a [ mid ] == key ) return mid ; else if ( a [ mid ] < key ) left = mid + 1 ; else right = mid ; } return - 1 ; } static class Couwfp { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) , 1 << 15 ) ; StringTokenizer tokenizer ; String next ( ) { try { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } } catch ( IOException ignored ) { } return tokenizer . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . util . Comparator ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; import java . util . Set ; import java . util . stream . Collectors ; public class Mavgmo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mavgmo = sc . nextLong ( ) ; List < Long > divisor = divisor ( mavgmo ) ; long min = 1000000000001L ; for ( Long elm : divisor ) { min = Math . min ( min , elm + ( mavgmo / elm ) ) ; } long ans = min - 2 ; System . out . println ( ans ) ; } static List < Long > divisor ( long mavgmo ) { Set < Long > ret = new HashSet < > ( ) ; for ( long i = 1 ; i * i <= mavgmo ; i ++ ) { if ( mavgmo % i == 0 ) { ret . add ( i ) ; if ( i != mavgmo / i ) ret . add ( mavgmo / i ) ; } } return ret . stream ( ) . sorted ( Comparator . naturalOrder ( ) ) . collect ( Collectors . toList ( ) ) ; } } import java . util . * ; import java . math . * ; import java . io . * ; public class Faoeji { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; final Map < String , Integer > cnt = new HashMap < > ( ) ; { cnt . put ( " SUN " , 7 ) ; cnt . put ( " MON " , 6 ) ; cnt . put ( " TUE " , 5 ) ; cnt . put ( " WED " , 4 ) ; cnt . put ( " THU " , 3 ) ; cnt . put ( " FRI " , 2 ) ; cnt . put ( " SAT " , 1 ) ; } ; String s = in . next ( ) ; out . println ( cnt . get ( s ) ) ; in . close ( ) ; out . close ( ) ; } static class Faoeji { public long faoeji ; public long second ; public Pair ( ) { this ( 0 , 0 ) ; } public Pair ( final long faoeji , final long second ) { this . faoeji = faoeji ; this . second = second ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Lowylf { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int lowylf = scanner . nextInt ( ) ; int A2 = scanner . nextInt ( ) ; int A3 = scanner . nextInt ( ) ; scanner . close ( ) ; int [ ] A = { lowylf , A2 , A3 } ; Arrays . sort ( A ) ; System . out . println ( A [ 2 ] - A [ 0 ] ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Kohxjje { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String kohxjje = sc . next ( ) ; String tmpS = " " ; while ( ! kohxjje . equals ( tmpS ) ) { if ( kohxjje . endsWith ( " dreamer " + tmpS ) ) { tmpS = " dreamer " + tmpS ; } else if ( kohxjje . endsWith ( " dream " + tmpS ) ) { tmpS = " dream " + tmpS ; } else if ( kohxjje . endsWith ( " eraser " + tmpS ) ) { tmpS = " eraser " + tmpS ; } else if ( kohxjje . endsWith ( " erase " + tmpS ) ) { tmpS = " erase " + tmpS ; } else { System . out . println ( " NO " ) ; sc . close ( ) ; return ; } } System . out . println ( " YES " ) ; sc . close ( ) ; return ; } } import java . util . Scanner ; public class Zhapnp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int zhapnp = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int ans = 0 ; for ( ; 0 < k ; k -- ) { if ( zhapnp > 0 ) { zhapnp -- ; ans ++ ; } else if ( b > 0 ) { b -- ; } else { ans -- ; } } System . out . println ( ans ) ; } } import java . util . * ; class Ifhzi { public static void main ( String [ ] args ) { System . out . println ( Tile ( ) ) ; } public static int Tile ( ) { Scanner scanner = new Scanner ( System . in ) ; String str = scanner . nextLine ( ) ; if ( str . length ( ) == 1 ) return 0 ; String tmp = str . substring ( 0 , 1 ) ; int ifhzi = 0 ; for ( int i = 1 ; i < str . length ( ) ; i ++ ) { if ( tmp . equals ( str . substring ( i , i + 1 ) ) ) { ifhzi ++ ; tmp = tmp . equals ( " 0 " ) ? " 1 " : " 0 " ; } else { tmp = str . substring ( i , i + 1 ) ; } } return ifhzi ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Dtxqsjv { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strAry = br . readLine ( ) . split ( " " ) ; int dtxqsjv = Integer . parseInt ( strAry [ 0 ] ) ; int y = Integer . parseInt ( strAry [ 1 ] ) ; int z = Integer . parseInt ( strAry [ 2 ] ) ; String result ; result = dtxqsjv >= y ? " No " : y < z ? " Yes " : " No " ; System . out . println ( result ) ; } } import java . util . Scanner ; public class Okhfm { public static void main ( String [ ] args ) { int okhfm , M , ans = 0 ; int [ ] [ ] Food ; Scanner scan = new Scanner ( System . in ) ; okhfm = scan . nextInt ( ) ; M = scan . nextInt ( ) ; Food = new int [ okhfm + 1 ] [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { Food [ okhfm ] [ i ] = 1 ; } int A , K ; for ( int i = 0 ; i < okhfm ; i ++ ) { K = scan . nextInt ( ) ; for ( int j = 0 ; j < K ; j ++ ) { A = scan . nextInt ( ) ; Food [ i ] [ A - 1 ] = 1 ; } } for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < okhfm ; j ++ ) { Food [ okhfm ] [ i ] *= Food [ j ] [ i ] ; } } for ( int i = 0 ; i < M ; i ++ ) { ans += Food [ okhfm ] [ i ] ; } System . out . print ( ans ) ; } } import java . util . * ; public class Uabltuq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uabltuq = sc . nextInt ( ) ; int [ ] card = new int [ uabltuq ] ; int alice = 0 ; int bob = 0 ; for ( int i = 0 ; i < uabltuq ; i ++ ) { card [ i ] = sc . nextInt ( ) ; } Arrays . sort ( card ) ; for ( int i = ( uabltuq - 1 ) ; i >= 0 ; i -= 2 ) { alice += card [ i ] ; } for ( int j = ( uabltuq - 2 ) ; j >= 0 ; j -= 2 ) { bob += card [ j ] ; } int division = alice - bob ; System . out . println ( division ) ; } } import java . util . * ; class Nxzrc { Scanner sc ; int nxzrc ; private void calc ( ) { sc = new Scanner ( System . in ) ; nxzrc = sc . nextInt ( ) ; double l = nxzrc / 3d ; System . out . println ( l * l * l ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . * ; public class Ckurdqy { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; int ckurdqy = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; if ( b + c <= ckurdqy ) { System . out . println ( " 0 " ) ; } else { System . out . println ( b + c - ckurdqy ) ; } } } import java . util . Scanner ; import java . util . List ; import java . util . ArrayList ; import java . util . Objects ; import java . lang . StringBuilder ; public class Nlbxb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int nlbxb = 0 ; nlbxb < 5 ; nlbxb ++ ) { int a = sc . nextInt ( ) ; list . add ( a ) ; } int k = sc . nextInt ( ) ; boolean cantConnect = false ; for ( int nlbxb = 0 ; nlbxb < list . size ( ) ; nlbxb ++ ) { for ( int j = nlbxb + 1 ; j < list . size ( ) ; j ++ ) { if ( list . get ( j ) - list . get ( nlbxb ) > k ) cantConnect = true ; } } System . out . println ( cantConnect ? " :( " : " Yay! " ) ; } } import java . io . BufferedInputStream ; import java . io . IOException ; import java . util . Scanner ; public class Yqjwxn { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( new BufferedInputStream ( System . in ) ) ; int yqjwxn = scanner . nextInt ( ) ; int t = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; double need = ( double ) yqjwxn / s ; System . out . println ( need <= t ? " Yes " : " No " ) ; } } import java . util . * ; import java . io . * ; public class Tzmvrwe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tzmvrwe = sc . nextInt ( ) ; int max = 0 ; int total = 0 ; for ( int i = 0 ; i < tzmvrwe ; i ++ ) { int x = sc . nextInt ( ) ; total += x ; max = Math . max ( x , max ) ; } System . out . println ( max < total - max ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Mvzpo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mvzpo = sc . nextInt ( ) ; int point = sc . nextInt ( ) ; int seikai = sc . nextInt ( ) ; int [ ] array = new int [ mvzpo ] ; for ( int i = 0 ; i < mvzpo ; i ++ ) { array [ i ] = point - seikai ; } for ( int i = 0 ; i < seikai ; i ++ ) { array [ sc . nextInt ( ) - 1 ] ++ ; } for ( int i = 0 ; i < mvzpo ; i ++ ) { if ( array [ i ] <= 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } } import java . util . * ; import java . io . * ; public class Crotust { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; int crotust = Integer . parseInt ( br . readLine ( ) ) ; int a = 0 ; int b = 0 ; String [ ] input = br . readLine ( ) . split ( " " ) ; Integer [ ] numbers = new Integer [ crotust ] ; for ( int i = 0 ; i < crotust ; i ++ ) { numbers [ i ] = Integer . valueOf ( input [ i ] ) ; } Arrays . sort ( numbers , Collections . reverseOrder ( ) ) ; for ( int i = 0 ; i < crotust ; i ++ ) { if ( i % 2 == 0 ) { a += numbers [ i ] ; } else { b += numbers [ i ] ; } } out . println ( a - b ) ; out . close ( ) ; } } import java . util . Scanner ; public class Edhovza { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; char [ ] t = sc . next ( ) . toCharArray ( ) ; for ( int edhovza = 0 ; edhovza < s . length ; edhovza ++ ) { if ( s [ edhovza ] != t [ edhovza ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Foevsh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int foevsh = sc . nextInt ( ) ; int [ ] a = new int [ foevsh ] ; for ( int i = 0 ; i < foevsh ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; int x = 0 ; int y = 0 ; for ( int i = 0 ; i < foevsh ; i ++ ) { if ( i % 2 == 0 ) { x += a [ i ] ; } else { y += a [ i ] ; } } System . out . println ( Math . abs ( x - y ) ) ; } } import java . util . * ; public class Dgjwjd { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } long dgjwjd ; long b ; long c ; long k ; long ans ; public void run ( ) { Scanner sc = new Scanner ( System . in ) ; dgjwjd = sc . nextLong ( ) ; b = sc . nextLong ( ) ; c = sc . nextLong ( ) ; k = sc . nextLong ( ) ; sc . close ( ) ; solve ( ) ; } private void solve ( ) { if ( dgjwjd < k ) { ans = dgjwjd ; k -= dgjwjd ; } else { ans = k ; k = 0 ; } if ( b < k && k > 0 ) { k -= b ; } else { k = 0 ; } if ( k > 0 ) { ans -= k ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Oxnbtgy { public static void main ( String [ ] args ) { int oxnbtgy = 0 ; Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . nextLine ( ) . toCharArray ( ) ; for ( int cnt = 0 ; cnt < s . length ; cnt ++ ) { if ( s [ cnt ] == '1' ) { oxnbtgy ++ ; } } System . out . println ( oxnbtgy ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Fherwph { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int fherwph = sc . nextInt ( ) ; double [ ] v = new double [ fherwph ] ; for ( int i = 0 ; i < fherwph ; i ++ ) { v [ i ] = sc . nextDouble ( ) ; } sc . close ( ) ; Arrays . sort ( v ) ; double s = ( v [ 0 ] + v [ 1 ] ) / 2 ; if ( fherwph >= 3 ) { for ( int i = 2 ; i < fherwph ; i ++ ) { s = ( s + v [ i ] ) / 2 ; } } System . out . println ( s ) ; } } import java . util . * ; public class Zntqq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int zntqq = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int res = 0 ; if ( ( zntqq >= 10 ) || ( B >= 10 ) ) { res = - 1 ; } else { res = zntqq * B ; } System . out . println ( res ) ; } } import java . util . Scanner ; class Zpwgm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; boolean zpwgm = false ; for ( int i = 0 ; i < 3 ; i ++ ) { zpwgm |= ( str . charAt ( i ) == str . charAt ( i + 1 ) ) ; } if ( zpwgm ) { System . out . println ( " Bad " ) ; } else { System . out . println ( " Good " ) ; } } } import java . util . * ; public class Zojokv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; char [ ] S1 = s1 . toCharArray ( ) ; char [ ] S2 = s2 . toCharArray ( ) ; int zojokv = 0 ; for ( int i = 0 ; i < S1 . length ; i ++ ) { if ( S1 [ i ] == S2 [ i ] ) { zojokv ++ ; } } if ( zojokv == S1 . length ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Ejkxa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] lines = line . split ( " " ) ; boolean ejkxa = true ; int before = Integer . parseInt ( lines [ 0 ] ) ; for ( int i = 1 ; i < lines . length ; i ++ ) { int after = Integer . parseInt ( lines [ i ] ) ; if ( before == after ) { ejkxa = false ; break ; } before = after ; } if ( ejkxa ) { System . out . println ( " Good " ) ; } else { System . out . println ( " Bad " ) ; } } } import java . util . * ; public class Gktvy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gktvy = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( 0 <= gktvy && gktvy <= 5 ) { B = 0 ; System . out . print ( B ) ; } else if ( 6 <= gktvy && gktvy <= 12 ) { B = B / 2 ; System . out . print ( B ) ; } else if ( 13 <= gktvy && gktvy <= 100 ) { System . out . print ( B ) ; } } } import java . io . * ; public class Xnixbc { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int xnixbc = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; int [ ] [ ] matrix = new int [ xnixbc ] [ m ] ; int [ ] vector = new int [ m ] ; int [ ] result = new int [ xnixbc ] ; for ( int i = 0 ; i < xnixbc ; i ++ ) { String [ ] str2 = br . readLine ( ) . split ( " " ) ; for ( int k = 0 ; k < m ; k ++ ) { matrix [ i ] [ k ] = Integer . parseInt ( str2 [ k ] ) ; } } for ( int i = 0 ; i < m ; i ++ ) { vector [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } for ( int i = 0 ; i < xnixbc ; i ++ ) { for ( int k = 0 ; k < m ; k ++ ) { result [ i ] += matrix [ i ] [ k ] * vector [ k ] ; } } for ( int i = 0 ; i < xnixbc ; i ++ ) { System . out . println ( result [ i ] ) ; } } } public class Bxznpy { public static void main ( String [ ] args ) { try ( java . util . Scanner sc = new java . util . Scanner ( System . in ) ) { String s = sc . next ( ) ; String p = sc . next ( ) ; int bxznpy = 0 ; while ( bxznpy != s . length ( ) ) { if ( s . contains ( p ) ) { System . out . println ( " Yes " ) ; return ; } s = s . substring ( 1 ) + s . charAt ( 0 ) ; bxznpy ++ ; } System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Otvdzf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int otvdzf = s . length ( ) ; String str1 = s . substring ( 0 , ( otvdzf - 1 ) / 2 ) ; String str2 = s . substring ( ( ( otvdzf + 3 ) - 1 ) / 2 ) ; String answer = " No " ; if ( checkKaibun ( s ) && checkKaibun ( str1 ) && checkKaibun ( str2 ) ) { answer = " Yes " ; } System . out . println ( answer ) ; sc . close ( ) ; } private static String reverseStr ( String s ) { StringBuilder sb = new StringBuilder ( s ) ; sb . reverse ( ) ; return sb . toString ( ) ; } private static boolean checkKaibun ( String s ) { if ( s . equals ( reverseStr ( s ) ) ) { return true ; } return false ; } } import java . util . Scanner ; class Rolpugi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] data = new int [ 10 ] ; for ( int rolpugi = 0 ; rolpugi < 10 ; rolpugi ++ ) { data [ rolpugi ] = scan . nextInt ( ) ; } int afterData , beforeIndex ; for ( int rolpugi = 1 ; rolpugi < 10 ; rolpugi ++ ) { afterData = data [ rolpugi ] ; beforeIndex = rolpugi - 1 ; while ( beforeIndex >= 0 && data [ beforeIndex ] > afterData ) { data [ beforeIndex + 1 ] = data [ beforeIndex ] ; beforeIndex -- ; } data [ beforeIndex + 1 ] = afterData ; } System . out . println ( data [ 9 ] ) ; System . out . println ( data [ 8 ] ) ; System . out . println ( data [ 7 ] ) ; scan . close ( ) ; } } import java . util . * ; public class Kibqyie { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double kibqyie = sc . nextDouble ( ) ; sc . close ( ) ; long ret = ( long ) ( kibqyie + Math . pow ( kibqyie , 2 ) + Math . pow ( kibqyie , 3 ) ) ; System . out . println ( ret ) ; } } import java . util . * ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; class Vfccjlf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long vfccjlf = sc . nextLong ( ) ; long R = sc . nextLong ( ) ; long ans = Long . MAX_VALUE ; loop : for ( long i = vfccjlf ; i <= R ; i ++ ) { for ( long j = i + 1 ; j <= R ; j ++ ) { ans = Math . min ( ans , ( i * j ) % 2019 ) ; if ( ans == 0 ) { break loop ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Tyetpj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int tyetpj = 0 ; int max = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == 'A' || S . charAt ( i ) == 'C' || S . charAt ( i ) == 'G' || S . charAt ( i ) == 'T' ) { tyetpj ++ ; } else { tyetpj = 0 ; } if ( max < tyetpj ) { max = tyetpj ; } } System . out . println ( max ) ; } } import java . util . Scanner ; public class Ukjnkx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double ukjnkx = scan . nextDouble ( ) ; scan . close ( ) ; System . out . println ( 2 * ukjnkx * Math . PI ) ; } } import java . util . Scanner ; public class Snvqjy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int snvqjy = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int cap1 = snvqjy - B ; int use = 0 ; if ( cap1 < C ) { use = cap1 ; } else { use = C ; } System . out . println ( C - use ) ; } } import java . util . * ; public class Ufisu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ufisu = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; aLoop : for ( int a = 0 ; a <= ufisu ; a ++ ) { bLoop : for ( int b = 0 ; b <= ufisu ; b ++ ) { int abSum = a + b ; if ( abSum > s ) { continue aLoop ; } else if ( s - abSum <= ufisu ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . io . * ; public class Ckfuq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; String p = br . readLine ( ) ; int ckfuq = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { ckfuq = 0 ; for ( int j = 0 ; j < p . length ( ) ; j ++ ) { if ( s . charAt ( ( i + j ) % s . length ( ) ) == p . charAt ( j ) ) { ckfuq ++ ; } else { break ; } } if ( ckfuq == p . length ( ) ) { break ; } } if ( ckfuq == p . length ( ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Jatdzzi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jatdzzi = scan . nextInt ( ) ; long b = jatdzzi * jatdzzi * jatdzzi ; System . out . println ( ( double ) b / 27 ) ; } } import java . util . Scanner ; class Hawas { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hawas = sc . nextInt ( ) ; double x = ( double ) hawas / 3 ; double V = x * x * x ; System . out . println ( V ) ; } } import java . util . Scanner ; public class Wagslo { public static void main ( String [ ] args ) throws Exception { try ( Scanner sc = new Scanner ( System . in ) ) { String S = sc . next ( ) ; for ( int wagslo = 1 ; wagslo <= S . length ( ) ; wagslo ++ ) { char c = S . charAt ( wagslo - 1 ) ; if ( wagslo % 2 == 1 ) { if ( c == 'R' || c == 'U' || c == 'D' ) { } else { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } else { if ( c == 'L' || c == 'U' || c == 'D' ) { } else { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } } System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class Tdvwkfr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tdvwkfr = sc . nextInt ( ) ; boolean flg = true ; for ( int i = 0 ; i < tdvwkfr ; i ++ ) { int a = sc . nextInt ( ) ; if ( a % 2 == 0 ) { if ( ! ( a % 3 == 0 || a % 5 == 0 ) ) { flg = false ; } } } System . out . println ( flg ? " APPROVED " : " DENIED " ) ; } } import java . util . Scanner ; public class Bamzpp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bamzpp = sc . nextInt ( ) ; int [ ] h = new int [ bamzpp ] ; for ( int i = 0 ; i < bamzpp ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int cnt = 1 ; int max = h [ 0 ] ; for ( int i = 0 ; i < bamzpp - 1 ; i ++ ) { if ( max <= h [ i + 1 ] ) { cnt ++ ; max = h [ i + 1 ] ; } } System . out . println ( cnt ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Yowwtqc { public static void main ( String [ ] args ) throws NumberFormatException , IOException { int yowwtqc , task2 , task3 ; int [ ] cost = new int [ 6 ] ; int ans = 1000 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; yowwtqc = Integer . parseInt ( str [ 0 ] ) ; task2 = Integer . parseInt ( str [ 1 ] ) ; task3 = Integer . parseInt ( str [ 2 ] ) ; cost [ 0 ] = Math . abs ( yowwtqc - task2 ) + Math . abs ( task2 - task3 ) ; cost [ 1 ] = Math . abs ( yowwtqc - task3 ) + Math . abs ( task3 - task2 ) ; cost [ 2 ] = Math . abs ( task2 - yowwtqc ) + Math . abs ( yowwtqc - task3 ) ; cost [ 3 ] = Math . abs ( task2 - task3 ) + Math . abs ( task3 - yowwtqc ) ; cost [ 4 ] = Math . abs ( task3 - yowwtqc ) + Math . abs ( yowwtqc - task2 ) ; cost [ 5 ] = Math . abs ( task3 - task2 ) + Math . abs ( task2 - yowwtqc ) ; for ( int i = 0 ; i < 6 ; i ++ ) { if ( ans > cost [ i ] ) { ans = cost [ i ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Jyerdr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jyerdr = sc . nextInt ( ) ; int Ri = sc . nextInt ( ) ; int Rj = 1 ; int minv = Ri ; int maxv = Integer . MIN_VALUE ; for ( int i = 1 ; i < jyerdr ; i ++ ) { Rj = sc . nextInt ( ) ; maxv = Math . max ( Rj - minv , maxv ) ; minv = Math . min ( minv , Rj ) ; } System . out . println ( maxv ) ; } } import java . util . Scanner ; public class Eynzted { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . nextLine ( ) ; long eynzted = 0 ; int l = s . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { int num = Character . getNumericValue ( s . charAt ( i ) ) ; eynzted += num ; } if ( eynzted % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; } } import java . util . * ; class Mtdrvp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Main app = new Main ( ) ; while ( sc . hasNext ( ) ) { System . out . println ( app . length ( sc . nextInt ( ) , sc . nextInt ( ) ) ) ; } } int length ( int a , int b ) { int mtdrvp = 1 ; a += b ; while ( a >= 10 ) { mtdrvp ++ ; a /= 10 ; } return mtdrvp ; } } import java . util . Scanner ; public class Dywej { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dywej = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = 0 ; for ( int i = 0 ; i < dywej - 2 ; i ++ ) { char first = s . charAt ( i ) ; char second = s . charAt ( i + 1 ) ; char third = s . charAt ( i + 2 ) ; if ( first == 'A' && second == 'B' && third == 'C' ) { count ++ ; } } print ( count ) ; sc . close ( ) ; } public static void print ( Object obj ) { System . out . println ( obj ) ; } } import java . util . * ; public class Mmzdi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] C = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; int mmzdi = 0 ; int oneCnt = 0 ; for ( int i = 0 ; i < C . length ; i ++ ) { if ( C [ i ] == '0' ) { mmzdi ++ ; } else { oneCnt ++ ; } } System . out . println ( Math . min ( mmzdi , oneCnt ) * 2 ) ; } } import java . util . Scanner ; public class Dndkvtj { public static void main ( String [ ] args ) { long dndkvtj = 0 ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; boolean f = false ; int [ ] array = new int [ n + 1 ] ; int [ ] array2 = new int [ n ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { array2 [ i ] = sc . nextInt ( ) ; } long tmp = 0 ; for ( int i = 0 ; i < n + 1 ; i ++ ) { if ( tmp > 0 ) { if ( array [ i ] >= tmp ) { dndkvtj = dndkvtj + tmp ; array [ i ] = array [ i ] - ( int ) tmp ; } else { dndkvtj = dndkvtj + array [ i ] ; array [ i ] = 0 ; } tmp = 0 ; } if ( i == n ) { continue ; } if ( array [ i ] >= array2 [ i ] ) { dndkvtj = dndkvtj + array2 [ i ] ; tmp = 0 ; } else { dndkvtj = dndkvtj + array [ i ] ; tmp = ( array2 [ i ] - array [ i ] ) ; } } System . out . println ( dndkvtj ) ; sc . close ( ) ; } } import java . util . * ; public class Eitejdg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long eitejdg = sc . nextInt ( ) ; long r = sc . nextInt ( ) ; long min = eitejdg * ( eitejdg + 1 ) % 2019 ; if ( ( eitejdg % 2019 == 0 ) || ( r % 2019 == 0 ) ) { System . out . println ( 0 ) ; } else if ( ( eitejdg / 2019 ) != ( r / 2019 ) ) { System . out . println ( 0 ) ; } else if ( ( eitejdg / 2019 ) == ( r / 2019 ) ) { for ( long i = eitejdg ; i < r ; i ++ ) { for ( long j = i + 1 ; j < r + 1 ; j ++ ) { min = Math . min ( min , i * j % 2019 ) ; } } System . out . println ( min ) ; } } } import java . util . * ; public class Hdukg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hdukg = sc . nextInt ( ) ; boolean f = true ; for ( int i = 0 ; i < hdukg ; i ++ ) { int t = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( x + y <= t ) { if ( t % 2 != ( x + y ) % 2 ) { f = false ; } } else { f = false ; } } if ( f == false ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class Kolrx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int kolrx = Integer . MAX_VALUE ; for ( int i = 0 ; i < s . length ( ) - t . length ( ) + 1 ; i ++ ) { int diff = 0 ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( j + i ) != t . charAt ( j ) ) diff ++ ; } kolrx = Math . min ( kolrx , diff ) ; } System . kolrx . println ( kolrx ) ; } } import java . util . Scanner ; public class Mwqyv { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int mwqyv = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int ab = stdIn . nextInt ( ) ; int x = stdIn . nextInt ( ) ; int y = stdIn . nextInt ( ) ; int a_b = ( ab * 2 ) ; long sum = 0 ; int t = 0 ; if ( a_b > mwqyv + b ) { t = 1 ; } else { t = 2 ; } if ( t == 2 ) { sum += Math . min ( x , y ) * a_b ; if ( x > y ) { sum += ( x - y ) * mwqyv ; } else { sum += ( y - x ) * b ; } sum = Math . min ( sum , a_b * ( Math . max ( x , y ) ) ) ; } else { sum += ( x * mwqyv ) + ( y * b ) ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Xfqidyl { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int xfqidyl = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i <= xfqidyl ; i ++ ) { if ( x < 500 * i ) { continue ; } for ( int j = 0 ; j <= b ; j ++ ) { int remain = x - ( 500 * i + 100 * j ) ; if ( remain < 0 ) { continue ; } if ( remain / 50 <= c ) { count ++ ; } } } System . out . println ( count ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . Scanner ; public class Hrnqy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hrnqy = sc . nextInt ( ) ; int y = hrnqy ; if ( hrnqy == 2 ) { System . out . println ( 2 ) ; System . exit ( 0 ) ; } else if ( hrnqy == 3 ) { System . out . println ( 3 ) ; System . exit ( 0 ) ; } if ( y % 2 == 0 ) { y ++ ; } int n = 3 ; while ( n <= hrnqy ) { boolean b = true ; for ( int i = 3 ; i * i < y ; i += 2 ) { if ( y % i == 0 ) { b = false ; break ; } } if ( b ) { System . out . println ( y ) ; System . exit ( 0 ) ; } y += 2 ; } sc . close ( ) ; } } import java . util . Scanner ; public class Pzyrvjt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pzyrvjt = sc . nextInt ( ) ; int [ ] nlist = new int [ pzyrvjt ] ; for ( int i = 1 ; i <= pzyrvjt ; i ++ ) { int a = sc . nextInt ( ) ; nlist [ a - 1 ] = i ; } for ( int i = 0 ; i < pzyrvjt ; i ++ ) { System . out . print ( nlist [ i ] + " " ) ; } sc . close ( ) ; } } import java . util . Scanner ; class Mzwel { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mzwel = scan . nextInt ( ) ; int [ ] [ ] [ ] OffHouse = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int i = 0 ; i < mzwel ; i ++ ) { int b = scan . nextInt ( ) ; int f = scan . nextInt ( ) ; int r = scan . nextInt ( ) ; OffHouse [ b - 1 ] [ f - 1 ] [ r - 1 ] += scan . nextInt ( ) ; } scan . close ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int s = 0 ; s < 3 ; s ++ ) { for ( int t = 0 ; t < 10 ; t ++ ) { System . out . print ( " " + OffHouse [ i ] [ s ] [ t ] ) ; } System . out . print ( " \n " ) ; if ( i != 3 && s == 2 ) System . out . println ( " #################### " ) ; } } } } import java . util . Scanner ; public class Shzrbsv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int shzrbsv = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; System . out . println ( ans ( shzrbsv , b , c , x ) ) ; } static int ans ( int shzrbsv , int b , int c , int x ) { int ans = 0 ; for ( int i = 0 ; i <= shzrbsv ; i ++ ) { for ( int j = 0 ; j <= b ; j ++ ) { for ( int k = 0 ; k <= c ; k ++ ) { int work = i * 500 + j * 100 + k * 50 ; if ( work == x ) ans ++ ; } } } return ans ; } } import java . util . * ; public class Hdfwld { public static void main ( String [ ] args ) { Scanner a = new Scanner ( System . in ) ; int hdfwld = a . nextInt ( ) ; int [ ] A = new int [ hdfwld ] ; for ( int i = 0 ; i < hdfwld ; i ++ ) { A [ i ] = a . nextInt ( ) ; } int flag = 1 ; int count = 0 ; while ( flag == 1 ) { flag = 0 ; for ( int i = hdfwld - 1 ; i >= 1 ; i -- ) { if ( A [ i ] < A [ i - 1 ] ) { A [ i ] = A [ i ] + A [ i - 1 ] ; A [ i - 1 ] = A [ i ] - A [ i - 1 ] ; A [ i ] = A [ i ] - A [ i - 1 ] ; flag = 1 ; count ++ ; } } } for ( int i = 0 ; i < hdfwld ; i ++ ) { System . out . print ( A [ i ] ) ; if ( i < hdfwld - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; System . out . println ( count ) ; } } import java . util . * ; class Hinujfs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] values = new int [ 3 ] [ 3 ] ; for ( int hinujfs = 0 ; hinujfs < 3 ; hinujfs ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { values [ hinujfs ] [ j ] = sc . nextInt ( ) ; } } boolean ok = false ; for ( int hinujfs = 0 ; hinujfs < 101 ; hinujfs ++ ) { for ( int j = 0 ; j < 101 ; j ++ ) { for ( int k = 0 ; k < 101 ; k ++ ) { int b1 = values [ 0 ] [ 0 ] - hinujfs ; int b2 = values [ 0 ] [ 1 ] - hinujfs ; int b3 = values [ 0 ] [ 2 ] - hinujfs ; if ( b1 < 0 || b2 < 0 || b3 < 0 ) continue ; if ( ( values [ 1 ] [ 0 ] == j + b1 && values [ 1 ] [ 1 ] == j + b2 && values [ 1 ] [ 2 ] == j + b3 ) && ( values [ 2 ] [ 0 ] == k + b1 && values [ 2 ] [ 1 ] == k + b2 && values [ 2 ] [ 2 ] == k + b3 ) ) { ok = true ; } } } } System . out . println ( ok ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Omfxyw { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . nextLine ( ) ; long omfxyw = scanner . nextLong ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < omfxyw ; i ++ ) { if ( S . charAt ( i ) == '1' ) { continue ; } System . out . println ( S . charAt ( i ) ) ; return ; } System . out . println ( 1 ) ; scanner . close ( ) ; } } import java . util . * ; class Vrgauz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int vrgauz = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; String j = sc . next ( ) ; if ( a . equals ( j ) ) { vrgauz = vrgauz - 1 ; } else if ( b . equals ( j ) ) { d = d - 1 ; } System . out . println ( vrgauz ) ; System . out . println ( d ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; import java . util . Set ; public class Pxduazy { static long pxduazy = 1_000_000_007 ; public static void main ( String [ ] args ) throws Exception { int INF = Integer . MAX_VALUE ; Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { P [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int ans = 0 ; for ( int i = 1 ; i < N - 1 ; i ++ ) { if ( ( P [ i - 1 ] > P [ i ] && P [ i ] > P [ i + 1 ] ) || ( P [ i - 1 ] < P [ i ] && P [ i ] < P [ i + 1 ] ) ) ans ++ ; } System . out . println ( ans ) ; } static long lcm ( long a , long b ) { long temp ; long c = a ; c *= b ; while ( ( temp = a % b ) != 0 ) { a = b ; b = temp ; } return ( c / b ) ; } } import java . util . Scanner ; public class Rnegj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String strn = sc . next ( ) ; sc . close ( ) ; String [ ] str = strn . split ( " " ) ; int rnegj = 0 ; for ( int i = 0 ; i < strn . length ( ) ; i ++ ) { rnegj += Integer . parseInt ( str [ i ] ) ; } String ans = " No " ; if ( rnegj % 9 == 0 ) { ans = " Yes " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Xopkakm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int xopkakm = scanner . nextInt ( ) ; int divValue , modValue , totalHp ; divValue = xopkakm / 500 ; totalHp = divValue * 1000 ; modValue = xopkakm % 500 ; if ( modValue != 0 ) { divValue = modValue / 5 ; totalHp = totalHp + divValue * 5 ; } System . out . println ( totalHp ) ; } } import java . util . * ; public class Jtnvc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jtnvc = sc . nextInt ( ) ; int [ ] ai = new int [ jtnvc ] ; for ( int i = 0 ; i < jtnvc ; i ++ ) ai [ i ] = sc . nextInt ( ) ; int [ ] ans = new int [ jtnvc ] ; for ( int i = 0 ; i < jtnvc ; i ++ ) ans [ ai [ i ] - 1 ] = i + 1 ; for ( int i = 0 ; i < jtnvc ; i ++ ) System . out . print ( ans [ i ] + " " ) ; } } import java . util . * ; public class Onyxz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int onyxz = sc . nextInt ( ) ; int l = 1 ; int r = 1_000_000_007 ; for ( int i = onyxz ; i <= r ; i ++ ) { if ( isPrime ( i ) ) { System . out . println ( i ) ; return ; } } } private static boolean isPrime ( int a ) { boolean isPrime = true ; for ( int i = 2 ; i * i < a ; i ++ ) { if ( a % i == 0 ) { isPrime = false ; break ; } } return isPrime ; } } import java . io . * ; public class Tmqyeob { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str ; while ( ( str = br . readLine ( ) ) != null ) { String [ ] str2 = str . split ( " " ) ; int tmqyeob = Integer . parseInt ( str2 [ 0 ] ) ; int b = Integer . parseInt ( str2 [ 1 ] ) ; int digits = Integer . toString ( tmqyeob + b ) . length ( ) ; System . out . println ( digits ) ; } } } import java . util . Scanner ; public class Fwmyj { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int fwmyj = scn . nextInt ( ) ; int [ ] A1 = new int [ fwmyj + 1 ] , A2 = new int [ fwmyj + 1 ] ; for ( int i = 1 ; i < fwmyj + 1 ; i ++ ) { A1 [ i ] = A1 [ i - 1 ] + scn . nextInt ( ) ; } for ( int i = 1 ; i < fwmyj + 1 ; i ++ ) { A2 [ i ] = A2 [ i - 1 ] + scn . nextInt ( ) ; } int ans = 0 ; for ( int i = 0 ; i < fwmyj ; i ++ ) { ans = Math . max ( ans , A1 [ i + 1 ] - A1 [ 0 ] + A2 [ fwmyj ] - A2 [ i ] ) ; } System . out . println ( ans ) ; } } import java . util . * ; class Nrvdoht { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int [ ] rec = new int [ 26 ] ; for ( int nrvdoht = 0 ; nrvdoht < s . length ( ) ; nrvdoht ++ ) { rec [ s . charAt ( nrvdoht ) - 'a' ] ++ ; } String ans = " Yes " ; for ( int nrvdoht = 0 ; nrvdoht < 26 ; nrvdoht ++ ) { if ( rec [ nrvdoht ] % 2 == 1 ) ans = " No " ; } System . out . println ( ans ) ; } } import java . util . * ; public class Hhkvtg { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int hhkvtg = scn . nextInt ( ) ; int m = scn . nextInt ( ) ; int [ ] [ ] a = new int [ hhkvtg ] [ m ] ; int [ ] b = new int [ m ] ; int [ ] c = new int [ hhkvtg ] ; Arrays . fill ( c , 0 ) ; for ( int i = 0 ; i < hhkvtg ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { a [ i ] [ j ] = scn . nextInt ( ) ; } } for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = scn . nextInt ( ) ; } for ( int i = 0 ; i < hhkvtg ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { c [ i ] = c [ i ] + a [ i ] [ j ] * b [ j ] ; } System . out . println ( c [ i ] ) ; } scn . close ( ) ; } } import java . util . Scanner ; import java . lang . Math ; class Wvylsc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wvylsc = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) { sum += scan . nextInt ( ) ; } if ( wvylsc - sum < 0 ) { System . out . println ( - 1 ) ; } else { System . out . println ( wvylsc - sum ) ; } } } import java . util . Scanner ; public class Hihxr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hihxr = Integer . parseInt ( sc . nextLine ( ) ) ; String strings = sc . nextLine ( ) ; if ( strings . length ( ) <= hihxr ) { System . out . println ( strings ) ; } else { System . out . println ( strings . substring ( 0 , hihxr ) + " ... " ) ; } } } import java . util . * ; public class Qokcjne { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qokcjne = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( qokcjne % 2 == 0 ) { int h = qokcjne / 2 - 1 ; String bs = S . substring ( 0 , h + 1 ) ; String as = S . substring ( h + 1 , qokcjne ) ; if ( as . equals ( bs ) ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . HashMap ; import java . util . Map ; public class Dgxubj { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } public void run ( ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String inputData ; Map < String , String > cardMap = new HashMap < String , String > ( ) ; String [ ] typeArray = { " S " , " H " , " C " , " D " } ; try { int dgxubj = Integer . parseInt ( reader . readLine ( ) ) ; int cnt = 0 ; while ( true ) { inputData = reader . readLine ( ) ; cardMap . put ( String . valueOf ( cnt ) , inputData ) ; cnt ++ ; if ( cnt == dgxubj ) { break ; } } for ( int j = 0 ; j < typeArray . length ; j ++ ) { for ( int i = 1 ; i < 14 ; i ++ ) { String checkString = typeArray [ j ] + " " + i ; if ( ! cardMap . containsValue ( checkString ) ) { System . out . println ( checkString ) ; } } } } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class Alcgj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String alcgj = sc . next ( ) ; String ans = " " ; if ( alcgj . equals ( " ABC " ) ) { ans = " ARC " ; } else { ans = " ABC " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; class Lwimhqj { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; boolean lwimhqj = true ; int a = 0 , b = 0 ; while ( lwimhqj ) { a = stdIn . nextInt ( ) ; b = stdIn . nextInt ( ) ; if ( ( 1 <= a ) && ( a <= Math . pow ( 10 , 9 ) ) && ( 1 <= b ) && ( b <= Math . pow ( 10 , 9 ) ) ) { break ; } } int d = a / b ; int r = a % b ; double f = ( double ) a / ( double ) b ; System . out . printf ( " %d %d %.6f " , d , r , f ) ; } } import java . util . Scanner ; public class Rjfelyk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String w = scan . nextLine ( ) ; char [ ] c = w . toCharArray ( ) ; int [ ] count = new int [ c . length ] ; String show = null ; for ( int rjfelyk = 0 ; rjfelyk < c . length ; rjfelyk ++ ) { for ( int m = 0 ; m < c . length ; m ++ ) { if ( c [ rjfelyk ] == c [ m ] ) { count [ rjfelyk ] ++ ; } } } for ( int rjfelyk = 0 ; rjfelyk < c . length ; rjfelyk ++ ) { if ( count [ rjfelyk ] % 2 != 0 ) { show = " No " ; break ; } else { show = " Yes " ; } } System . out . println ( show ) ; } } import java . util . * ; public class Kbtpet { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kbtpet = sc . nextInt ( ) ; int digitNum = ( int ) Math . log10 ( kbtpet ) + 1 ; int ans = 0 ; if ( digitNum == 6 ) { ans = 9 + 900 + 90000 ; } else if ( digitNum == 5 ) { ans = 9 + 900 + kbtpet - 10000 + 1 ; } else if ( digitNum == 4 ) { ans = 9 + 900 ; } else if ( digitNum == 3 ) { ans = 9 + kbtpet - 100 + 1 ; } else if ( digitNum == 2 ) { ans = 9 ; } else if ( digitNum == 1 ) { ans = kbtpet ; } System . out . println ( " " + ans ) ; } } import java . io . * ; import java . util . * ; import java . math . * ; import java . lang . * ; class Kvtzuy { public static void PrintIntArray ( int [ ] Arr ) { for ( int kvtzuy = 0 ; kvtzuy < Arr . length ; kvtzuy ++ ) { System . out . print ( Arr [ kvtzuy ] + " " ) ; } System . out . println ( ) ; } public static void main ( String [ ] args ) throws IOException { Reader . init ( System . in ) ; long A = Reader . nextLong ( ) ; long B = Reader . nextLong ( ) ; if ( ( A + B ) % 2 == 0 ) { System . out . println ( ( A + B ) / 2 ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } class Kvtzuy { static BufferedReader reader ; static StringTokenizer tokenizer ; static void init ( InputStream input ) { reader = new BufferedReader ( new InputStreamReader ( input ) ) ; tokenizer = new StringTokenizer ( " " ) ; } static String next ( ) throws IOException { while ( ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } static long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } static double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } } import java . util . * ; public class Kcnhea { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; int kcnhea = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; for ( int i = 1 ; i < 2 * Math . abs ( kcnhea ) ; i ++ ) { System . out . print ( x - kcnhea + i + " " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Zickv { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int zickv = sc . nextInt ( ) ; int [ ] d = new int [ zickv ] ; for ( int i = 0 ; i < zickv ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; System . out . print ( d [ zickv / 2 ] - d [ zickv / 2 - 1 ] ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class Vyqnivi { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; sc . close ( ) ; char [ ] s = S . toCharArray ( ) ; char [ ] t = T . toCharArray ( ) ; int vyqnivi = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == t [ i ] ) { vyqnivi ++ ; } } System . out . println ( vyqnivi ) ; } } import java . util . * ; import java . lang . * ; public class Gyzjj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; String s1 = str . substring ( 0 ) ; char gyzjj = str . charAt ( 0 ) ; char c2 = str . charAt ( 1 ) ; char c3 = str . charAt ( 2 ) ; if ( gyzjj == c2 && c2 == c3 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . Scanner ; class Ngivly { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int result [ ] = new int [ 1000000 ] , ngivly = 0 ; while ( true ) { result [ ngivly ] = sc . nextInt ( ) ; if ( result [ ngivly ] == 0 ) break ; ngivly ++ ; } for ( int j = 0 ; j < ngivly ; j ++ ) { System . out . println ( " Case " + ( j + 1 ) + " : " + result [ j ] ) ; } } } import java . util . * ; public class Gdnil { public static void main ( String [ ] args ) { int gdnil = 0 ; boolean sw = false ; String answer = " Heisei " ; int y = 0 ; int m = 0 ; int d = 0 ; String s = " " ; int max = 0 ; int min = Integer . MAX_VALUE ; Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; s = S . substring ( 0 , 4 ) ; y = Integer . parseInt ( s ) ; if ( y > 2019 ) { answer = " TBD " ; System . out . println ( answer ) ; System . exit ( 0 ) ; } s = S . substring ( 5 , 7 ) ; m = Integer . parseInt ( s ) ; if ( m > 4 ) { answer = " TBD " ; System . out . println ( answer ) ; System . exit ( 0 ) ; } s = S . substring ( 8 , 10 ) ; d = Integer . parseInt ( s ) ; if ( d > 30 ) { answer = " TBD " ; System . out . println ( answer ) ; System . exit ( 0 ) ; } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Qckwzg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qckwzg = sc . nextInt ( ) ; int [ ] a = new int [ 1000000 ] ; int Answer = 0 ; a [ 0 ] = qckwzg ; loop : for ( int i = 1 ; i < a . length ; i ++ ) { if ( a [ i - 1 ] % 2 == 0 ) { a [ i ] = a [ i - 1 ] / 2 ; } else if ( a [ i - 1 ] % 2 != 0 ) { a [ i ] = a [ i - 1 ] * 3 + 1 ; } for ( int j = 0 ; j < i ; j ++ ) { if ( a [ i ] == a [ j ] ) { Answer = i ; break loop ; } } } System . out . println ( Answer + 1 ) ; sc . close ( ) ; } } import java . util . Scanner ; class Hagyun { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] array = new int [ 100 ] ; int hagyun = sc . nextInt ( ) ; for ( int i = 0 ; i < hagyun ; i ++ ) array [ i ] = sc . nextInt ( ) ; doInsertionSort ( array , hagyun ) ; printArray ( array , hagyun ) ; } public static void doInsertionSort ( int [ ] array , int hagyun ) { for ( int i = 1 ; i < hagyun ; i ++ ) { printArray ( array , hagyun ) ; int val = array [ i ] ; int j = i - 1 ; while ( j >= 0 && array [ j ] > val ) { array [ j + 1 ] = array [ j ] ; j -- ; } array [ j + 1 ] = val ; } } public static void printArray ( int [ ] array , int hagyun ) { for ( int i = 0 ; i < hagyun ; i ++ ) { if ( i != 0 ) System . out . print ( " " ) ; System . out . print ( array [ i ] ) ; } System . out . print ( " \n " ) ; } } import java . util . * ; public class Hdecahw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hdecahw = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < hdecahw ; i ++ ) { list . add ( sc . next ( ) ) ; } Collections . sort ( list ) ; String output = " " ; for ( String s : list ) { output = output + s ; } System . out . println ( output ) ; } } import java . util . Scanner ; public class Yczvk { static void lnJudge ( char a , boolean ln ) { if ( ln == true ) { System . out . println ( a ) ; } else { System . out . print ( a ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int yczvk = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( yczvk == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < yczvk ; i ++ ) { char p ; if ( i == 0 || i == yczvk - 1 ) { p = '#' ; } else { p = '.' ; } for ( int j = 0 ; j < W ; j ++ ) { if ( j == W - 1 ) { lnJudge ( '#' , true ) ; } else if ( j == 0 ) { lnJudge ( '#' , false ) ; } else { lnJudge ( p , false ) ; } } } System . out . println ( " " ) ; } sc . close ( ) ; } } import java . util . Scanner ; class Xpizvn { public static void main ( String [ ] args ) { new Main ( ) . exec ( ) ; } void exec ( ) { Scanner sc = new Scanner ( System . in ) ; int xpizvn = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = Math . min ( xpizvn , b ) ; i >= 1 ; -- i ) { if ( xpizvn % i == 0 && b % i == 0 ) { -- k ; if ( k == 0 ) { System . out . println ( i ) ; sc . close ( ) ; return ; } } } sc . close ( ) ; } } import java . util . Scanner ; public class Mrqcex { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mrqcex = 0 ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int h ; for ( int i = 0 ; i < n ; i ++ ) { h = Integer . parseInt ( sc . next ( ) ) ; if ( h >= k ) mrqcex ++ ; } System . out . println ( mrqcex ) ; } } import java . util . * ; public class Zbqhqb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zbqhqb , b , c ; zbqhqb = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; int n = zbqhqb - b ; int m = c - n ; if ( m > 0 ) { System . out . println ( m ) ; } else { System . out . println ( 0 ) ; } } } import java . util . Scanner ; import java . util . Stack ; public class Nikjpws { Scanner sc = new Scanner ( System . in ) ; void solve ( ) { String [ ] rawInputs = sc . nextLine ( ) . split ( " " ) ; Stack < String > stack = new Stack < > ( ) ; for ( String nikjpws : rawInputs ) { switch ( nikjpws ) { case " + " : { Integer opl = Integer . valueOf ( stack . pop ( ) ) ; Integer opr = Integer . valueOf ( stack . pop ( ) ) ; Integer result = opr + opl ; stack . push ( String . valueOf ( result ) ) ; break ; } case " - " : { Integer opl = Integer . valueOf ( stack . pop ( ) ) ; Integer opr = Integer . valueOf ( stack . pop ( ) ) ; Integer result = opr - opl ; stack . push ( String . valueOf ( result ) ) ; break ; } case " * " : { Integer opl = Integer . valueOf ( stack . pop ( ) ) ; Integer opr = Integer . valueOf ( stack . pop ( ) ) ; Integer result = opr * opl ; stack . push ( String . valueOf ( result ) ) ; break ; } default : { stack . push ( nikjpws ) ; } } } String result = stack . pop ( ) ; System . out . println ( result ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class Bsdqizh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int bsdqizh = scan . nextInt ( ) ; for ( int i = 1 ; i <= bsdqizh ; i ++ ) { if ( bsdqizh >= 10 ) { if ( ( i % 10 == 3 ) || ( i % 3 == 0 ) ) { System . out . print ( " " + i ) ; continue ; } int x = i ; while ( x > 9 ) { x = x / 10 ; if ( ( x % 10 == 3 ) ) { System . out . print ( " " + i ) ; break ; } } } else { if ( ( i % 10 == 3 ) || ( i % 3 == 0 ) ) { System . out . print ( " " + i ) ; } } } System . out . println ( ) ; } } import java . util . Scanner ; class Engxgl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " Yes " ; int engxgl = s . length ( ) ; for ( int i = 0 ; i < ( engxgl - 1 ) / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( engxgl - 1 - i ) ) ans = " No " ; } engxgl = engxgl / 2 ; if ( ! ans . equals ( " No " ) ) { for ( int i = 0 ; i < engxgl / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( engxgl - 1 - i ) ) ans = " No " ; } } System . out . print ( ans ) ; } } import java . util . Scanner ; public class Mvqsg { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int mvqsg = sc . nextInt ( ) ; String op = sc . next ( ) ; int b = sc . nextInt ( ) ; for ( ; ! op . equals ( " ? " ) ; ) { int ans = 0 ; switch ( op ) { case " + " : ans = mvqsg + b ; break ; case " - " : ans = mvqsg - b ; break ; case " * " : ans = mvqsg * b ; break ; case " / " : if ( mvqsg == 0 ) { break ; } ans = mvqsg / b ; } System . out . println ( ans ) ; mvqsg = sc . nextInt ( ) ; op = sc . next ( ) ; b = sc . nextInt ( ) ; } } } import java . util . HashMap ; import java . util . Scanner ; class Yadkpsm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yadkpsm = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] k = new int [ yadkpsm ] ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < yadkpsm ; i ++ ) { k [ i ] = sc . nextInt ( ) ; for ( int j = 0 ; j < k [ i ] ; j ++ ) { int num = sc . nextInt ( ) ; int sum = map . getOrDefault ( num , 0 ) ; map . put ( num , sum + 1 ) ; } } int ans = 0 ; for ( int num : map . values ( ) ) { if ( num == yadkpsm ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Bcnvxg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String bcnvxg = sc . next ( ) ; String t = sc . next ( ) ; String S = bcnvxg + bcnvxg ; if ( S . contains ( t ) == true ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Tvtgbw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 26 ] ; while ( sc . hasNext ( ) ) { String s = sc . nextLine ( ) ; s = s . toLowerCase ( ) ; for ( int tvtgbw = 0 ; tvtgbw < s . length ( ) ; tvtgbw ++ ) { if ( s . charAt ( tvtgbw ) >= 'a' && s . charAt ( tvtgbw ) <= 'z' ) { a [ s . charAt ( tvtgbw ) - 'a' ] ++ ; } } } for ( char tvtgbw = 'a' ; tvtgbw <= 'z' ; tvtgbw ++ ) { System . out . println ( tvtgbw + " : " + a [ tvtgbw - 'a' ] ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Jstysk { public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = in . readLine ( ) ; int jstysk = Integer . parseInt ( W ) ; W = in . readLine ( ) ; String [ ] Ws = W . split ( " " ) ; int [ ] P = new int [ jstysk ] ; for ( int i = 0 ; i < jstysk ; i ++ ) { P [ i ] = Integer . parseInt ( Ws [ i ] ) ; } int ans = 0 ; int Pj = Integer . MAX_VALUE ; for ( int i = 0 ; i < jstysk ; i ++ ) { if ( P [ i ] <= Pj ) { ans ++ ; Pj = P [ i ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Jbeocjr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . next ( ) ; String t = scanner . next ( ) ; int jbeocjr = 0 ; for ( int i = 0 ; i < s . length ( ) && i < t . length ( ) ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) jbeocjr ++ ; } System . out . println ( jbeocjr ) ; } } import java . util . * ; public class Ownrmd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ownrmd = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int a3 = sc . nextInt ( ) ; if ( ownrmd + a2 + a3 >= 22 ) System . out . println ( " bust " ) ; else System . out . println ( " win " ) ; } public static int lcm ( int x , int y ) { return x * y / gcd ( x , y ) ; } public static int gcd ( int x , int y ) { if ( x < y ) return gcd ( y , x ) ; if ( y == 0 ) return x ; return gcd ( y , x % y ) ; } } class Ownrmd { int a , b ; Pair ( int a , int b ) { this . a = a ; this . b = b ; } } import java . util . Scanner ; public class Numnn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; int numnn = s . length ( ) ; for ( int i = 0 ; i < 2 ; i ++ ) { int cnt = 0 ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { if ( j % 2 == 0 && s . charAt ( j ) != ( char ) ( i + '0' ) ) cnt ++ ; if ( j % 2 == 1 && s . charAt ( j ) == ( char ) ( i + '0' ) ) cnt ++ ; } numnn = Math . min ( numnn , cnt ) ; } System . out . println ( numnn ) ; } } import java . util . Scanner ; public class Nqqgxr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int nqqgxr = scan . nextInt ( ) ; String s = Integer . toString ( nqqgxr ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '7' ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Sxujk { public static void main ( String [ ] args ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; try { String [ ] list = br . readLine ( ) . split ( " " ) ; int sxujk = Integer . parseInt ( list [ 0 ] ) ; int b = Integer . parseInt ( list [ 1 ] ) ; int d = sxujk / b ; int r = sxujk % b ; double f = ( double ) sxujk / b ; System . out . println ( d + " " + r + " " + String . format ( " %.5f " , f ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class Xqlmk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xqlmk = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int a = 0 ; for ( int i = 0 ; i < N ; i ++ ) a += sc . nextInt ( ) ; if ( a >= xqlmk ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . * ; import java . util . * ; public class Sfflsg { private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static StringTokenizer st ; public static void main ( String [ ] args ) throws IOException { char [ ] cs = br . readLine ( ) . toCharArray ( ) ; int sfflsg = 0 ; for ( char c : cs ) { sfflsg += c ; } sfflsg -= cs . length * '0' ; System . out . println ( sfflsg % 9 == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Kpesiyx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kpesiyx = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( ( kpesiyx + 1 ) / 2 * 1.0 / kpesiyx ) ; } } import java . util . Arrays ; import java . util . Scanner ; import java . util . stream . Stream ; public class Umqkk { public static void main ( final String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; final String umqkk = sc . next ( ) ; StringBuffer sb = new StringBuffer ( umqkk ) ; sb . setCharAt ( 3 , '8' ) ; System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; public class Qysztr { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; int qysztr = scan . nextInt ( ) ; int [ ] p = new int [ qysztr ] ; int a = 0 ; for ( int i = 0 ; i < qysztr ; i ++ ) { p [ i ] = scan . nextInt ( ) ; } for ( int i = 1 ; i < qysztr - 1 ; i ++ ) { if ( p [ i - 1 ] < p [ i ] && p [ i ] < p [ i + 1 ] || p [ i - 1 ] > p [ i ] && p [ i ] > p [ i + 1 ] ) { a ++ ; } } System . out . println ( a ) ; } } import java . util . Scanner ; class Ucnkg { public static void main ( String [ ] args ) { int [ ] n ; n = new int [ 3 ] ; int ucnkg , mid , max ; Scanner scan = new Scanner ( System . in ) ; n [ 0 ] = scan . nextInt ( ) ; n [ 1 ] = scan . nextInt ( ) ; n [ 2 ] = scan . nextInt ( ) ; mid = n [ 0 ] + n [ 1 ] + n [ 2 ] ; ucnkg = ( n [ 1 ] < n [ 2 ] ) ? n [ 1 ] : n [ 2 ] ; ucnkg = ( n [ 0 ] < ucnkg ) ? n [ 0 ] : ucnkg ; max = ( n [ 1 ] < n [ 2 ] ) ? n [ 2 ] : n [ 1 ] ; max = ( n [ 0 ] < max ) ? max : n [ 0 ] ; mid = mid - ( ucnkg + max ) ; System . out . println ( ucnkg + " " + mid + " " + max ) ; scan . close ( ) ; } } import java . util . * ; import java . io . * ; import java . math . BigInteger ; public class Suyxqxr { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; int suyxqxr = Integer . parseInt ( br . readLine ( ) ) ; int [ ] arr = new int [ suyxqxr ] ; StringTokenizer st1 = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < suyxqxr ; i ++ ) { arr [ i ] = Integer . parseInt ( st1 . nextToken ( ) ) ; } int [ ] cnt = new int [ suyxqxr ] ; int max = 0 ; for ( int i = suyxqxr - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] >= arr [ i + 1 ] ) { cnt [ i ] = cnt [ i + 1 ] + 1 ; } } for ( int i = 0 ; i < suyxqxr ; i ++ ) max = Math . max ( max , cnt [ i ] ) ; out . println ( max ) ; out . flush ( ) ; out . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Pvqrbd { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int pvqrbd = Integer . parseInt ( br . readLine ( ) ) ; int [ ] num = new int [ pvqrbd ] ; String [ ] strings = br . readLine ( ) . split ( " \\ s " ) ; for ( int i = 0 ; i < strings . length ; i ++ ) { num [ i ] = Integer . parseInt ( strings [ i ] ) ; } int q = Integer . parseInt ( br . readLine ( ) ) ; String [ ] strs = br . readLine ( ) . split ( " \\ s " ) ; int sum = 0 ; for ( int i = 0 ; i < q ; i ++ ) { if ( binarySearch ( num , Integer . parseInt ( strs [ i ] ) ) ) { sum ++ ; } } System . out . println ( sum ) ; } private static boolean binarySearch ( int [ ] num , int key ) { int left = 0 ; int right = num . length ; while ( left < right ) { int mid = ( left + right ) / 2 ; if ( key == num [ mid ] ) { return true ; } else if ( key < num [ mid ] ) { right = mid ; } else { left = mid + 1 ; } } return false ; } } import java . util . Scanner ; public class Ylqngls { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; char [ ] c = str . toCharArray ( ) ; for ( int ylqngls = 0 ; ylqngls < c . length ; ylqngls ++ ) { int count = 0 ; for ( int j = 0 ; j < c . length ; j ++ ) { if ( c [ ylqngls ] == c [ j ] ) { count ++ ; } } if ( count % 2 != 0 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Mnarzt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mnarzt = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = 0 ; for ( int i = mnarzt ; i <= b ; i ++ ) { char [ ] array = String . valueOf ( i ) . toCharArray ( ) ; int count = 0 ; for ( int j = 0 ; j < array . length - 2 ; j ++ ) { int tail = array . length - 1 - j ; if ( array [ j ] == array [ tail ] ) { count ++ ; } } if ( count == 3 ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Rxrgxzj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rxrgxzj = sc . nextInt ( ) ; int [ ] x = new int [ rxrgxzj ] ; int l = Integer . MAX_VALUE / 2 , r = - 1 ; for ( int i = 0 ; i < rxrgxzj ; i ++ ) { x [ i ] = sc . nextInt ( ) ; l = Math . min ( l , x [ i ] ) ; r = Math . max ( r , x [ i ] ) ; } long min = Integer . MAX_VALUE / 2 ; for ( int i = l ; i <= r ; i ++ ) { long d = 0 ; for ( int j = 0 ; j < rxrgxzj ; j ++ ) { d += Math . pow ( i - x [ j ] , 2 ) ; } min = Math . min ( min , d ) ; } System . out . println ( min ) ; } } import java . util . * ; public class Jejdr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int jejdr = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; long z = jejdr + y ; System . out . println ( ( jejdr + y ) % 2 == 0 ? ( jejdr + y ) / 2 : " IMPOSSIBLE " ) ; } } import java . io . * ; public class Fvjbxyh { public static void main ( String [ ] args ) { try { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int fvjbxyh = Integer . parseInt ( in . readLine ( ) ) ; int [ ] iArr = new int [ fvjbxyh ] ; String [ ] sArr = in . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < sArr . length ; i ++ ) { iArr [ i ] = Integer . parseInt ( sArr [ i ] ) ; } int swapCount = 0 ; for ( int i = 0 ; i < iArr . length ; i ++ ) { int minj = i ; for ( int j = i ; j < iArr . length ; j ++ ) { if ( iArr [ j ] < iArr [ minj ] ) { minj = j ; } } if ( minj != i ) { int tmp = iArr [ minj ] ; iArr [ minj ] = iArr [ i ] ; iArr [ i ] = tmp ; swapCount ++ ; } } StringBuilder sb = new StringBuilder ( ) ; for ( int i : iArr ) { sb . append ( i ) . append ( " " ) ; } System . out . println ( sb . toString ( ) . trim ( ) ) ; System . out . println ( swapCount ) ; } catch ( IOException e ) { } } } import java . io . FileNotFoundException ; import java . util . ArrayList ; import java . util . HashSet ; import java . util . Scanner ; public class Ixwrdk { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int ixwrdk = sc . nextInt ( ) ; ArrayList < String > result = new ArrayList < > ( ) ; result . add ( sc . next ( ) ) ; for ( int i = 1 ; i < ixwrdk ; i ++ ) { result . add ( sc . next ( ) ) ; } ArrayList < String > ans = new ArrayList < String > ( new HashSet < > ( result ) ) ; System . out . println ( ans . size ( ) ) ; } } import java . util . * ; public class Cplmhlq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cplmhlq = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; int x = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i <= cplmhlq ; i ++ ) { if ( i * 500 + b * 100 + c * 50 < x ) continue ; for ( int j = 0 ; j <= b ; j ++ ) { if ( i * 500 + j * 100 + c * 50 < x ) continue ; for ( int k = 0 ; k <= c ; k ++ ) { if ( i * 500 + j * 100 + k * 50 == x ) { count ++ ; break ; } } } } System . out . println ( count ) ; } } import java . util . * ; public class Oxycrs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long oxycrs = sc . nextLong ( ) ; long h = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; double ans = 0.5 * oxycrs * h ; StringBuilder builder = new StringBuilder ( String . valueOf ( ans ) ) ; int flag = 0.5 * oxycrs == x && 0.5 * h == y ? 1 : 0 ; builder . append ( " " + flag ) ; System . out . println ( builder ) ; } } import java . util . Scanner ; public class Umlyz { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; int umlyz = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; scanner . close ( ) ; int c = umlyz * b ; if ( c % 2 == 1 ) { System . out . println ( " Odd " ) ; } else if ( c % 2 == 0 ) { System . out . println ( " Even " ) ; } } } import java . util . * ; public class Diest { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int diest = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] num = new int [ m ] ; String [ ] s = new String [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { num [ i ] = sc . nextInt ( ) ; s [ i ] = sc . next ( ) ; } int [ ] cnt = new int [ diest ] ; int [ ] wa = new int [ diest ] ; for ( int i = 0 ; i < m ; i ++ ) { if ( s [ i ] . equals ( " AC " ) && cnt [ num [ i ] - 1 ] == 0 ) { cnt [ num [ i ] - 1 ] ++ ; continue ; } if ( s [ i ] . equals ( " WA " ) && cnt [ num [ i ] - 1 ] == 0 ) { wa [ num [ i ] - 1 ] ++ ; } } int a = 0 ; int w = 0 ; for ( int i = 0 ; i < diest ; i ++ ) { a += cnt [ i ] ; if ( cnt [ i ] > 0 ) { w += wa [ i ] ; } } System . out . println ( a + " " + w ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Ksyuofe { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ksyuofe = scanner . nextInt ( ) ; final Set < Integer > appeared = new HashSet < > ( ) ; int m = 1 ; do { appeared . add ( ksyuofe ) ; if ( ksyuofe % 2 == 0 ) { ksyuofe = ksyuofe / 2 ; } else { ksyuofe = 3 * ksyuofe + 1 ; } m ++ ; } while ( ! appeared . contains ( ksyuofe ) ) ; System . out . println ( m ) ; } } import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Ajkdr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; String Sa = sc . next ( ) ; String Sb = sc . next ( ) ; String Sc = sc . next ( ) ; int ajkdr = Sa . length ( ) , b = Sb . length ( ) , c = Sc . length ( ) ; char p = Sa . charAt ( Sa . length ( ) - ajkdr ) ; ajkdr -- ; while ( true ) { switch ( p ) { case 'a' : if ( ajkdr == 0 ) { out . println ( " A " ) ; exit ( 0 ) ; } p = Sa . charAt ( Sa . length ( ) - ajkdr ) ; ajkdr -- ; break ; case 'b' : if ( b == 0 ) { out . println ( " B " ) ; exit ( 0 ) ; } p = Sb . charAt ( Sb . length ( ) - b ) ; b -- ; break ; case 'c' : if ( c == 0 ) { out . println ( " C " ) ; exit ( 0 ) ; } p = Sc . charAt ( Sc . length ( ) - c ) ; c -- ; break ; } } } } import java . util . Scanner ; public class Qhyezte { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long qhyezte = scan . nextLong ( ) ; long syou = 0 ; long a = 0 , b = 0 ; long re = Long . MAX_VALUE ; for ( int i = 1 ; i <= Math . sqrt ( qhyezte ) ; i ++ ) { if ( qhyezte % i == 0 ) { a = i ; b = qhyezte / i ; } re = Math . min ( re , a + b - 2 ) ; } System . out . println ( re ) ; scan . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintStream ; class Xhmydt { public static void main ( String [ ] args ) throws IOException { doit ( args , System . in , System . out ) ; } static void doit ( String [ ] args , InputStream in , PrintStream out ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( in ) ) ; int xhmydt = Integer . parseInt ( reader . readLine ( ) ) ; int n = Integer . parseInt ( reader . readLine ( ) ) ; int [ ] numbers = new int [ xhmydt ] ; for ( int i = 0 ; i < xhmydt ; i ++ ) { numbers [ i ] = i + 1 ; } for ( int i = 0 ; i < n ; i ++ ) { String [ ] values = reader . readLine ( ) . split ( " , " ) ; int a = Integer . parseInt ( values [ 0 ] ) ; int b = Integer . parseInt ( values [ 1 ] ) ; int tmp = numbers [ a - 1 ] ; numbers [ a - 1 ] = numbers [ b - 1 ] ; numbers [ b - 1 ] = tmp ; } for ( int i = 0 ; i < xhmydt ; i ++ ) { out . println ( numbers [ i ] ) ; } } } import java . util . Scanner ; public class Bqlcojz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; long bqlcojz = sc . nextLong ( ) ; int ans = 0 ; int n = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { n = s . charAt ( i ) - '0' ; bqlcojz -- ; if ( bqlcojz == 0 || n > 1 ) break ; } System . out . println ( n ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Iixjb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iixjb = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean [ ] broken = new boolean [ iixjb + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { broken [ sc . nextInt ( ) ] = true ; } int [ ] dp = new int [ iixjb + 1 ] ; Arrays . fill ( dp , 0 ) ; dp [ 0 ] = 1 ; dp [ 1 ] = broken [ 1 ] ? 0 : 1 ; for ( int i = 2 ; i <= iixjb ; i ++ ) { if ( broken [ i ] ) { continue ; } dp [ i ] = dp [ i - 1 ] + dp [ i - 2 ] ; dp [ i ] %= 1000000007 ; } boolean canNotUpStairs = false ; for ( int i = 1 ; i < broken . length ; i ++ ) { if ( broken [ i - 1 ] && broken [ i ] ) { canNotUpStairs = true ; } } if ( canNotUpStairs ) { System . out . println ( 0 ) ; } else { System . out . println ( dp [ dp . length - 1 ] ) ; } } } import java . util . * ; public class Sjhdony { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sjhdony = sc . nextInt ( ) ; int num2 = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( sjhdony < num2 ) { sum += num2 ; num2 -- ; } else { sum += sjhdony ; sjhdony -- ; } } System . out . println ( sum ) ; } } 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 Tczin { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AChangingACharacter solver = new AChangingACharacter ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Tczin { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int tczin = in . nextInt ( ) ; int k = in . nextInt ( ) ; StringBuilder ans = new StringBuilder ( in . next ( ) ) ; ans . setCharAt ( k - 1 , ( char ) ( ans . charAt ( k - 1 ) + 32 ) ) ; out . println ( ans . toString ( ) ) ; } } static class Tczin { 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 Lohwaw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int lohwaw = Integer . parseInt ( scan . next ( ) ) ; if ( lohwaw <= 111 ) { System . out . println ( 111 ) ; } else if ( lohwaw <= 222 ) { System . out . println ( 222 ) ; } else if ( lohwaw <= 333 ) { System . out . println ( 333 ) ; } else if ( lohwaw <= 444 ) { System . out . println ( 444 ) ; } else if ( lohwaw <= 555 ) { System . out . println ( 555 ) ; } else if ( lohwaw <= 666 ) { System . out . println ( 666 ) ; } else if ( lohwaw <= 777 ) { System . out . println ( 777 ) ; } else if ( lohwaw <= 888 ) { System . out . println ( 888 ) ; } else if ( lohwaw <= 999 ) { System . out . println ( 999 ) ; } } } import java . util . * ; public class Amlpqb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int amlpqb = sc . nextInt ( ) ; int result = 100000 ; for ( int i = 0 ; i < amlpqb ; i ++ ) { result += result * 0.05 ; result = ( int ) Math . ceil ( ( double ) result / 1000 ) * 1000 ; } System . out . println ( result ) ; } } import java . util . * ; public class Rpionnk { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String rpionnk = sc . next ( ) ; rpionnk = " 2018 " + rpionnk . substring ( 4 , rpionnk . length ( ) ) ; System . out . println ( rpionnk ) ; } public static void main ( String [ ] args ) { solve ( ) ; } } import java . util . * ; public class Geslq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int geslq = Integer . parseInt ( sc . nextLine ( ) ) ; String sTaro ; String sHanako ; int iTaro = 0 ; int iHanako = 0 ; for ( int i = 0 ; i < geslq ; i ++ ) { sTaro = sc . next ( ) ; sHanako = sc . next ( ) ; if ( sTaro . compareTo ( sHanako ) < 0 ) { iHanako += 3 ; } else if ( sTaro . compareTo ( sHanako ) > 0 ) { iTaro += 3 ; } else { iTaro ++ ; iHanako ++ ; } } System . out . println ( iTaro + " " + iHanako ) ; } } import java . util . * ; public class Haxwbvx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int haxwbvx = sc . nextInt ( ) ; System . out . println ( ( ( haxwbvx + 1 ) / 2 ) ) ; } } import java . util . * ; public class Pwacp { static String Rort ( String s , String t ) { String pwacp = s + s ; pwacp = pwacp . replaceFirst ( t , " " ) ; if ( pwacp . equals ( s ) ) return " Yes " ; return " No " ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; System . out . println ( Rort ( S , T ) ) ; } } import java . io . * ; public class Yfeplb { public static void main ( String [ ] args ) throws IOException { int yfeplb = 0 , f = 0 , r = 0 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String str = br . readLine ( ) ; String [ ] i = str . split ( " " ) ; yfeplb = Integer . parseInt ( i [ 0 ] ) ; f = Integer . parseInt ( i [ 1 ] ) ; r = Integer . parseInt ( i [ 2 ] ) ; if ( yfeplb == ( - 1 ) && f == ( - 1 ) && r == ( - 1 ) ) { break ; } if ( yfeplb == ( - 1 ) || f == ( - 1 ) ) { System . out . println ( " F " ) ; } else if ( yfeplb + f >= 80 ) { System . out . println ( " A " ) ; } else if ( yfeplb + f >= 65 ) { System . out . println ( " B " ) ; } else if ( yfeplb + f >= 50 ) { System . out . println ( " C " ) ; } else if ( yfeplb + f >= 30 ) { if ( r >= 50 ) { System . out . println ( " C " ) ; } else { System . out . println ( " D " ) ; } } else { System . out . println ( " F " ) ; } } } } import java . io . * ; import java . util . * ; class Vvpmrbt { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int vvpmrbt = 0 ; int n ; while ( true ) { vvpmrbt ++ ; n = Integer . parseInt ( br . readLine ( ) ) ; if ( n == 0 ) break ; System . out . println ( " Case " + vvpmrbt + " : " + n ) ; } } } import java . util . Scanner ; public class Jimvplb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jimvplb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; boolean ok = true ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i == jimvplb && s . charAt ( jimvplb ) != '-' ) { ok = false ; } if ( i != jimvplb && s . charAt ( i ) == '-' ) { ok = false ; } } if ( ok ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Ewxubyn { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( true ) { String s = in . nextLine ( ) ; if ( s . equals ( " 0 " ) ) return ; long ewxubyn = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { ewxubyn += Integer . parseInt ( " " + s . charAt ( i ) ) ; } System . out . println ( ewxubyn ) ; } } } import java . util . * ; public class Zdmfxjj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String num = scan . nextLine ( ) ; String str = scan . nextLine ( ) ; String str_cha = " ABCDEFGHIJKLMNOPQRSTUVWXYZ " ; int zdmfxjj = Integer . parseInt ( num ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { for ( int j = 0 ; j < str_cha . length ( ) ; j ++ ) { if ( str . charAt ( i ) == str_cha . charAt ( j ) ) { System . out . print ( str_cha . charAt ( ( j + zdmfxjj ) % 26 ) ) ; } } } System . out . print ( " \n " ) ; } } import java . util . * ; public class Gcpoo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int gcpoo = str . length ( ) ; String leftStr = str . substring ( 0 , ( gcpoo - 1 ) / 2 ) ; String rightStr = str . substring ( ( gcpoo + 1 ) / 2 , gcpoo ) ; boolean isStrongPalindrome = new StringBuffer ( leftStr ) . reverse ( ) . toString ( ) . equals ( leftStr ) && new StringBuffer ( rightStr ) . reverse ( ) . toString ( ) . equals ( rightStr ) && new StringBuffer ( str ) . reverse ( ) . toString ( ) . equals ( str ) ; System . out . println ( isStrongPalindrome ? " Yes " : " No " ) ; } } import java . util . * ; public class Idwqox { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long [ ] a = new long [ 2 ] ; long [ ] b = new long [ 2 ] ; a [ 0 ] = sc . nextLong ( ) ; a [ 1 ] = sc . nextLong ( ) ; b [ 0 ] = sc . nextLong ( ) ; b [ 1 ] = sc . nextLong ( ) ; long idwqox = Long . MIN_VALUE ; for ( int i = 0 ; i < 2 ; ++ i ) { for ( int j = 0 ; j < 2 ; ++ j ) { long tmp = a [ i ] * b [ j ] ; idwqox = Math . idwqox ( tmp , idwqox ) ; } } System . out . println ( idwqox ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Lvheswl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lvheswl = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; long p = 1 ; int r = 0 ; while ( p <= lvheswl ) { p *= k ; r ++ ; } System . out . println ( r ) ; } } import java . util . Scanner ; public class Njnrz { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int njnrz = stdIn . nextInt ( ) ; int [ ] A = new int [ njnrz ] ; int count = 0 ; int ans = 0 ; for ( int i = 0 ; i < njnrz ; i ++ ) { A [ i ] = stdIn . nextInt ( ) ; if ( A [ i ] % 2 == 0 ) { count ++ ; if ( A [ i ] % 3 == 0 || A [ i ] % 5 == 0 ) { ans ++ ; } } } if ( ans == count ) { System . out . println ( " APPROVED " ) ; } else { System . out . println ( " DENIED " ) ; } stdIn . close ( ) ; } } import java . util . Scanner ; public class Syyduz { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int syyduz = gi ( ) ; int [ ] A = new int [ syyduz ] ; for ( int i = 0 ; i < syyduz ; i ++ ) { A [ i ] = gi ( ) ; } int max = 0 ; int t = 0 ; for ( int i = 0 ; i < syyduz ; i ++ ) { if ( max <= A [ i ] ) { t ++ ; max = A [ i ] ; } } System . out . print ( t ) ; } public static String gs ( ) { return scanner . next ( ) ; } public static int gi ( ) { return Integer . parseInt ( scanner . next ( ) ) ; } public static long gl ( ) { return Long . parseLong ( scanner . next ( ) ) ; } public static double gd ( ) { return Double . parseDouble ( scanner . next ( ) ) ; } } import java . util . Scanner ; public class Vrmucsz { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vrmucsz = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int H = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; sc . close ( ) ; double h = ( double ) H / 12.0 ; h += ( double ) M / 60.0 / 12.0 ; double m = ( double ) M / 60.0 ; double rad = Math . PI * 2 * ( h - m ) ; double rsq = ( vrmucsz * vrmucsz ) + ( B * B ) - ( 2 * vrmucsz * B * Math . cos ( rad ) ) ; System . out . println ( Math . sqrt ( rsq ) ) ; } } import java . util . * ; public class Exmvgkj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int exmvgkj = sc . nextInt ( ) ; int check = 0 ; String [ ] W = new String [ exmvgkj ] ; for ( int i = 0 ; i < exmvgkj ; i ++ ) { W [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < exmvgkj - 1 ; i ++ ) { if ( W [ i ] . charAt ( W [ i ] . length ( ) - 1 ) != W [ i + 1 ] . charAt ( 0 ) ) { check ++ ; break ; } for ( int j = i + 1 ; j < exmvgkj ; j ++ ) { if ( W [ i ] . equals ( W [ j ] ) ) { check ++ ; break ; } } } if ( check != 0 ) { System . out . print ( " No " ) ; } else { System . out . print ( " Yes " ) ; } } } import java . util . Scanner ; class Kuwsbqt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double kuwsbqt = scan . nextDouble ( ) ; double B = scan . nextDouble ( ) ; double H = scan . nextDouble ( ) ; double M = scan . nextDouble ( ) ; double hour , minute , c , co , ans ; hour = H * 30 + M * 0.5 ; minute = M * 6 ; c = hour - minute ; if ( c > 180 ) { c = 360 - c ; } else if ( c < 0 ) { c = 360 + c ; } co = Math . cos ( Math . toRadians ( c ) ) ; ans = kuwsbqt * kuwsbqt + B * B - 2 * kuwsbqt * B * co ; System . out . println ( Math . sqrt ( ans ) ) ; } } import java . util . * ; public class Qulekib { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qulekib = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int a = x - ( qulekib - 1 ) ; for ( int i = 0 ; i < qulekib * 2 - 1 ; i ++ ) { if ( a < - 1000000 || a > 1000000 ) continue ; System . out . print ( a + " " ) ; a ++ ; } } } import java . util . * ; public class Hmrmzya { public static void main ( String [ ] args ) { Scanner yomi = new Scanner ( System . in ) ; int hmrmzya = yomi . nextInt ( ) ; boolean tf = true ; int [ ] n = new int [ hmrmzya ] ; for ( int i = 0 ; i < hmrmzya ; i ++ ) { n [ i ] = yomi . nextInt ( ) ; } for ( int i = 0 ; i < hmrmzya ; i ++ ) { if ( n [ i ] % 2 == 0 ) { if ( n [ i ] % 3 == 0 || n [ i ] % 5 == 0 ) { } else tf = false ; } } if ( tf ) { System . out . println ( " APPROVED " ) ; } else System . out . println ( " DENIED " ) ; } } import java . util . * ; import java . math . * ; import java . io . * ; import java . lang . * ; public class Ddqltsx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ddqltsx = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] ar = new int [ ddqltsx ] ; int sum = 0 ; int res = 114514 ; for ( int i = 0 ; i < ddqltsx ; i ++ ) { ar [ i ] = l + i ; sum += ar [ i ] ; if ( Math . abs ( res ) > Math . abs ( ar [ i ] ) ) { res = ar [ i ] ; } } res = sum - res ; System . out . println ( res ) ; } } class Ddqltsx { public static void br ( ) { System . out . println ( " " ) ; } public static void YesNo ( boolean f ) { System . out . println ( f ? " Yes " : " No " ) ; } public static void YESNO ( boolean f ) { System . out . println ( f ? " YES " : " NO " ) ; } } class Ddqltsx { public static boolean isOdd ( int ddqltsx ) { return ddqltsx % 2 == 1 ; } public static boolean isEven ( int ddqltsx ) { return ddqltsx % 2 == 0 ; } } import java . util . Scanner ; public class Hdbehb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int hdbehb = scan . nextInt ( ) ; int sum = scan . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x <= hdbehb ; ++ x ) { for ( int y = 0 ; y <= hdbehb ; ++ y ) { int z = sum - x - y ; if ( 0 <= z && z <= hdbehb ) { ans = ans + 1 ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; class Asleg { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int asleg = cin . nextInt ( ) ; int res = sol ( asleg ) ; System . out . println ( res ) ; } private static int sol ( int asleg ) { return ( asleg * asleg * asleg ) ; } } import java . util . Scanner ; public class Fqezdsl { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int fqezdsl = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c ; int k = scanner . nextInt ( ) ; if ( fqezdsl > b ) c = fqezdsl ; else c = b ; for ( int i = c ; i >= 1 ; i -- ) { if ( fqezdsl % i == 0 && b % i == 0 ) { -- k ; if ( k == 0 ) { System . out . println ( i ) ; } } } } } import java . util . * ; import java . io . * ; public class Rxwglf { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int rxwglf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( ( rxwglf * b ) % 2 == 0 ) System . out . println ( " Even " ) ; else System . out . println ( " Odd " ) ; } } import java . util . * ; public class Tlwcs { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int tlwcs = sc . nextInt ( ) ; int [ ] [ ] nums = new int [ 4 ] [ 13 ] ; for ( int i = 0 ; i < tlwcs ; i ++ ) { String suit = sc . next ( ) ; int num = sc . nextInt ( ) ; if ( " S " . equals ( suit ) ) { nums [ 0 ] [ num - 1 ] = 1 ; } else if ( " H " . equals ( suit ) ) { nums [ 1 ] [ num - 1 ] = 1 ; } else if ( " C " . equals ( suit ) ) { nums [ 2 ] [ num - 1 ] = 1 ; } else { nums [ 3 ] [ num - 1 ] = 1 ; } } for ( int i = 0 ; i < 4 ; i ++ ) { String suit = " S " ; if ( i == 0 ) { suit = " S " ; } else if ( i == 1 ) { suit = " H " ; } else if ( i == 2 ) { suit = " C " ; } else { suit = " D " ; } for ( int j = 0 ; j < 13 ; j ++ ) { if ( nums [ i ] [ j ] == 0 ) { System . out . println ( suit + " " + ( j + 1 ) ) ; } } } } } import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Ttlkkpo { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; PrintWriter printWriter = new PrintWriter ( System . out ) ; if ( scanner . nextLine ( ) . equals ( " ABC " ) ) { printWriter . println ( " ARC " ) ; } else { printWriter . println ( " ABC " ) ; } printWriter . flush ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; import java . lang . Exception ; import java . lang . Integer ; import java . lang . String ; import java . lang . System ; import java . util . StringTokenizer ; class Lkkinzk { public static void main ( String [ ] a ) throws IOException { java . io . BufferedReader r = new java . io . BufferedReader ( new java . io . InputStreamReader ( System . in ) ) ; try { int lkkinzk = Integer . parseInt ( r . readLine ( ) ) ; String [ ] ans = new String [ lkkinzk ] ; for ( int i = 0 ; i < lkkinzk ; i ++ ) { String s = r . readLine ( ) ; StringTokenizer st = new StringTokenizer ( s ) ; int [ ] num = new int [ 4 ] ; for ( int j = 0 ; j < 3 ; j ++ ) { num [ j ] = Integer . parseInt ( st . nextToken ( ) ) ; if ( num [ 0 ] < num [ j ] ) { int tmp = num [ 0 ] ; num [ 0 ] = num [ j ] ; num [ j ] = tmp ; } } if ( num [ 0 ] * num [ 0 ] == num [ 1 ] * num [ 1 ] + num [ 2 ] * num [ 2 ] ) { ans [ i ] = " YES " ; } else { ans [ i ] = " NO " ; } } for ( int i = 0 ; i < lkkinzk ; i ++ ) { System . out . println ( ans [ i ] ) ; } } catch ( Exception ex ) { System . exit ( 0 ) ; } } } import java . util . * ; public class Lbngkuv { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int lbngkuv = Integer . parseInt ( sc . next ( ) ) ; String str = sc . next ( ) ; if ( lbngkuv % 2 == 1 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } String m = str . substring ( lbngkuv / 2 ) ; if ( str . substring ( 0 , lbngkuv / 2 ) . equals ( m ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Gdkyvs { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int gdkyvs = Integer . parseInt ( sc . next ( ) ) ; if ( gdkyvs % 2 == 0 ) { System . out . println ( gdkyvs / 2 ) ; } else { System . out . println ( ( gdkyvs + 1 ) / 2 ) ; } } } import java . util . Scanner ; class Rjlpg { public static void main ( String [ ] arg ) { String input ; Scanner in = new Scanner ( System . in ) ; while ( true ) { input = in . nextLine ( ) ; if ( input . equals ( " 0 " ) ) break ; int rjlpg = 0 ; for ( int i = 0 ; i < input . length ( ) ; ++ i ) { char ch = input . charAt ( i ) ; rjlpg += Character . getNumericValue ( ch ) ; } System . out . println ( rjlpg ) ; } } } import java . util . * ; public class Cjtgi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] nt = line . split ( " " ) ; int cjtgi = Integer . parseInt ( nt [ 0 ] ) ; int t = Integer . parseInt ( nt [ 1 ] ) ; String rel = " TLE " ; for ( int i = 0 ; i < cjtgi ; i ++ ) { String keiro = sc . nextLine ( ) ; String [ ] k = keiro . split ( " " ) ; if ( Integer . parseInt ( k [ 1 ] ) <= t ) { if ( rel . equals ( " TLE " ) ) { rel = String . valueOf ( k [ 0 ] ) ; } else if ( Integer . parseInt ( rel ) > Integer . parseInt ( k [ 0 ] ) ) { rel = String . valueOf ( k [ 0 ] ) ; } } } System . out . println ( rel ) ; sc . close ( ) ; } } import java . util . * ; public class Aahli { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aahli = 0 ; String s = sc . nextLine ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '+' ) { aahli ++ ; } else if ( s . charAt ( i ) == '-' ) { aahli -- ; } } System . out . println ( aahli ) ; } } import java . util . * ; public class Aggvdca { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String aggvdca = sc . next ( ) ; if ( aggvdca . toUpperCase ( ) . equals ( aggvdca ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . Scanner ; public class Zytom { public static void main ( String [ ] args ) { Diagram diagram = new Diagram ( ) ; try ( Scanner stdin = new Scanner ( System . in ) ) { int zytom , w ; while ( stdin . hasNext ( ) ) { zytom = Integer . parseInt ( stdin . next ( ) ) ; w = Integer . parseInt ( stdin . next ( ) ) ; if ( zytom < 0 || zytom > 300 || w < 0 || w > 300 ) { throw new RuntimeException ( " Input Error:Range 0 to 300 " ) ; } if ( zytom == 0 && w == 0 ) { break ; } diagram . draw ( zytom , w ) ; System . out . println ( " " ) ; } } catch ( RuntimeException e ) { e . printStackTrace ( ) ; } } } abstract class Zytom { abstract void draw ( int height , int width ) ; } class Zytom extends AbstractDiagram { @ Override void draw ( int zytom , int w ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i <= zytom ; i ++ ) { for ( int j = 1 ; j <= w ; j ++ ) { if ( ( i == 1 || i == zytom ) || ( j == 1 || j == w ) ) { sb . append ( '#' ) ; } else { sb . append ( '.' ) ; } } System . out . println ( sb ) ; sb . setLength ( 0 ) ; } } } import java . util . Scanner ; public class Aaeubtz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aaeubtz = sc . nextInt ( ) ; int point = sc . nextInt ( ) ; int min = point - aaeubtz + 1 ; int max = point + aaeubtz - 1 ; for ( int i = min ; i <= max ; i ++ ) { System . out . print ( i + " " ) ; } } } import java . util . * ; import java . io . * ; import java . math . * ; public class Sniwot { public static void main ( String [ ] omkar ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; String sniwot = st . nextToken ( ) ; if ( sniwot . charAt ( 2 ) == sniwot . charAt ( 3 ) && sniwot . charAt ( 4 ) == sniwot . charAt ( 5 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class Wnavnfe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wnavnfe = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int LMax = 0 ; int RMin = wnavnfe ; for ( int i = 0 ; i < M ; i ++ ) { int L = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; LMax = L >= LMax ? L : LMax ; RMin = R <= RMin ? R : RMin ; } sc . close ( ) ; if ( LMax > RMin ) { System . out . println ( 0 ) ; } else { System . out . println ( RMin - LMax + 1 ) ; } } } import java . util . Scanner ; public class Ttndp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ttndp = sc . nextInt ( ) ; int cnt = 0 ; while ( ttndp -- > 0 ) { int num = sc . nextInt ( ) ; if ( isPrime ( num ) ) cnt ++ ; } System . out . println ( cnt ) ; } public static boolean isPrime ( int num ) { for ( int i = 2 ; i * i <= num ; i ++ ) if ( num % i == 0 ) return false ; return true ; } } import java . util . * ; import java . lang . * ; public class Hqyedfg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int hqyedfg = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; List < Integer > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < M ; i ++ ) { a . add ( scanner . nextInt ( ) ) ; } Set < Integer > bloken = new HashSet < > ( a ) ; List < Integer > w = new ArrayList < > ( ) ; w . add ( 1 ) ; if ( bloken . contains ( 1 ) ) { w . add ( 0 ) ; } else { w . add ( 1 ) ; } for ( int i = 2 ; i <= hqyedfg ; i ++ ) { if ( bloken . contains ( i ) ) { w . add ( 0 ) ; } else { w . add ( ( w . get ( i - 1 ) + w . get ( i - 2 ) ) % 1000000007 ) ; } } System . out . println ( w . get ( hqyedfg ) % 1000000007 ) ; } } import java . io . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . util . * ; public class Eatavy { static class Eatavy { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { 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 ; } public Character charAt ( int i ) { return null ; } } public static void main ( String [ ] args ) throws IOException { FastReader s = new FastReader ( ) ; String n = s . next ( ) ; int eatavy = ( int ) n . charAt ( 0 ) ; eatavy ++ ; System . out . println ( ( char ) eatavy ) ; } } import java . util . Scanner ; public class Mcdiyhm { public static void main ( String ... nui ) { Scanner sc = new Scanner ( System . in ) ; int mcdiyhm = sc . nextInt ( ) ; int min = ( int ) 1e9 ; for ( int i = 0 ; i < mcdiyhm ; i ++ ) { int a = sc . nextInt ( ) ; int cnt = 0 ; while ( a % 2 == 0 ) { a /= 2 ; cnt ++ ; } min = Math . min ( min , cnt ) ; } System . out . println ( min ) ; } } import java . util . * ; public class Sanvdz { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int sanvdz = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] ints = new int [ sanvdz ] [ m ] ; int [ ] line = new int [ sanvdz ] ; int [ ] row = new int [ m ] ; int sum = 0 ; for ( int i = 0 ; i < sanvdz ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int temp = Integer . parseInt ( sc . next ( ) ) ; ints [ i ] [ j ] = temp ; line [ i ] += temp ; row [ j ] += temp ; } sum += line [ i ] ; } for ( int i = 0 ; i < sanvdz + 1 ; i ++ ) { for ( int j = 0 ; j < m + 1 ; j ++ ) { if ( i == sanvdz && j == m ) { System . out . print ( sum ) ; } else if ( j == m ) { System . out . print ( line [ i ] ) ; } else if ( i == sanvdz ) { System . out . print ( row [ j ] ) ; } else { System . out . print ( ints [ i ] [ j ] ) ; } if ( j != m ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } } import java . util . * ; import java . io . * ; import java . nio . charset . StandardCharsets ; public class Xlzufr { public static void main ( String [ ] args ) throws IOException { InputStreamReader reader = new InputStreamReader ( System . in , StandardCharsets . UTF_8 ) ; BufferedReader in = new BufferedReader ( reader ) ; Main ins = new Main ( in ) ; ins . calc ( ) ; ins . showResult ( ) ; } Main ( BufferedReader in ) throws IOException { String [ ] tok = in . readLine ( ) . split ( " " ) ; int xlzufr = Integer . parseInt ( tok [ 0 ] ) ; int B = Integer . parseInt ( tok [ 1 ] ) ; System . out . println ( xlzufr * B ) ; } void calc ( ) { } void showResult ( ) { } } import java . util . Scanner ; public class Okdeclb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int okdeclb = Integer . parseInt ( sc . next ( ) ) ; int b = okdeclb + ( okdeclb * okdeclb ) + ( okdeclb * okdeclb * okdeclb ) ; System . out . println ( b ) ; } } import java . util . Scanner ; public class Hfkof { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hfkof = sc . nextInt ( ) ; long [ ] a = new long [ hfkof ] ; for ( int i = 0 ; i < hfkof ; i ++ ) { a [ i ] = sc . nextLong ( ) ; if ( a [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } long prod = 1 ; for ( int i = 0 ; i < hfkof ; i ++ ) { if ( 1000000000000000000l / prod < a [ i ] ) { System . out . println ( - 1 ) ; return ; } else { prod *= a [ i ] ; } } System . out . println ( prod ) ; sc . close ( ) ; } } import java . util . Scanner ; class Qnejq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qnejq = scan . nextInt ( ) ; int [ ] a = new int [ qnejq + 1 ] ; for ( int i = 1 ; i < qnejq ; i ++ ) { int j = scan . nextInt ( ) ; a [ j ] ++ ; } for ( int i = 1 ; i < qnejq + 1 ; i ++ ) { System . out . println ( a [ i ] ) ; } } } import java . io . * ; class Ubkqg { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String input = br . readLine ( ) ; double ubkqg = Double . parseDouble ( input ) ; double s = ubkqg * ubkqg * Math . PI ; double l = ubkqg * 2 * Math . PI ; String ansS = String . format ( " %.6f " , s ) ; String ansL = String . format ( " %.6f " , l ) ; System . out . println ( ansS + " " + ansL ) ; } } import java . util . * ; import java . io . * ; public class Lemhdpb { public static void main ( String [ ] Args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int lemhdpb = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int check = 0 ; for ( int j = 0 ; j < 4 ; j ++ ) { if ( s . charAt ( j ) - 'A' == i ) { check ++ ; } } if ( check != 0 && check != 2 ) { lemhdpb = 1 ; } } if ( lemhdpb == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Ofyixfm { public static void main ( String [ ] args ) { try { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line ; while ( ( line = stdReader . readLine ( ) ) != null ) { int ofyixfm = Integer . parseInt ( line ) ; System . out . println ( ofyixfm * ofyixfm * ofyixfm ) ; } stdReader . close ( ) ; } catch ( Exception e ) { e . getStackTrace ( ) ; System . exit ( 0 ) ; } } } import java . util . * ; import java . text . * ; public class Dxanzx { public static void main ( String [ ] args ) throws ParseException { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String S2 = " 2019/05/01 " ; SimpleDateFormat sdf = new SimpleDateFormat ( " yyyy/MM/dd " ) ; SimpleDateFormat sdf2 = new SimpleDateFormat ( " yyyy/MM/dd " ) ; Date formatDate = sdf . parse ( S ) ; Date formatDate2 = sdf . parse ( S2 ) ; boolean dxanzx = formatDate2 . after ( formatDate ) ; if ( ! dxanzx ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } } } import java . util . * ; public class Jiwciiy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jiwciiy = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < b . length ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } int [ ] [ ] a = new int [ jiwciiy ] [ m ] ; for ( int i = 0 ; i < a . length ; i ++ ) { for ( int j = 0 ; j < a [ i ] . length ; j ++ ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } int counter = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { int sum = c ; for ( int j = 0 ; j < a [ i ] . length ; j ++ ) { sum += a [ i ] [ j ] * b [ j ] ; } if ( sum > 0 ) { counter ++ ; } } System . out . println ( counter ) ; sc . close ( ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class Xmyscql { public static void main ( String [ ] args ) throws Exception { solve ( System . in , System . out ) ; } static void solve ( InputStream is , PrintStream os ) { Scanner scan = new Scanner ( is ) ; int xmyscql = scan . nextInt ( ) ; int A = scan . nextInt ( ) ; int ans = ( int ) Math . ceil ( ( double ) xmyscql / A ) ; os . println ( ans ) ; } } import java . util . Scanner ; public class Sjmmjup { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int sjmmjup = 0 ; int ans = 0 ; for ( int i = 1 ; i < 6 ; i ++ ) { sjmmjup = scan . nextInt ( ) ; if ( sjmmjup == 0 ) { ans = i ; } } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Okmlgyo { public static void main ( String ... args ) { Scanner scanner = new Scanner ( System . in ) ; int okmlgyo = scanner . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; int cnt = 1 ; for ( int i = 0 ; i < okmlgyo ; i ++ ) { int sc = scanner . nextInt ( ) ; if ( sc == cnt ) { list . add ( cnt ++ ) ; } } int rst = okmlgyo - list . size ( ) ; System . out . println ( rst == okmlgyo ? - 1 : rst ) ; } } import java . util . * ; public class Iversa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iversa = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] b = new int [ iversa ] [ 3 ] ; for ( int i = 0 ; i < m ; i ++ ) { int p = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( b [ p - 1 ] [ 0 ] == 0 ) { if ( " AC " . equals ( s ) ) { b [ p - 1 ] [ 0 ] = i + 1 ; } else { b [ p - 1 ] [ 1 ] ++ ; } } } int ok = 0 ; int ng = 0 ; for ( int i = 0 ; i < iversa ; i ++ ) { if ( b [ i ] [ 0 ] > 0 ) { ok ++ ; ng += b [ i ] [ 1 ] ; } } System . out . println ( ok + " " + ng ) ; } } import java . util . Scanner ; public class Gkkhxgo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gkkhxgo = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int toZero = 0 ; int toN = 0 ; Integer [ ] a = new Integer [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { if ( a [ i ] < x ) { toZero ++ ; } else { toN ++ ; } } System . out . println ( Math . min ( toZero , toN ) ) ; } } import java . util . * ; public class Cktvlk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cktvlk = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < n ; ++ i ) { count += a [ i ] ; } if ( count >= cktvlk ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Ptylw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] n = new int [ 3 ] ; for ( int ptylw = 0 ; ptylw < 3 ; ptylw ++ ) { n [ ptylw ] = scan . nextInt ( ) ; } int k = scan . nextInt ( ) ; Arrays . sort ( n ) ; for ( int ptylw = 0 ; ptylw < k ; ptylw ++ ) { n [ 2 ] *= 2 ; } int a = 0 ; for ( int ptylw = 0 ; ptylw < 3 ; ptylw ++ ) { a += n [ ptylw ] ; } System . out . println ( a ) ; } } import java . util . Scanner ; public class Bhvmynm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int bhvmynm = 0 ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; if ( n == 0 && x == 0 ) { break ; } for ( int i = n ; i >= 3 ; i -- ) { for ( int j = i - 1 ; j >= 2 ; j -- ) { int remainder = x - i - j ; if ( remainder <= 0 ) { continue ; } else if ( remainder >= j ) { break ; } else { bhvmynm ++ ; } } } System . out . println ( bhvmynm ) ; } } } import java . util . * ; public class Zdnrhjz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zdnrhjz = sc . nextInt ( ) ; int [ ] a = new int [ zdnrhjz + 1 ] ; for ( int i = 1 ; i <= zdnrhjz ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int answer = 0 ; int lightNum = 1 ; while ( 1 == 1 ) { lightNum = a [ lightNum ] ; answer ++ ; if ( lightNum == 2 ) { System . out . println ( answer ) ; return ; } if ( answer > 110000 ) { System . out . println ( - 1 ) ; return ; } } } } import java . util . * ; public class Dayij { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dayij = sc . nextInt ( ) ; int [ ] k = new int [ dayij ] ; Boolean allZero = false ; int count = 0 ; for ( int i = 0 ; i < dayij ; i ++ ) { k [ i ] = sc . nextInt ( ) ; } while ( ! allZero ) { allZero = true ; int now = 0 ; Boolean isZero = true ; while ( now < dayij ) { if ( k [ now ] > 0 ) { k [ now ] -= 1 ; isZero = false ; allZero = false ; } else if ( k [ now ] <= 0 && isZero ) { } else { count ++ ; isZero = true ; } now ++ ; } if ( ! isZero ) { count ++ ; } } sc . close ( ) ; System . out . println ( count ) ; } } import java . util . Scanner ; public class Mqvaws { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mqvaws = Long . parseLong ( sc . next ( ) ) ; long r = Long . parseLong ( sc . next ( ) ) ; long ans = Long . MAX_VALUE ; long num = 0 ; for ( long i = mqvaws ; i < r ; i ++ ) { for ( long j = i + 1 ; j <= r ; j ++ ) { num = ( i * j ) % 2019 ; if ( num < ans ) { ans = num ; } if ( num == 0 ) { System . out . println ( 0 ) ; return ; } } } System . out . println ( ans ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Hmpjoeo { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Hmpjoeo { int hmpjoeo = - 1000_000_000 ; int UPPER_LIMIT = 1000_000_000 ; public void solve ( int testNumber , Scanner in , PrintWriter out ) { int K = in . nextInt ( ) ; int X = in . nextInt ( ) ; int start = 0 ; int end = 0 ; if ( X - hmpjoeo + 1 < K ) { start = hmpjoeo ; end = X + K - 1 ; } else if ( UPPER_LIMIT - X + 1 < K ) { start = UPPER_LIMIT - X + 1 ; end = UPPER_LIMIT ; } else { start = X - ( K - 1 ) ; end = X + ( K - 1 ) ; } for ( int i = start ; i <= end ; i ++ ) { out . println ( i ) ; } } } } import java . util . Arrays ; import java . util . Scanner ; public class Yqwcp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] A = new int [ 3 ] ; A [ 0 ] = sc . nextInt ( ) ; A [ 1 ] = sc . nextInt ( ) ; A [ 2 ] = sc . nextInt ( ) ; int yqwcp = sc . nextInt ( ) ; Arrays . parallelSort ( A ) ; System . out . println ( A [ 0 ] + A [ 1 ] + ( int ) ( A [ 2 ] * Math . pow ( 2 , yqwcp ) ) ) ; } } import java . util . Scanner ; class Epwuqi { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int epwuqi = Integer . parseInt ( stdIn . next ( ) ) ; int b = Integer . parseInt ( stdIn . next ( ) ) ; int pl = 0 ; int pr = 1250 ; do { int pc = ( pl + pr ) / 2 ; if ( ( int ) ( pc * 0.08 ) == epwuqi && ( int ) ( pc * 0.1 ) == b ) { while ( ( int ) ( pc * 0.08 ) == epwuqi && ( int ) ( pc * 0.1 ) == b ) { pc -- ; } pc ++ ; System . out . println ( pc ) ; return ; } else if ( ( int ) ( pc * 0.08 ) < epwuqi || ( int ) ( pc * 0.1 ) < b ) { pl = pc + 1 ; } else if ( ( int ) ( pc * 0.08 ) > epwuqi || ( int ) ( pc * 0.1 ) > b ) { pr = pc - 1 ; } } while ( pl <= pr ) ; System . out . println ( - 1 ) ; } } import java . util . * ; class Vizzzb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vizzzb = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; String tmp = sc . nextLine ( ) ; for ( int i = 0 ; i < vizzzb ; ++ i ) { String s = sc . nextLine ( ) ; map . putIfAbsent ( s , 0 ) ; map . put ( s , map . get ( s ) + 1 ) ; } SortedSet < String > st = new TreeSet < > ( ) ; int maxi = 0 ; for ( Map . Entry < String , Integer > entry : map . entrySet ( ) ) { maxi = Math . max ( maxi , entry . getValue ( ) ) ; } for ( Map . Entry < String , Integer > entry : map . entrySet ( ) ) { if ( entry . getValue ( ) == maxi ) { st . add ( entry . getKey ( ) ) ; } } for ( String ele : st ) { System . out . println ( ele ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Zkqpo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zkqpo = sc . nextInt ( ) ; int [ ] n = new int [ zkqpo ] ; for ( int i = 0 ; i < zkqpo ; i ++ ) { n [ i ] = sc . nextInt ( ) ; } Arrays . sort ( n ) ; int sum = 0 ; for ( int i = 0 ; i < zkqpo - 1 ; i ++ ) { sum += n [ i ] ; } if ( n [ zkqpo - 1 ] < sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Anjoeqc { public static void main ( String [ ] args ) { solve_149_B ( ) ; return ; } private static void solve_149_B ( ) { Scanner sc = new Scanner ( System . in ) ; long anjoeqc = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; if ( anjoeqc >= K ) { anjoeqc = anjoeqc - K ; } else { if ( B >= ( K - anjoeqc ) ) { B = B - ( K - anjoeqc ) ; } else { B = 0 ; } anjoeqc = 0 ; } System . out . println ( anjoeqc + " " + B ) ; } } import java . util . Scanner ; public class Unziv { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int unziv = scanner . nextInt ( ) ; int i = 0 ; int m = 0 ; i = unziv / 500 ; unziv = unziv - 500 * i ; m = unziv / 5 ; System . out . println ( 1000 * i + 5 * m ) ; } } import java . time . LocalDate ; import java . time . format . DateTimeFormatter ; import java . time . format . DateTimeParseException ; import java . util . Scanner ; public class Ujvcy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String sdate = sc . next ( ) ; try { DateTimeFormatter formatter = DateTimeFormatter . ofPattern ( " uuuu/MM/dd " ) ; LocalDate date = LocalDate . parse ( sdate , formatter ) ; LocalDate today = LocalDate . of ( 2019 , 4 , 30 ) ; int ujvcy = date . compareTo ( today ) ; if ( ujvcy <= 0 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } catch ( DateTimeParseException e ) { System . out . println ( " 堥力値がyyyy/mm/dd形式ではありません"); } } } import java . util . * ; public class Doqilev { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int doqilev = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; String s = sc . next ( ) ; StringBuffer buf = new StringBuffer ( ) ; for ( int i = 0 ; i < doqilev ; i ++ ) { char si = s . charAt ( i ) ; if ( i == k - 1 ) { if ( si == 'A' ) { buf . append ( " a " ) ; } if ( si == 'B' ) { buf . append ( " b " ) ; } if ( si == 'C' ) { buf . append ( " c " ) ; } } else { buf . append ( s . charAt ( i ) ) ; } } String new_s = buf . toString ( ) ; System . out . println ( new_s ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class Gqjlb { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int gqjlb = scn . nextInt ( ) ; float temp = ( float ) gqjlb / 3 ; BigDecimal b1 = new BigDecimal ( temp ) ; b1 = b1 . multiply ( new BigDecimal ( temp ) ) ; b1 = b1 . multiply ( new BigDecimal ( temp ) ) ; System . out . println ( b1 ) ; } } import java . util . Scanner ; public class Hwgki { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hwgki = sc . nextInt ( ) ; sc . close ( ) ; int c = hwgki / 4 ; int d = hwgki / 7 ; for ( int i = 0 ; i <= c ; i ++ ) { for ( int j = 0 ; j <= d ; j ++ ) { if ( 4 * i + 7 * j == hwgki ) { System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } } import java . util . * ; public class Tgdsxoy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . next ( ) ; char [ ] charArray = input . toCharArray ( ) ; Arrays . sort ( charArray ) ; String sortedString = new String ( charArray ) ; int tgdsxoy = sortedString . length ( ) ; int cnt = 0 ; char tmpVal = sortedString . charAt ( 0 ) ; if ( tgdsxoy <= 1 ) { System . out . println ( " No " ) ; return ; } for ( int i = 0 ; i < tgdsxoy ; i ++ ) { char val = sortedString . charAt ( i ) ; if ( val == tmpVal ) { cnt ++ ; } else { if ( cnt % 2 != 0 ) { System . out . println ( " No " ) ; return ; } cnt = 1 ; tmpVal = val ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Fkmoyqc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int fkmoyqc = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; int m = fkmoyqc * y ; int n = 2 * fkmoyqc + 2 * y ; System . out . println ( m + " " + n ) ; } } import java . util . * ; public class Wizgm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wizgm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = wizgm * b ; if ( ans == 2 ) { System . out . println ( " 3 " ) ; } else if ( ans == 3 ) { System . out . println ( " 2 " ) ; } else { System . out . println ( " 1 " ) ; } } } import java . io . * ; class Ymbllk { public static int prime ( int x ) { int ymbllk = 0 ; if ( x == 1 ) { ymbllk = 1 ; } else if ( x % 2 == 0 ) { ymbllk = 1 ; } for ( int i = 3 ; i <= Math . sqrt ( x ) ; i += 2 ) { if ( x % i == 0 ) { ymbllk = 1 ; break ; } } if ( x == 2 ) { ymbllk = 0 ; } return ymbllk ; } public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { int N = Integer . parseInt ( reader . readLine ( ) ) ; ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = Integer . parseInt ( reader . readLine ( ) ) ; } int count = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { if ( prime ( a [ i ] ) == 0 ) { count += 1 ; } } System . out . println ( count ) ; } catch ( IOException e ) { System . out . println ( e ) ; } } } import java . io . * ; import java . util . * ; public class Byhfjep { public static void main ( String [ ] args ) throws IOException { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String s = br . readLine ( ) ; StringTokenizer st = new StringTokenizer ( s , " " ) ; int byhfjep = Integer . parseInt ( st . nextToken ( ) ) ; int y = Integer . parseInt ( st . nextToken ( ) ) ; System . out . print ( byhfjep * y ) ; System . out . print ( " " ) ; System . out . println ( 2 * byhfjep + 2 * y ) ; } } import java . io . * ; import java . util . * ; class Nlsiae { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int nlsiae = Integer . parseInt ( st . nextToken ( ) ) ; int T = Integer . parseInt ( st . nextToken ( ) ) ; int S = Integer . parseInt ( st . nextToken ( ) ) ; float tmp = ( float ) nlsiae / T ; if ( S >= tmp ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Aguwp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aguwp = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int sum = 0 ; int [ ] arr = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; sum = sum + arr [ i ] ; } if ( aguwp - sum >= 0 ) { System . out . print ( ( aguwp - sum ) ) ; } else { System . out . print ( - 1 ) ; } } } import java . util . * ; public class Lqjerql { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lqjerql = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; double sum = 0 ; int cnt = 0 ; Integer [ ] items = new Integer [ lqjerql ] ; for ( int i = 0 ; i < lqjerql ; i ++ ) { int itemVote = sc . nextInt ( ) ; sum += itemVote ; items [ i ] = itemVote ; } Arrays . sort ( items , Collections . reverseOrder ( ) ) ; double baseNum = sum / ( ( double ) 4 * ( double ) M ) ; for ( int l = 0 ; l < M ; l ++ ) { double val = ( double ) items [ l ] ; if ( val < baseNum ) { continue ; } cnt ++ ; } if ( cnt >= M ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Pkjlenb { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int pkjlenb = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; int K = in . nextInt ( ) ; int sum = pkjlenb + B + C ; int max = Math . max ( pkjlenb , Math . max ( B , C ) ) ; sum += - max + ( max << K ) ; System . out . println ( sum ) ; } } } import java . util . Scanner ; public class Mnbxcbp { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int mnbxcbp = input . nextInt ( ) ; int [ ] level = new int [ mnbxcbp ] ; int count = 1 ; int min = 0 ; for ( int i = 0 ; i < mnbxcbp ; i ++ ) { level [ i ] = input . nextInt ( ) ; if ( i == 0 ) { min = level [ 0 ] ; } else { if ( level [ i ] <= min ) { count ++ ; min = level [ i ] ; } } } System . out . println ( count ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . LinkedList ; import java . util . Scanner ; public class Rllnh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rllnh = sc . nextInt ( ) ; int strength1 = sc . nextInt ( ) ; int health2 = sc . nextInt ( ) ; int strength2 = sc . nextInt ( ) ; while ( true ) { health2 -= strength1 ; if ( health2 <= 0 ) break ; rllnh -= strength2 ; if ( rllnh <= 0 ) break ; } if ( rllnh > health2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Qkoqr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int qkoqr = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; if ( qkoqr == - 1 && f == - 1 && r == - 1 ) { break ; } else { int x ; x = qkoqr + f ; if ( qkoqr == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } if ( x >= 80 && qkoqr != - 1 && f != - 1 ) { System . out . println ( " A " ) ; } if ( x < 80 && x >= 65 && qkoqr != - 1 && f != - 1 ) { System . out . println ( " B " ) ; } if ( x < 65 && x >= 50 && qkoqr != - 1 && f != - 1 ) { System . out . println ( " C " ) ; } if ( x < 50 && x >= 30 && qkoqr != - 1 && f != - 1 && r >= 50 ) { System . out . println ( " C " ) ; } if ( x >= 30 && x < 50 && qkoqr != - 1 && f != - 1 && r < 50 ) { System . out . println ( " D " ) ; } if ( x < 30 && qkoqr != - 1 && f != - 1 ) { System . out . println ( " F " ) ; } } } } } import java . util . Scanner ; public class Pymtt { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int pymtt = gi ( ) ; int M = gi ( ) ; int a = ( int ) Math . ceil ( ( double ) ( M - 1 ) / ( double ) ( pymtt - 1 ) ) ; System . out . print ( a ) ; } public static String gs ( ) { return scanner . next ( ) ; } public static int gi ( ) { return Integer . parseInt ( scanner . next ( ) ) ; } public static long gl ( ) { return Long . parseLong ( scanner . next ( ) ) ; } public static double gd ( ) { return Double . parseDouble ( scanner . next ( ) ) ; } } import java . util . * ; public class Kftttq { static final Scanner stdin = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { while ( stdin . hasNext ( ) ) { int kftttq = stdin . nextInt ( ) ; int b = stdin . nextInt ( ) ; int comp_val = kftttq - b ; int num , aval , m , n , ans1 ; if ( comp_val > 0 ) { for ( int i = 0 ; i <= kftttq ; i ++ ) { aval = kftttq - i ; if ( kftttq % aval == 0 && b % aval == 0 ) { m = kftttq / aval ; n = b / aval ; ans1 = m * n * aval ; System . out . println ( aval + " " + ans1 ) ; break ; } } } else { for ( int i = 0 ; i <= b ; i ++ ) { aval = b - i ; if ( kftttq % aval == 0 && b % aval == 0 ) { m = kftttq / aval ; n = b / aval ; ans1 = m * n * aval ; System . out . println ( aval + " " + ans1 ) ; break ; } } } } } } import java . util . Scanner ; public class Oasbbee { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String S = input . next ( ) ; long oasbbee = input . nextLong ( ) ; String ans = " " ; double days = 5.0 * Math . pow ( 10 , 15 ) ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { char c = S . charAt ( i ) ; int n = Character . getNumericValue ( c ) ; oasbbee -= ( long ) Math . pow ( n , days ) ; if ( oasbbee <= 0 ) { System . out . println ( c ) ; return ; } } } } import java . util . Scanner ; public class Znbmf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int znbmf = sc . nextInt ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) for ( int a = 1 ; a <= 9 ; a ++ ) { if ( i * a == znbmf ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Sjhkysv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String sjhkysv = sc . next ( ) ; char [ ] wordStr = sjhkysv . toCharArray ( ) ; if ( wordStr [ 2 ] != wordStr [ 3 ] ) { System . out . println ( " No " ) ; return ; } if ( wordStr [ 4 ] != wordStr [ 5 ] ) { System . out . println ( " No " ) ; return ; } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Pzokfi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int pzokfi = scanner . nextInt ( ) ; int homeworkNumber = scanner . nextInt ( ) ; int [ ] daysSpentInHomework = new int [ homeworkNumber ] ; int studyDay = 0 ; for ( int i = 0 ; i < homeworkNumber ; i ++ ) { daysSpentInHomework [ i ] = scanner . nextInt ( ) ; } for ( int j = 0 ; j < homeworkNumber ; j ++ ) { studyDay = studyDay + daysSpentInHomework [ j ] ; } int playable ; if ( pzokfi - studyDay >= 0 ) { playable = pzokfi - studyDay ; System . out . println ( playable ) ; } else { System . out . println ( " -1 " ) ; } scanner . close ( ) ; } } import java . util . * ; public class Mynfnf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mynfnf = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] c = new int [ mynfnf ] ; int [ ] t = new int [ mynfnf ] ; int cmin = 1001 ; int twithin = 1001 ; for ( int i = 0 ; i < mynfnf ; i ++ ) { c [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; if ( t [ i ] <= T && cmin > c [ i ] ) { twithin = t [ i ] ; cmin = c [ i ] ; } } if ( twithin == 1001 ) { System . out . println ( " TLE " ) ; } else { System . out . println ( cmin ) ; } } } import java . util . * ; public class Ibawtfj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ibawtfj = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; String ss = s ; ss = ss . substring ( ibawtfj , ibawtfj + 1 ) ; if ( ss . equals ( " - " ) ) { s = s . replace ( " - " , " " ) ; int slen = s . length ( ) ; if ( slen == ibawtfj + b ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Jghrppj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jghrppj = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; if ( C - ( jghrppj - B ) < 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( C - ( jghrppj - B ) ) ; } } } import java . util . * ; public class Qxvpmbh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qxvpmbh = sc . nextInt ( ) ; int [ ] arr = new int [ qxvpmbh ] ; for ( int i = 0 ; i < qxvpmbh ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int [ ] leftSum = new int [ qxvpmbh ] ; leftSum [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < qxvpmbh ; i ++ ) leftSum [ i ] = leftSum [ i - 1 ] + arr [ i ] ; int [ ] rightSum = new int [ qxvpmbh ] ; rightSum [ qxvpmbh - 1 ] = arr [ qxvpmbh - 1 ] ; for ( int i = qxvpmbh - 2 ; i >= 0 ; i -- ) { rightSum [ i ] += rightSum [ i + 1 ] + arr [ i ] ; } int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < qxvpmbh - 1 ; i ++ ) min = Math . min ( min , Math . abs ( leftSum [ i ] - rightSum [ i + 1 ] ) ) ; System . out . println ( min ) ; } } import java . util . * ; public class Rnxviqn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rnxviqn = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] [ ] a = new int [ rnxviqn ] [ m ] ; int [ ] [ ] b = new int [ m ] [ l ] ; for ( int i = 0 ; i < rnxviqn ; i ++ ) for ( int j = 0 ; j < m ; j ++ ) a [ i ] [ j ] = sc . nextInt ( ) ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = 0 ; j < l ; j ++ ) b [ i ] [ j ] = sc . nextInt ( ) ; for ( int i = 0 ; i < rnxviqn ; i ++ ) { for ( int j = 0 ; j < l ; j ++ ) { long cij = 0 ; for ( int k = 0 ; k < m ; k ++ ) cij += a [ i ] [ k ] * b [ k ] [ j ] ; System . out . print ( ( j == 0 ) ? cij : " " + cij ) ; } System . out . println ( ) ; } } } import java . util . * ; class Koqvd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int koqvd = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == '1' ) { koqvd += 1 ; } } System . out . println ( koqvd ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class Sbwsipj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] parts = br . readLine ( ) . split ( " " ) ; long sbwsipj = Integer . parseInt ( parts [ 0 ] ) ; long K = Integer . parseInt ( parts [ 1 ] ) ; parts = br . readLine ( ) . split ( " " ) ; long [ ] H = new long [ parts . length ] ; for ( int i = 0 ; i < H . length ; i ++ ) { H [ i ] = Integer . parseInt ( parts [ i ] ) ; } Arrays . sort ( H ) ; long sum = 0 ; for ( int i = 0 ; i < H . length - K ; i ++ ) { sum += H [ i ] ; } System . out . println ( sum ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Uhcomt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uhcomt = sc . nextInt ( ) ; int [ ] x = new int [ uhcomt ] ; for ( int i = 0 ; i < uhcomt ; i ++ ) x [ i ] = sc . nextInt ( ) ; Arrays . sort ( x ) ; int alice = 0 ; int bob = 0 ; if ( uhcomt % 2 == 0 ) { for ( int i = uhcomt - 1 ; i >= 0 ; i -= 2 ) { alice += x [ i ] ; bob += x [ i - 1 ] ; } } if ( uhcomt % 2 != 0 ) { if ( uhcomt == 1 ) alice += x [ 0 ] ; else { for ( int i = 0 ; i < uhcomt ; i += 2 ) alice += x [ i ] ; for ( int i = 1 ; i < uhcomt ; i += 2 ) bob += x [ i ] ; } } System . out . println ( alice - bob ) ; } } import java . util . * ; public class Eyctdmy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eyctdmy = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; List < Integer > divsA = new ArrayList < > ( ) ; List < Integer > divsB = new ArrayList < > ( ) ; for ( int i = 1 ; i <= eyctdmy ; ++ i ) { if ( eyctdmy % i == 0 ) divsA . add ( i ) ; } for ( int i = 1 ; i <= b ; ++ i ) { if ( b % i == 0 ) divsB . add ( i ) ; } List < Integer > divs = new ArrayList < > ( ) ; for ( int i = 0 ; i < divsA . size ( ) ; ++ i ) { for ( int j = 0 ; j < divsB . size ( ) ; ++ j ) { if ( divsA . get ( i ) == divsB . get ( j ) ) { divs . add ( divsA . get ( i ) ) ; } } } System . out . println ( divs . get ( divs . size ( ) - k ) ) ; } } import java . util . Arrays ; import java . util . Scanner ; class Ujsstv { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int ujsstv = s . nextInt ( ) ; int [ ] arr = new int [ ujsstv ] ; for ( int i = 0 ; i < ujsstv ; i ++ ) { arr [ i ] = s . nextInt ( ) ; } long [ ] dp = new long [ ujsstv ] ; dp [ 0 ] = 0 ; for ( int i = 1 ; i < ujsstv ; i ++ ) { long option1 = Math . abs ( arr [ i ] - arr [ i - 1 ] ) + dp [ i - 1 ] ; long option2 = i == 1 ? Integer . MAX_VALUE : Math . abs ( arr [ i ] - arr [ i - 2 ] ) + dp [ i - 2 ] ; dp [ i ] = Math . min ( option1 , option2 ) ; } System . out . println ( dp [ ujsstv - 1 ] ) ; } } import java . util . * ; class Nmhmszb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long nmhmszb = sc . nextLong ( ) ; double B = sc . nextDouble ( ) ; long ans = 0 ; ans = nmhmszb * ( Math . round ( B * 100 ) ) / 100 ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Wihaz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wihaz = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int count = 0 ; while ( wihaz != 0 || x != 0 ) { for ( int i = 1 ; i <= wihaz ; i ++ ) { for ( int j = i + 1 ; j <= wihaz ; j ++ ) { for ( int k = j + 1 ; k <= wihaz ; k ++ ) { if ( i + j + k == x ) { count ++ ; } } } } System . out . println ( count ) ; wihaz = scan . nextInt ( ) ; x = scan . nextInt ( ) ; count = 0 ; } } } import java . util . * ; public class Vhdapf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] a = s . toCharArray ( ) ; for ( int vhdapf = a . length - 1 ; vhdapf >= 0 ; vhdapf -- ) System . out . print ( a [ vhdapf ] ) ; System . out . println ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; class Qmoze { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String name ; int qmoze ; int compare ; String waku = " " ; int [ ] a = new int [ 2 ] ; int i = 0 ; while ( true ) { try { name = br . readLine ( ) ; StringTokenizer st = new StringTokenizer ( name , " " ) ; while ( st . hasMoreTokens ( ) ) { a [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; i ++ ; } i = 0 ; if ( a [ 0 ] == 0 && a [ 1 ] == 0 ) { System . exit ( 0 ) ; } else { for ( int k = 0 ; k < a [ 1 ] ; k ++ ) { waku = waku + " # " ; } for ( int j = 0 ; j < a [ 0 ] ; j ++ ) { System . out . println ( waku ) ; } System . out . println ( " " ) ; waku = " " ; } } catch ( Exception e ) { System . exit ( 0 ) ; } } } } import java . util . * ; public class Yptbtx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] n = sc . nextLine ( ) . toCharArray ( ) ; int yptbtx = 0 ; for ( char c : n ) { yptbtx += Character . getNumericValue ( c ) ; } if ( yptbtx % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Vkgeqmf { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int vkgeqmf = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; int [ ] l = new int [ m ] ; int [ ] r = new int [ m ] ; int l_max = 0 ; int r_min = 100000 ; for ( int i = 0 ; i < m ; i ++ ) { str = in . readLine ( ) . split ( " " ) ; l [ i ] = Integer . parseInt ( str [ 0 ] ) ; l_max = Math . max ( l [ i ] , l_max ) ; r [ i ] = Integer . parseInt ( str [ 1 ] ) ; r_min = Math . min ( r [ i ] , r_min ) ; } System . out . println ( r_min - l_max + 1 > 0 ? r_min - l_max + 1 : 0 ) ; } } import java . io . * ; import java . util . * ; class Anuhb { public static void main ( String [ ] args ) throws IOException { int anuhb = 0 ; int b = 0 ; int c = 0 ; int i = 0 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; String delimiter = " " ; StringTokenizer stringTokenizer = new StringTokenizer ( str , delimiter ) ; while ( stringTokenizer . hasMoreTokens ( ) ) { String current = stringTokenizer . nextToken ( ) ; if ( i == 0 ) anuhb = Integer . parseInt ( current ) ; if ( i == 1 ) b = Integer . parseInt ( current ) ; if ( i == 2 ) c = Integer . parseInt ( current ) ; i ++ ; } if ( anuhb < b && b < c ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Klkfyag { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int klkfyag = s . nextInt ( ) ; int numn = s . nextInt ( ) ; if ( numn == 0 ) { System . out . println ( klkfyag ) ; s . close ( ) ; System . exit ( 0 ) ; } Integer [ ] array = new Integer [ numn ] ; for ( int i = 0 ; i < numn ; i ++ ) { array [ i ] = s . nextInt ( ) ; } List < Integer > listNum = Arrays . asList ( array ) ; s . close ( ) ; int ans = 0 ; boolean flg_con = true ; if ( ! listNum . contains ( klkfyag ) ) { ans = klkfyag ; flg_con = false ; } int count = 0 ; while ( flg_con ) { count ++ ; int mnx = klkfyag - count ; int plx = klkfyag + count ; if ( ! listNum . contains ( mnx ) ) { ans = mnx ; flg_con = false ; } else if ( ! listNum . contains ( plx ) ) { ans = plx ; flg_con = false ; } } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . * ; import java . util . * ; import java . util . ArrayList ; import java . util . Iterator ; import java . util . List ; import java . util . Collections ; public class Xfjsu { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xfjsu = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = 0 ; if ( xfjsu % 2 == 1 ) { count ++ ; } char [ ] work = new char [ s . length ( ) ] ; for ( int i = 0 ; i < xfjsu ; i ++ ) { work [ i ] = s . charAt ( i ) ; } for ( int i = 0 ; i < xfjsu / 2 ; i ++ ) { if ( work [ i ] == work [ i + xfjsu / 2 ] ) { } else { count ++ ; } } if ( count == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Efciz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int efciz = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < C + 1 ; i ++ ) { int Y = X - 50 * i ; if ( Y == 0 ) { cnt ++ ; continue ; } for ( int j = 0 ; j < B + 1 ; j ++ ) { int Z = Y - 100 * j ; if ( Z == 0 ) { cnt ++ ; continue ; } for ( int k = 0 ; k < efciz + 1 ; k ++ ) { int W = Z - 500 * k ; if ( W == 0 ) { cnt ++ ; continue ; } } } } System . out . println ( cnt ) ; } } import java . util . * ; public class Vytcon { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vytcon = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ 101 ] ; for ( int i = 1 ; i <= 100 ; i ++ ) { if ( ( vytcon % i == 0 ) && ( b % i == 0 ) ) { arr [ i ] = i ; } } int count = 0 ; for ( int i = 100 ; i >= 0 ; i -- ) { if ( arr [ i ] > 0 ) { count ++ ; } if ( count == k ) { System . out . println ( i ) ; break ; } } } } import java . util . Scanner ; public class Nqeufvs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int nqeufvs = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { nqeufvs += str . charAt ( i ) - '0' ; } System . out . println ( Integer . parseInt ( str ) % nqeufvs == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Kjexf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String day = sc . nextLine ( ) ; String [ ] str = day . split ( " / " ) ; int [ ] a = new int [ 3 ] ; for ( int kjexf = 0 ; kjexf < str . length ; kjexf ++ ) a [ kjexf ] = Integer . parseInt ( str [ kjexf ] ) ; if ( a [ 0 ] > 2019 ) System . out . println ( " TBD " ) ; else if ( a [ 0 ] == 2019 && a [ 1 ] > 4 ) System . out . println ( " TBD " ) ; else if ( a [ 0 ] == 2019 && a [ 1 ] > 4 && a [ 2 ] < 31 ) System . out . println ( " TBD " ) ; else System . out . println ( " Heisei " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Xzrmmaf { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] nums = br . readLine ( ) . split ( " " ) ; br . close ( ) ; int xzrmmaf = Integer . parseInt ( nums [ 0 ] ) ; int b = Integer . parseInt ( nums [ 1 ] ) ; if ( xzrmmaf > 9 || b > 9 ) System . out . println ( - 1 ) ; else System . out . println ( xzrmmaf * b ) ; } } import java . util . * ; class Blbscwl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int blbscwl = sc . nextInt ( ) ; int [ ] T = new int [ blbscwl + 1 ] ; int [ ] X = new int [ blbscwl + 1 ] ; int [ ] Y = new int [ blbscwl + 1 ] ; T [ 0 ] = X [ 0 ] = Y [ 0 ] = 0 ; boolean yes = true ; for ( int i = 1 ; i <= blbscwl ; i ++ ) { T [ i ] = sc . nextInt ( ) ; X [ i ] = sc . nextInt ( ) ; Y [ i ] = sc . nextInt ( ) ; int d = Math . abs ( X [ i ] - X [ i - 1 ] ) + Math . abs ( Y [ i ] - Y [ i - 1 ] ) ; int dt = T [ i ] - T [ i - 1 ] ; if ( d > dt || d % 2 != dt % 2 ) { yes = false ; break ; } } System . out . println ( yes ? " Yes " : " No " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Teoboj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < String > slist = new ArrayList < String > ( ) ; String beforeWord = null ; String word = null ; boolean teoboj = true ; int size = sc . nextInt ( ) ; if ( size > 100 ) { teoboj = false ; System . out . println ( " No " ) ; return ; } word = sc . nextLine ( ) ; for ( int i = 0 ; i < size ; i ++ ) { word = sc . nextLine ( ) ; if ( beforeWord != null ) { char shiri = beforeWord . charAt ( beforeWord . length ( ) - 1 ) ; char atama = word . charAt ( 0 ) ; if ( shiri == atama ) { teoboj = true ; } else { teoboj = false ; break ; } } if ( ! slist . contains ( word ) ) { if ( teoboj ) { slist . add ( word ) ; beforeWord = word ; } } else { teoboj = false ; break ; } } if ( teoboj ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Vgzdu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int vgzdu = Integer . parseInt ( sc . next ( ) ) ; int W = Integer . parseInt ( sc . next ( ) ) ; if ( vgzdu == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < vgzdu ; i ++ ) { if ( i == 0 || i == vgzdu - 1 ) { for ( int j = 0 ; j < W ; j ++ ) { System . out . print ( " # " ) ; } System . out . print ( " \n " ) ; } else { System . out . print ( " # " ) ; for ( int j = 0 ; j < W - 2 ; j ++ ) { System . out . print ( " . " ) ; } System . out . print ( " # " ) ; System . out . print ( " \n " ) ; } } System . out . print ( " \n " ) ; } } } import java . util . Scanner ; public class Ainpzk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ainpzk = sc . nextInt ( ) ; int ans = ainpzk + ainpzk * ainpzk + ( int ) Math . pow ( ainpzk , 3 ) ; System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; import java . math . BigInteger ; class Hntoarp { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; BigInteger a , b , c , d ; BigInteger q , w , e , r , s ; a = cin . nextBigInteger ( ) ; b = cin . nextBigInteger ( ) ; c = cin . nextBigInteger ( ) ; d = cin . nextBigInteger ( ) ; q = a . multiply ( c ) ; w = a . multiply ( d ) ; e = b . multiply ( c ) ; r = b . multiply ( d ) ; BigInteger ans ; ans = q . max ( w ) ; ans = ans . max ( e ) ; ans = ans . max ( r ) ; s = BigInteger . valueOf ( 0 ) ; if ( a . compareTo ( s ) <= 0 && b . compareTo ( s ) >= 0 || c . compareTo ( s ) <= 0 && d . compareTo ( s ) >= 0 ) { if ( ans . compareTo ( s ) <= 0 ) ans = s ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Bfruow { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bfruow = Integer . parseInt ( sc . nextLine ( ) ) ; int result = 0 ; for ( int i = 0 ; i < bfruow ; i ++ ) { int target = Integer . parseInt ( sc . nextLine ( ) ) ; if ( target == 1 ) { continue ; } boolean flgPrime = true ; for ( int j = 2 ; j <= ( int ) Math . sqrt ( target ) ; j ++ ) { if ( target % j == 0 ) { flgPrime = false ; break ; } } if ( flgPrime ) { result ++ ; } } System . out . println ( result ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Stack ; public class Xsnmmm { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] inputArray = br . readLine ( ) . split ( " " ) ; Stack < Integer > stack = new Stack < Integer > ( ) ; int xsnmmm = 0 ; int b = 0 ; for ( int i = 0 ; i < inputArray . length ; i ++ ) { if ( inputArray [ i ] . equals ( " + " ) ) { xsnmmm = stack . pop ( ) ; b = stack . pop ( ) ; stack . add ( b + xsnmmm ) ; continue ; } if ( inputArray [ i ] . equals ( " - " ) ) { xsnmmm = stack . pop ( ) ; b = stack . pop ( ) ; stack . add ( b - xsnmmm ) ; continue ; } if ( inputArray [ i ] . equals ( " * " ) ) { xsnmmm = stack . pop ( ) ; b = stack . pop ( ) ; stack . add ( b * xsnmmm ) ; continue ; } stack . push ( Integer . parseInt ( inputArray [ i ] ) ) ; } System . out . println ( stack . pop ( ) ) ; } } import java . util . Arrays ; import java . util . Scanner ; class Txzpnvb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int txzpnvb = sc . nextInt ( ) ; long [ ] A = new long [ txzpnvb ] ; for ( long i = 0L ; i < txzpnvb ; i ++ ) { long t = sc . nextLong ( ) * 100000000L + ( i + 1L ) ; A [ ( int ) i ] = t ; } Arrays . sort ( A ) ; for ( int i = 0 ; i < txzpnvb - 1 ; i ++ ) { System . out . print ( A [ i ] % 100000000 + " " ) ; } System . out . println ( A [ txzpnvb - 1 ] % 100000000 ) ; } public static void p ( Object o ) { System . out . println ( o ) ; } } import java . util . Scanner ; import java . util . Arrays ; import static java . lang . System . out ; class Yhbzwf { public static int [ ] sorted ( int [ ] inputs ) { int [ ] res = Arrays . copyOf ( inputs , inputs . length ) ; for ( int yhbzwf = 0 ; yhbzwf < res . length ; yhbzwf ++ ) { for ( int j = 1 ; j < res . length - yhbzwf ; j ++ ) { if ( res [ j - 1 ] > res [ j ] ) { int tmp = res [ j - 1 ] ; res [ j - 1 ] = res [ j ] ; res [ j ] = tmp ; } } } return res ; } } public class Yhbzwf { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] inputs = new int [ 3 ] ; int yhbzwf = 0 ; while ( scan . hasNext ( ) ) { inputs [ yhbzwf ] = scan . nextInt ( ) ; yhbzwf ++ ; } StringBuilder output = new StringBuilder ( ) ; for ( int num : SortingThreeNumbers . sorted ( inputs ) ) { output . append ( String . valueOf ( num ) + " " ) ; } output . deleteCharAt ( output . length ( ) - 1 ) ; out . println ( output ) ; } } import java . io . * ; import java . util . * ; class Krefqif { public static void main ( String [ ] args ) throws IOException { int krefqif = 0 ; int b = 0 ; int c = 0 ; int i = 0 ; int tmp = 0 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; String delimiter = " " ; StringTokenizer stringTokenizer = new StringTokenizer ( str , delimiter ) ; while ( stringTokenizer . hasMoreTokens ( ) ) { String current = stringTokenizer . nextToken ( ) ; if ( i == 0 ) krefqif = Integer . parseInt ( current ) ; if ( i == 1 ) b = Integer . parseInt ( current ) ; if ( i == 2 ) c = Integer . parseInt ( current ) ; i ++ ; } if ( krefqif > c ) { tmp = krefqif ; krefqif = c ; c = tmp ; } if ( krefqif > b ) { tmp = krefqif ; krefqif = b ; b = tmp ; } if ( b > c ) { tmp = b ; b = c ; c = tmp ; } System . out . println ( krefqif + " " + b + " " + c ) ; } } import java . util . * ; public class Dzxjvev { static StringBuilder a = new StringBuilder ( ) ; static StringBuilder b = new StringBuilder ( ) ; static StringBuilder c = new StringBuilder ( ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; a . append ( sc . next ( ) ) ; b . append ( sc . next ( ) ) ; c . append ( sc . next ( ) ) ; char dzxjvev = a . charAt ( 0 ) ; a . deleteCharAt ( 0 ) ; Main . nextTurn ( dzxjvev ) ; } public static void nextTurn ( char card ) { if ( card == 'a' ) { if ( a . length ( ) == 0 ) { System . out . println ( " A " ) ; return ; } char dzxjvev = a . charAt ( 0 ) ; a . deleteCharAt ( 0 ) ; Main . nextTurn ( dzxjvev ) ; } else if ( card == 'b' ) { if ( b . length ( ) == 0 ) { System . out . println ( " B " ) ; return ; } char dzxjvev = b . charAt ( 0 ) ; b . deleteCharAt ( 0 ) ; Main . nextTurn ( dzxjvev ) ; } else if ( card == 'c' ) { if ( c . length ( ) == 0 ) { System . out . println ( " C " ) ; return ; } char dzxjvev = c . charAt ( 0 ) ; c . deleteCharAt ( 0 ) ; Main . nextTurn ( dzxjvev ) ; } } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Ehdvm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ehdvm = Integer . parseInt ( sc . nextLine ( ) ) ; Map < String , Long > m = new HashMap < > ( ) ; for ( int i = 0 ; i < ehdvm ; i ++ ) { char [ ] c = sc . nextLine ( ) . toCharArray ( ) ; Arrays . sort ( c ) ; String k = new String ( c ) ; if ( m . get ( k ) == null ) { m . put ( k , 1L ) ; } else { m . put ( k , m . get ( k ) + 1 ) ; } } long ans = 0 ; for ( Long v : m . values ( ) ) { ans += v * ( v - 1 ) / 2 ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Lsohff { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lsohff = sc . nextInt ( ) ; System . out . println ( ( 10000 - lsohff ) % 1000 ) ; sc . close ( ) ; } } import java . util . * ; public class Nyqsoj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int nyqsoj = sc . nextInt ( ) ; long A = ( long ) ( Math . pow ( 10 , 18 ) ) ; long [ ] B = new long [ nyqsoj ] ; boolean chk_0 = false ; for ( int i = 0 ; i < nyqsoj ; i ++ ) { B [ i ] = sc . nextLong ( ) ; if ( B [ i ] == 0 ) { chk_0 = true ; } } long C = 0L ; boolean chk = true ; if ( ! chk_0 ) { C = B [ 0 ] ; for ( int i = 1 ; i < B . length ; i ++ ) { try { C = Math . multiplyExact ( C , B [ i ] ) ; } catch ( ArithmeticException e ) { chk = false ; break ; } } } if ( ! chk || A < C ) { System . out . println ( - 1 ) ; } else { System . out . println ( C ) ; } } } import java . util . * ; class Bxavnfc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bxavnfc = sc . nextInt ( ) ; int [ ] [ ] t = new int [ bxavnfc ] [ 3 ] ; for ( int i = 0 ; i < bxavnfc ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { t [ i ] [ j ] = sc . nextInt ( ) ; } if ( triangle ( i , t ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } public static boolean triangle ( int i , int [ ] [ ] t ) { double max = Math . max ( Math . max ( t [ i ] [ 0 ] , t [ i ] [ 1 ] ) , t [ i ] [ 2 ] ) ; double res = Math . min ( Math . min ( Math . hypot ( t [ i ] [ 0 ] , t [ i ] [ 1 ] ) , Math . hypot ( t [ i ] [ 0 ] , t [ i ] [ 2 ] ) ) , Math . hypot ( t [ i ] [ 2 ] , t [ i ] [ 1 ] ) ) ; if ( res == max ) { return true ; } else { return false ; } } } import java . util . * ; public class Tljuf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tljuf = Integer . parseInt ( sc . next ( ) ) ; Integer [ ] d1 = new Integer [ tljuf ] ; Integer [ ] d2 = new Integer [ tljuf ] ; for ( int i = 0 ; i < tljuf ; i ++ ) { d1 [ i ] = Integer . parseInt ( sc . next ( ) ) ; d2 [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; boolean judge = false ; int renzoku = 0 ; for ( int i = 0 ; i < tljuf ; i ++ ) { if ( d1 [ i ] == d2 [ i ] ) { renzoku ++ ; } else { renzoku = 0 ; } if ( renzoku == 3 ) { judge = true ; break ; } } String result = judge ? " Yes " : " No " ; System . out . println ( result ) ; } } import java . util . Scanner ; public class Wyfocfx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int wyfocfx = scanner . nextInt ( ) ; String s = scanner . next ( ) ; System . out . println ( ( wyfocfx - s . replaceAll ( " ABC " , " " ) . length ( ) ) / 3 ) ; } } import java . util . * ; import java . util . Map . Entry ; import java . util . stream . Collectors ; public class Vefiw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vefiw = sc . nextInt ( ) ; String [ ] S = new String [ vefiw ] ; for ( int i = 0 ; i < vefiw ; i ++ ) { S [ i ] = sc . next ( ) ; } sc . close ( ) ; int maxDup = 1 ; Map < String , Integer > m = new HashMap < String , Integer > ( ) ; for ( String s : S ) { int v ; if ( m . containsKey ( s ) ) { v = m . get ( s ) + 1 ; if ( v > maxDup ) { maxDup = v ; } } else { v = 1 ; } m . put ( s , v ) ; } ArrayList < String > list = new ArrayList < String > ( ) ; for ( Entry < String , Integer > entry : m . entrySet ( ) ) { if ( entry . getValue ( ) == maxDup ) { list . add ( entry . getKey ( ) ) ; } } Collections . sort ( list ) ; for ( String s : list ) { System . out . println ( s ) ; } } } import java . util . * ; public class Visttb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int visttb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = 0 ; int [ ] d = new int [ visttb ] ; for ( int i = 0 ; i < visttb ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < visttb ; i ++ ) { if ( d [ i ] >= b ) { c ++ ; } } System . out . println ( c ) ; } } import java . util . * ; import java . io . * ; public class Pspepq { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; long pspepq = sc . nextLong ( ) ; long m = sc . nextLong ( ) ; if ( pspepq > m ) System . out . println ( pspepq * m / gcd ( pspepq , m ) ) ; else System . out . println ( pspepq * m / gcd ( m , pspepq ) ) ; } static long gcd ( long a , long b ) { long temp ; while ( ( temp = a % b ) != 0 ) { a = b ; b = temp ; } return b ; } } import java . util . Scanner ; public class Kryok { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { long kryok = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; long c = gcd ( kryok , b ) ; long d = kryok * b / c ; System . out . println ( c + " " + d ) ; } sc . close ( ) ; } public long gcd ( long kryok , long b ) { if ( b == 0 ) { return kryok ; } else { return gcd ( b , kryok % b ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Zhxxmi { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int zhxxmi ; int result ; String readLine = br . readLine ( ) ; zhxxmi = Integer . parseInt ( readLine ) ; result = zhxxmi * zhxxmi * zhxxmi ; System . out . println ( result ) ; } } import java . util . Scanner ; public class Pkrnhi { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int pkrnhi = in . nextInt ( ) ; int [ ] order = new int [ pkrnhi + 1 ] ; for ( int i = 1 ; i <= pkrnhi ; i ++ ) { order [ in . nextInt ( ) ] = i ; } for ( int i = 1 ; i <= pkrnhi ; i ++ ) { System . out . print ( order [ i ] + " " ) ; } in . close ( ) ; } } import java . util . * ; class Wuhtcox { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wuhtcox = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] a = new int [ wuhtcox ] ; for ( int i = 0 ; i < wuhtcox ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; int sum = 0 ; int j = 0 ; while ( k -- > 0 ) { sum += a [ j ] ; j ++ ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Xormx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s , t ; int xormx , b ; String u ; s = scan . next ( ) ; t = scan . next ( ) ; xormx = scan . nextInt ( ) ; b = scan . nextInt ( ) ; u = scan . next ( ) ; if ( u . equals ( s ) ) xormx -= 1 ; else b -= 1 ; System . out . printf ( xormx + " " + b ) ; } } import java . util . * ; class Fwpqb { public static void main ( String [ ] g ) { Scanner S = new Scanner ( System . in ) ; for ( int fwpqb = S . nextInt ( ) , j , x , y , z , a [ ] = new int [ 3 ] ; fwpqb -- > 0 ; System . out . println ( a [ 2 ] * a [ 2 ] == a [ 1 ] * a [ 1 ] + a [ 0 ] * a [ 0 ] ? " YES " : " NO " ) ) { for ( j = 0 ; j < 3 ; ) a [ j ++ ] = S . nextInt ( ) ; Arrays . sort ( a ) ; } } } import java . util . * ; public class Swueh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int swueh = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; ArrayList < Integer > aList = new ArrayList < Integer > ( swueh ) ; ArrayList < Integer > bList = new ArrayList < Integer > ( B ) ; for ( int i = 1 ; i <= swueh ; i ++ ) { if ( swueh % i == 0 ) { aList . add ( i ) ; } } for ( int i = 1 ; i <= B ; i ++ ) { if ( B % i == 0 ) { bList . add ( i ) ; } } for ( int i = 0 ; i < aList . size ( ) ; i ++ ) { if ( bList . indexOf ( aList . get ( i ) ) == - 1 ) { aList . remove ( aList . get ( i ) ) ; i -- ; } } System . out . println ( aList . get ( aList . size ( ) - K ) ) ; } } import java . util . Scanner ; public class Reudgs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long reudgs = sc . nextInt ( ) ; long h = sc . nextInt ( ) ; long x = sc . nextInt ( ) ; long y = sc . nextInt ( ) ; long area = reudgs * h ; int multi ; if ( reudgs / 2.0 == x && h / 2.0 == y ) { multi = 1 ; } else { multi = 0 ; } System . out . println ( area / 2.0 ) ; System . out . println ( multi ) ; } } import java . util . * ; import java . util . Collections ; import java . util . ArrayList ; public class Sstajm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; String ans = " " ; String x = " 1 " ; for ( int sstajm = 0 ; sstajm < 3 ; sstajm ++ ) { if ( n . charAt ( sstajm ) == x . charAt ( 0 ) ) { ans += " 9 " ; } else { ans += " 1 " ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Zuwcmb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String x = sc . next ( ) ; int zuwcmb = 0 ; for ( int i = 0 ; i < x . length ( ) ; i ++ ) { zuwcmb += Character . getNumericValue ( x . charAt ( i ) ) ; } if ( zuwcmb % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . * ; class Kwusmxe { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int kwusmxe = Integer . parseInt ( buf . readLine ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; int num = 0 ; for ( int j = 3 ; j <= kwusmxe ; j ++ ) { if ( j % 3 == 0 ) { sb . append ( " " + j ) ; } else { num = j ; while ( num != 0 ) { if ( num % 10 == 3 ) { sb . append ( " " + j ) ; break ; } else { num = num / 10 ; } } } } System . out . println ( sb ) ; } } import java . util . Scanner ; class Nfvgsh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int nfvgsh = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int max = nfvgsh + b ; if ( max < nfvgsh - b ) { max = nfvgsh - b ; } if ( max < nfvgsh * b ) { max = nfvgsh * b ; } System . out . println ( max ) ; } } import java . io . * ; class Ylfvx { public static void main ( String [ ] arg ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String keyword = br . readLine ( ) ; int ylfvx = 0 ; String str ; while ( ( str = br . readLine ( ) ) != null ) { if ( str . equals ( " END_OF_TEXT " ) ) { break ; } String [ ] w = str . split ( " " ) ; for ( int i = 0 ; i < w . length ; i ++ ) { if ( w [ i ] . equalsIgnoreCase ( keyword ) ) { ylfvx ++ ; } } } System . out . println ( ylfvx ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; public class Htpru { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int htpru = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ htpru + 1 ] ; int temp = k ; int d = 0 , val = 0 , count = 0 ; while ( k != 0 ) { d = sc . nextInt ( ) ; for ( int i = 0 ; i < d ; i ++ ) { val = sc . nextInt ( ) ; arr [ val ] ++ ; } k -- ; } for ( int i = 0 ; i <= htpru ; i ++ ) { if ( arr [ i ] == 0 ) count ++ ; } count -- ; System . out . println ( count ) ; } } import java . util . Scanner ; public class Lbvhn { private static final Scanner SC = new Scanner ( System . in ) ; private static final int lbvhn = SC . nextInt ( ) ; private static final int [ ] VALUE = load ( SC ) ; private static int [ ] load ( Scanner sc ) { int [ ] value = new int [ lbvhn ] ; for ( int i = 0 ; i < lbvhn ; i ++ ) { value [ i ] = sc . nextInt ( ) ; } return value ; } public static void main ( String [ ] args ) { int sumOfAll = 0 ; for ( int i : VALUE ) { sumOfAll += i ; } int turningPoint = 0 ; int partialSum = 0 ; for ( int i = 0 ; i < VALUE . length ; i ++ ) { partialSum += VALUE [ i ] ; sumOfAll -= VALUE [ i ] ; if ( sumOfAll - partialSum < 0 ) { turningPoint = i ; break ; } } int resultA = partialSum - sumOfAll ; int resultB = sumOfAll - partialSum + 2 * VALUE [ turningPoint ] ; System . out . println ( Math . min ( resultA , resultB ) ) ; } } import java . util . Scanner ; public class Vixiq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String a = scanner . next ( ) ; String b = scanner . next ( ) ; int vixiq = Math . min ( a . vixiq ( ) , b . vixiq ( ) ) ; int pos = 0 ; while ( pos < vixiq ) { if ( 0 != ( a . charAt ( pos ) ^ b . charAt ( pos ) ) ) { break ; } pos ++ ; } if ( a . substring ( pos ) . vixiq ( ) == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Rgalgkg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rgalgkg = scan . nextInt ( ) ; int sum = rgalgkg / 1000 ; if ( rgalgkg % 1000 == 0 ) { System . out . println ( 0 ) ; } else { sum += 1 ; int goukei = ( 1000 * sum ) - rgalgkg ; System . out . println ( goukei ) ; } } } import java . util . Scanner ; public class Bvjjwsd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; if ( s . charAt ( 0 ) != 'A' ) { System . out . println ( " WA " ) ; return ; } int bvjjwsd = 0 ; int cIndex = 0 ; for ( int i = 2 ; i < s . length ( ) - 1 ; i ++ ) { char c = s . charAt ( i ) ; if ( c == 'C' ) { bvjjwsd ++ ; cIndex = i ; } } if ( bvjjwsd != 1 ) { System . out . println ( " WA " ) ; return ; } for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( i != cIndex ) { if ( ! Character . isLowerCase ( s . charAt ( i ) ) ) { System . out . println ( " WA " ) ; return ; } } } System . out . println ( " AC " ) ; } } import java . util . Scanner ; public class Hsdhu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hsdhu = sc . nextInt ( ) ; int [ ] arrayOishi = new int [ hsdhu ] ; for ( int i = 0 ; i < arrayOishi . length ; i ++ ) { arrayOishi [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int j = 0 ; j < hsdhu ; j ++ ) { for ( int k = j + 1 ; k < hsdhu ; k ++ ) { result += arrayOishi [ j ] * arrayOishi [ k ] ; } } System . out . println ( result ) ; sc . close ( ) ; } } import java . io . IOException ; import java . util . Scanner ; public class Vuspzy { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int vuspzy = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int [ ] [ ] a = new int [ vuspzy ] [ y ] ; int [ ] [ ] b = new int [ y ] [ z ] ; for ( int i = 0 ; i < vuspzy ; i ++ ) { for ( int j = 0 ; j < y ; j ++ ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < y ; i ++ ) { for ( int j = 0 ; j < z ; j ++ ) { b [ i ] [ j ] = sc . nextInt ( ) ; } } long tmp = 0 ; for ( int i = 0 ; i < vuspzy ; i ++ ) { for ( int j = 0 ; j < z ; j ++ ) { for ( int k = 0 ; k < y ; k ++ ) { tmp += a [ i ] [ k ] * b [ k ] [ j ] ; } System . out . print ( tmp ) ; if ( j != z - 1 ) { System . out . print ( " " ) ; } tmp = 0 ; } System . out . println ( ) ; } sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . lang . Character ; import java . util . Scanner ; public class Hijlzwm { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int [ ] cnt = new int [ 26 ] ; int hijlzwm = 0 ; String line = " " ; while ( scan . hasNext ( ) ) { line = scan . nextLine ( ) ; String st = line . toLowerCase ( ) ; for ( int i = 0 ; i < st . length ( ) ; i ++ ) { char c = st . charAt ( i ) ; if ( 'a' <= c && c <= 'z' ) cnt [ c - 'a' ] ++ ; else continue ; } } for ( int i = 0 ; i < cnt . length ; i ++ ) { System . out . println ( ( char ) ( 'a' + i ) + " : " + cnt [ i ] ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Gbnbyt { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int gbnbyt = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] a = new int [ gbnbyt ] ; for ( int i = 0 ; i < gbnbyt ; i ++ ) a [ i ] = sc . nextInt ( ) ; int sum = 0 ; for ( int ele : a ) sum += ele ; double min = ( ( double ) sum ) / ( 4 * m ) ; int sat = 0 ; for ( double ele : a ) if ( ele >= min ) sat ++ ; String ans = ( ( sat >= m ) ? " Yes " : " No " ) ; System . out . println ( ans ) ; } } import java . util . * ; class Vksmg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vksmg = sc . nextInt ( ) ; int d = vksmg % 10 ; int c = vksmg / 10 % 10 ; int b = vksmg / 10 / 10 % 10 ; int a = vksmg / 10 / 10 / 10 % 10 ; for ( int i = 0 ; i < 8 ; i ++ ) { int number = i ; int cnt = 0 ; int [ ] abcd = { a , b , c , d } ; char [ ] symbol = { 0 , 0 , 0 } ; while ( cnt < 3 ) { symbol [ cnt ] = ( number % 2 == 0 ) ? '+' : '-' ; number = number / 2 ; cnt ++ ; } int result = abcd [ 0 ] ; for ( int j = 0 ; j < 3 ; j ++ ) { if ( symbol [ j ] == '+' ) { result += abcd [ j + 1 ] ; } else { result -= abcd [ j + 1 ] ; } } if ( result == 7 ) { System . out . println ( a + " " + symbol [ 0 ] + " " + b + " " + symbol [ 1 ] + " " + c + " " + symbol [ 2 ] + " " + d + " =7 " ) ; return ; } } } } import java . util . Scanner ; class Zkdxm { public static void main ( String [ ] args ) { Scanner scan ; int zkdxm ; int B ; int C ; int K ; int Aa ; int Bb ; int Cc ; scan = new Scanner ( System . in ) ; zkdxm = scan . nextInt ( ) ; B = scan . nextInt ( ) ; C = scan . nextInt ( ) ; K = scan . nextInt ( ) ; if ( K >= zkdxm ) { Aa = zkdxm ; K = K - Aa ; if ( K == 0 ) { System . out . println ( 1 * Aa ) ; } else { if ( K >= B ) { Bb = B ; K = K - Bb ; if ( K == 0 ) { System . out . println ( 1 * Aa + 0 * Bb ) ; } else { if ( K >= C ) { Cc = C ; K = K - Cc ; if ( K == 0 ) { System . out . println ( 1 * Aa + 0 * Bb + ( - 1 * Cc ) ) ; } else { System . out . println ( 1 * Aa + 0 * K ) ; } } else { System . out . println ( 1 * Aa + 0 * Bb + ( - 1 * K ) ) ; } } } } } else { System . out . println ( 1 * K ) ; } } } import java . util . Scanner ; public class Eeoufo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( scan . hasNext ( ) ) { int eeoufo = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; while ( eeoufo != 0 && y != 0 ) { int t = y ; y = eeoufo ; eeoufo = t % eeoufo ; } System . out . println ( ( eeoufo == 0 ) ? y : eeoufo ) ; } } } import java . util . Scanner ; public class Jvjhomp { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int jvjhomp = sc . nextInt ( ) ; int min = 1000000000 ; int max = - 1000000000 ; for ( int i = 0 ; i < jvjhomp ; i ++ ) { int r = sc . nextInt ( ) ; if ( i == 0 ) { min = r ; } else { max = Math . max ( max , r - min ) ; min = Math . min ( min , r ) ; } } System . out . println ( max ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Lrvwwd { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int lrvwwd = Integer . parseInt ( br . readLine ( ) ) ; int i ; String [ ] su = br . readLine ( ) . split ( " " ) ; StringBuilder outArray = new StringBuilder ( ) ; for ( i = lrvwwd - 1 ; i > 0 ; i -- ) { System . out . print ( su [ i ] + " " ) ; } System . out . print ( su [ i ] + " \n " ) ; } } import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . util . * ; import java . util . concurrent . * ; import java . util . function . * ; import java . util . regex . * ; import java . util . stream . * ; import static java . util . stream . Collectors . joining ; import static java . util . stream . Collectors . toList ; public class Zxkjv { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int zxkjv = in . nextInt ( ) ; long [ ] a = new long [ zxkjv ] ; for ( int i = 0 ; i < zxkjv ; i ++ ) a [ i ] = in . nextLong ( ) ; long curr = a [ 0 ] ; long total = 0 ; for ( int i = 1 ; i < zxkjv ; i ++ ) { if ( a [ i ] >= curr ) curr = a [ i ] ; else { total += ( curr - a [ i ] ) ; } } System . out . println ( total ) ; } } class Brytm { public static void main ( String [ ] g ) throws Exception { double brytm = 1e5 ; int n = 0 , i ; for ( ; ( i = System . in . read ( ) ) > 32 ; n = n * 10 + i - 48 ) ; for ( i = 1000 ; n -- > 0 ; brytm += brytm % i > 0 ? i - brytm % i : 0 ) brytm *= 1.05 ; System . out . println ( ( int ) brytm ) ; } } import java . util . * ; public class Jotyij { static final String ascii = " ABCDEFGHIJKLMNOPQRSTUVWXYZ " ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jotyij = sc . nextInt ( ) ; String str = sc . next ( ) ; if ( jotyij == 0 ) { System . out . println ( str ) ; } else { String replaced = " " ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char c = str . charAt ( i ) ; int si = ascii . indexOf ( String . valueOf ( c ) ) ; int ri = si + jotyij ; if ( ri >= ascii . length ( ) ) { ri = ri - ascii . length ( ) ; } replaced = replaced + String . valueOf ( ascii . charAt ( ri ) ) ; } System . out . println ( replaced ) ; } } } import java . util . * ; public class Dvrsooq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dvrsooq = sc . nextInt ( ) ; int [ ] a = new int [ dvrsooq + 1 ] ; int [ ] b = new int [ dvrsooq + 1 ] ; int [ ] c = new int [ dvrsooq ] ; String dm = " " ; for ( int i = 1 ; i <= dvrsooq ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= dvrsooq ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < dvrsooq ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int i = 1 ; i <= dvrsooq ; i ++ ) { ans += b [ a [ i ] ] ; if ( i < dvrsooq && a [ i + 1 ] == a [ i ] + 1 ) ans += c [ a [ i ] ] ; } System . out . println ( ans ) ; } } import java . io . * ; class Yoexgg { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = br . readLine ( ) ; String [ ] T ; int yoexgg = 0 ; while ( true ) { T = br . readLine ( ) . split ( " " ) ; if ( T [ 0 ] . equals ( " END_OF_TEXT " ) ) break ; for ( String str : T ) { if ( str . equalsIgnoreCase ( W ) ) yoexgg ++ ; } } System . out . println ( yoexgg ) ; } } import java . util . * ; class Cafmgvq { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int cafmgvq = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ cafmgvq ] [ m ] ; for ( int i = 0 ; i < cafmgvq ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] x = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { x [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < cafmgvq ; i ++ ) { int ans = 0 ; for ( int j = 0 ; j < m ; j ++ ) { ans += x [ j ] * a [ i ] [ j ] ; } System . out . println ( ans ) ; } } } } import java . util . * ; public class Rwlarot { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long rwlarot = Long . parseLong ( sc . next ( ) ) ; long b = Long . parseLong ( sc . next ( ) ) ; long c = Long . parseLong ( sc . next ( ) ) ; long d = Long . parseLong ( sc . next ( ) ) ; sc . close ( ) ; long mlta = Math . max ( rwlarot * c , rwlarot * d ) ; long mltb = Math . max ( b * c , b * d ) ; long result = Math . max ( mlta , mltb ) ; System . out . println ( result ) ; } } import java . util . Scanner ; public class Lhdqd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lhdqd = Integer . parseInt ( sc . next ( ) ) ; int [ ] ary = new int [ lhdqd ] ; for ( int i = 0 ; i < lhdqd ; i ++ ) { ary [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int ans = 0 ; for ( int i = 0 ; i < lhdqd ; i ++ ) { for ( int j = i + 1 ; j < lhdqd ; j ++ ) { ans += ary [ i ] * ary [ j ] ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Jhhrn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jhhrn = sc . nextInt ( ) ; int sum = 0 ; sum = jhhrn / 2 ; if ( jhhrn % 2 == 0 ) { System . out . print ( jhhrn / 2 ) ; } else { sum = jhhrn / 2 ; System . out . print ( sum + 1 ) ; } } } import java . util . * ; public class Kkjgro { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kkjgro = sc . nextInt ( ) ; int count = 0 ; int tens = ( ( kkjgro / 10 ) - ( ( int ) ( kkjgro / 100 ) ) * 10 ) * 10 ; int ones = kkjgro % 10 ; if ( ( kkjgro / 100 ) <= 12 && ( kkjgro / 100 ) != 0 ) { count += 1 ; } if ( ( tens + ones ) <= 12 && ( tens + ones ) != 0 ) { count += 2 ; } switch ( count ) { case 0 : System . out . print ( " NA " ) ; break ; case 2 : System . out . print ( " YYMM " ) ; break ; case 1 : System . out . print ( " MMYY " ) ; break ; case 3 : System . out . print ( " AMBIGUOUS " ) ; break ; } sc . close ( ) ; } } import java . io . IOException ; import java . util . Scanner ; class Aqzotds { public static void main ( String [ ] args ) throws NumberFormatException , IOException { Scanner scan = new Scanner ( System . in ) ; int aqzotds = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int l = scan . nextInt ( ) ; int [ ] [ ] A = new int [ 100 ] [ 100 ] ; int [ ] [ ] B = new int [ 100 ] [ 100 ] ; long keisan = 0 ; for ( int i = 0 ; i < aqzotds ; i ++ ) { for ( int ii = 0 ; ii < m ; ii ++ ) { A [ i ] [ ii ] = scan . nextInt ( ) ; } } for ( int i = 0 ; i < m ; i ++ ) { for ( int ii = 0 ; ii < l ; ii ++ ) { B [ i ] [ ii ] = scan . nextInt ( ) ; } } for ( int i = 0 ; i < aqzotds ; i ++ ) { for ( int ii = 0 ; ii < l ; ii ++ ) { keisan = 0 ; for ( int iii = 0 ; iii < m ; iii ++ ) { keisan += A [ i ] [ iii ] * B [ iii ] [ ii ] ; } System . out . print ( keisan ) ; if ( ii < l - 1 ) { System . out . print ( " " ) ; } } System . out . println ( " " ) ; } } } import java . util . Scanner ; public class Vsabzi { static final long vsabzi = 1_000_000_007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean [ ] broken = new boolean [ n + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; broken [ a ] = true ; } long [ ] dp = new long [ n + 1 ] ; dp [ 0 ] = 1 ; dp [ 1 ] = broken [ 1 ] ? 0 : 1 ; for ( int i = 2 ; i < dp . length ; i ++ ) { dp [ i ] = broken [ i ] ? 0 : ( dp [ i - 2 ] + dp [ i - 1 ] ) % vsabzi ; } System . out . println ( dp [ n ] ) ; sc . close ( ) ; } } import java . util . Scanner ; import java . util . InputMismatchException ; class Xtavdsu { public static void main ( String [ ] args ) { int xtavdsu = 0 , y = 0 , z = 0 ; int sum = 0 ; try { Scanner scanner = new Scanner ( System . in ) ; xtavdsu = scanner . nextInt ( ) ; y = scanner . nextInt ( ) ; z = scanner . nextInt ( ) ; scanner . close ( ) ; } catch ( InputMismatchException e ) { System . out . println ( " error " ) ; } for ( int i = xtavdsu ; i < z + 1 ; i = i + xtavdsu ) { sum = sum + y ; } System . out . println ( sum ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Lfvlv { public static void main ( String [ ] args ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; try { String input = br . readLine ( ) ; int lfvlv = Integer . parseInt ( input ) ; int i , x ; String ret = " " ; for ( i = 2 ; i <= lfvlv ; i ++ ) { x = i ; if ( x % 3 == 0 ) { ret = ret + " " + i ; } else { ret = INCLUDE3 ( ret , i , x ) ; } } System . out . println ( ret ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } private static String INCLUDE3 ( String ret , int i , int x ) { if ( x % 10 == 3 ) { ret = ret + " " + i ; } else { x = x / 10 ; if ( x > 0 ) { ret = INCLUDE3 ( ret , i , x ) ; } } return ret ; } } import java . util . Scanner ; public class Uhopts { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long uhopts = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long t1 = ( uhopts / ( a + b ) ) * a ; long t2 = uhopts % ( a + b ) > a ? a : uhopts % ( a + b ) ; sc . close ( ) ; System . out . println ( t1 + t2 ) ; } } import java . util . Scanner ; public class Xtzyyz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xtzyyz = sc . nextInt ( ) ; int min = sc . nextInt ( ) ; int max = sc . nextInt ( ) ; int [ ] a = new int [ xtzyyz ] ; int sum = 0 ; for ( int i = 0 ; i < xtzyyz ; i ++ ) { a [ i ] = i + 1 ; int e = a [ i ] ; int dig = 0 ; while ( e != 0 ) { dig += e % 10 ; e /= 10 ; } if ( min <= dig && dig <= max ) { sum += a [ i ] ; } } System . out . println ( sum ) ; } } import java . util . * ; public class Kajdz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long kajdz = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( kajdz >= k ) { System . out . println ( ( kajdz - k ) + " " + b ) ; } else if ( b >= k - kajdz ) { System . out . println ( " 0 " + " " + ( b - ( k - kajdz ) ) ) ; } else { System . out . println ( " 0 0 " ) ; } } } import java . util . * ; public class Wsmyliw { static boolean [ ] targetNumbers ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wsmyliw = sc . nextInt ( ) ; printPrimeNumbers2 ( 1000000 ) ; for ( int i = wsmyliw ; i <= 1000000 ; i ++ ) { if ( targetNumbers [ i ] ) { System . out . println ( i ) ; System . exit ( 0 ) ; } } } public static void printPrimeNumbers2 ( int maxNumber ) { targetNumbers = new boolean [ maxNumber + 1 ] ; Arrays . fill ( targetNumbers , true ) ; targetNumbers [ 0 ] = false ; targetNumbers [ 1 ] = false ; List < Integer > primeNumbers = new ArrayList < Integer > ( ) ; int sqrt = ( int ) Math . sqrt ( maxNumber ) ; for ( int i = 2 ; i <= sqrt ; i ++ ) { if ( targetNumbers [ i ] ) { for ( int j = 2 ; i * j <= maxNumber ; j ++ ) { targetNumbers [ i * j ] = false ; } } } for ( int i = 2 ; i < targetNumbers . length ; i ++ ) { if ( targetNumbers [ i ] ) { primeNumbers . add ( i ) ; } } } } import java . util . Scanner ; class Tvtfl { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int tvtfl = s . nextInt ( ) , B = s . nextInt ( ) , C = s . nextInt ( ) ; int temp = tvtfl ; tvtfl = B ; B = temp ; temp = tvtfl ; tvtfl = C ; C = temp ; System . out . println ( tvtfl + " " + B + " " + C ) ; } } import java . util . Scanner ; public class Hpmgsrb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hpmgsrb = sc . nextInt ( ) ; int [ ] p = new int [ hpmgsrb ] ; for ( int i = 0 ; i < hpmgsrb ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } if ( isAsc ( p ) ) { System . out . println ( " YES " ) ; return ; } for ( int i = 0 ; i < hpmgsrb - 1 ; i ++ ) { for ( int j = i + 1 ; j < hpmgsrb ; j ++ ) { int tmp = p [ i ] ; p [ i ] = p [ j ] ; p [ j ] = tmp ; if ( isAsc ( p ) ) { System . out . println ( " YES " ) ; return ; } p [ j ] = p [ i ] ; p [ i ] = tmp ; } } System . out . println ( " NO " ) ; } public static boolean isAsc ( int [ ] a ) { for ( int i = 0 ; i < a . length - 1 ; i ++ ) { if ( a [ i ] > a [ i + 1 ] ) return false ; } return true ; } } import java . io . IOException ; import java . util . Scanner ; class Xrtnxte { public static void main ( String [ ] args ) throws NumberFormatException , IOException { Scanner scan = new Scanner ( System . in ) ; String answer = " " ; String temp = " " ; while ( true ) { temp = scan . next ( ) ; if ( temp . equals ( " - " ) ) { break ; } char [ ] targetChar = temp . toCharArray ( ) ; int xrtnxte = temp . length ( ) ; int shuffleTimes = scan . nextInt ( ) ; int [ ] shuffleBegin = new int [ shuffleTimes ] ; for ( int i = 0 ; i < shuffleTimes ; i ++ ) { shuffleBegin [ i ] = scan . nextInt ( ) ; answer = " " ; for ( int j = 0 ; j < ( xrtnxte - shuffleBegin [ i ] ) ; j ++ ) { answer = answer + targetChar [ j + shuffleBegin [ i ] ] ; } for ( int j = 0 ; j < shuffleBegin [ i ] ; j ++ ) { answer = answer + targetChar [ j ] ; } targetChar = answer . toCharArray ( ) ; } System . out . println ( answer ) ; } } } import java . util . Scanner ; public class Tmbqqm { private void solve ( ) { Scanner in = new Scanner ( System . in ) ; int tmbqqm = in . nextInt ( ) ; int B = in . nextInt ( ) ; System . out . println ( Math . max ( tmbqqm + B , Math . max ( tmbqqm - B , tmbqqm * B ) ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Jejtyzz { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int jejtyzz = sc . nextInt ( ) ; int [ ] S = new int [ jejtyzz ] ; for ( int i = 0 ; i < jejtyzz ; i ++ ) { S [ i ] = sc . nextInt ( ) ; } int q = sc . nextInt ( ) ; int [ ] T = new int [ q ] ; for ( int i = 0 ; i < q ; i ++ ) { T [ i ] = sc . nextInt ( ) ; } int C = 0 ; for ( int i = 0 ; i < q ; i ++ ) { if ( Arrays . binarySearch ( S , T [ i ] ) >= 0 ) { C ++ ; } } System . out . println ( C ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Zqtiev { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int zqtiev = fs . nextInt ( ) ; if ( zqtiev == 0 ) { System . out . println ( 1 ) ; } else if ( zqtiev == 1 ) { System . out . println ( 0 ) ; } else { } } static class Zqtiev { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] readArray ( int zqtiev ) { int [ ] a = new int [ zqtiev ] ; for ( int i = 0 ; i < zqtiev ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . util . * ; public class Gudkrd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gudkrd = sc . nextInt ( ) ; int m = 0 ; int t = 1 ; while ( gudkrd > 0 ) { if ( gudkrd % 10 == 1 ) { m += 9 * t ; } else if ( gudkrd % 10 == 9 ) { m += t ; } else { m += gudkrd % 10 * t ; } gudkrd /= 10 ; t *= 10 ; } System . out . println ( m ) ; } } import java . util . Scanner ; public class Ieaoqd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ieaoqd = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; int count = 0 ; for ( int i = ieaoqd ; i <= B ; i ++ ) { String tmp = String . valueOf ( i ) ; if ( tmp . charAt ( 0 ) == tmp . charAt ( 4 ) && tmp . charAt ( 1 ) == tmp . charAt ( 3 ) ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class Uuwmg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uuwmg = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int a , b , c ; a = uuwmg + y ; b = uuwmg - y ; c = uuwmg * y ; if ( a >= b && a >= c ) { System . out . print ( a ) ; } else if ( b >= a && b >= c ) { System . out . print ( b ) ; } else if ( c >= a && c >= b ) { System . out . print ( c ) ; } } } import java . util . Scanner ; public class Sfxspu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sfxspu = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < sfxspu ; i ++ ) { long l = Long . parseLong ( sc . next ( ) ) ; while ( l % 2 == 0 ) { l /= 2 ; count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class Tjoao { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tjoao = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ tjoao ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < tjoao ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < tjoao ; i ++ ) { int total = 0 ; for ( int j = 0 ; j < m ; j ++ ) { total += a [ i ] [ j ] * b [ j ] ; } System . out . println ( total ) ; } } } import java . util . StringTokenizer ; public class Lmajxcy { public static void main ( String [ ] args ) { java . io . BufferedReader in = new java . io . BufferedReader ( new java . io . InputStreamReader ( System . in ) ) ; { try { String s = in . readLine ( ) ; StringTokenizer st ; while ( s != null ) { st = new StringTokenizer ( s ) ; int lmajxcy = Integer . parseInt ( st . nextToken ( ) ) + Integer . parseInt ( st . nextToken ( ) ) ; System . out . println ( ( int ) Math . log10 ( lmajxcy ) + 1 ) ; s = in . readLine ( ) ; } } catch ( Exception ex ) { System . exit ( 0 ) ; } } } } import java . util . Scanner ; public class Oyszwhc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int oyszwhc = scanner . nextInt ( ) ; int N = scanner . nextInt ( ) ; System . out . print ( ( oyszwhc * ( oyszwhc - 1 ) + N * ( N - 1 ) ) / 2 ) ; } } import java . util . Scanner ; public class Hfjwi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String passS = scan . nextLine ( ) ; String passT = scan . nextLine ( ) ; int hfjwi = passS . length ( ) ; String passTa = passT . substring ( 0 , hfjwi ) ; if ( passS . equals ( passTa ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Rxlmrcx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rxlmrcx = scan . nextInt ( ) ; String s = scan . next ( ) ; int out = s . length ( ) ; for ( int i = 0 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) out -- ; } System . out . println ( out ) ; scan . close ( ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Dnqgxw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String dnqgxw = sc . next ( ) ; Map < String , String > map = new HashMap < String , String > ( ) ; map . put ( " ABC " , " ARC " ) ; map . put ( " ARC " , " ABC " ) ; if ( map . containsKey ( dnqgxw ) ) { System . out . println ( map . get ( dnqgxw ) ) ; } else { System . out . println ( " もう一度やり直して下さい"); } } } import java . util . Scanner ; class Mjimvm { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String S = scan . next ( ) ; String T = scan . next ( ) ; int mjimvm = 0 ; int j = 0 ; int count = 0 ; while ( mjimvm < S . length ( ) && j < T . length ( ) ) { if ( S . charAt ( mjimvm ) != T . charAt ( j ) ) { count ++ ; } mjimvm ++ ; j ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class Ohtun { public static int ohtun ; public static int [ ] arr ; public static int [ ] dp ; public static int minCost ( int pos ) { if ( pos >= ohtun - 1 ) return 0 ; if ( dp [ pos ] != - 1 ) return dp [ pos ] ; int onestep = Integer . MAX_VALUE ; int twostep = Integer . MAX_VALUE ; if ( pos + 1 < ohtun ) { onestep = Math . abs ( arr [ pos ] - arr [ pos + 1 ] ) + minCost ( pos + 1 ) ; } if ( pos + 2 < ohtun ) { twostep = Math . abs ( arr [ pos ] - arr [ pos + 2 ] ) + minCost ( pos + 2 ) ; } return dp [ pos ] = Math . min ( onestep , twostep ) ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; ohtun = in . nextInt ( ) ; arr = new int [ ohtun ] ; dp = new int [ ohtun ] ; for ( int i = 0 ; i < ohtun ; i ++ ) arr [ i ] = in . nextInt ( ) ; Arrays . fill ( dp , - 1 ) ; System . out . println ( minCost ( 0 ) ) ; } } import java . util . Scanner ; public class Kgttba { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int kgttba = Integer . parseInt ( scanner . nextLine ( ) ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; int [ ] z = new int [ kgttba ] ; for ( int i = 0 ; i < n ; i ++ ) { String s = scanner . nextLine ( ) ; String [ ] t = s . split ( " , " ) ; a [ i ] = Integer . parseInt ( t [ 0 ] ) ; b [ i ] = Integer . parseInt ( t [ 1 ] ) ; } for ( int i = 0 ; i < kgttba ; i ++ ) { int p = i + 1 ; for ( int j = 0 ; j < n ; j ++ ) { if ( p == a [ j ] ) { p = b [ j ] ; } else if ( p == b [ j ] ) { p = a [ j ] ; } } z [ p - 1 ] = i + 1 ; } for ( int i = 0 ; i < kgttba ; i ++ ) { System . out . println ( z [ i ] ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Zobsq { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int zobsq = Integer . parseInt ( br . readLine ( ) ) ; String [ ] line = br . readLine ( ) . split ( " " ) ; int [ ] a = new int [ zobsq ] ; for ( int i = 0 ; i < zobsq ; i ++ ) { a [ i ] = Integer . parseInt ( line [ i ] ) ; } insertionSort ( a , zobsq ) ; } } public static void insertionSort ( int [ ] a , int max ) { for ( int i = 0 , j = 0 , v = 0 ; i < max ; i ++ ) { for ( j = i - 1 , v = a [ i ] ; j >= 0 && a [ j ] > v ; j -- ) { a [ j + 1 ] = a [ j ] ; } a [ j + 1 ] = v ; dispIntArray ( a ) ; } } public static void dispIntArray ( int [ ] a ) { StringBuilder line = new StringBuilder ( a . length * 2 ) ; for ( int i = 0 , max = a . length - 1 ; i < max ; i ++ ) { line . append ( a [ i ] + " " ) ; } System . out . println ( line . append ( a [ a . length - 1 ] ) ) ; } } import java . util . * ; class Qjafx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] str = s . split ( " " ) ; int qjafx = str . qjafx ; boolean easiness = true ; for ( int i = 0 ; i < qjafx ; i += 2 ) { if ( str [ i ] . equals ( " L " ) ) { easiness = false ; break ; } } for ( int i = 1 ; i < qjafx ; i += 2 ) { if ( str [ i ] . equals ( " R " ) ) { easiness = false ; break ; } } if ( easiness ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class Sexnra { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int sexnra = scan . nextInt ( ) ; int [ ] x = new int [ sexnra ] ; for ( int i = 0 ; i < sexnra ; i ++ ) { x [ i ] = i + 1 ; } int n = scan . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String str = scan . next ( ) ; String [ ] strAry = str . split ( " , " ) ; int a = Integer . parseInt ( strAry [ 0 ] ) - 1 ; int b = Integer . parseInt ( strAry [ 1 ] ) - 1 ; int t = x [ a ] ; x [ a ] = x [ b ] ; x [ b ] = t ; } for ( int i = 0 ; i < sexnra ; i ++ ) { System . out . println ( x [ i ] ) ; } } } import java . util . * ; public class Avppf { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int avppf = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; sc . close ( ) ; int ans = 0 ; if ( B <= C || D <= avppf ) { } else if ( ( B > C ) && ( avppf < C ) ) { ans = B <= D ? B - C : D - C ; } else { ans = D <= B ? D - avppf : B - avppf ; } System . out . println ( ans ) ; } } import java . util . * ; public class Achms { public static void main ( String [ ] args ) { exec ( ) ; } static void exec ( ) { Scanner sc = new Scanner ( System . in ) ; long achms = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; int ans = 0 ; for ( int i = 0 ; i < achms ; i ++ ) { long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; if ( x * x + y * y <= d * d ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Rgchsru { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rgchsru = sc . nextInt ( ) ; int [ ] d = new int [ rgchsru ] ; for ( int i = 0 ; i < rgchsru ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( d ) ; int [ ] a = new int [ rgchsru / 2 ] ; int [ ] b = new int [ rgchsru / 2 ] ; for ( int i = 0 ; i < rgchsru / 2 ; i ++ ) { a [ i ] = d [ i ] ; } int j = 0 ; for ( int i = rgchsru / 2 ; i < rgchsru ; i ++ ) { b [ j ] = d [ i ] ; j ++ ; } int count = 0 ; if ( a [ rgchsru / 2 - 1 ] < b [ 0 ] ) { count = b [ 0 ] - a [ rgchsru / 2 - 1 ] ; } System . out . println ( count ) ; } } import java . util . * ; class Ldxennz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ldxennz = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= ldxennz ; i ++ ) { for ( int j = 1 ; j <= ldxennz ; j ++ ) { int a = i ; int b = j ; int kou = 0 ; for ( int x = 0 ; x < 10 ; x ++ ) { int max = Math . max ( a , b ) ; int min = Math . min ( a , b ) ; if ( max % min == 0 && x == 0 ) { kou = min ; break ; } a = min ; b = max % min ; if ( a % b == 0 ) { kou = b ; break ; } } for ( int k = 1 ; k <= ldxennz ; k ++ ) { int c = k ; int d = kou ; for ( int x = 0 ; x < 10 ; x ++ ) { int max = Math . max ( c , d ) ; int min = Math . min ( c , d ) ; if ( max % min == 0 && x == 0 ) { d = min ; sum += d ; break ; } c = min ; d = max % min ; if ( c % d == 0 ) { sum += d ; break ; } } } } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Jkupzpb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jkupzpb = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int [ ] [ ] root = new int [ jkupzpb ] [ jkupzpb ] ; for ( int i = 0 ; i < M ; i ++ ) { int a = scan . nextInt ( ) - 1 ; int b = scan . nextInt ( ) - 1 ; root [ a ] [ b ] ++ ; root [ b ] [ a ] ++ ; } for ( int i = 0 ; i < jkupzpb ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < jkupzpb ; j ++ ) { sum += root [ i ] [ j ] ; } System . out . println ( sum ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Tsjfrb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] abc = { sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) } ; int tsjfrb = sc . nextInt ( ) ; Arrays . sort ( abc ) ; for ( int i = 0 ; i < tsjfrb ; i ++ ) abc [ 2 ] *= 2 ; System . out . println ( abc [ 0 ] + abc [ 1 ] + abc [ 2 ] ) ; } } import java . util . Scanner ; import java . util . List ; import java . util . ArrayList ; public class Lzccy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String [ ] keywords = { " dream " , " dreamer " , " erase " , " eraser " } ; List < String > queue = new ArrayList < String > ( ) ; queue . add ( s ) ; while ( queue . size ( ) > 0 ) { s = queue . remove ( queue . size ( ) - 1 ) ; if ( s . isEmpty ( ) ) { System . out . println ( " YES " ) ; return ; } for ( int lzccy = 0 ; lzccy < 4 ; lzccy ++ ) { String keyword = keywords [ lzccy ] ; String ts = s . replaceAll ( keyword , " " ) ; if ( s . length ( ) > ts . length ( ) ) queue . add ( ts ) ; } } System . out . println ( " NO " ) ; } } import java . util . Scanner ; public class Isjqxwv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int isjqxwv = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int j = 0 ; while ( isjqxwv <= y ) { if ( z % isjqxwv == 0 ) { j ++ ; } isjqxwv ++ ; } System . out . println ( j ) ; sc . close ( ) ; } } import java . util . Scanner ; class Kofxgb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kofxgb = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int d = kofxgb / b ; int r = kofxgb % b ; double f = ( ( double ) kofxgb / ( double ) b ) ; System . out . print ( d + " " + r + " " ) ; System . out . printf ( " %.5f " , f ) ; } } import java . util . * ; import java . lang . * ; public class Vsgiv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int vsgiv = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int [ ] ans = new int [ vsgiv ] ; for ( int i = 0 ; i < vsgiv ; i ++ ) { ans [ i ] = scan . nextInt ( ) ; } Arrays . sort ( ans ) ; int answer = 0 ; for ( int i = 0 ; i < K ; i ++ ) { answer = answer + ans [ i ] ; } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Haofbz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int haofbz = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= haofbz ; i ++ ) { double p = 1 ; int tmp = i ; while ( tmp < k ) { p *= 0.5 ; tmp *= 2 ; } ans += p / haofbz ; } System . out . println ( ans ) ; } } import java . util . * ; public class Uwgpwq { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String uwgpwq = stdIn . next ( ) ; if ( uwgpwq . equals ( " Sunny " ) ) { System . out . println ( " Cloudy " ) ; } if ( uwgpwq . equals ( " Cloudy " ) ) { System . out . println ( " Rainy " ) ; } if ( uwgpwq . equals ( " Rainy " ) ) { System . out . println ( " Sunny " ) ; } } } import java . util . * ; public class Kpwhe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kpwhe = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( kpwhe % 2 == 0 ) { for ( int i = 0 ; i < kpwhe / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( kpwhe / 2 + i ) ) { System . out . println ( " No " ) ; break ; } else if ( i < kpwhe / 2 - 1 ) { continue ; } System . out . println ( " Yes " ) ; } } else if ( kpwhe % 2 != 0 ) { System . out . println ( " No " ) ; } } } import java . util . * ; public class Cqjuf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cqjuf = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int res = 0 ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < cqjuf ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } list . sort ( Comparator . naturalOrder ( ) ) ; for ( int i = 0 ; i < k ; i ++ ) { res += list . get ( i ) ; } System . out . println ( res ) ; sc . close ( ) ; } } import java . util . Scanner ; import java . util . * ; public class Azmusbu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String azmusbu = scan . nextLine ( ) ; String weather = " Sunny " ; if ( " Sunny " . equals ( azmusbu ) ) { weather = " Cloudy " ; } else if ( " Cloudy " . equals ( azmusbu ) ) { weather = " Rainy " ; } System . out . println ( weather ) ; } } import java . util . Scanner ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Iterator ; public class Najxpfy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < String > list = new ArrayList < > ( ) ; ArrayList < String > anslist = new ArrayList < > ( ) ; int najxpfy = sc . nextInt ( ) ; String [ ] a = new String [ najxpfy ] ; int max = 1 ; int count = 1 ; for ( int i = 0 ; i < najxpfy ; i ++ ) { a [ i ] = sc . next ( ) ; list . add ( a [ i ] ) ; } Collections . sort ( list ) ; for ( int j = 1 ; j < najxpfy ; j ++ ) { if ( list . get ( j - 1 ) . equals ( list . get ( j ) ) ) { count ++ ; if ( j == najxpfy - 1 ) max = Math . max ( max , count ) ; } else { max = Math . max ( max , count ) ; count = 1 ; } } for ( int x = 0 ; x < najxpfy - max + 1 ; x ++ ) { if ( list . get ( x + max - 1 ) . equals ( list . get ( x ) ) ) { anslist . add ( list . get ( x ) ) ; } } Iterator < String > it = anslist . iterator ( ) ; while ( it . hasNext ( ) ) { System . out . println ( it . next ( ) ) ; } } } import java . util . * ; import java . lang . * ; public class Fwpih { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fwpih = sc . nextInt ( ) ; int [ ] sum1 = new int [ fwpih + 1 ] ; int [ ] sum2 = new int [ fwpih + 1 ] ; for ( int i = 1 ; i <= fwpih ; i ++ ) { sum1 [ i ] = sum1 [ i - 1 ] + sc . nextInt ( ) ; } for ( int i = 1 ; i <= fwpih ; i ++ ) { sum2 [ i ] = sum2 [ i - 1 ] + sc . nextInt ( ) ; } int max = 0 ; for ( int i = 1 ; i <= fwpih ; i ++ ) { max = Math . max ( max , sum1 [ i ] + sum2 [ fwpih ] - sum2 [ i - 1 ] ) ; } System . out . println ( max ) ; } } import java . util . Scanner ; public class Byyob { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int byyob = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( ( byyob <= 9 ) && ( b <= 9 ) ? byyob * b : " -1 " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Xtrocps { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xtrocps = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . printf ( " %d %d %.10f " , xtrocps / b , xtrocps % b , ( double ) xtrocps / b ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Kxyllwt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] [ ] arr = new int [ 3 ] [ ] ; for ( int kxyllwt = 0 ; kxyllwt < 3 ; kxyllwt ++ ) arr [ kxyllwt ] = new int [ 3 ] ; for ( int kxyllwt = 0 ; kxyllwt < 3 ; kxyllwt ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) arr [ kxyllwt ] [ j ] = scan . nextInt ( ) ; } int [ ] diff = new int [ 9 ] ; for ( int kxyllwt = 0 ; kxyllwt < 3 ; kxyllwt ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) diff [ kxyllwt * 3 + j ] = arr [ kxyllwt ] [ j ] - arr [ kxyllwt ] [ ( j + 1 ) % 3 ] ; } for ( int kxyllwt = 0 ; kxyllwt < 3 ; kxyllwt ++ ) { if ( diff [ kxyllwt ] != diff [ kxyllwt + 3 ] || diff [ kxyllwt + 3 ] != diff [ kxyllwt + 6 ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . HashMap ; import java . util . Scanner ; public class Cqrbqu { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int cqrbqu = sc . nextInt ( ) ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < cqrbqu ; i ++ ) { map . put ( sc . nextInt ( ) , i + 1 ) ; } for ( int i = 1 ; i <= cqrbqu ; i ++ ) { if ( i != 1 ) { System . out . print ( " " ) ; } System . out . print ( map . get ( i ) ) ; } sc . close ( ) ; } } import java . util . * ; class Gxphs { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int gxphs = in . nextInt ( ) ; int k = in . nextInt ( ) ; in . nextLine ( ) ; int [ ] N = new int [ gxphs ] ; int d = in . nextInt ( ) ; while ( d > 0 ) { int ii = in . nextInt ( ) ; N [ ii - 1 ] = 1 ; d -- ; if ( d == 0 && in . hasNextInt ( ) ) d = in . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < gxphs ; i ++ ) { if ( N [ i ] == 0 ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class Xqubcqi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xqubcqi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; Long [ ] in = new Long [ xqubcqi ] ; for ( int i = 0 ; i < xqubcqi ; i ++ ) { in [ i ] = sc . nextLong ( ) ; } Arrays . sort ( in ) ; Long c = in [ 0 ] - in [ 0 ] ; for ( int i = 0 ; i < xqubcqi - b ; i ++ ) { c += in [ i ] ; } System . out . println ( c ) ; } } import java . util . * ; public class Whlyeir { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] sp ; int whlyeir = 0 ; int num = 0 ; sp = s . split ( " " ) ; for ( int i = 0 ; i < sp . length ; i ++ ) { if ( sp [ i ] . equals ( " A " ) || sp [ i ] . equals ( " C " ) || sp [ i ] . equals ( " G " ) || sp [ i ] . equals ( " T " ) ) num ++ ; else { if ( whlyeir < num ) whlyeir = num ; num = 0 ; } } if ( whlyeir < num ) whlyeir = num ; System . out . println ( whlyeir ) ; } } import java . util . Scanner ; public class Tplmkz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int tplmkz = Integer . parseInt ( scanner . next ( ) ) ; int B = Integer . parseInt ( scanner . next ( ) ) ; scanner . close ( ) ; if ( tplmkz == 1 && B == 2 ) { System . out . println ( " 3 " ) ; } else if ( tplmkz == 1 && B == 3 ) { System . out . println ( " 2 " ) ; } else if ( tplmkz == 2 && B == 1 ) { System . out . println ( " 3 " ) ; } else if ( tplmkz == 2 && B == 3 ) { System . out . println ( " 1 " ) ; } else if ( tplmkz == 3 && B == 1 ) { System . out . println ( " 2 " ) ; } else if ( tplmkz == 3 && B == 2 ) { System . out . println ( " 1 " ) ; } } } import java . util . Scanner ; class Nyfoz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int nyfoz = scan . nextInt ( ) ; int [ ] data = new int [ nyfoz ] ; int sum = 0 ; for ( int i = 0 ; i < nyfoz ; i ++ ) { data [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < nyfoz ; i ++ ) { while ( data [ i ] % 2 == 0 ) { sum ++ ; data [ i ] /= 2 ; } } System . out . println ( sum ) ; } } import java . awt . * ; import java . io . PrintWriter ; import java . lang . reflect . Array ; import java . math . BigInteger ; import java . util . * ; import java . util . List ; public class Ufjrxnr { static String br = System . getProperty ( " line.separator " ) ; static Scanner sc = new Scanner ( System . in ) ; static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] args ) { int ufjrxnr = nextInt ( ) ; int [ ] K = new int [ ufjrxnr ] ; for ( int i = 0 ; i < ufjrxnr ; i ++ ) { K [ nextInt ( ) - 1 ] = i ; } for ( int i = 0 ; i < ufjrxnr ; i ++ ) { print ( K [ i ] + 1 + " " ) ; } } static int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } static Long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } static String next ( ) { return sc . next ( ) ; } static String nextLine ( ) { return sc . nextLine ( ) ; } static void println ( Object o ) { out . println ( o ) ; out . flush ( ) ; } static void print ( Object o ) { PrintWriter out = new PrintWriter ( System . out ) ; out . print ( o ) ; out . flush ( ) ; } } import java . util . Scanner ; public class Ijfssn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] list = sc . nextLine ( ) . split ( " " , 0 ) ; int ijfssn = Integer . parseInt ( list [ 0 ] ) ; int B = Integer . parseInt ( list [ 1 ] ) ; int T = Integer . parseInt ( list [ 2 ] ) ; System . out . println ( B * ( T / ijfssn ) ) ; sc . close ( ) ; } } import java . util . * ; public class Wufmvu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; if ( s [ 2 ] == s [ 3 ] && s [ 4 ] == s [ 5 ] ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Chyid { public static void main ( String [ ] args ) throws Exception { BufferedReader breader = getReader ( ) ; int [ ] ary = getAry ( breader ) ; while ( ary [ 0 ] != 0 || ary [ 1 ] != 0 ) { for ( int chyid = 0 ; chyid < ary [ 0 ] ; chyid ++ ) { for ( int j = 0 ; j < ary [ 1 ] ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( " " ) ; } System . out . println ( " " ) ; ary = getAry ( breader ) ; } } public static BufferedReader getReader ( ) { return ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; } public static int [ ] getAry ( BufferedReader br ) throws Exception { String line = br . readLine ( ) ; String [ ] nstr = line . split ( " " ) ; int [ ] n = new int [ nstr . length ] ; for ( int chyid = 0 ; chyid < nstr . length ; chyid ++ ) { n [ chyid ] = Integer . valueOf ( nstr [ chyid ] ) ; } return n ; } } import java . util . Scanner ; public class Zxrrlgc { public static double temp ( int t , int x ) { return t - x * 0.006 ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zxrrlgc = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int [ ] h = new int [ zxrrlgc ] ; for ( int i = 0 ; i < zxrrlgc ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } double minDiff = Math . abs ( a - temp ( t , h [ 0 ] ) ) ; int num = 0 ; for ( int i = 1 ; i < zxrrlgc ; i ++ ) { double hoge = Math . abs ( a - temp ( t , h [ i ] ) ) ; if ( minDiff > hoge ) { minDiff = hoge ; num = i ; } } System . out . println ( num + 1 ) ; } } import java . util . Scanner ; public class Buzboi { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int buzboi = Integer . parseInt ( s . next ( ) ) ; int k = Integer . parseInt ( s . next ( ) ) ; int count = 1 ; for ( int i = 1 ; i < buzboi ; ) { i = i * k ; if ( buzboi / i >= 1 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class Xtrxv { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int xtrxv = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int ans ; if ( K <= xtrxv ) { ans = K ; } else if ( K <= xtrxv + B ) { ans = xtrxv ; } else { ans = xtrxv - ( K - ( xtrxv + B ) ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class Mcewt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mcewt = sc . nextInt ( ) ; int ac = 0 ; int wa = 0 ; int tle = 0 ; int re = 0 ; for ( int i = 0 ; i < mcewt + 1 ; i ++ ) { String S = sc . nextLine ( ) ; if ( S . equals ( " AC " ) ) { ac ++ ; } else if ( S . equals ( " WA " ) ) { wa ++ ; } else if ( S . equals ( " TLE " ) ) { tle ++ ; } else if ( S . equals ( " RE " ) ) { re ++ ; } } System . out . println ( " AC x " + ac ) ; System . out . println ( " WA x " + wa ) ; System . out . println ( " TLE x " + tle ) ; System . out . println ( " RE x " + re ) ; } } import java . util . * ; public class Eeheujw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eeheujw = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int count = 1 ; while ( true ) { if ( eeheujw / ( int ) ( Math . pow ( k , count ) ) == 0 ) break ; count ++ ; } System . out . println ( " " + count ) ; } } import java . util . Scanner ; public class Rprxfp { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; Main m = new Main ( sc ) ; m . show ( m . solve ( ) ) ; sc . close ( ) ; } Scanner sc ; int rprxfp ; int [ ] [ ] D ; Main ( Scanner sc ) { this . sc = sc ; this . rprxfp = sc . nextInt ( ) ; this . D = new int [ rprxfp ] [ 2 ] ; for ( int i = 0 ; i < rprxfp ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { this . D [ i ] [ j ] = sc . nextInt ( ) ; } } } private String solve ( ) { String answer = " No " ; for ( int i = 0 ; i < rprxfp - 2 ; i ++ ) { if ( D [ i ] [ 0 ] == D [ i ] [ 1 ] && D [ i + 1 ] [ 0 ] == D [ i + 1 ] [ 1 ] && D [ i + 2 ] [ 0 ] == D [ i + 2 ] [ 1 ] ) { answer = " Yes " ; break ; } } return answer ; } public void show ( String answer ) { System . out . println ( answer ) ; } } import java . util . Scanner ; public class Yxqisw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long yxqisw = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; boolean flag = true ; long d = 0 ; yxqisw = yxqisw % k ; d = Math . min ( yxqisw , Math . abs ( yxqisw - k ) ) ; System . out . println ( d ) ; } } import java . util . Scanner ; class Mtodp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int mtodp = scanner . nextInt ( ) ; int numB = scanner . nextInt ( ) ; int numC = scanner . nextInt ( ) ; int ans = 0 ; for ( int val = mtodp ; val <= numB ; val ++ ) { if ( numC % val == 0 ) ans ++ ; } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class Celoxmb { static class Celoxmb { 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 ( ) ) ; } } public static void main ( String [ ] args ) { FastReader scanner = new FastReader ( ) ; int celoxmb = scanner . nextInt ( ) ; int [ ] A = new int [ celoxmb ] ; for ( int i = 0 ; i < celoxmb ; i ++ ) { A [ i ] = scanner . nextInt ( ) ; } int [ ] DP = new int [ celoxmb ] ; DP [ 1 ] = Math . abs ( A [ 1 ] - A [ 0 ] ) ; for ( int i = 2 ; i < celoxmb ; i ++ ) { DP [ i ] = Math . min ( DP [ i - 1 ] + Math . abs ( A [ i ] - A [ i - 1 ] ) , DP [ i - 2 ] + Math . abs ( A [ i ] - A [ i - 2 ] ) ) ; } System . out . println ( DP [ celoxmb - 1 ] ) ; } } import java . util . Scanner ; public class Jipijyv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long [ ] dd = new long [ 10000 ] ; int jipijyv = 9 ; long r = 0 ; long su ; for ( int i = 0 ; jipijyv == 9 ; i ++ ) { su = sc . nextInt ( ) ; if ( su != 0 ) { dd [ i ] = su ; } if ( su == 0 ) { r = i ; break ; } } for ( int y = 0 ; y < r ; y ++ ) { int l = y + 1 ; System . out . println ( " Case " + l + " : " + dd [ y ] ) ; } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Jzgxl { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; abc155_b solver = new abc155_b ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Jzgxl { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int jzgxl = in . nextInt ( ) ; boolean ret = true ; for ( int i = 0 ; i < jzgxl ; i ++ ) { int a = in . nextInt ( ) ; if ( ( a % 2 ) == 0 ) { if ( ( a % 3 ) == 0 || ( a % 5 ) == 0 ) { ret = true ; } else { ret = false ; break ; } } } if ( ret ) { out . println ( " APPROVED " ) ; } else { out . println ( " DENIED " ) ; } } } } import java . util . * ; public class Tlxyjl { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int tlxyjl = sc . nextInt ( ) , t = 0 ; while ( tlxyjl -- > 0 ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; if ( a == b ) t ++ ; else t = 0 ; if ( t == 3 ) break ; } System . out . println ( t == 3 ? " Yes " : " No " ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { solve ( ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class Rkabot { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int rkabot = scn . nextInt ( ) ; HashSet < Integer > arr = new HashSet < Integer > ( ) ; boolean yes = true ; for ( int i = 0 ; i < rkabot ; i ++ ) { int a = scn . nextInt ( ) ; if ( arr . contains ( a ) ) { yes = false ; break ; } else { arr . add ( a ) ; } } System . out . println ( yes ? " YES " : " NO " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Zenrb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < String > list = new ArrayList < String > ( ) ; while ( true ) { list . add ( sc . nextLine ( ) ) ; if ( list . get ( list . size ( ) - 1 ) . equals ( " 0 0 " ) ) { break ; } } int [ ] [ ] data = new int [ list . size ( ) - 1 ] [ 2 ] ; for ( int zenrb = 0 ; zenrb < list . size ( ) - 1 ; zenrb ++ ) { String s = list . get ( zenrb ) ; String [ ] ary = s . split ( " " ) ; data [ zenrb ] [ 0 ] = Integer . parseInt ( ary [ 0 ] ) ; data [ zenrb ] [ 1 ] = Integer . parseInt ( ary [ 1 ] ) ; } int answer = 0 ; for ( int cntData = 0 ; cntData < data . length ; cntData ++ ) { for ( int count1 = 1 ; count1 < data [ cntData ] [ 0 ] - 1 ; count1 ++ ) { for ( int count2 = count1 + 1 ; count2 < data [ cntData ] [ 0 ] ; count2 ++ ) { for ( int count3 = count2 + 1 ; count3 <= data [ cntData ] [ 0 ] ; count3 ++ ) { if ( count1 + count2 + count3 == data [ cntData ] [ 1 ] ) { answer ++ ; } } } } System . out . println ( answer ) ; answer = 0 ; } } } import java . util . Scanner ; public class Igvnbn { public static void main ( String [ ] argv ) { Scanner scan = new Scanner ( System . in ) ; int igvnbn = scan . nextInt ( ) ; int h = 0 , m = 0 , s = 0 ; while ( true ) { if ( igvnbn - 3600 >= 0 ) { igvnbn = igvnbn - 3600 ; h ++ ; } else if ( igvnbn - 60 >= 0 ) { igvnbn = igvnbn - 60 ; m ++ ; } else { if ( igvnbn == 0 ) break ; s ++ ; igvnbn -- ; } } System . out . println ( h + " : " + m + " : " + s ) ; } } import java . util . * ; public class Aqjjx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aqjjx = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < String > ( ) ; char last = 'X' ; boolean flag = true ; for ( int i = 0 ; i < aqjjx ; i ++ ) { String s = sc . next ( ) ; if ( list . contains ( s ) ) { flag = false ; break ; } else { list . add ( s ) ; } if ( i != 0 && s . charAt ( 0 ) != last ) { flag = false ; break ; } last = s . charAt ( s . length ( ) - 1 ) ; } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; class Mdnsx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mdnsx = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int ANS = 0 ; if ( mdnsx == 0 ) { if ( N != 100 ) { ANS = N ; } else { ANS = N + 1 ; } } else if ( mdnsx == 1 ) { if ( N != 100 ) { ANS = N * 100 ; } else { ANS = ( N + 1 ) * 100 ; } } else { if ( N != 100 ) { ANS = N * 10000 ; } else { ANS = ( N + 1 ) * 10000 ; } } System . out . println ( ANS ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Frcat { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str ; while ( ( str = br . readLine ( ) ) != null ) { String [ ] inputs = str . split ( " " ) ; int frcat = Integer . parseInt ( inputs [ 0 ] ) ; int b = Integer . parseInt ( inputs [ 1 ] ) ; int c = Integer . parseInt ( inputs [ 2 ] ) ; int k = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < k ; i ++ ) { if ( frcat > b && frcat > c ) { frcat *= 2 ; } else if ( b > c ) { b *= 2 ; } else { c *= 2 ; } } System . out . println ( frcat + b + c ) ; } } } import java . util . Scanner ; public class Dhpho { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dhpho = sc . nextInt ( ) ; int [ ] h = new int [ dhpho ] ; for ( int i = 0 ; i < dhpho ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < ( dhpho - 1 ) ; i ++ ) { if ( ( h [ i + 1 ] - h [ i ] ) < 0 ) { System . out . println ( " No " ) ; return ; } else if ( h [ i + 1 ] > h [ i ] ) { h [ i + 1 ] -- ; } } System . out . println ( " Yes " ) ; } } import java . io . IOException ; import java . io . InputStreamReader ; import java . io . BufferedReader ; public class Qbkia { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int qbkia = Integer . parseInt ( br . readLine ( ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int [ ] array = new int [ qbkia ] ; for ( int i = 0 ; i < qbkia ; i ++ ) { array [ i ] = i + 1 ; } for ( int i = 0 ; i < n ; i ++ ) { String [ ] input = br . readLine ( ) . split ( " , " ) ; int a = Integer . parseInt ( input [ 0 ] ) ; int b = Integer . parseInt ( input [ 1 ] ) ; int tmp = array [ a - 1 ] ; array [ a - 1 ] = array [ b - 1 ] ; array [ b - 1 ] = tmp ; } for ( int i : array ) { System . out . println ( i ) ; } } } import java . util . * ; class Zazgvh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int zazgvh = Integer . parseInt ( str ) ; int h_point = 0 , t_point = 0 ; for ( int i = 0 ; i < zazgvh ; i ++ ) { String taro = sc . next ( ) ; String hanako = sc . next ( ) ; if ( taro . compareTo ( hanako ) > 0 ) t_point += 3 ; else if ( taro . compareTo ( hanako ) < 0 ) h_point += 3 ; else { t_point ++ ; h_point ++ ; } } System . out . println ( t_point + " " + h_point ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Yinssl { public static void main ( String [ ] args ) throws Exception { InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( is ) ; while ( true ) { String str = br . readLine ( ) ; String [ ] num = getElement ( str ) ; int yinssl = Integer . parseInt ( num [ 0 ] ) ; int w = Integer . parseInt ( num [ 1 ] ) ; if ( yinssl == 0 && w == 0 ) { break ; } for ( int i = 0 ; i < yinssl ; i ++ ) { if ( i == 0 || i == yinssl - 1 ) { for ( int j = 0 ; j < w ; j ++ ) { System . out . print ( " # " ) ; } } else { for ( int j = 0 ; j < w ; j ++ ) { if ( j == 0 || j == w - 1 ) { System . out . print ( " # " ) ; } else { System . out . print ( " . " ) ; } } } System . out . print ( " \r \n " ) ; } System . out . print ( " \r \n " ) ; } } public static String [ ] getElement ( String element ) { return ( element . split ( " " ) ) ; } } import java . util . * ; public class Uzgyqgv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uzgyqgv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int powk = ( ( int ) Math . pow ( 2 , k ) ) ; int answer = 0 ; if ( uzgyqgv > b && uzgyqgv > c ) { answer = uzgyqgv * powk + b + c ; } else if ( b > uzgyqgv && b > c ) { answer = b * powk + uzgyqgv + c ; } else { answer = c * powk + uzgyqgv + b ; } System . out . println ( answer ) ; } } import java . util . Scanner ; class Fftbqqz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int fftbqqz = scan . nextInt ( ) ; int str2 = scan . nextInt ( ) ; System . out . println ( fftbqqz * str2 + " " + ( fftbqqz * 2 + str2 * 2 ) ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Ryfwg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ryfwg = sc . nextInt ( ) ; int [ ] s = new int [ ryfwg ] ; for ( int i = 0 ; i < ryfwg ; i ++ ) { s [ i ] = sc . nextInt ( ) ; } int q = sc . nextInt ( ) ; int [ ] t = new int [ q ] ; for ( int i = 0 ; i < q ; i ++ ) { t [ i ] = sc . nextInt ( ) ; } Arrays . sort ( s ) ; Arrays . sort ( t ) ; int count = 0 ; for ( int i = 0 , key = 0 ; i < ryfwg && key < q ; ) { if ( s [ i ] < t [ key ] ) { i ++ ; } else if ( s [ i ] == t [ key ] ) { count ++ ; i ++ ; key ++ ; } else { key ++ ; } } System . out . println ( count ) ; sc . close ( ) ; } } import java . util . * ; class Fohph { public static void main ( String ... args ) { final Scanner sc = new Scanner ( System . in ) ; final int fohph = sc . nextInt ( ) ; System . out . println ( fohph * fohph * fohph ) ; } } public class Fohph { public static void main ( String ... args ) { XCubic . main ( ) ; } } import java . util . HashMap ; import java . util . HashSet ; import java . util . Map ; import java . util . Scanner ; import java . util . Set ; public class Jfjjf { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { solve_abc151_a ( ) ; } public static void solve_abc151_a ( ) { Scanner sc = new Scanner ( System . in ) ; String c = sc . next ( ) ; String [ ] s = { " a " , " b " , " c " , " d " , " e " , " f " , " g " , " h " , " i " , " j " , " k " , " l " , " m " , " n " , " o " , " p " , " q " , " r " , " s " , " t " , " u " , " v " , " w " , " x " , " y " , " z " } ; int jfjjf = 0 ; for ( int si = 0 ; si < s . length ; si ++ ) { if ( c . equals ( s [ si ] ) ) { jfjjf = si ; break ; } } System . out . println ( s [ jfjjf + 1 ] ) ; sc . close ( ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; class Rctetq { static class Rctetq { 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 ; } } public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int rctetq = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = 0 ; for ( int i = a ; i <= b ; i ++ ) { if ( i % rctetq == 0 ) { sum = 1 ; } } if ( sum == 1 ) { System . out . println ( " OK " ) ; } else { System . out . println ( " NG " ) ; } } } import java . util . Scanner ; public class Zfxqjd { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long zfxqjd = s . nextLong ( ) ; long a = s . nextLong ( ) ; long b = s . nextLong ( ) ; long set = zfxqjd / ( a + b ) ; long rem = zfxqjd % ( a + b ) ; long ans = a * set ; ans = ans + Math . min ( a , rem ) ; System . out . println ( ans ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class Fyftiv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int fyftiv = scan . nextInt ( ) ; BigDecimal [ ] an = new BigDecimal [ fyftiv ] ; for ( int i = 0 ; i < fyftiv ; i ++ ) { BigDecimal a = scan . nextBigDecimal ( ) ; if ( BigDecimal . ZERO . compareTo ( a ) == 0 ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } an [ i ] = a ; } BigDecimal ans = BigDecimal . ONE ; for ( int i = 0 ; i < an . length ; i ++ ) { ans = ans . multiply ( an [ i ] ) ; if ( ans . compareTo ( BigDecimal . ONE . scaleByPowerOfTen ( 18 ) ) > 0 ) { System . out . println ( - 1 ) ; System . exit ( 0 ) ; } } if ( ans . compareTo ( BigDecimal . ONE . scaleByPowerOfTen ( 18 ) ) <= 0 ) { System . out . println ( ans ) ; } else { System . out . println ( - 1 ) ; } scan . close ( ) ; } } import java . util . * ; public class Rtbea { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int rtbea = 0 ; rtbea < 3 ; rtbea ++ ) a [ rtbea ] = sc . nextInt ( ) ; int [ ] b = new int [ 3 ] ; for ( int rtbea = 0 ; rtbea < 3 ; rtbea ++ ) { b [ rtbea ] = a [ ( rtbea + 2 ) % 3 ] ; System . out . print ( b [ rtbea ] + " " ) ; } } } import java . util . * ; public class Oukkw { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int oukkw = sc . nextInt ( ) ; int answer = oukkw + oukkw * oukkw + oukkw * oukkw * oukkw ; System . out . println ( answer ) ; } } import java . util . Scanner ; class Joekwav { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String key = in . next ( ) . toLowerCase ( ) ; int joekwav = 0 ; while ( true ) { String input = in . next ( ) ; if ( input . equals ( " END_OF_TEXT " ) ) break ; if ( input . equalsIgnoreCase ( key ) ) joekwav ++ ; } System . out . println ( joekwav ) ; } } import java . util . * ; public class Qlfszbz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qlfszbz = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] S = sc . nextLine ( ) . split ( " " ) ; int ans = 0 ; for ( int i = 0 ; i < qlfszbz ; i ++ ) { int n = Integer . parseInt ( S [ i ] ) ; while ( n % 2 == 0 ) { n /= 2 ; ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; class Nwgayht { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nwgayht = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = s . length ( ) ; String add = " ... " ; if ( count <= nwgayht ) { System . out . println ( s ) ; } else if ( count > nwgayht ) { String result = s . substring ( 0 , nwgayht ) + add ; System . out . println ( result ) ; } } } import java . util . * ; import static java . lang . Math . * ; import java . math . BigInteger ; public class Lvcvzed { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String result = " No " ; int lvcvzed = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { lvcvzed += s . charAt ( i ) - '0' ; } if ( Integer . valueOf ( s ) % lvcvzed == 0 ) result = " Yes " ; System . out . println ( result ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Hulaqc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hulaqc = sc . nextInt ( ) ; Integer [ ] d = new Integer [ hulaqc ] ; for ( int i = 0 ; i < hulaqc ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( d , Collections . reverseOrder ( ) ) ; int ans = 1 ; for ( int i = 0 ; i < hulaqc - 1 ; i ++ ) { if ( d [ i ] > d [ i + 1 ] ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Wrjmf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wrjmf = Integer . parseInt ( scan . next ( ) ) ; int counter = 0 ; int min = Integer . MAX_VALUE ; ArrayList < Integer > pi = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < wrjmf ; ++ i ) { int numPi = Integer . parseInt ( scan . next ( ) ) ; if ( i == 0 ) { counter ++ ; } else { if ( numPi <= min ) { counter ++ ; } } if ( min > numPi ) { min = numPi ; } } System . out . println ( counter ) ; } } import java . util . Scanner ; public class Bjkpvl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String W = sc . next ( ) . toLowerCase ( ) ; String T ; int bjkpvl = 0 ; while ( ! ( T = sc . next ( ) ) . equals ( " END_OF_TEXT " ) ) { if ( T . toLowerCase ( ) . equals ( W ) ) { bjkpvl ++ ; } } sc . close ( ) ; System . out . println ( bjkpvl ) ; } } import java . util . * ; public class Znewc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int znewc = 0 ; boolean flag = false ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( str . charAt ( i ) == 'R' ) { znewc ++ ; flag = true ; } else { if ( flag == true ) break ; } } System . out . println ( znewc ) ; } } import java . util . Scanner ; public class Eymurt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char eymurt = ' ' ; for ( int i = 0 ; i < S . length ( ) ; i = i + 2 ) { eymurt = S . charAt ( i ) ; if ( eymurt != 'R' && eymurt != 'U' && eymurt != 'D' ) { System . out . println ( " No " ) ; return ; } } for ( int k = 1 ; k < S . length ( ) ; k = k + 2 ) { eymurt = S . charAt ( k ) ; if ( eymurt != 'L' && eymurt != 'U' && eymurt != 'D' ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Hwqmgaj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hwqmgaj = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] L = new int [ M ] ; int [ ] R = new int [ M ] ; int max = hwqmgaj + 1 ; int min = 0 ; for ( int i = 0 ; i < M ; i ++ ) { L [ i ] = sc . nextInt ( ) ; R [ i ] = sc . nextInt ( ) ; min = Math . max ( min , L [ i ] ) ; max = Math . min ( max , R [ i ] ) ; } int res = Math . max ( max - min + 1 , 0 ) ; System . out . println ( res ) ; } } import java . util . Scanner ; public class Hjmusj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long hjmusj = sc . nextLong ( ) ; if ( hjmusj == 1 || hjmusj == 2 || hjmusj == 3 ) { System . out . println ( hjmusj ) ; return ; } while ( true ) { boolean prime = true ; for ( int i = 2 ; i <= hjmusj / 2 ; i ++ ) { if ( hjmusj % i == 0 ) { prime = false ; break ; } } if ( prime ) { System . out . println ( hjmusj ) ; return ; } hjmusj ++ ; } } } import java . util . Scanner ; public class Ixaplc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ixaplc = Integer . parseInt ( sc . next ( ) ) ; int [ ] d = new int [ ixaplc ] ; for ( int i = 0 ; i < ixaplc ; i ++ ) { d [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int ans = 0 ; for ( int a = 0 ; a < ixaplc - 1 ; a ++ ) { for ( int b = 0 ; b < ixaplc - 1 - a ; b ++ ) { ans += d [ a ] * d [ a + 1 + b ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; class Qhxjm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qhxjm = sc . nextInt ( ) ; int numCol = sc . nextInt ( ) ; int [ ] [ ] mat = new int [ qhxjm ] [ numCol ] ; int [ ] vecIn = new int [ numCol ] ; int [ ] vecOut = new int [ qhxjm ] ; int i , j ; for ( i = 0 ; i < qhxjm ; i ++ ) { for ( j = 0 ; j < numCol ; j ++ ) { mat [ i ] [ j ] = sc . nextInt ( ) ; } } for ( j = 0 ; j < numCol ; j ++ ) vecIn [ j ] = sc . nextInt ( ) ; for ( i = 0 ; i < qhxjm ; i ++ ) { for ( j = 0 ; j < numCol ; j ++ ) { vecOut [ i ] += mat [ i ] [ j ] * vecIn [ j ] ; } System . out . println ( vecOut [ i ] ) ; } } } import java . util . Scanner ; import java . util . Queue ; import java . util . ArrayDeque ; import java . util . Arrays ; public class Kiffmwz { static int kiffmwz = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; long c = sc . nextInt ( ) ; long d = sc . nextInt ( ) ; long max = - 1000000000000000000l ; long ac = a * c ; long bc = b * c ; long cd = b * d ; long da = d * a ; System . out . println ( Math . max ( Math . max ( ac , bc ) , Math . max ( cd , da ) ) ) ; } } import java . util . HashMap ; import java . util . Scanner ; public class Xlqqd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xlqqd = sc . nextInt ( ) ; String [ ] s = new String [ xlqqd ] ; for ( int i = 0 ; i < xlqqd ; i ++ ) { s [ i ] = sc . next ( ) ; } HashMap < String , Integer > map = new HashMap < String , Integer > ( ) ; map . put ( s [ 0 ] , 1 ) ; int ans = 1 ; for ( int i = 1 ; i < xlqqd ; i ++ ) { if ( ! map . containsKey ( s [ i ] ) ) { ans ++ ; map . put ( s [ i ] , 1 ) ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Olktmv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String olktmv = scan . next ( ) ; if ( olktmv . length ( ) == 3 ) { if ( olktmv . contains ( " 7 " ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; class Ujyaf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ujyaf = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int value ; int rowTotal ; int [ ] colTotal = new int [ c ] ; for ( int i = 0 ; i < ujyaf ; i ++ ) { rowTotal = 0 ; for ( int j = 0 ; j < c ; j ++ ) { value = sc . nextInt ( ) ; System . out . print ( value + " " ) ; rowTotal += value ; colTotal [ j ] += value ; } System . out . println ( rowTotal ) ; } rowTotal = 0 ; for ( int i = 0 ; i < c ; i ++ ) { System . out . print ( colTotal [ i ] + " " ) ; rowTotal += colTotal [ i ] ; } System . out . println ( rowTotal ) ; } } import java . util . * ; import java . io . * ; public class Ogtkg { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String S = s . next ( ) ; String T = s . next ( ) ; int ogtkg = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) != T . charAt ( i ) ) ogtkg ++ ; } System . out . println ( ogtkg ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Vpgrq { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int vpgrq = 1 ; while ( true ) { int n = Integer . parseInt ( br . readLine ( ) ) ; if ( n == 0 ) { break ; } sb . append ( " Case " ) . append ( vpgrq ) . append ( " : " ) . append ( n ) . append ( " \n " ) ; vpgrq ++ ; } System . out . print ( sb ) ; } } import java . util . * ; public class Eganunu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eganunu = sc . nextInt ( ) ; int [ ] a = new int [ eganunu ] ; for ( int i = 0 ; i < eganunu ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int bigTall = a [ 0 ] ; long count = 0 ; for ( int i = 1 ; i < eganunu ; i ++ ) { if ( bigTall > a [ i ] ) { int sub = bigTall - a [ i ] ; count += sub ; } else { bigTall = a [ i ] ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Vyapnj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String vyapnj = scan . next ( ) ; String result = " No " ; if ( String . valueOf ( vyapnj . charAt ( 2 ) ) . equals ( String . valueOf ( vyapnj . charAt ( 3 ) ) ) && ( String . valueOf ( vyapnj . charAt ( 4 ) ) . equals ( String . valueOf ( vyapnj . charAt ( 5 ) ) ) ) ) { result = " Yes " ; } System . out . println ( result ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Qpyogk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qpyogk = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] key = new int [ qpyogk ] ; int [ ] L = new int [ M ] ; int [ ] R = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { L [ i ] = sc . nextInt ( ) ; R [ i ] = sc . nextInt ( ) ; } Arrays . sort ( R ) ; Arrays . sort ( L ) ; if ( R [ 0 ] - L [ M - 1 ] + 1 > 0 ) { System . out . println ( R [ 0 ] - L [ M - 1 ] + 1 ) ; } else { System . out . println ( " 0 " ) ; } sc . close ( ) ; } } import java . util . * ; public class Jgdhcvu { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long [ ] line = new long [ 4 ] ; for ( int jgdhcvu = 0 ; jgdhcvu < 4 ; jgdhcvu ++ ) { line [ jgdhcvu ] = sc . nextLong ( ) ; } long max = Long . MIN_VALUE ; for ( int jgdhcvu = 0 ; jgdhcvu < 2 ; jgdhcvu ++ ) { for ( int j = 2 ; j < 4 ; j ++ ) { max = Math . max ( max , line [ jgdhcvu ] * line [ j ] ) ; } } System . out . println ( max ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Gpdkjcv { int gpdkjcv , k ; public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; if ( Character . isUpperCase ( a . charAt ( 0 ) ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class Lknhvdt { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; String lknhvdt = sc . next ( ) . replace ( " 2017 " , " 2018 " ) ; System . out . println ( lknhvdt ) ; sc . close ( ) ; } } import java . util . Scanner ; class Vulovt { public static void main ( String [ ] argv ) { Scanner sc = new Scanner ( System . in ) ; boolean vulovt = false ; for ( int i = 0 ; i < 2 ; i ++ ) { int x = sc . nextInt ( ) ; if ( ( x % 2 ) == 0 ) { vulovt = true ; } } sc . close ( ) ; if ( vulovt == true ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Scanner ; public class Xyhxiu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xyhxiu = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int result = 0 ; if ( xyhxiu == B ) { result = xyhxiu + B ; } else if ( xyhxiu > B ) { result = xyhxiu + xyhxiu - 1 ; } else if ( B > xyhxiu ) { result = B + B - 1 ; } System . out . println ( result ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Yqzcwsj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long yqzcwsj = sc . nextLong ( ) ; ArrayList < Integer > numList = new ArrayList < Integer > ( ) ; while ( true ) { int digit = ( int ) ( yqzcwsj % 26L ) ; if ( digit == 0 ) { digit = 26 ; } numList . add ( digit + 96 ) ; yqzcwsj = ( yqzcwsj - digit ) / 26L ; if ( yqzcwsj == 0 ) { break ; } } for ( int i = numList . size ( ) - 1 ; i >= 0 ; i -- ) { int let = ( int ) numList . get ( i ) ; char c = ( char ) let ; System . out . print ( c ) ; } } } import java . util . * ; public class Rgorgtf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long rgorgtf , b1 , r1 , r2 , temp , a2 , b2 ; while ( scan . hasNext ( ) ) { rgorgtf = scan . nextInt ( ) ; a2 = rgorgtf ; b1 = scan . nextInt ( ) ; b2 = b1 ; while ( a2 % b2 != 0 ) { if ( a2 < b2 ) { temp = a2 ; a2 = b2 ; b2 = temp ; } a2 = a2 % b2 ; } r1 = b2 ; r2 = ( rgorgtf * b1 ) / r1 ; System . out . println ( r1 + " " + r2 ) ; } } } import java . util . LinkedHashSet ; import java . util . Scanner ; import java . util . Set ; public class Uzrjuis { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int uzrjuis = scan . nextInt ( ) ; String [ ] list = new String [ uzrjuis ] ; for ( int i = 0 ; i < uzrjuis ; i ++ ) { list [ i ] = scan . next ( ) ; } scan . close ( ) ; Set < String > linkedHashSet = new LinkedHashSet < String > ( ) ; for ( int i = 0 ; i < list . length ; i ++ ) { linkedHashSet . add ( list [ i ] ) ; } Object [ ] num = linkedHashSet . toArray ( ) ; System . out . println ( num . length ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Cohrro { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int cohrro = Integer . parseInt ( in . readLine ( ) ) ; long [ ] a = new long [ cohrro ] ; long sum = 1 ; long lastSum = 1 ; boolean over = false ; String [ ] str = in . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < cohrro ; i ++ ) { a [ i ] = Long . parseLong ( str [ i ] ) ; if ( a [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } sum *= a [ i ] ; if ( lastSum > sum || sum > 1000000000000000000L ) { over = true ; } lastSum = sum ; } System . out . println ( over ? - 1 : sum ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class Jfghtv { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int jfghtv = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; boolean flg = false ; for ( int i = 1 ; i < 1269 ; i ++ ) { if ( Math . floor ( i * 0.08 ) == jfghtv && Math . floor ( i * 0.10 ) == B ) { System . out . println ( i ) ; flg = true ; break ; } } if ( flg == false ) { System . out . println ( " -1 " ) ; } } } import java . io . PrintWriter ; import java . util . * ; class Fykyju { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fykyju = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ fykyju ] ; int [ ] B = new int [ fykyju - 1 ] ; for ( int i = 0 ; i < fykyju ; i ++ ) A [ i ] = 100_000 ; for ( int i = 0 ; i < fykyju - 1 ; i ++ ) { B [ i ] = Integer . parseInt ( sc . next ( ) ) ; if ( B [ i ] < A [ i ] ) A [ i ] = B [ i ] ; if ( B [ i ] < A [ i + 1 ] ) A [ i + 1 ] = B [ i ] ; } sc . close ( ) ; int sum = Arrays . stream ( A ) . sum ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; out . println ( sum ) ; out . flush ( ) ; } } import java . math . BigDecimal ; import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Objects ; import java . util . Scanner ; import java . util . StringJoiner ; import java . util . stream . Stream ; public class Ghmeg { public static void main ( final String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ghmeg = sc . nextInt ( ) ; int [ ] [ ] route = new int [ 2 ] [ ghmeg ] ; for ( int i = 0 ; i < 2 ; i ++ ) { route [ i ] = new int [ ghmeg ] ; for ( int j = 0 ; j < ghmeg ; j ++ ) { route [ i ] [ j ] = sc . nextInt ( ) ; } } int maxCandy = Integer . MIN_VALUE ; for ( int i = 0 ; i < ghmeg ; i ++ ) { int tmp = 0 ; int h = 0 ; for ( int j = 0 ; j < ghmeg ; j ++ ) { tmp += route [ h ] [ j ] ; if ( i == j ) { h ++ ; tmp += route [ h ] [ j ] ; } } maxCandy = Math . max ( maxCandy , tmp ) ; } System . out . println ( maxCandy ) ; } } import java . util . Scanner ; public class Hzrdv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hzrdv = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < hzrdv ; i ++ ) { int a = sc . nextInt ( ) ; while ( ( a % 2 ) == 0 ) { cnt ++ ; a /= 2 ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Nqeivlh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nqeivlh = sc . nextInt ( ) ; double ans1 = 0 ; for ( int i = 0 ; i < nqeivlh ; i ++ ) { ans1 += 1 / ( double ) sc . nextInt ( ) ; } sc . close ( ) ; double ans2 = ( 1 / ans1 ) ; System . out . println ( ans2 ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Sntrad { static int getMorePrime ( int n ) { if ( n == 2 ) return n ; ArrayList < Integer > primes = new ArrayList < Integer > ( ) ; primes . add ( 2 ) ; int sntrad = 2 ; while ( true ) { for ( int j = 0 ; j < primes . size ( ) ; j ++ ) if ( sntrad % primes . get ( j ) == 0 ) { ++ sntrad ; j = 0 ; } if ( sntrad >= n ) return sntrad ; primes . add ( sntrad ) ; ++ sntrad ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; System . out . println ( getMorePrime ( n ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Pgznhr { public static void main ( String [ ] args ) throws IOException { int pgznhr = 0 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] inputNum = br . readLine ( ) . split ( " " ) ; int a = Integer . parseInt ( inputNum [ 0 ] ) ; int b = Integer . parseInt ( inputNum [ 1 ] ) ; int c = Integer . parseInt ( inputNum [ 2 ] ) ; for ( int i = a ; i <= b ; i ++ ) { if ( c % i == 0 ) { pgznhr ++ ; } } System . out . println ( pgznhr ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Yzraqor { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int yzraqor = sc . nextInt ( ) ; int ans = 1 ; lavel : for ( int i = 2 ; i < yzraqor ; i ++ ) { for ( int j = 2 ; ; j ++ ) { if ( ( int ) Math . pow ( i , j ) > yzraqor ) { continue lavel ; } else if ( ans < ( int ) Math . pow ( i , j ) ) { ans = ( int ) Math . pow ( i , j ) ; } } } System . out . println ( ans ) ; } } import java . io . IOException ; import java . util . Scanner ; public class Nauap { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int nauap = 0 ; String n = sc . next ( ) ; for ( char ch : n . toCharArray ( ) ) { nauap += ch - '0' ; nauap %= 9 ; } if ( nauap == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Qoheral { public static void main ( String [ ] argsp ) { Scanner sc = new Scanner ( System . in ) ; int qoheral = 0 ; String s = sc . next ( ) , t = sc . next ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) { qoheral ++ ; } } System . out . print ( qoheral ) ; } } import java . util . * ; public class Lmdnsj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lmdnsj = sc . nextInt ( ) ; if ( lmdnsj % 2 == 1 ) { System . out . println ( ( double ) ( ( lmdnsj - 1 ) / 2 + 1 ) / lmdnsj ) ; } else { System . out . println ( 0.5 ) ; } } } import java . util . * ; import java . lang . Integer ; public class Xljqo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double xljqo = sc . nextInt ( ) ; double y = sc . nextInt ( ) ; double crane = - ( y / 2 ) + 2 * xljqo ; double turtle = xljqo - crane ; if ( turtle < 0 || crane < 0 || turtle % 1 != 0 || crane % 1 != 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; import java . lang . * ; public class Axxwm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int axxwm = sc . nextInt ( ) ; int result = 0 ; result += axxwm / 100 ; result = result * 111 ; System . out . println ( axxwm <= result ? result : result == 999 ? result + 112 : result + 111 ) ; } } import java . util . * ; public class Zgxyjnw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int zgxyjnw = str . length ( ) ; char [ ] c = new char [ zgxyjnw ] ; char c1 = str . charAt ( 0 ) ; char c2 = str . charAt ( 1 ) ; char c3 = str . charAt ( 2 ) ; if ( ( c1 == 'A' ) && ( c2 == 'A' ) && ( c3 == 'A' ) ) { System . out . println ( " No " ) ; } else if ( ( c1 == 'B' ) && ( c2 == 'B' ) && ( c3 == 'B' ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Lpqulfh { public static void main ( String [ ] args ) { Scanner sn = new Scanner ( System . in ) ; ArrayList < Integer > a = new ArrayList < Integer > ( ) ; for ( int lpqulfh = 0 ; lpqulfh < 10 ; lpqulfh ++ ) { a . add ( sn . nextInt ( ) ) ; } Collections . sort ( a ) ; for ( int lpqulfh = 0 ; lpqulfh < 3 ; lpqulfh ++ ) { System . out . println ( a . get ( a . size ( ) - lpqulfh - 1 ) ) ; } } } import java . math . BigInteger ; import java . util . Scanner ; public class Nvhtv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nvhtv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; BigInteger c = BigInteger . valueOf ( nvhtv ) . multiply ( BigInteger . valueOf ( b ) ) ; int d = nvhtv % b ; while ( d != 0 ) { nvhtv = b ; b = d ; d = nvhtv % b ; } System . out . println ( c . divide ( BigInteger . valueOf ( b ) ) ) ; } } import java . util . Scanner ; public class Wmpycq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String wmpycq = sc . next ( ) ; char [ ] c = wmpycq . toCharArray ( ) ; c [ 3 ] = '8' ; String st = new String ( c ) ; System . out . println ( st ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Dzjuq { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] values = new int [ 5 ] ; for ( int dzjuq = 0 ; dzjuq < 5 ; dzjuq ++ ) { values [ dzjuq ] = Integer . parseInt ( input . readLine ( ) ) ; } int k = Integer . parseInt ( input . readLine ( ) ) ; for ( int dzjuq = 0 ; dzjuq < 5 ; dzjuq ++ ) { for ( int j = dzjuq + 1 ; j < 5 ; j ++ ) { if ( Math . abs ( values [ dzjuq ] - values [ j ] ) > k ) { System . out . println ( " :( " ) ; return ; } } } System . out . println ( " Yay! " ) ; } } import java . util . * ; public class Ulbjts { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ulbjts = sc . nextInt ( ) ; String f = sc . next ( ) ; if ( ulbjts % 2 == 0 ) { if ( f . substring ( 0 , ulbjts / 2 ) . equals ( f . substring ( ulbjts / 2 , ulbjts ) ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Wydnvzm { public static void main ( String [ ] args ) throws IOException { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String input = br . readLine ( ) ; String [ ] inputan = br . readLine ( ) . split ( " " ) ; for ( int wydnvzm = Integer . parseInt ( input ) - 1 ; wydnvzm >= 0 ; wydnvzm -- ) { System . out . print ( inputan [ wydnvzm ] ) ; if ( wydnvzm > 0 ) System . out . print ( " " ) ; if ( wydnvzm == 0 ) System . out . println ( ) ; } } } import java . util . Scanner ; public class Hwloysv { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int hwloysv = S . length ( ) ; String ans = " " ; for ( int i = 0 ; i < hwloysv ; i ++ ) { ans = ans . concat ( " x " ) ; } System . out . println ( ans ) ; } } import java . util . * ; import java . lang . * ; public class Hukfa { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long hukfa = scan . nextLong ( ) ; char [ ] alpha = new char [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { alpha [ i ] = ( char ) ( 97 + i ) ; } ArrayList < Character > ans = new ArrayList < > ( ) ; while ( hukfa >= 1 ) { long a = hukfa % 26 ; int b = ( int ) a ; if ( b != 0 ) { ans . add ( alpha [ b - 1 ] ) ; } else if ( b == 0 ) { ans . add ( alpha [ 25 ] ) ; } if ( hukfa % 26 != 0 ) { hukfa = hukfa / 26 ; } else { hukfa = hukfa / 26 - 1 ; } } for ( int i = ans . size ( ) - 1 ; i >= 0 ; i -- ) { System . out . print ( ans . get ( i ) ) ; } } } import java . util . Scanner ; public class Lyskneb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lyskneb = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += Integer . parseInt ( sc . next ( ) ) ; System . out . println ( lyskneb > sum ? " No " : " Yes " ) ; } } import java . util . Scanner ; class Jmwfhmi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jmwfhmi = scan . nextInt ( ) ; int [ ] a = new int [ jmwfhmi ] ; for ( int i = 0 ; i < jmwfhmi ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } boolean flag = true ; int swap ; int count = 0 ; int min ; for ( int i = 0 ; i < jmwfhmi ; i ++ ) { min = i ; for ( int j = i ; j < jmwfhmi ; j ++ ) { if ( a [ j ] < a [ min ] ) { min = j ; } } if ( a [ i ] != a [ min ] ) { swap = a [ i ] ; a [ i ] = a [ min ] ; a [ min ] = swap ; count ++ ; } } for ( int i = 0 ; i < jmwfhmi ; i ++ ) { System . out . print ( a [ i ] ) ; if ( i != jmwfhmi - 1 ) System . out . print ( " " ) ; } System . out . println ( ) ; System . out . println ( count ) ; } } import java . util . Scanner ; public class Sacwr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int sacwr = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s [ i ] - '0' == 1 ) sacwr ++ ; } System . out . println ( sacwr ) ; } } import java . util . * ; public class Pprltbz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pprltbz = sc . nextInt ( ) ; int [ ] result = new int [ 4 ] ; for ( int i = 0 ; i < pprltbz ; i ++ ) { String s = sc . next ( ) ; switch ( s ) { case " AC " : result [ 0 ] ++ ; break ; case " WA " : result [ 1 ] ++ ; break ; case " TLE " : result [ 2 ] ++ ; break ; case " RE " : result [ 3 ] ++ ; break ; } } System . out . println ( " AC x " + result [ 0 ] ) ; System . out . println ( " WA x " + result [ 1 ] ) ; System . out . println ( " TLE x " + result [ 2 ] ) ; System . out . println ( " RE x " + result [ 3 ] ) ; } } import java . util . Scanner ; public class Ezeurwz { public static void main ( String [ ] args ) { long ezeurwz = System . currentTimeMillis ( ) ; Scanner sc = new Scanner ( System . in ) ; long thing = sc . nextLong ( ) ; long i = thing ; long j = thing ; for ( long ii = 1 ; ii <= Math . pow ( thing , 0.5 ) ; ii ++ ) { if ( thing % ii != 0 ) { continue ; } if ( ( ii + ( thing / ii ) ) < i + j ) { i = ii ; j = ( thing / ii ) ; } } System . out . println ( i + j - 2 ) ; } } import java . util . * ; import java . util . stream . * ; import java . math . * ; class Vuhorir { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigDecimal A = new BigDecimal ( sc . next ( ) ) ; BigDecimal B = new BigDecimal ( sc . next ( ) ) ; System . out . println ( A . multiply ( B ) . setScale ( 0 , RoundingMode . DOWN ) ) ; } } import java . util . * ; public class Jpnxo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jpnxo = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String [ ] s = sc . next ( ) . split ( " " ) ; String ans = " Yes " ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( i == jpnxo ) { if ( ! s [ jpnxo ] . equals ( " - " ) ) { ans = " No " ; break ; } } else { if ( s [ i ] . equals ( " - " ) ) { ans = " No " ; break ; } } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; class Rwjzgjm { void solve ( ) { int rwjzgjm = in . nextInt ( ) ; if ( rwjzgjm % 2 == 0 ) System . out . println ( 0.5 ) ; else { double b = rwjzgjm / 2 + 1 ; double c = rwjzgjm ; System . out . println ( String . format ( " %.6f " , b / c ) ) ; } } public static PrintWriter out = new PrintWriter ( System . out ) ; public static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; out . flush ( ) ; } } import java . util . Scanner ; public class Anjypz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; while ( true ) { int anjypz = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; if ( anjypz == - 1 && b == - 1 && c == - 1 ) break ; if ( anjypz == - 1 || b == - 1 ) System . out . println ( " F " ) ; else if ( anjypz + b >= 80 ) System . out . println ( " A " ) ; else if ( anjypz + b >= 65 ) System . out . println ( " B " ) ; else if ( anjypz + b >= 50 ) System . out . println ( " C " ) ; else if ( anjypz + b >= 30 ) if ( c >= 50 ) System . out . println ( " C " ) ; else System . out . println ( " D " ) ; else System . out . println ( " F " ) ; } } } import java . util . Scanner ; public class Lolstu { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int lolstu , b ; Scanner sc = new Scanner ( System . in ) ; while ( true ) { String [ ] input = sc . nextLine ( ) . split ( " " ) ; lolstu = Integer . parseInt ( input [ 0 ] ) ; b = Integer . parseInt ( input [ 1 ] ) ; if ( lolstu == 0 && b == 0 ) { break ; } System . out . println ( Math . min ( lolstu , b ) + " " + Math . max ( lolstu , b ) ) ; } } } import java . util . Scanner ; public class Kcevk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kcevk = sc . nextInt ( ) ; int [ ] a = new int [ kcevk ] ; for ( int i = 0 ; i < kcevk ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int t ; int j = 1 ; for ( int i = 0 ; i < kcevk ; i ++ ) { for ( int k = 0 ; k < kcevk ; k ++ ) { if ( a [ i ] > a [ k ] ) { t = a [ i ] ; a [ i ] = a [ k ] ; a [ k ] = t ; } } } int max = a [ 0 ] ; for ( int i = 0 ; i < kcevk ; i ++ ) { if ( max > a [ i ] ) { j ++ ; max = a [ i ] ; } } System . out . println ( j ) ; } } import java . util . Scanner ; public class Tuyeyq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tuyeyq = sc . nextInt ( ) ; int [ ] a = new int [ tuyeyq ] ; int [ ] b = new int [ tuyeyq - 1 ] ; for ( int i = 0 ; i < tuyeyq - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } a [ 0 ] = b [ 0 ] ; int score = a [ 0 ] ; for ( int i = 1 ; i < tuyeyq - 1 ; i ++ ) { a [ i ] = Math . min ( b [ i - 1 ] , b [ i ] ) ; score += a [ i ] ; } if ( tuyeyq != 1 ) { a [ tuyeyq - 1 ] = b [ tuyeyq - 2 ] ; score += a [ tuyeyq - 1 ] ; } System . out . println ( score ) ; } } import java . util . Scanner ; public class Ilmclsi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 26 ] ; while ( sc . hasNextLine ( ) ) { char [ ] c = sc . nextLine ( ) . toCharArray ( ) ; for ( int ilmclsi = 0 , l = c . length ; ilmclsi < l ; ++ ilmclsi ) { char _c = c [ ilmclsi ] ; if ( 97 <= _c && _c <= 122 ) ++ a [ _c - 'a' ] ; else if ( 65 <= _c && _c <= 90 ) ++ a [ _c - 'A' ] ; } } for ( int ilmclsi = 0 ; ilmclsi < 26 ; ++ ilmclsi ) System . out . printf ( " %c : %d \n " , 'a' + ilmclsi , a [ ilmclsi ] ) ; } } import java . util . Scanner ; public class Khdaut { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int khdaut = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; if ( khdaut * B > C ) { System . out . println ( C ) ; } else { System . out . println ( khdaut * B ) ; } } } import java . io . * ; import java . util . * ; public class Helphz { public static void main ( String [ ] args ) { new Main ( ) ; } Scanner in = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int helphz , b ; Main ( ) { helphz = in . nextInt ( ) ; b = in . nextInt ( ) ; if ( ( helphz % 2 ) != ( b % 2 ) ) out . println ( " IMPOSSIBLE " ) ; else out . println ( ( helphz + b ) / 2 ) ; out . close ( ) ; } } import java . util . * ; import java . lang . * ; public class Xlgyz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xlgyz = sc . nextInt ( ) ; if ( xlgyz < 105 ) { System . out . println ( 0 ) ; } else if ( xlgyz >= 105 && xlgyz < 135 ) { System . out . println ( 1 ) ; } else if ( xlgyz >= 135 && xlgyz < 165 ) { System . out . println ( 2 ) ; } else if ( xlgyz >= 165 && xlgyz < 189 ) { System . out . println ( 3 ) ; } else if ( xlgyz >= 189 && xlgyz < 195 ) { System . out . println ( 4 ) ; } else if ( xlgyz >= 195 ) { System . out . println ( 5 ) ; } } } import java . util . Scanner ; public class Ghtim { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ghtim = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int s = ghtim / a ; if ( ghtim % a != 0 ) { s ++ ; } System . out . println ( s ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Cqtbi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int cqtbi = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < cqtbi ; i ++ ) { final int number = sc . nextInt ( ) ; final int limit = ( int ) ( Math . sqrt ( number ) ) ; boolean not_prime = false ; for ( int j = 2 ; j <= limit ; j ++ ) { if ( number % j == 0 ) { not_prime = true ; break ; } } count += not_prime ? 0 : 1 ; } System . out . println ( count ) ; } } import java . util . Scanner ; import java . util . Arrays ; class Hlkxumt { public static void main ( String [ ] args ) { int [ ] m = new int [ 10 ] ; input ( m , 10 ) ; Arrays . sort ( m ) ; reverse ( m ) ; output ( m , 3 ) ; } private static final void reverse ( int [ ] m ) { int hlkxumt = m . length ; for ( int i = 0 ; i < hlkxumt / 2 ; i ++ ) { int tmp = m [ i ] ; m [ i ] = m [ hlkxumt - i - 1 ] ; m [ hlkxumt - i - 1 ] = tmp ; } } private static final void output ( int [ ] m , int hlkxumt ) { for ( int i = 0 ; i < hlkxumt ; i ++ ) { System . out . println ( m [ i ] ) ; } } private static final void input ( int [ ] m , int hlkxumt ) { Scanner cin = new Scanner ( System . in ) ; for ( int i = 0 ; i < hlkxumt ; i ++ ) { m [ i ] = cin . nextInt ( ) ; } } } import java . util . * ; public class Nwlvxjd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int nwlvxjd = Integer . parseInt ( scan . next ( ) ) ; int varN = Integer . parseInt ( scan . next ( ) ) ; ArrayList < Integer > attack = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < varN ; i ++ ) { attack . add ( Integer . parseInt ( scan . next ( ) ) ) ; } boolean flag = false ; for ( int i = 0 ; i < varN ; i ++ ) { nwlvxjd -= attack . remove ( 0 ) ; if ( nwlvxjd <= 0 ) { flag = true ; break ; } } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Bjtgp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long bjtgp = scan . nextLong ( ) ; long ans = 0 ; for ( int i = 1 ; i < bjtgp + 1 ; i ++ ) { if ( ( i % 3 ) == 0 || ( i % 5 ) == 0 ) { ans += 0 ; } else { ans += i ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Qfhefew { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qfhefew = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] p = new int [ N ] ; int [ ] q = new int [ 102 ] ; for ( int i = 0 ; i < N ; i ++ ) { p [ i ] = sc . nextInt ( ) ; q [ p [ i ] ] = 1 ; } int minDif = 1000 ; int ans = qfhefew ; for ( int i = 0 ; i <= 101 ; i ++ ) { if ( q [ i ] == 0 ) { if ( Math . abs ( qfhefew - i ) < minDif ) { ans = i ; minDif = Math . abs ( qfhefew - i ) ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Ptjuegn { Scanner sc ; int ptjuegn , D ; public Main ( ) { sc = new Scanner ( System . in ) ; } void out ( Object o ) { System . out . println ( o ) ; System . out . flush ( ) ; } public void exec ( ) throws Exception { ptjuegn = sc . nextInt ( ) ; D = sc . nextInt ( ) ; int n = ( ptjuegn + 2 * D ) / ( 2 * D + 1 ) ; out ( n ) ; } public static void main ( String [ ] args ) throws Exception { Main m = new Main ( ) ; m . exec ( ) ; } } import java . util . Scanner ; public class Oarqt { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int oarqt = scanner . nextInt ( ) ; int w = scanner . nextInt ( ) ; while ( oarqt + w > 0 ) { for ( int i = 0 ; i < oarqt ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( j == 0 || j == w - 1 || i == 0 || i == oarqt - 1 ) System . out . print ( " # " ) ; else System . out . print ( " . " ) ; } System . out . println ( ) ; } System . out . println ( ) ; oarqt = scanner . nextInt ( ) ; w = scanner . nextInt ( ) ; } } } import java . util . * ; public class Scssq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int scssq = sc . nextInt ( ) ; int [ ] l = new int [ scssq ] ; int max = 0 ; int pnt = - 1 ; for ( int i = 0 ; i < scssq ; i ++ ) { l [ i ] = sc . nextInt ( ) ; if ( max < l [ i ] ) { max = l [ i ] ; pnt = i ; } } int total = 0 ; for ( int i = 0 ; i < scssq ; i ++ ) { if ( i == pnt ) continue ; total += l [ i ] ; } if ( max < total ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class Oufqyr { public static void main ( String [ ] arge ) { Scanner sc = new Scanner ( System . in ) ; int oufqyr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int men = oufqyr * b ; int syu = ( oufqyr + b ) * 2 ; System . out . print ( men ) ; System . out . println ( " " + syu ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Ezrws { public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( System . in ) ; long ezrws = sc . nextLong ( ) ; long D = sc . nextLong ( ) ; long ans = 0 ; for ( long i = 0 ; i < ezrws ; i ++ ) { long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; if ( Math . sqrt ( ( x * x ) + ( y * y ) ) <= D ) { ans ++ ; } } System . out . println ( ans ) ; } private static class Ezrws { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public FastScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; tokenizer = null ; } public String next ( ) { if ( 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 ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . util . Scanner ; public class Dgynp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dgynp = sc . nextInt ( ) ; int numX = sc . nextInt ( ) ; int initNum = numX - dgynp + 1 ; String retStr = " " + initNum ; for ( int i = initNum + 1 ; i < numX + dgynp ; i ++ ) { retStr = retStr + " " + i ; } System . out . println ( retStr ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Cbcrns { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cbcrns = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; int res = 0 ; for ( int i = 0 ; i < cbcrns ; i ++ ) { String s = sc . next ( ) ; if ( ! set . contains ( s ) ) { set . add ( s ) ; res ++ ; } } System . out . println ( res ) ; } } import java . util . ArrayDeque ; import java . util . Scanner ; public class Tvvppu { static final Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] __ ) { D [ ] deques = new D [ 3 ] ; for ( int tvvppu = 0 ; tvvppu < 3 ; tvvppu ++ ) { deques [ tvvppu ] = new D ( ) ; for ( char c : s . next ( ) . toCharArray ( ) ) deques [ tvvppu ] . add ( c ) ; } char next = 'a' ; while ( ! deques [ next - 'a' ] . isEmpty ( ) ) { next = deques [ next - 'a' ] . poll ( ) ; } System . out . println ( Character . toUpperCase ( next ) ) ; } static class Tvvppu extends ArrayDeque < Character > { } } import java . util . Scanner ; public class Whegxob { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String whegxob = s . nextLine ( ) ; if ( whegxob . charAt ( 0 ) == whegxob . charAt ( 1 ) && whegxob . charAt ( 0 ) == whegxob . charAt ( 2 ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } s . close ( ) ; } } import java . util . Scanner ; public class Xtoedrw { private int xtoedrw ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int xtoedrw = 0 ; if ( N % 2 == 1 ) { xtoedrw = ( N / 2 ) + 1 ; } else { xtoedrw = ( N / 2 ) ; } System . out . print ( xtoedrw ) ; } } import java . util . * ; public class Lfuya { public static void main ( String [ ] args ) { int lfuya ; Scanner sc = new Scanner ( System . in ) ; for ( ; ; ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( x == 0 && y == 0 ) break ; if ( x > y ) { lfuya = x ; x = y ; y = lfuya ; } System . out . println ( x + " " + y ) ; } } } import java . math . BigDecimal ; import java . util . Scanner ; class Txesclk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int txesclk = sc . nextInt ( ) ; long ans = 1 ; long [ ] A = new long [ txesclk ] ; for ( int i = 0 ; i < txesclk ; i ++ ) { A [ i ] = sc . nextLong ( ) ; if ( A [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } for ( int i = 0 ; i < txesclk ; i ++ ) { long a = A [ i ] ; if ( Math . log10 ( ans ) + Math . log10 ( a ) > 18 ) { System . out . println ( - 1 ) ; return ; } ans *= a ; } if ( ans <= 1000000000000000000l ) { System . out . println ( ans ) ; } else { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; public class Yvfjo { private static final int yvfjo = 1_000_000_007 ; private static int [ ] [ ] X ; private static int D ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; D = sc . nextInt ( ) ; X = new int [ N ] [ D ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < D ; j ++ ) { X [ i ] [ j ] = sc . nextInt ( ) ; } } int cnt = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( i == j ) break ; if ( distance ( i , j ) ) cnt ++ ; } } System . out . println ( cnt ) ; } private static boolean distance ( int i , int j ) { double sum = 0 ; for ( int k = 0 ; k < D ; k ++ ) { long x = X [ i ] [ k ] - X [ j ] [ k ] ; sum += x * x ; } double s = Math . sqrt ( sum ) ; return s == Math . floor ( s ) ; } } import java . util . Scanner ; public class Zemofai { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long zemofai = sc . nextLong ( ) ; sc . close ( ) ; long ret = zemofai ; while ( true ) { if ( isPrime ( ret ) ) { break ; } ret ++ ; } System . out . println ( ret ) ; } public static boolean isPrime ( long zemofai ) { if ( zemofai == 1 || zemofai == 2 ) { return true ; } if ( zemofai % 2 == 0 ) { return false ; } boolean ret = false ; for ( long i = 2 ; i <= Math . sqrt ( zemofai ) ; i ++ ) { if ( zemofai % i == 0 ) { ret = false ; break ; } ret = true ; } return ret ; } } import java . io . FileNotFoundException ; import java . util . Arrays ; import java . util . Scanner ; public class Szamec { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int szamec = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] p = new int [ szamec + 1 ] ; Arrays . fill ( p , K ) ; int border = 0 ; for ( int i = 0 ; i < Q ; i ++ ) { int x = sc . nextInt ( ) ; p [ x ] ++ ; border ++ ; } for ( int i = 1 ; i <= szamec ; i ++ ) { if ( p [ i ] > border ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class Yjfakp { static Scanner scan ; static int yjfakp = 0 ; public static void main ( String [ ] args ) { scan = new Scanner ( System . in ) ; final int slen = scan . nextInt ( ) ; int [ ] s = new int [ slen ] ; for ( int i = 0 ; i < slen ; i ++ ) { s [ i ] = scan . nextInt ( ) ; } final int tlen = scan . nextInt ( ) ; int [ ] t = new int [ tlen ] ; for ( int i = 0 ; i < tlen ; i ++ ) { t [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < tlen ; i ++ ) { binarySearch ( s , t [ i ] ) ; } System . out . println ( yjfakp ) ; } public static void binarySearch ( int [ ] s , int t ) { int hi = 0 ; int ti = s . length - 1 ; int p ; while ( hi <= ti ) { p = ( hi + ti ) / 2 ; if ( s [ p ] == t ) { yjfakp ++ ; break ; } else if ( s [ p ] < t ) { hi = p + 1 ; continue ; } else { ti = p - 1 ; continue ; } } return ; } } import java . util . Arrays ; import java . util . Scanner ; public class Caghvzy { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; int caghvzy = std . nextInt ( ) ; int k = std . nextInt ( ) ; int q = std . nextInt ( ) ; int [ ] as = new int [ q ] ; for ( int i = 0 ; i < q ; i ++ ) { as [ i ] = std . nextInt ( ) - 1 ; } int [ ] cp = new int [ caghvzy ] ; for ( int i = 0 ; i < q ; i ++ ) { int c = as [ i ] ; cp [ c ] ++ ; } int [ ] dp = new int [ caghvzy ] ; Arrays . fill ( dp , k ) ; long [ ] sum = new long [ caghvzy ] ; long all = Arrays . stream ( cp ) . sum ( ) ; for ( int i = 0 ; i < caghvzy ; i ++ ) { sum [ i ] = all - cp [ i ] ; } for ( int i = 0 ; i < caghvzy ; i ++ ) { if ( k > sum [ i ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class Eqhst { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eqhst = sc . nextInt ( ) ; String S = sc . next ( ) ; int count = 1 ; char [ ] slime = S . toCharArray ( ) ; for ( int i = 1 ; i < eqhst ; i ++ ) { if ( slime [ i ] != slime [ i - 1 ] ) { count += 1 ; } } System . out . println ( count ) ; } } import java . util . * ; import java . text . DecimalFormat ; public class Dmvcnr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String dmvcnr = sc . nextLine ( ) ; if ( dmvcnr . equals ( " SUN " ) ) System . out . println ( 7 ) ; else if ( dmvcnr . equals ( " MON " ) ) System . out . println ( 6 ) ; else if ( dmvcnr . equals ( " TUE " ) ) System . out . println ( 5 ) ; else if ( dmvcnr . equals ( " WED " ) ) System . out . println ( 4 ) ; else if ( dmvcnr . equals ( " THU " ) ) System . out . println ( 3 ) ; else if ( dmvcnr . equals ( " FRI " ) ) System . out . println ( 2 ) ; else System . out . println ( 1 ) ; } } import java . util . Scanner ; public class Criqy { public static void main ( String [ ] args ) { long criqy = 0 ; long ans2 = 0 ; Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long m = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; boolean f = false ; long temp = k - n ; if ( k >= n + m ) { criqy = 0 ; ans2 = 0 ; } else { if ( k <= n ) { criqy = n - k ; ans2 = m ; } else { criqy = 0 ; ans2 = m - ( k - n ) ; } } System . out . println ( criqy ) ; System . out . println ( ans2 ) ; sc . close ( ) ; } } import java . util . * ; public class Xpptfv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xpptfv = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; String dummy = sc . nextLine ( ) ; int [ ] [ ] x = new int [ xpptfv ] [ d ] ; for ( int i = 0 ; i < xpptfv ; i ++ ) { String [ ] s = sc . nextLine ( ) . split ( " " ) ; for ( int j = 0 ; j < d ; j ++ ) { x [ i ] [ j ] = Integer . parseInt ( s [ j ] ) ; } } int ans = 0 ; for ( int i = 0 ; i < xpptfv - 1 ; i ++ ) { for ( int j = i + 1 ; j < xpptfv ; j ++ ) { int sum = 0 ; for ( int k = 0 ; k < d ; k ++ ) { sum += ( x [ i ] [ k ] - x [ j ] [ k ] ) * ( x [ i ] [ k ] - x [ j ] [ k ] ) ; } if ( Math . sqrt ( sum ) == ( int ) Math . sqrt ( sum ) ) ans ++ ; } } System . out . println ( ans ) ; } } import java . io . IOException ; import java . util . ArrayList ; import java . util . Scanner ; public class Qpibh { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int qpibh = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( S . length ( ) <= qpibh ) { System . out . println ( S ) ; } else { System . out . println ( S . substring ( 0 , qpibh ) + " ... " ) ; } } static private int binarySearch ( long num , long [ ] orderedArray ) { int lowerBorder = - 1 ; int upperBorder = orderedArray . length ; int mid ; while ( upperBorder - lowerBorder > 1 ) { mid = ( upperBorder + lowerBorder ) / 2 ; if ( orderedArray [ mid ] <= num ) { lowerBorder = mid ; } else { upperBorder = mid ; } } return lowerBorder ; } static private int binarySearch ( long num , ArrayList < Long > orderedList ) { int lowerBorder = - 1 ; int upperBorder = orderedList . size ( ) ; int mid ; while ( upperBorder - lowerBorder > 1 ) { mid = ( upperBorder + lowerBorder ) / 2 ; if ( orderedList . get ( mid ) <= num ) { lowerBorder = mid ; } else { upperBorder = mid ; } } return lowerBorder ; } public static int gcd ( int a , int b ) { return b == 0 ? a : gcd ( b , a % b ) ; } public static long gcd ( long a , long b ) { return b == 0 ? a : gcd ( b , a % b ) ; } } import java . util . Scanner ; import java . util . regex . Pattern ; public class Etsyzlp { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) throws Exception { new Main ( ) . run ( ) ; } void run ( ) { int etsyzlp = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; Pattern ptn = Pattern . compile ( " \\ d { " + etsyzlp + " } - \\ d { " + b + " } " ) ; String s = sc . next ( ) ; System . out . println ( ptn . matcher ( s ) . matches ( ) ? " Yes " : " No " ) ; } } import java . io . * ; import java . util . * ; public class Wmjff { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int wmjff = in . nextInt ( ) ; boolean [ ] rate = new boolean [ 8 ] ; int free = 0 ; int a ; for ( int i = 0 ; i < wmjff ; i ++ ) { a = in . nextInt ( ) ; if ( a <= 399 ) { rate [ 0 ] = true ; } else if ( a <= 799 ) { rate [ 1 ] = true ; } else if ( a <= 1199 ) { rate [ 2 ] = true ; } else if ( a <= 1599 ) { rate [ 3 ] = true ; } else if ( a <= 1999 ) { rate [ 4 ] = true ; } else if ( a <= 2399 ) { rate [ 5 ] = true ; } else if ( a <= 2799 ) { rate [ 6 ] = true ; } else if ( a <= 3199 ) { rate [ 7 ] = true ; } else { free ++ ; } } int ans = 0 ; for ( int i = 0 ; i < rate . length ; i ++ ) { if ( rate [ i ] == true ) { ans ++ ; } } int max = ans + free ; if ( ans == 0 ) { ans = 1 ; } System . out . println ( ans + " " + max ) ; } } import java . util . Scanner ; public class Ealjnci { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ealjnci = sc . nextInt ( ) ; int [ ] button = new int [ ealjnci + 1 ] ; for ( int i = 1 ; i <= ealjnci ; i ++ ) { button [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int count = 0 ; int nextButton = 1 ; boolean success = false ; for ( int j = 0 ; j < ealjnci ; j ++ ) { count ++ ; nextButton = button [ nextButton ] ; if ( nextButton == 2 ) { success = true ; break ; } } if ( ! success ) { count = - 1 ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Fjlfrb { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int fjlfrb = 124 ; int max = - 1 ; for ( int i = 0 ; i < 5 ; i ++ ) { int n = in . nextInt ( ) ; if ( n < fjlfrb ) fjlfrb = n ; if ( n > max ) max = n ; } int k = in . nextInt ( ) ; System . out . println ( ( max - fjlfrb <= k ) ? " Yay! " : " :( " ) ; in . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Ofqesjy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ofqesjy = sc . nextInt ( ) ; int [ ] array = new int [ ofqesjy ] ; boolean b = true ; int i ; for ( i = 0 ; i < ofqesjy ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } Arrays . sort ( array ) ; for ( i = 0 ; i < ofqesjy ; i ++ ) { if ( i != 0 ) { if ( array [ i - 1 ] == array [ i ] ) { b = false ; break ; } } } System . out . println ( b ? " YES " : " NO " ) ; } } import java . util . Scanner ; import java . util . TreeSet ; public class Tnqhyt { public static void main ( String [ ] args ) { TreeSet < Integer > numerosUtiles = new TreeSet < > ( ) ; Scanner in = new Scanner ( System . in ) ; int tnqhyt = in . nextInt ( ) ; int [ ] numbers = new int [ tnqhyt ] ; for ( int i = 0 ; i < tnqhyt ; i ++ ) { numbers [ i ] = in . nextInt ( ) ; } for ( int i = 1 ; i < ( tnqhyt - 1 ) ; i ++ ) { int a = numbers [ i - 1 ] ; int b = numbers [ i ] ; int c = numbers [ i + 1 ] ; if ( ( b > a && b < c ) || ( b < a && b > c ) ) { numerosUtiles . add ( b ) ; } } System . out . println ( numerosUtiles . size ( ) ) ; } } import java . util . * ; public class Jfjomss { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jfjomss = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] variation = new int [ jfjomss ] ; int count = 0 ; int i , j , k = 0 ; int [ ] max = new int [ jfjomss ] ; for ( i = 0 ; i < jfjomss ; i ++ ) { variation [ i ] = sc . nextInt ( ) ; } for ( j = 0 ; j < jfjomss ; j ++ ) { X = X - variation [ j ] ; count ++ ; } for ( k = 0 ; k < jfjomss ; k ++ ) { max [ k ] = X / variation [ k ] ; } for ( j = 0 ; j < jfjomss ; j ++ ) { for ( k = j + 1 ; k < jfjomss ; k ++ ) { if ( max [ k ] > max [ j ] ) { int t = max [ k ] ; max [ k ] = max [ j ] ; max [ j ] = t ; } } } count = count + max [ 0 ] ; System . out . println ( count ) ; } } import java . util . * ; public class Fxxln { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fxxln = sc . nextInt ( ) ; int happy500 = 0 ; int happy5 = 0 ; happy500 = fxxln / 500 * 1000 ; happy5 = ( fxxln % 500 ) / 5 * 5 ; System . out . println ( happy500 + happy5 ) ; } } import java . util . Scanner ; class Ohztgcz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ohztgcz = sc . nextInt ( ) ; int [ ] a = new int [ ohztgcz ] ; int [ ] b = new int [ ohztgcz - 1 ] ; for ( int i = 0 ; i < ohztgcz ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int j = 0 ; j < ohztgcz - 1 ; j ++ ) { if ( a [ j + 1 ] <= a [ j ] ) { b [ j ] = 1 ; } else { b [ j ] = 0 ; } } int b_max = 0 ; int count = 0 ; for ( int c = 0 ; c < ohztgcz - 1 ; c ++ ) { if ( b [ c ] == 1 ) { count ++ ; } else { if ( count > b_max ) { b_max = count ; } count = 0 ; } } if ( count > b_max ) { b_max = count ; } System . out . println ( b_max ) ; } } import java . util . * ; public class Tcnackr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long tcnackr = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; long A = tcnackr % K ; long ans = 0 ; if ( tcnackr % K == 0 ) { ans = 0 ; } else { ans = Math . min ( A , K - A ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Gboqiyl { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int gboqiyl = scanner . nextInt ( ) ; if ( gboqiyl == 0 ) { System . out . println ( " 1 " ) ; } else if ( gboqiyl == 1 ) { System . out . println ( " 0 " ) ; } } } import java . util . Scanner ; public class Elkrd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String elkrd = sc . next ( ) ; String s1 = elkrd . substring ( 2 , 3 ) ; String s2 = elkrd . substring ( 3 , 4 ) ; String s3 = elkrd . substring ( 4 , 5 ) ; String s4 = elkrd . substring ( 5 , 6 ) ; if ( s1 . equals ( s2 ) && s3 . equals ( s4 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . IOException ; import java . util . Scanner ; public class Twdzgua { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int twdzgua = sc . nextInt ( ) ; int min = 1_000_000_000 ; int max = 1 ; for ( int i = 0 ; i < twdzgua ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp < min ) min = tmp ; if ( tmp > max ) max = tmp ; } System . out . println ( max - min ) ; sc . close ( ) ; } } import java . util . * ; public class Xyylfe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xyylfe = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( ( b - 1 + xyylfe - 2 ) / ( xyylfe - 1 ) ) ; } } import java . util . Scanner ; public class Ufyvg { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; String ufyvg = std . next ( ) ; String first = ufyvg . substring ( 0 , 2 ) ; String last = ufyvg . substring ( 2 ) ; Integer firstValue = Integer . parseInt ( first ) ; Integer lastValue = Integer . parseInt ( last ) ; String format ; if ( availableMonth ( firstValue ) && availableMonth ( lastValue ) ) { format = " AMBIGUOUS " ; } else if ( availableMonth ( firstValue ) ) { format = " MMYY " ; } else if ( availableMonth ( lastValue ) ) { format = " YYMM " ; } else { format = " NA " ; } System . out . println ( format ) ; } static boolean availableMonth ( int val ) { return val >= 1 && val <= 12 ; } } import java . util . Scanner ; public class Pqxkcpm { public static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int pqxkcpm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int max = pqxkcpm ; int max_index = 0 ; if ( max < b ) { max = b ; max_index = 1 ; } if ( max < c ) { max = c ; max_index = 2 ; } switch ( max_index ) { case 0 : pqxkcpm *= 2 ; break ; case 1 : b *= 2 ; break ; case 2 : c *= 2 ; break ; } } System . out . println ( pqxkcpm + b + c ) ; } } import java . util . * ; class Ogewkhi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ogewkhi = sc . next ( ) ; switch ( ogewkhi ) { case " ABC " : System . out . println ( " ARC " ) ; break ; case " ARC " : System . out . println ( " ABC " ) ; break ; } sc . close ( ) ; } } import java . util . Scanner ; public class Aldjs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aldjs , n , j , S = 0 ; double avr , O = 0 , s ; for ( aldjs = 0 ; ; aldjs ++ ) { n = sc . nextInt ( ) ; int [ ] array = new int [ n ] ; if ( n == 0 ) { break ; } else { for ( j = 1 ; j <= n ; j ++ ) { array [ j - 1 ] = sc . nextInt ( ) ; S += array [ j - 1 ] ; } avr = S / ( double ) n ; for ( j = 1 ; j <= n ; j ++ ) { O += ( avr - array [ j - 1 ] ) * ( avr - array [ j - 1 ] ) ; } s = Math . sqrt ( O / n ) ; System . out . println ( s ) ; } S = 0 ; O = 0 ; } } } import java . util . Scanner ; public class Ijmuy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String x = sc . next ( ) ; if ( x . equals ( " 0 " ) ) break ; int ijmuy = 0 , i ; for ( i = 0 ; i < x . length ( ) ; i ++ ) { ijmuy = ijmuy + x . charAt ( i ) - 48 ; } System . out . printf ( " %d \n " , ijmuy ) ; } } } import java . util . Scanner ; public class Tyiuvw { public static void main ( String [ ] args ) { int tyiuvw , b ; Scanner scanner = new Scanner ( System . in ) ; while ( scanner . hasNext ( ) ) { tyiuvw = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; System . out . println ( ( String . valueOf ( tyiuvw + b ) . length ( ) ) ) ; } scanner . close ( ) ; } } import java . util . Scanner ; public class Gaavs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gaavs = sc . nextInt ( ) ; int [ ] value = new int [ gaavs ] ; int [ ] cost = new int [ gaavs ] ; int [ ] trueValue = new int [ gaavs ] ; int max = 0 ; for ( int i = 0 ; i < gaavs ; i ++ ) { value [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < gaavs ; i ++ ) { cost [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < gaavs ; i ++ ) { trueValue [ i ] = value [ i ] - cost [ i ] ; if ( trueValue [ i ] > 0 ) { max += trueValue [ i ] ; } } System . out . println ( max ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Zmqvuh { public static void main ( String [ ] args ) { int zmqvuh = 0 ; int i = 0 ; String outputNum = " " ; String [ ] NumList ; try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; zmqvuh = Integer . parseInt ( line ) ; line = br . readLine ( ) ; if ( line != null ) { NumList = line . split ( " " , 0 ) ; int Count = zmqvuh - 1 ; for ( i = 0 ; i < NumList . length ; i ++ ) { if ( Count != zmqvuh - 1 ) { outputNum += " " ; } outputNum += NumList [ Count ] ; Count -- ; } System . out . println ( outputNum ) ; } } catch ( NumberFormatException e ) { System . out . println ( e ) ; } catch ( IOException e ) { System . out . println ( e ) ; } } } import java . util . Scanner ; class Cjqnm { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int [ ] arr = new int [ 101010 ] ; int cjqnm ; int n ; int cnt = 0 ; n = reader . nextInt ( ) ; cjqnm = reader . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= cjqnm ) { cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; class Jtrycm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jtrycm = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; if ( jtrycm == b || b == c || jtrycm == c ) { System . out . println ( " No " ) ; } else if ( jtrycm > b || jtrycm > c ) { System . out . println ( " No " ) ; } else if ( b > c ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; import java . math . * ; public class Ggipwct { public static void main ( String [ ] args ) { Scanner as = new Scanner ( System . in ) ; double ggipwct , t , s ; ggipwct = as . nextDouble ( ) ; s = 3.141592653589 * ggipwct * ggipwct ; t = 2.0 * 3.141592653589 * ggipwct ; BigDecimal ros = new BigDecimal ( s ) ; BigDecimal rot = new BigDecimal ( t ) ; ros = ros . setScale ( 6 , BigDecimal . ROUND_HALF_UP ) ; rot = rot . setScale ( 6 , BigDecimal . ROUND_HALF_UP ) ; System . out . println ( ros + " " + rot ) ; } } import java . util . Scanner ; public class Kgyjjy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kgyjjy = Integer . parseInt ( sc . next ( ) ) ; int taro = 0 ; int hanako = 0 ; for ( int i = 0 ; i < kgyjjy ; i ++ ) { String TS = sc . next ( ) ; String HS = sc . next ( ) ; if ( TS . compareTo ( HS ) > 0 ) { taro += 3 ; } else if ( TS . compareTo ( HS ) < 0 ) { hanako += 3 ; } else if ( TS . compareTo ( HS ) == 0 ) { taro ++ ; hanako ++ ; } } System . out . printf ( " %d %d \n " , taro , hanako ) ; } } import java . util . Scanner ; public class Btdhgrb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int btdhgrb = sc . nextInt ( ) ; int result = 0 ; int ahead ; int current = 100000 ; for ( int i = 0 ; i < btdhgrb - 1 ; i ++ ) { ahead = current ; current = sc . nextInt ( ) ; result += Math . min ( ahead , current ) ; } result += current ; System . out . println ( result ) ; } } import java . util . Scanner ; public class Fzgipoz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fzgipoz = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i <= fzgipoz ; i ++ ) { int ans1 = + 500 * i ; for ( int j = 0 ; j <= B ; j ++ ) { int ans2 = + 100 * j ; for ( int k = 0 ; k <= C ; k ++ ) { int ans3 = + 50 * k ; if ( ans1 + ans2 + ans3 == X ) { ans ++ ; } } } } System . out . print ( ans ) ; } } import java . util . * ; public class Zwskf { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; int zwskf = scanner . nextInt ( ) ; int i = 0 ; int X ; int hantei = 0 ; int ans = 0 ; while ( hantei == 0 ) { X = zwskf + i ; for ( int j = 2 ; j <= X ; j ++ ) { if ( X % j == 0 ) { if ( j == X ) { hantei = 1 ; ans = X ; } else { break ; } } } i ++ ; } System . out . println ( ans ) ; } } import java . util . * ; public class Foryjfn { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int foryjfn = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; sc . close ( ) ; int sum = 0 ; for ( int i = 1 ; i < foryjfn ; i ++ ) { sum += i ; } for ( int i = 1 ; i < M ; i ++ ) { sum += i ; } System . out . println ( sum ) ; } } import java . util . * ; public class Niaow { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int niaow = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int gugu = niaow * ( niaow - 1 ) / 2 ; int kiki = M * ( M - 1 ) / 2 ; System . out . println ( gugu + kiki ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; public class Fbzcd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fbzcd = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ q ] ; for ( int i = 0 ; i < q ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int [ ] point = new int [ fbzcd ] ; for ( int i = 0 ; i < q ; i ++ ) { int ans = a [ i ] - 1 ; point [ ans ] ++ ; } for ( int i = 0 ; i < fbzcd ; i ++ ) { if ( k - q + point [ i ] > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; public class Hrsqgh { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int hrsqgh = scanner . nextInt ( ) ; int max = 1 ; for ( int i = 2 ; i <= hrsqgh ; i ++ ) { int j = i ; while ( true ) { j *= i ; if ( j > hrsqgh ) { break ; } max = Math . max ( max , j ) ; } } System . out . println ( max ) ; } } import java . util . * ; class Hrfodi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hrfodi = sc . nextInt ( ) ; int res = 0 ; for ( int a = 1 ; a <= hrfodi ; ++ a ) { for ( int b = 1 ; b <= hrfodi ; ++ b ) { for ( int c = 1 ; c <= hrfodi ; ++ c ) { res += greatestCommonFactor ( a , b , c ) ; } } } System . out . println ( res ) ; } private static int greatestCommonFactor ( int a , int b , int c ) { int limit = Math . min ( a , b ) ; limit = Math . min ( limit , c ) ; for ( int n = limit ; n >= 2 ; n -- ) { if ( ( a % n == 0 ) && ( b % n == 0 ) && ( c % n == 0 ) ) { return n ; } } return 1 ; } } import java . util . Scanner ; public class Qytjwwn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Integer a = scanner . nextInt ( ) ; Integer b = scanner . nextInt ( ) ; Integer h = scanner . nextInt ( ) ; Integer m = scanner . nextInt ( ) ; double qytjwwn ; double rad = Math . PI * 2 * ( ( double ) h / 12 + ( ( double ) m / 60 ) / 12 - ( double ) m / 60 ) ; qytjwwn = Math . sqrt ( Math . pow ( a , 2 ) + Math . pow ( b , 2 ) - 2 * a * b * Math . cos ( rad ) ) ; System . out . printf ( " %.20f " , qytjwwn ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Pimnsj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pimnsj = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; Integer [ ] a = new Integer [ pimnsj ] ; for ( int i = 0 ; i < pimnsj ; i ++ ) { a [ i ] = sc . nextInt ( ) ; map . put ( a [ i ] , i + 1 ) ; } Arrays . sort ( a ) ; StringBuilder ans = new StringBuilder ( ) ; for ( Integer i : a ) { ans . append ( map . get ( i ) ) ; ans . append ( " " ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class Edrtvys { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] nyu = sc . nextLine ( ) . split ( " " ) ; int edrtvys = Integer . parseInt ( nyu [ 0 ] ) ; int numnext = Integer . parseInt ( nyu [ 1 ] ) ; int numend = Integer . parseInt ( nyu [ 2 ] ) ; int count = 0 ; if ( numend - ( edrtvys - numnext ) < 0 ) { count = 0 ; } else { count = numend - ( edrtvys - numnext ) ; } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; import java . nio . charset . StandardCharsets ; public class Bhtzj { public static void main ( String [ ] args ) throws IOException { InputStreamReader reader = new InputStreamReader ( System . in , StandardCharsets . UTF_8 ) ; BufferedReader in = new BufferedReader ( reader ) ; String [ ] tokens = in . readLine ( ) . split ( " " ) ; int bhtzj = Integer . parseInt ( tokens [ 0 ] ) ; int B = Integer . parseInt ( tokens [ 1 ] ) ; String S = in . readLine ( ) ; Set < Character > numbers = new HashSet < > ( ) ; for ( int i = 0 ; i < 10 ; ++ i ) { numbers . add ( Integer . toString ( i ) . charAt ( 0 ) ) ; } boolean valid = isValid ( S , numbers , bhtzj ) ; String str = valid ? " Yes " : " No " ; System . out . println ( str ) ; } static boolean isValid ( String S , Set < Character > numbers , int bhtzj ) { for ( int i = 0 ; i < S . length ( ) ; ++ i ) { if ( i == bhtzj ) { if ( S . charAt ( i ) != '-' ) { return false ; } } else { if ( ! numbers . contains ( S . charAt ( i ) ) ) { return false ; } } } return true ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Ahegdng { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String ahegdng = br . readLine ( ) ; Integer num = Integer . parseInt ( ahegdng ) ; System . out . println ( num * num * num ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Nybkh { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int nybkh = Integer . parseInt ( br . readLine ( ) ) ; String [ ] sNumbers = br . readLine ( ) . split ( " " ) ; int [ ] numbers = new int [ nybkh ] ; for ( int i = 0 ; i < nybkh ; i ++ ) { numbers [ i ] = Integer . parseInt ( sNumbers [ i ] ) ; } insertionSort ( numbers ) ; } private static void insertionSort ( int [ ] numbers ) { displayNumbers ( numbers ) ; for ( int i = 1 ; i < numbers . length ; i ++ ) { int currentNumber = numbers [ i ] ; int insertIndex = i ; for ( int y = i - 1 ; y >= 0 ; y -- ) { if ( currentNumber < numbers [ y ] ) { numbers [ y + 1 ] = numbers [ y ] ; insertIndex = y ; } else { break ; } } numbers [ insertIndex ] = currentNumber ; displayNumbers ( numbers ) ; } } private static void displayNumbers ( int [ ] numbers ) { StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < numbers . length ; i ++ ) { sb . append ( numbers [ i ] ) ; sb . append ( " " ) ; } System . out . println ( sb . toString ( ) . trim ( ) ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Meoux { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int meoux = Integer . parseInt ( in . readLine ( ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int [ ] a = new int [ meoux ] ; int hantei = 1 ; int cntContinuous = 0 ; for ( int i = 0 ; i < meoux ; i ++ ) { a [ i ] = Integer . parseInt ( str [ i ] ) ; if ( hantei == a [ i ] ) { cntContinuous ++ ; hantei ++ ; } } System . out . println ( cntContinuous == 0 ? - 1 : meoux - cntContinuous ) ; } } import java . util . Scanner ; public class Jfvfoj { public static void main ( String [ ] args ) { final int jfvfoj = 0 ; final int X = 1 ; final int Y = 2 ; Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int [ ] [ ] travel = new int [ n ] [ 3 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { travel [ i ] [ j ] = Integer . parseInt ( sc . next ( ) ) ; } } boolean can = true ; int pt = 0 , px = 0 , py = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int d = length ( px , py , travel [ i ] [ X ] , travel [ i ] [ Y ] ) ; int t = travel [ i ] [ jfvfoj ] - pt ; if ( d > t ) { can = false ; break ; } else if ( ( t - d ) % 2 == 1 ) { can = false ; break ; } px = travel [ i ] [ X ] ; py = travel [ i ] [ Y ] ; pt = travel [ i ] [ jfvfoj ] ; } if ( can ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } static int length ( int px , int py , int cx , int cy ) { return ( Math . abs ( cx - px ) + Math . abs ( cy - py ) ) ; } } import java . math . BigInteger ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Rxfrrv { static BigInteger limit = new BigInteger ( " 1000000000000000000 " ) ; public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int rxfrrv = sc . nextInt ( ) ; List < BigInteger > values = new ArrayList < BigInteger > ( ) ; for ( int i = 0 ; i < rxfrrv ; i ++ ) { values . add ( sc . nextBigInteger ( ) ) ; } Collections . sort ( values ) ; BigInteger result = BigInteger . ONE ; for ( BigInteger value : values ) { result = result . multiply ( value ) ; if ( result . equals ( BigInteger . ZERO ) ) { System . out . println ( 0 ) ; return ; } else if ( limit . compareTo ( result ) < 0 ) { System . out . println ( - 1 ) ; return ; } } System . out . println ( result . toString ( ) ) ; } catch ( Exception e ) { System . out . println ( - 1 ) ; e . printStackTrace ( ) ; } } } import java . util . Scanner ; public class Jbtlus { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int jbtlus = scanner . nextInt ( ) , B = scanner . nextInt ( ) , C = scanner . nextInt ( ) ; System . out . println ( C / jbtlus * B ) ; } } import java . util . * ; public class Cuiigq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cuiigq = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int res = 9999 ; for ( int i = 0 ; i < cuiigq ; i ++ ) { int ci = sc . nextInt ( ) ; int ti = sc . nextInt ( ) ; if ( ti <= t && ci < res ) { res = ci ; } } if ( res != 9999 ) { System . out . println ( res ) ; } else { System . out . println ( " TLE " ) ; } } } import java . util . Scanner ; class Xfkzn { public static void main ( String [ ] args ) { StringBuilder sb = new StringBuilder ( ) ; Scanner as = new Scanner ( System . in ) ; int xfkzn = 0 ; int tre = 0 ; int count = 0 ; int [ ] A ; Boolean flag = true ; xfkzn = Integer . parseInt ( as . next ( ) ) ; A = new int [ xfkzn ] ; for ( int i = 0 ; i < xfkzn ; i ++ ) { A [ i ] = Integer . parseInt ( as . next ( ) ) ; } while ( flag ) { flag = false ; for ( int j = xfkzn - 1 ; j >= 1 ; j -- ) { if ( A [ j ] < A [ j - 1 ] ) { tre = A [ j ] ; A [ j ] = A [ j - 1 ] ; A [ j - 1 ] = tre ; flag = true ; count ++ ; } } } for ( int i = 0 ; i < xfkzn ; i ++ ) { if ( i != xfkzn - 1 ) { sb . append ( A [ i ] ) . append ( ' ' ) ; } else { sb . append ( A [ i ] ) ; } } System . out . println ( sb . toString ( ) ) ; sb . setLength ( 0 ) ; sb . append ( count ) ; System . out . println ( sb . toString ( ) ) ; } } import java . util . Scanner ; class Nmfbpv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nmfbpv = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int time = t ; int x1 = x ; while ( x < nmfbpv ) { t = t + time ; x = x + x1 ; } System . out . println ( t ) ; sc . close ( ) ; } } import java . util . * ; public class Hmgcsxm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hmgcsxm = sc . nextInt ( ) ; long min = sc . nextInt ( ) ; long ret = - 1000000001 ; for ( int i = 1 ; i < hmgcsxm ; i ++ ) { long r = sc . nextInt ( ) ; if ( r - min > ret ) ret = r - min ; if ( r < min ) min = r ; } System . out . println ( ret ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Qfmted { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; List < Integer > list_two = new ArrayList < Integer > ( ) ; int qfmted = sc . nextInt ( ) ; for ( int i = 0 ; qfmted > i ; i ++ ) { int a = sc . nextInt ( ) ; list . add ( a ) ; list_two . add ( a ) ; } Collections . sort ( list , Collections . reverseOrder ( ) ) ; int list_in_max = Collections . max ( list_two ) ; int maxIndex = list_two . indexOf ( Collections . max ( list_two ) ) ; if ( list . get ( 0 ) . equals ( list . get ( 1 ) ) ) { for ( int i = 0 ; qfmted > i ; i ++ ) { System . out . println ( list_in_max ) ; } System . exit ( 0 ) ; } else { for ( int i = 0 ; qfmted > i ; i ++ ) { if ( i == maxIndex ) { list_two . remove ( i ) ; System . out . println ( Collections . max ( list_two ) ) ; } else { System . out . println ( list_in_max ) ; } } } } } import java . util . * ; class Dgmgjeu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dgmgjeu = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] a = new int [ k ] ; long sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { a [ i ] = sc . nextInt ( ) ; sum = sum + a [ i ] ; } if ( sum >= dgmgjeu ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; public class Amaula { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String amaula = reader . readLine ( ) ; String p = reader . readLine ( ) ; String ss = amaula + amaula ; Pattern pat = Pattern . compile ( p ) ; check ( pat , ss ) ; } catch ( IOException e ) { System . out . print ( e ) ; } } private static void check ( Pattern pat , String ss ) { Matcher m = pat . matcher ( ss ) ; if ( m . find ( ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Scntbu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String answer = " Good " ; for ( int scntbu = 0 ; scntbu < 3 ; scntbu ++ ) { if ( s . charAt ( scntbu ) == s . charAt ( scntbu + 1 ) ) { answer = " Bad " ; break ; } } System . out . println ( answer ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Jvpmd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int jvpmd = scanner . nextInt ( ) ; System . out . println ( jvpmd / 2 + jvpmd % 2 ) ; } } import java . util . Scanner ; public class Clssnvz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; final int clssnvz = scan . nextInt ( ) ; final int M = scan . nextInt ( ) ; int [ ] [ ] codes = new int [ clssnvz ] [ M ] ; int [ ] rate = new int [ M ] ; int bonus = scan . nextInt ( ) ; for ( int i = 0 ; i < M ; i ++ ) { rate [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < clssnvz ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { codes [ i ] [ j ] = scan . nextInt ( ) ; } } int count = 0 ; for ( int i = 0 ; i < clssnvz ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < M ; j ++ ) { sum += codes [ i ] [ j ] * rate [ j ] ; } sum += bonus ; if ( sum > 0 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class Zbnhmyq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zbnhmyq = sc . nextInt ( ) ; String ans = " No " ; for ( int i = 1 ; i < 10 ; i ++ ) { for ( int j = 1 ; j < 10 ; j ++ ) { if ( i * j == zbnhmyq ) { ans = " Yes " ; break ; } } } System . out . println ( ans ) ; } } import identifier . identifier . * ; import identifier . identifier . * ; public class Oahbyqs { public static void_type identifier ( type_identifier [ ] identifier ) { type_identifier identifier = new type_identifier ( identifier . identifier ) ; identifier . identifier . identifier ( decimal_integer_literal - identifier . identifier ( ) . identifier ( " string_fragment " , " string_fragment " ) . identifier ( ) * decimal_integer_literal ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Mohpytr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mohpytr = sc . nextInt ( ) ; int [ ] a = new int [ mohpytr ] ; int sum = 0 ; for ( int i = 0 ; i < mohpytr ; i ++ ) { a [ i ] = sc . nextInt ( ) ; sum += a [ i ] ; } Arrays . parallelSort ( a ) ; sum -= a [ mohpytr - 1 ] ; if ( sum > a [ mohpytr - 1 ] ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Bvojgmv { private static final BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static void main ( String [ ] args ) { exec ( args ) ; } public static void exec ( String [ ] args ) { String str = readLineStandardInput ( ) ; int bvojgmv = Integer . parseInt ( str ) ; str = readLineStandardInput ( ) ; String [ ] Astr = str . split ( " " ) ; int min = Integer . MAX_VALUE ; int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < Astr . length ; i ++ ) { int tmp = Integer . parseInt ( Astr [ i ] ) ; min = min > tmp ? tmp : min ; max = max < tmp ? tmp : max ; } int res = max - min ; System . out . println ( res ) ; } private static String readLineStandardInput ( ) { String str ; try { str = input . readLine ( ) ; } catch ( IOException e ) { str = null ; System . out . println ( e ) ; } return str ; } } import java . util . Scanner ; class Bpuyjmg { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; String [ ] s = { " SUN " , " MON " , " TUE " , " WED " , " THU " , " FRI " , " SAT " } ; String input = scn . next ( ) ; int bpuyjmg = 0 ; for ( int i = 0 ; i <= 6 ; i ++ ) { if ( input . equals ( s [ i ] ) ) bpuyjmg = 7 - i ; } System . out . println ( bpuyjmg ) ; } } import java . util . * ; public class Dvtnbz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; char [ ] s1 = s . toCharArray ( ) ; char [ ] t1 = t . toCharArray ( ) ; int dvtnbz = 0 ; for ( int i = 0 ; i < s1 . length ; i ++ ) { if ( s1 [ i ] != t1 [ i ] ) { dvtnbz ++ ; } } System . out . println ( dvtnbz ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Osxtm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int osxtm = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) , x = sc . nextInt ( ) , y = sc . nextInt ( ) ; long min = Long . MAX_VALUE ; for ( int i = 0 ; i <= Math . max ( x , y ) ; i ++ ) { min = Math . min ( min , 2 * c * i + Math . max ( 0 , x - i ) * osxtm + Math . max ( 0 , y - i ) * b ) ; } System . out . println ( min ) ; } } import java . lang . Math ; import java . util . Scanner ; class Qcpwks { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long qcpwks = sc . nextLong ( ) ; double interest = 100 ; int year = 0 ; while ( interest < qcpwks ) { year += 1 ; interest *= 1.01 ; interest = Math . floor ( interest ) ; if ( interest >= qcpwks ) { break ; } } System . out . println ( year ) ; } } import java . util . Scanner ; public class Kwgkr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; char [ ] c = S . toCharArray ( ) ; int kwgkr = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( c [ i ] == '+' ) { kwgkr ++ ; } else { kwgkr -- ; } } System . out . println ( kwgkr ) ; } } import java . util . * ; public class Jywgbnf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jywgbnf = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int tasu = jywgbnf + B ; int hiku = jywgbnf - B ; int kakeru = jywgbnf * B ; System . out . println ( Math . max ( kakeru , Math . max ( tasu , hiku ) ) ) ; } } import java . util . Scanner ; public class Mrdynf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mrdynf = sc . nextInt ( ) ; int input_100 = sc . nextInt ( ) ; int input_50 = sc . nextInt ( ) ; int input_pay = sc . nextInt ( ) ; int result = 0 ; sc . close ( ) ; for ( int i = 0 ; i <= mrdynf ; i ++ ) { for ( int j = 0 ; j <= input_100 ; j ++ ) { for ( int k = 0 ; k <= input_50 ; k ++ ) { if ( i * 500 + j * 100 + k * 50 == input_pay ) { result ++ ; } } } } System . out . println ( result ) ; } } import static java . lang . System . out ; import java . util . Scanner ; public class Unawkp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int unawkp = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int divideAns = unawkp / b ; int modAns = unawkp % b ; double fewAns = ( double ) unawkp / b ; out . printf ( " %d %d %f%n " , divideAns , modAns , fewAns ) ; } } import java . util . * ; public class Cgzsr { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int cgzsr = s . nextInt ( ) ; String yvgubhij = s . nextLine ( ) ; HashSet < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < cgzsr ; i ++ ) { String b = s . nextLine ( ) ; set . add ( b ) ; } System . out . println ( set . size ( ) ) ; } } import java . util . Scanner ; public class Qoxfs { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int qoxfs = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int d = scanner . nextInt ( ) ; int ans = 0 ; if ( c < qoxfs && d < qoxfs ) { ans = 0 ; } if ( c <= qoxfs && d >= qoxfs && d <= b ) { ans = d - qoxfs ; } if ( c >= qoxfs && d <= b ) { ans = d - c ; } if ( c >= qoxfs && d >= b && c <= b ) { ans = b - c ; } if ( b < c ) { ans = 0 ; } if ( c <= qoxfs && b <= d ) { ans = b - qoxfs ; } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; import static java . lang . Math . * ; public class Xenspf { static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( System . in ) ; int xenspf = sc . nextInt ( ) , q = sc . nextInt ( ) ; String s = sc . next ( ) ; int [ ] AC = new int [ xenspf + 1 ] ; for ( int i = 1 ; i < xenspf ; i ++ ) { if ( s . charAt ( i - 1 ) == 'A' && s . charAt ( i ) == 'C' ) { AC [ i ] = 1 ; } } for ( int i = 1 ; i < xenspf + 1 ; i ++ ) { AC [ i ] += AC [ i - 1 ] ; } for ( int i = 0 ; i < q ; i ++ ) { int l = sc . nextInt ( ) , r = sc . nextInt ( ) ; int k = 0 ; if ( r < xenspf && s . charAt ( r - 1 ) == 'A' && s . charAt ( r ) == 'C' ) k ++ ; out . println ( max ( 0 , AC [ r ] - AC [ l - 1 ] - k ) ) ; } out . close ( ) ; } } import java . util . * ; public class Bzxggwt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bzxggwt = sc . nextInt ( ) ; int [ ] tako = new int [ bzxggwt ] ; for ( int i = 0 ; i < bzxggwt ; i ++ ) { tako [ i ] = sc . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < bzxggwt ; i ++ ) { for ( int k = i + 1 ; k < bzxggwt ; k ++ ) { sum += tako [ i ] * tako [ k ] ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; class Rvvjkc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int rvvjkc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String ans = sc . next ( ) ; int sum = 0 ; if ( ans . equals ( s ) ) { sum = rvvjkc - 1 ; System . out . println ( sum + " " + b ) ; } if ( ans . equals ( t ) ) { sum = b - 1 ; System . out . println ( rvvjkc + " " + sum ) ; } sc . close ( ) ; } } import java . util . * ; public class Aofcgrp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " " ; int aofcgrp = Integer . parseInt ( s . substring ( 0 , 2 ) ) ; int l = Integer . parseInt ( s . substring ( 2 , 4 ) ) ; if ( aofcgrp < 1 || 12 < aofcgrp ) { if ( l < 1 || 12 < l ) { ans = " NA " ; } else { ans = " YYMM " ; } } else { if ( l < 1 || 12 < l ) { ans = " MMYY " ; } else { ans = " AMBIGUOUS " ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . math . * ; public class Snwqm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int snwqm = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; List < Integer > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < snwqm ; i ++ ) { int d = sc . nextInt ( ) ; a . add ( d ) ; } Collections . sort ( a ) ; int price = 0 ; for ( int j = 0 ; j < K ; j ++ ) { price += a . get ( j ) ; } System . out . println ( price ) ; } } import java . io . * ; class Papall { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strAry ; long papall , max , min , sum ; papall = Integer . parseInt ( br . readLine ( ) ) ; int i ; strAry = br . readLine ( ) . split ( " " ) ; min = Integer . parseInt ( strAry [ 0 ] ) ; max = Integer . parseInt ( strAry [ 0 ] ) ; for ( i = 0 , sum = 0 ; i < papall ; i ++ ) { sum = sum + Integer . parseInt ( strAry [ i ] ) ; if ( min > Integer . parseInt ( strAry [ i ] ) ) { min = Integer . parseInt ( strAry [ i ] ) ; } if ( max < Integer . parseInt ( strAry [ i ] ) ) { max = Integer . parseInt ( strAry [ i ] ) ; } } System . out . println ( min + " " + max + " " + sum ) ; } } import java . util . * ; public class Ttlwjst { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ttlwjst = sc . nextInt ( ) ; int [ ] r = new int [ ttlwjst ] ; for ( int i = 1 ; i <= ttlwjst ; i ++ ) r [ sc . nextInt ( ) - 1 ] = i ; for ( int rr : r ) System . out . print ( rr + " " ) ; } } import java . util . Scanner ; public class Nfesc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; while ( true ) { String a = scanner . nextLine ( ) ; if ( a . equals ( " 0 " ) ) break ; int nfesc = 0 ; for ( char b : a . toCharArray ( ) ) { nfesc += Integer . parseInt ( String . valueOf ( b ) ) ; } System . out . println ( nfesc ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Wjgbp { public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( System . in ) ; int wjgbp = sc . nextInt ( ) ; int ans = 0 ; ans = wjgbp + ( int ) Math . pow ( wjgbp , 2 ) + ( int ) Math . pow ( wjgbp , 3 ) ; System . out . println ( ans ) ; } private static class Wjgbp { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public FastScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; tokenizer = null ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } } import java . util . Arrays ; import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Jxkpog { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; Map < String , Integer > tV = new TreeMap < > ( ) ; int jxkpog = scn . nextInt ( ) ; int [ ] VList = new int [ jxkpog ] ; for ( int i = 0 ; i < jxkpog ; i ++ ) { String v = scn . next ( ) ; if ( ! tV . isEmpty ( ) ) { if ( tV . containsKey ( v ) ) { tV . put ( v , tV . get ( v ) + 1 ) ; } else { tV . put ( v , 1 ) ; } } else { tV . put ( v , 1 ) ; } VList [ i ] = tV . get ( v ) ; } Arrays . sort ( VList ) ; if ( VList [ jxkpog - 1 ] == VList [ 0 ] ) { for ( Map . Entry < String , Integer > vote : tV . entrySet ( ) ) { System . out . println ( vote . getKey ( ) . toString ( ) ) ; } } else { if ( VList [ 0 ] != VList [ jxkpog - 1 ] ) { for ( Map . Entry < String , Integer > vote : tV . entrySet ( ) ) { if ( vote . getValue ( ) == VList [ jxkpog - 1 ] ) { System . out . println ( vote . getKey ( ) . toString ( ) ) ; } } } } scn . close ( ) ; } } import java . util . Scanner ; import java . util . Arrays ; class Xrzeqa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long xrzeqa = sc . nextLong ( ) ; int i = 0 ; for ( i = 1 ; xrzeqa > 1 ; i ++ ) { xrzeqa = xrzeqa / 2 ; } System . out . println ( ( long ) ( Math . pow ( 2 , i - 1 ) + Math . pow ( 2 , i - 1 ) - 1 ) ) ; } } import java . util . Scanner ; public class Assco { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int assco = sc . nextInt ( ) ; double pi = 3.141592653558209749448214808651 ; double l = 2 * pi * assco ; System . out . println ( l ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class Jvulmui { @ SuppressWarnings ( " deprecation " ) public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int jvulmui = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; System . out . println ( jvulmui * ( jvulmui - 1 ) / 2 + M * ( M - 1 ) / 2 ) ; } } import java . util . * ; public class Aukos { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aukos = sc . nextInt ( ) ; String s = sc . next ( ) ; int b = 0 ; for ( int i = 0 ; i < aukos - 2 ; i ++ ) { if ( s . substring ( i , i + 3 ) . equals ( " ABC " ) ) { b ++ ; } } System . out . println ( b ) ; } } import java . util . Scanner ; public class Jfkbeit { static public void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jfkbeit = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] counts = new int [ jfkbeit ] ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; counts [ a ] ++ ; counts [ b ] ++ ; } for ( int count : counts ) System . out . println ( count ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Ayjyo { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ayjyo = Integer . parseInt ( scanner . next ( ) ) ; double [ ] S = new double [ ayjyo ] ; for ( int i = 0 ; i < ayjyo ; i ++ ) { S [ i ] = Double . parseDouble ( scanner . next ( ) ) ; } Arrays . parallelSort ( S ) ; double m = ( S [ 0 ] + S [ 1 ] ) / 2 ; for ( int i = 2 ; i < ayjyo ; i ++ ) { m = ( m + S [ i ] ) / 2 ; } System . out . print ( m ) ; } } import java . util . ArrayList ; import java . util . HashMap ; import java . util . Scanner ; public class Asqdbfm { public static void main ( String [ ] args ) { HashMap < Integer , Integer > num = new HashMap < > ( ) ; Scanner sc = new Scanner ( System . in ) ; int asqdbfm = sc . nextInt ( ) ; for ( int i = 1 ; i < asqdbfm ; i ++ ) { int a = sc . nextInt ( ) ; if ( num . containsKey ( a ) ) { num . put ( a , num . get ( a ) + 1 ) ; } else { num . put ( a , 1 ) ; } } for ( int i = 1 ; i <= asqdbfm ; i ++ ) { if ( num . containsKey ( i ) ) { System . out . println ( num . get ( i ) ) ; } else { System . out . println ( 0 ) ; } } } } import java . util . Scanner ; public class Cymct { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cymct = sc . nextInt ( ) ; sc . nextLine ( ) ; String [ ] array = new String [ cymct ] ; for ( int i = 0 ; i < cymct ; i ++ ) { array [ i ] = sc . nextLine ( ) ; if ( i == 0 ) { continue ; } if ( ! ( array [ i ] . substring ( 0 , 1 ) ) . equals ( array [ i - 1 ] . substring ( array [ i - 1 ] . cymct ( ) - 1 ) ) ) { System . out . println ( " No " ) ; return ; } } for ( int i = 0 ; i < cymct - 1 ; i ++ ) { for ( int j = i + 1 ; j < cymct ; j ++ ) { if ( array [ i ] . equals ( array [ j ] ) ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Yuyun { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yuyun = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int min = x - yuyun + 1 ; int max = x + yuyun - 1 ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = min ; i <= max ; i ++ ) { if ( i > 1000000 || i < - 1000000 ) { break ; } if ( i == min ) { sb . append ( i ) ; } else { sb . append ( " " + i ) ; } } System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; public class Dqwyir { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Set < Character > ODD_STEP = new HashSet < Character > ( ) ; Set < Character > EVEN_STEP = new HashSet < Character > ( ) ; String ODD_STEP_STR = " RUD " ; String EVEN_STEP_STR = " LUD " ; for ( int dqwyir = 0 ; dqwyir < 3 ; dqwyir ++ ) { ODD_STEP . add ( ODD_STEP_STR . charAt ( dqwyir ) ) ; EVEN_STEP . add ( EVEN_STEP_STR . charAt ( dqwyir ) ) ; } int current_step = 0 ; String steps = sc . next ( ) ; for ( int dqwyir = 0 ; dqwyir < steps . length ( ) ; dqwyir ++ ) { char step = steps . charAt ( dqwyir ) ; if ( ( dqwyir + 1 ) % 2 == 0 && ! EVEN_STEP . contains ( step ) ) { break ; } else if ( ( dqwyir + 1 ) % 2 != 0 && ! ODD_STEP . contains ( step ) ) { break ; } current_step ++ ; } if ( current_step == steps . length ( ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class Fmtobn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fmtobn = sc . nextInt ( ) ; int ex = 0 ; int [ ] h = new int [ 8 ] ; for ( int i = 0 ; i < 8 ; i ++ ) { h [ i ] = 0 ; } for ( int i = 0 ; i < fmtobn ; i ++ ) { int buf = sc . nextInt ( ) ; for ( int j = 0 ; j < 8 ; j ++ ) { if ( buf <= 399 + j * 400 ) { h [ j ] ++ ; break ; } if ( j == 7 ) { ex ++ ; } } } int min = 0 ; for ( int i = 0 ; i < 8 ; i ++ ) { if ( h [ i ] >= 1 ) { min ++ ; } } int max = min + ex ; if ( min == 0 ) { min = 1 ; } System . out . println ( min + " " + max ) ; } } import java . util . Scanner ; class Jukdumo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int jukdumo = 1 ; int count = 0 ; if ( S . length ( ) % 2 == 0 ) { jukdumo = S . length ( ) ; } else { jukdumo = S . length ( ) - 1 ; } for ( int i = 0 ; i < jukdumo / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( S . length ( ) - 1 - i ) ) { count ++ ; } } System . out . println ( count ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; public class Tapsmzj { public static void main ( String [ ] args ) throws Exception { InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader reader = new BufferedReader ( is ) ; List < String > mylist = new ArrayList < > ( ) ; String tapsmzj = reader . readLine ( ) ; while ( tapsmzj != null ) { mylist . add ( tapsmzj ) ; tapsmzj = reader . readLine ( ) ; } List < String > list01 = new ArrayList < String > ( Arrays . asList ( " SUN " , " MON " , " TUE " , " WED " , " THU " , " FRI " , " SAT " ) ) ; String [ ] arr01 = mylist . get ( 0 ) . split ( " " ) ; String s = arr01 [ 0 ] ; System . out . println ( list01 . indexOf ( s ) == 0 ? 7 : 7 - list01 . indexOf ( s ) ) ; } } import java . util . * ; public class Xgseox { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xgseox = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] arr = new int [ m ] ; for ( int i = 0 ; i < arr . length ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int [ ] flag = new int [ xgseox ] ; for ( int i = 0 ; i < flag . length ; i ++ ) { flag [ i ] = 0 ; } for ( int i = 0 ; i < flag . length ; i ++ ) { for ( int j = 0 ; j < arr . length ; j ++ ) { if ( arr [ j ] == i ) { flag [ i ] = 1 ; } } } int leftResult = 0 ; int rightResult = 0 ; for ( int i = x ; i >= 0 ; i -- ) { leftResult = leftResult + flag [ i ] ; } for ( int i = x + 1 ; i < xgseox ; i ++ ) { rightResult = rightResult + flag [ i ] ; } if ( leftResult < rightResult ) { System . out . println ( leftResult ) ; } else { System . out . println ( rightResult ) ; } } } import java . util . * ; public class Gzvsv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gzvsv = sc . nextInt ( ) ; int [ ] hights = new int [ gzvsv ] ; boolean reach = false ; String answer = " Yes " ; for ( int i = 0 ; i < gzvsv ; i ++ ) { hights [ i ] = sc . nextInt ( ) ; } for ( int i = gzvsv - 1 ; i > 0 ; i -- ) { if ( hights [ i - 1 ] - hights [ i ] > 1 ) { answer = " No " ; break ; } else if ( hights [ i - 1 ] - hights [ i ] == 1 && ! reach ) { reach = true ; } else if ( hights [ i - 1 ] - hights [ i ] == 1 && reach ) { answer = " No " ; break ; } else if ( hights [ i - 1 ] - hights [ i ] == 0 && reach ) { reach = true ; } else { reach = false ; } } System . out . println ( answer ) ; } } import java . lang . reflect . Array ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; class Ztaqsze { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ztaqsze = sc . nextInt ( ) ; int xx = ztaqsze / 2 ; int ans = 0 ; for ( int i = 1 ; i <= ztaqsze ; i ++ ) { for ( int j = 2 ; j <= ztaqsze + 1 ; j ++ ) { if ( Math . pow ( i , j ) > ans && Math . pow ( i , j ) <= ztaqsze ) { ans = ( int ) Math . pow ( i , j ) ; } } } System . out . println ( ans ) ; } } import java . util . * ; import java . util . stream . Collectors ; import java . io . * ; import java . nio . charset . StandardCharsets ; public class Hrvpjv { public static void main ( String [ ] args ) throws IOException { InputStreamReader reader = new InputStreamReader ( System . in , StandardCharsets . UTF_8 ) ; BufferedReader in = new BufferedReader ( reader ) ; Main ins = new Main ( in ) ; ins . calc ( ) ; ins . showResult ( ) ; } Main ( BufferedReader in ) throws IOException { String [ ] tokens = in . readLine ( ) . split ( " " ) ; int hrvpjv = Integer . parseInt ( tokens [ 0 ] ) ; int M = Integer . parseInt ( tokens [ 1 ] ) ; int [ ] A = new int [ M ] ; tokens = in . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < M ; ++ i ) { A [ i ] = Integer . parseInt ( tokens [ i ] ) ; } long sum = 0 ; for ( int i = 0 ; i < M ; ++ i ) { sum += A [ i ] ; } if ( sum > hrvpjv ) { System . out . println ( " -1 " ) ; } else { System . out . println ( ( hrvpjv - sum ) ) ; } } void calc ( ) { } void showResult ( ) { } } import java . io . * ; import java . util . * ; class Egivp { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int egivp = Integer . parseInt ( st . nextToken ( ) ) ; int w = Integer . parseInt ( st . nextToken ( ) ) ; if ( w == 0 && egivp == 0 ) break ; for ( int i = 0 ; i < egivp ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . * ; class Zuzzv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zuzzv = sc . nextInt ( ) ; long [ ] a = new long [ zuzzv ] ; for ( int i = 0 ; i < zuzzv ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long num = lcm ( a , zuzzv ) ; long deno = sum ( a , zuzzv , num ) ; double ans = num / ( double ) deno ; System . out . println ( ans ) ; } public static long gcd ( long a , long b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } public static long lcm ( long [ ] a , long zuzzv ) { long lc = 1 ; for ( int i = 0 ; i < zuzzv ; i ++ ) { lc = ( lc * a [ i ] ) / gcd ( lc , a [ i ] ) ; } return lc ; } public static long sum ( long [ ] a , int zuzzv , long num ) { long count = 0 ; for ( int i = 0 ; i < zuzzv ; i ++ ) { count += ( num / a [ i ] ) ; } return count ; } } import java . util . * ; public class Judojb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int judojb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int min = 0 ; int min2 = 0 ; if ( judojb < b ) { min = judojb ; if ( b < c ) { min2 = b ; } else { min2 = c ; } } else { min = b ; if ( judojb < c ) { min2 = judojb ; } else { min2 = c ; } } System . out . println ( min + min2 ) ; } } import java . io . * ; public class Bkfrr { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long bkfrr = Long . parseLong ( reader . readLine ( ) ) ; System . out . println ( calc ( 1 , bkfrr ) - calc ( 3 , bkfrr ) - calc ( 5 , bkfrr ) + calc ( 15 , bkfrr ) ) ; return ; } static long calc ( long n , long bkfrr ) { return ( n + bkfrr / n * n ) * ( bkfrr / n ) / 2 ; } } import java . util . Scanner ; public class Nbfbk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; char [ ] chars = s . toCharArray ( ) ; int nbfbk = 0 ; for ( int i = 0 ; i < chars . length / 2 ; i ++ ) { if ( chars [ i ] != chars [ chars . length - 1 - i ] ) { nbfbk ++ ; } } System . out . println ( nbfbk ) ; } } import java . io . * ; public class Abqnlfu { public static void main ( String ... args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String [ ] line = br . readLine ( ) . split ( " " ) ; int abqnlfu = Integer . parseInt ( line [ 0 ] ) ; int k = Integer . parseInt ( line [ 1 ] ) ; int q = Integer . parseInt ( line [ 2 ] ) ; int [ ] point = new int [ abqnlfu ] ; for ( int i = 0 ; i < q ; i ++ ) { point [ Integer . parseInt ( br . readLine ( ) ) - 1 ] += 1 ; } for ( int i = 0 ; i < abqnlfu ; i ++ ) { point [ i ] += k - q ; } for ( int i = 0 ; i < point . length ; i ++ ) { if ( point [ i ] <= 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } br . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . lang . * ; import java . util . * ; public class Pbpgcs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pbpgcs = sc . nextInt ( ) ; int kari = pbpgcs + 1 ; int keta = 1 ; while ( ( int ) ( kari / 10 ) != 0 ) { keta ++ ; kari = ( int ) ( kari / 10 ) ; } if ( keta == 1 ) { System . out . println ( pbpgcs ) ; } else if ( keta == 2 ) { System . out . println ( 9 ) ; } else if ( keta == 3 ) { System . out . println ( ( 10 + pbpgcs - 100 ) ) ; } else if ( keta == 4 ) { System . out . println ( 909 ) ; } else if ( keta == 5 ) { System . out . println ( ( 910 + pbpgcs - 10000 ) ) ; } else { System . out . println ( 90909 ) ; } sc . close ( ) ; } } import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Zsabo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] A = sc . next ( ) . toCharArray ( ) ; Map < Character , Integer > maplst = new TreeMap < Character , Integer > ( ) ; for ( char zsabo : A ) { if ( maplst . containsKey ( zsabo ) ) { maplst . put ( zsabo , maplst . get ( zsabo ) + 1 ) ; } else { maplst . put ( zsabo , 1 ) ; } } boolean judge = true ; if ( maplst . keySet ( ) . size ( ) == 2 ) { for ( char zsabo : maplst . keySet ( ) ) { if ( maplst . get ( zsabo ) != 2 ) { judge = ! judge ; break ; } } } else { judge = ! judge ; } if ( judge ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Eeigsxb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eeigsxb = sc . nextInt ( ) ; int break_count = 0 ; int next = 1 ; for ( int i = 0 ; i < eeigsxb ; i ++ ) { if ( sc . nextInt ( ) == next ) { next ++ ; } else { break_count ++ ; } } if ( next == 1 ) { System . out . println ( - 1 ) ; } else { System . out . println ( break_count ) ; } } } import java . util . Scanner ; public class Wfhufla { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wfhufla = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int sta = d * 2 + 1 ; for ( int i = 0 ; i < 20 ; i ++ ) { if ( sta * i >= wfhufla ) { System . out . println ( i ) ; break ; } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Cjang { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int cjang , b , w ; String str ; String [ ] s ; str = br . readLine ( ) ; while ( str != null ) { StringBuilder out = new StringBuilder ( ) ; s = str . split ( " " ) ; cjang = Integer . parseInt ( s [ 0 ] ) ; b = Integer . parseInt ( s [ 1 ] ) ; w = cjang + b ; out . append ( w ) ; System . out . println ( out . length ( ) ) ; str = br . readLine ( ) ; } } } import java . util . Scanner ; public class Ngvqdw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ngvqdw = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = ( ngvqdw + b ) / 2 ; String ans = " " ; if ( ( ngvqdw + b ) % 2 == 0 && Math . abs ( ngvqdw - k ) == Math . abs ( b - k ) ) { ans = String . valueOf ( k ) ; } else { ans = " IMPOSSIBLE " ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class Hopoe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hopoe = sc . nextInt ( ) ; int [ ] h = new int [ hopoe ] ; for ( int i = 0 ; i < hopoe ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int number = 0 ; int ans = 0 ; for ( int i = 0 ; i < hopoe ; i ++ ) { if ( number > h [ i ] ) ans += number - h [ i ] ; number = h [ i ] ; } ans += number ; System . out . println ( ans ) ; } } import java . util . * ; public class Nyhgz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; if ( s . indexOf ( t ) != - 1 ) { System . out . println ( 0 ) ; } else { int nyhgz = Integer . MAX_VALUE ; for ( int i = 0 ; i <= s . length ( ) - t . length ( ) ; i ++ ) { if ( nyhgz > helper ( s . substring ( i , i + t . length ( ) ) , t ) ) { nyhgz = helper ( s . substring ( i , i + t . length ( ) ) , t ) ; } } System . out . println ( nyhgz ) ; } } public static int helper ( String s1 , String s2 ) { int count = 0 ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { if ( s1 . charAt ( i ) != s2 . charAt ( i ) ) { count ++ ; } } return count ; } } import java . util . * ; public class Sktgu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sktgu = sc . nextInt ( ) ; int [ ] B = new int [ sktgu ] ; for ( int i = 1 ; i < sktgu ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int [ ] A = new int [ sktgu + 1 ] ; A [ 1 ] = B [ 1 ] ; for ( int i = 1 ; i < sktgu ; i ++ ) { if ( B [ i ] < A [ i ] ) { A [ i ] = B [ i ] ; } A [ i + 1 ] = B [ i ] ; } int max = 0 ; for ( int i = 1 ; i <= sktgu ; i ++ ) { max += A [ i ] ; } System . out . println ( max ) ; } } import java . io . * ; import java . util . * ; public class Gvjbt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Question question = new Question ( ) ; question . solve ( sc ) ; } static class Gvjbt { public void solve ( Scanner sc ) { int gvjbt = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] distances = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { distances [ i ] = sc . nextInt ( ) ; } int m = 0 ; for ( int i = 0 ; i < n ; ++ i ) { int t = ( i + 1 ) % n ; int dist = distances [ t ] - distances [ i ] ; m = Math . max ( m , Math . min ( Math . abs ( dist ) , gvjbt - Math . abs ( dist ) ) ) ; } System . out . println ( gvjbt - m ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Pnhsz { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] Alph = new int [ 26 ] ; for ( int pnhsz = 0 ; pnhsz < 26 ; pnhsz ++ ) { Alph [ pnhsz ] = 0 ; } while ( true ) { String line = br . readLine ( ) ; if ( line == null ) break ; String [ ] token = line . split ( " " ) ; for ( int i = 0 ; i < token . length ; i ++ ) { String str = token [ i ] . toLowerCase ( ) ; for ( char ch : str . toCharArray ( ) ) { if ( Character . isLetter ( ch ) ) { Alph [ ch - 'a' ] ++ ; } } } } for ( int i = 0 ; i < 26 ; i ++ ) { System . out . println ( ( char ) ( 'a' + i ) + " : " + Alph [ i ] ) ; } } } import java . util . Scanner ; public class Aytlxr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int aytlxr = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int count = 0 ; for ( int i = aytlxr ; i < B + 1 ; i ++ ) { String s = String . valueOf ( i ) ; String [ ] array = new String [ 5 ] ; for ( int j = 0 ; j < 5 ; j ++ ) { array [ j ] = s . substring ( j , j + 1 ) ; } if ( array [ 0 ] . equals ( array [ 4 ] ) && array [ 1 ] . equals ( array [ 3 ] ) ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; class Lcjnen { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double lcjnen = sc . nextDouble ( ) ; double b = sc . nextDouble ( ) ; int h = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int time = h * 60 + m ; double len = 0 ; double rad = 0 ; double hh = 0 ; double mm = 0 ; for ( int i = 0 ; i < time ; i ++ ) { hh += 0.5 ; mm += 6 ; } hh = hh % 360 ; mm = mm % 360 ; rad = Math . abs ( hh - mm ) ; len = Math . sqrt ( Math . pow ( lcjnen , 2 ) + Math . pow ( b , 2 ) - 2 * lcjnen * b * Math . cos ( Math . toRadians ( rad ) ) ) ; System . out . println ( len ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class Qvwfhy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qvwfhy = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; HashSet < Integer > sunuke = new HashSet < > ( ) ; for ( int i = 0 ; i < qvwfhy ; i ++ ) { sunuke . add ( i + 1 ) ; } for ( int i = 0 ; i < k ; i ++ ) { int ki = sc . nextInt ( ) ; for ( int j = 0 ; j < ki ; j ++ ) { int temp = sc . nextInt ( ) ; if ( sunuke . contains ( temp ) ) { sunuke . remove ( temp ) ; } } } System . out . println ( sunuke . size ( ) ) ; } } import java . util . * ; public class Hgvcj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hgvcj = sc . nextInt ( ) ; int standard = 1 ; while ( true ) { int target = standard * 2 ; if ( target <= hgvcj ) { standard = target ; } else { break ; } } System . out . println ( standard ) ; } } import java . lang . * ; import java . util . * ; public class Fzdmxz { public static void main ( String [ ] args ) { Scanner stdId = new Scanner ( System . in ) ; int fzdmxz = stdId . nextInt ( ) ; fzdmxz = fzdmxz * fzdmxz * fzdmxz ; System . out . println ( String . valueOf ( fzdmxz ) ) ; } } import java . util . Scanner ; public class Choxsq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String choxsq = scan . nextLine ( ) ; String str2 = scan . nextLine ( ) ; String c = str2 . substring ( 0 , choxsq . length ( ) ) ; if ( choxsq . equals ( c ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; } } import java . util . Scanner ; public class Bowkyg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bowkyg = Integer . parseInt ( sc . next ( ) ) ; int d = Integer . parseInt ( sc . next ( ) ) ; int range = 2 * d + 1 ; System . out . println ( ( bowkyg + range - 1 ) / range ) ; System . out . flush ( ) ; sc . close ( ) ; } } import java . util . * ; public class Jygqq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int jygqq = s . lastIndexOf ( " Z " ) - s . indexOf ( " A " ) + 1 ; System . out . println ( jygqq ) ; } } import java . util . Scanner ; class Sxaeow { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; char [ ] S ; int sxaeow = 0 ; S = input . next ( ) . toCharArray ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( S [ i ] == S [ i + 1 ] ) { System . out . println ( " Bad " ) ; sxaeow ++ ; break ; } } if ( sxaeow == 0 ) { System . out . println ( " Good " ) ; } } } import java . util . Scanner ; public class Jinvre { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jinvre = sc . nextInt ( ) ; int [ ] h = new int [ jinvre ] ; int viewableCnt = 0 ; for ( int i = 0 ; i < jinvre ; i ++ ) { h [ i ] = sc . nextInt ( ) ; for ( int j = ( i - 1 ) ; j >= 0 ; j -- ) { if ( h [ i ] < h [ j ] ) { break ; } else if ( j == 0 ) { viewableCnt ++ ; } } } System . out . println ( viewableCnt + 1 ) ; sc . close ( ) ; } } import java . util . * ; public class Gutwpf { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String gutwpf = sc . next ( ) ; if ( Character . isUpperCase ( gutwpf . charAt ( 0 ) ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . Scanner ; public class Dzzal { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; boolean dzzal = S . contains ( " A " ) ; boolean containsB = S . contains ( " B " ) ; System . out . println ( ( dzzal && containsB ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Emgwht { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; while ( true ) { int emgwht = Integer . parseInt ( std . next ( ) ) ; if ( emgwht == 0 ) { break ; } double [ ] score = new double [ emgwht ] ; double ave = 0 ; for ( int i = 0 ; i < emgwht ; i ++ ) { score [ i ] = Double . parseDouble ( std . next ( ) ) ; ave += score [ i ] ; } ave /= emgwht ; double sd = 0 ; for ( int i = 0 ; i < emgwht ; i ++ ) { sd += Math . pow ( ( score [ i ] - ave ) , 2 ) ; } sd /= emgwht ; sd = Math . pow ( sd , 0.5 ) ; System . out . println ( String . format ( " %.5f " , sd ) ) ; } } } import java . io . * ; import java . util . * ; public class Txzta { private void solve ( ) { int txzta = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; for ( int i = A ; i <= B ; ++ i ) { if ( i % txzta == 0 ) { out . println ( " OK " ) ; return ; } } out . println ( " NG " ) ; } private static PrintWriter out ; private static MyScanner sc ; private static class Txzta { BufferedReader br ; StringTokenizer st ; private MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } public static void main ( String [ ] args ) { out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; sc = new MyScanner ( ) ; new Main ( ) . solve ( ) ; out . close ( ) ; } } import java . util . * ; class Kwuok { public static void main ( String [ ] a ) { Scanner c = new Scanner ( System . in ) ; String s = c . next ( ) ; String t = c . next ( ) ; int kwuok = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != t . charAt ( i ) ) kwuok ++ ; } System . out . println ( kwuok ) ; } } import java . util . Scanner ; public class Pzcubj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pzcubj = sc . nextInt ( ) ; int [ ] result = new int [ pzcubj ] ; for ( int i = 1 ; sc . hasNextInt ( ) ; i ++ ) { result [ sc . nextInt ( ) - 1 ] = i ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < pzcubj ; i ++ ) { sb . append ( result [ i ] ) ; if ( i != pzcubj ) { sb . append ( " " ) ; } else { sb . append ( " \n " ) ; } } System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; public class Bwfamk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int bwfamk = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int l = scan . nextInt ( ) ; int [ ] [ ] vectorA = new int [ bwfamk ] [ m ] ; int [ ] [ ] vectorB = new int [ m ] [ l ] ; long [ ] [ ] vectorC = new long [ bwfamk ] [ l ] ; for ( int i = 0 ; i < bwfamk ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int elm = scan . nextInt ( ) ; vectorA [ i ] [ j ] = elm ; } } for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < l ; j ++ ) { int elm = scan . nextInt ( ) ; vectorB [ i ] [ j ] = elm ; } } for ( int i = 0 ; i < bwfamk ; i ++ ) { for ( int j = 0 ; j < l ; j ++ ) { long ans = 0 ; for ( int k = 0 ; k < m ; k ++ ) { ans += ( long ) vectorA [ i ] [ k ] * ( long ) vectorB [ k ] [ j ] ; } vectorC [ i ] [ j ] = ans ; System . out . printf ( j != l - 1 ? " %d " : " %d \n " , vectorC [ i ] [ j ] ) ; } } } } import java . util . Scanner ; public class Dsfqii { public long getTotalHeightOfStools ( int n , int [ ] arr ) { long dsfqii = 0 ; int prevHeight = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( prevHeight > arr [ i ] ) { dsfqii += prevHeight - arr [ i ] ; arr [ i ] = prevHeight ; } prevHeight = arr [ i ] ; } return dsfqii ; } public static void main ( String [ ] args ) throws Exception { Main solution = new Main ( ) ; Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = scanner . nextInt ( ) ; } long answer = solution . getTotalHeightOfStools ( n , arr ) ; System . out . println ( answer ) ; } } import java . util . * ; import java . math . * ; public class Mzcvvi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mzcvvi = sc . nextInt ( ) ; String [ ] a = new String [ mzcvvi ] ; for ( int i = 0 ; i < mzcvvi ; i ++ ) a [ i ] = sc . next ( ) ; Set < String > s = new HashSet < > ( ) ; for ( String x : a ) s . add ( x ) ; System . out . println ( s . size ( ) ) ; } } import java . io . * ; import java . util . * ; public class Eovhqrf { private static Scanner sc ; private static Printer pr ; private static void solve ( ) { int eovhqrf = sc . nextInt ( ) ; for ( int i = 0 ; 4 * i <= 100 ; i ++ ) { for ( int j = 0 ; 4 * i + 7 * j <= 100 ; j ++ ) { if ( 4 * i + 7 * j == eovhqrf ) { pr . println ( " Yes " ) ; return ; } } } pr . println ( " No " ) ; } public static void main ( String [ ] args ) { sc = new Scanner ( INPUT == null ? System . in : new ByteArrayInputStream ( INPUT . getBytes ( ) ) ) ; pr = new Printer ( System . out ) ; solve ( ) ; pr . flush ( ) ; } static String INPUT = null ; private static class Eovhqrf extends PrintWriter { Printer ( OutputStream out ) { super ( out ) ; } } } import java . util . Scanner ; public class Wexzsya { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wexzsya = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i < wexzsya ; i ++ ) { double x1 = sc . nextDouble ( ) ; double x2 = sc . nextDouble ( ) ; double dis = Math . sqrt ( Math . pow ( x1 , 2 ) + Math . pow ( x2 , 2 ) ) ; if ( dis <= q ) result ++ ; } System . out . println ( result ) ; } } import java . util . Scanner ; public class Xdpgws { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xdpgws = scan . nextInt ( ) ; int intH = scan . nextInt ( ) ; int intX = scan . nextInt ( ) ; int intY = scan . nextInt ( ) ; int intR = scan . nextInt ( ) ; if ( intX <= xdpgws - intR && intR <= intX && intY <= intH - intR && intR <= intY ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; import java . lang . Math ; public class Clgsw { public static void main ( String [ ] args ) { int clgsw ; double sum = 0.0 , m , v , t = 0.0 ; Scanner sc = new Scanner ( System . in ) ; while ( true ) { clgsw = sc . nextInt ( ) ; if ( clgsw == 0 ) break ; double [ ] A = new double [ clgsw ] ; for ( int i = 0 ; i < A . length ; i ++ ) { A [ i ] = ( double ) sc . nextInt ( ) ; sum += A [ i ] ; } m = sum / ( double ) A . length ; for ( int i = 0 ; i < A . length ; i ++ ) { t += ( A [ i ] - m ) * ( A [ i ] - m ) ; } v = t / ( double ) A . length ; System . out . println ( Math . sqrt ( v ) ) ; sum = 0.0 ; t = 0.0 ; } } } import java . util . * ; public class Swpydd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > List = new ArrayList < > ( ) ; for ( int swpydd = 0 ; swpydd < 5 ; swpydd ++ ) { int j = sc . nextInt ( ) ; List . add ( j ) ; } int k = sc . nextInt ( ) ; int num = 0 ; for ( int swpydd = 0 ; swpydd < 4 ; swpydd ++ ) { for ( int j = swpydd + 1 ; j < 5 ; j ++ ) { if ( List . get ( j ) - List . get ( swpydd ) > k ) num ++ ; } } if ( num == 0 ) System . out . println ( " Yay! " ) ; else System . out . println ( " :( " ) ; } } import java . util . * ; public class Plgtlyo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Long > List = new ArrayList < > ( ) ; long plgtlyo = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; for ( int i = 0 ; i < plgtlyo ; i ++ ) List . add ( sc . nextLong ( ) ) ; Collections . sort ( List , Collections . reverseOrder ( ) ) ; long sum = 0 ; for ( long i = K ; i < List . size ( ) ; i ++ ) sum += List . get ( ( int ) i ) ; System . out . println ( sum ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Oiusujk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String s = br . readLine ( ) ; StringTokenizer st ; while ( s != null ) { st = new StringTokenizer ( s ) ; int oiusujk = Integer . parseInt ( st . nextToken ( ) ) + Integer . parseInt ( st . nextToken ( ) ) ; System . out . println ( ( int ) Math . log10 ( oiusujk ) + 1 ) ; s = br . readLine ( ) ; } } catch ( Exception ex ) { System . exit ( 0 ) ; } } } import java . util . * ; public class Ybufkc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ybufkc = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; boolean [ ] bool = new boolean [ ybufkc + 1 ] ; for ( int i = 0 ; i <= ybufkc ; i ++ ) { bool [ i ] = true ; } for ( int i = 0 ; i < m ; i ++ ) { bool [ scanner . nextInt ( ) ] = false ; } int [ ] b = new int [ ybufkc + 1 ] ; b [ 0 ] = 1 ; b [ 1 ] = 1 ; int mod = 1000000007 ; for ( int i = 2 ; i <= ybufkc ; i ++ ) { b [ i ] = 0 ; if ( bool [ i - 2 ] ) b [ i ] += b [ i - 2 ] ; if ( bool [ i - 1 ] ) b [ i ] += b [ i - 1 ] ; b [ i ] %= mod ; } System . out . println ( b [ ybufkc ] ) ; } } import java . util . Scanner ; public class Xyfnabr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String numbers = " 1 " ; int xyfnabr ; while ( true ) { numbers = scanner . nextLine ( ) ; if ( numbers . equals ( " 0 " ) ) break ; xyfnabr = 0 ; for ( int i = 0 ; i < numbers . length ( ) ; ++ i ) { xyfnabr += Character . getNumericValue ( numbers . charAt ( i ) ) ; } System . out . println ( xyfnabr ) ; } } } import java . util . * ; public class Oqcgq { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long oqcgq = in . nextLong ( ) , c = 0 , s = 0 ; long k = in . nextLong ( ) ; long [ ] arr = new long [ ( int ) oqcgq ] ; for ( int i = 0 ; i < oqcgq ; i ++ ) { arr [ i ] = in . nextInt ( ) ; s = s + arr [ i ] ; } if ( k >= oqcgq ) { System . out . println ( " 0 " ) ; System . exit ( 0 ) ; } Arrays . sort ( arr ) ; long mid = oqcgq - 1 ; while ( c != k ) { s = s - arr [ ( int ) mid ] ; mid -- ; c ++ ; } System . out . println ( s ) ; } } import java . util . * ; public class Lityxw { public static void main ( String [ ] args ) { PriorityQueue < String > caca = new PriorityQueue < String > ( ) ; Scanner scn = new Scanner ( System . in ) ; int lityxw = scn . nextInt ( ) ; int n2 = scn . nextInt ( ) ; for ( int i = 0 ; i < lityxw ; i ++ ) caca . add ( scn . next ( ) ) ; for ( int i = 0 ; i < lityxw ; i ++ ) System . out . print ( caca . poll ( ) ) ; System . out . println ( ) ; scn . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; import java . util . stream . Collectors ; import java . util . stream . Stream ; public class Gufaffu { public static void main ( String [ ] args ) throws Exception { Scanner fr = new Scanner ( System . in ) ; int gufaffu = fr . nextInt ( ) ; int x = fr . nextInt ( ) ; int xx = x ; int t = fr . nextInt ( ) ; int tt = t ; if ( gufaffu < x ) { System . out . println ( t ) ; } else { while ( x < gufaffu ) { x += xx ; t += tt ; } System . out . println ( t ) ; } } } import java . util . Scanner ; public class Ogucoql { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ogucoql = Integer . parseInt ( scanner . next ( ) ) ; int s = Integer . parseInt ( scanner . next ( ) ) ; if ( ogucoql < 10 && s < 10 ) { System . out . println ( ogucoql * s ) ; } else { System . out . println ( - 1 ) ; } scanner . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Wqmevde { public static void main ( String [ ] args ) throws IOException { BufferedReader bis = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = bis . readLine ( ) ; int wqmevde = s . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < wqmevde ; i ++ ) { char c = s . charAt ( i ) ; if ( c == '+' ) { ans += 1 ; } if ( c == '-' ) { ans -= 1 ; } } System . out . println ( ans ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Mdgkf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mdgkf = sc . nextInt ( ) , a = sc . nextInt ( ) ; if ( mdgkf % a == 0 ) System . out . println ( mdgkf / a ) ; else System . out . println ( mdgkf / a + 1 ) ; } } import java . util . * ; public class Tvjuvqh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tvjuvqh = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int ans = 0 ; int b = K - tvjuvqh ; int c = K - tvjuvqh - B ; if ( tvjuvqh == 0 && C == 0 ) { System . out . println ( " 0 " ) ; } else if ( K >= tvjuvqh && c < 1 ) { System . out . println ( tvjuvqh ) ; } else if ( K >= tvjuvqh && c >= 1 ) { System . out . println ( tvjuvqh + ( c * - 1 ) ) ; } else if ( K < tvjuvqh ) { System . out . println ( K ) ; } } } import java . util . Scanner ; public class Wfdgd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wfdgd = sc . nextInt ( ) ; int [ ] a = new int [ wfdgd ] ; for ( int i = 0 ; i < a . length ; ++ i ) { a [ i ] = sc . nextInt ( ) - 1 ; } System . out . println ( solve ( a ) ) ; sc . close ( ) ; } static int solve ( int [ ] a ) { boolean [ ] visited = new boolean [ a . length ] ; visited [ 0 ] = true ; int index = 0 ; for ( int step = 1 ; ; ++ step ) { index = a [ index ] ; if ( index == 1 ) { return step ; } if ( visited [ index ] ) { return - 1 ; } visited [ index ] = true ; } } } import java . util . Scanner ; public class Aigoq { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int aigoq = sc . nextInt ( ) ; int [ ] d = new int [ 100001 ] ; for ( int i = 0 ; i < aigoq ; i ++ ) { d [ sc . nextInt ( ) ] ++ ; } int tmp = 0 ; int cnt = 0 ; for ( int i = 0 ; i < 100001 ; i ++ ) { tmp += d [ i ] ; if ( aigoq == tmp * 2 ) { cnt ++ ; } else if ( aigoq < tmp * 2 ) { break ; } } System . out . println ( cnt ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Gvixw { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] best = { 0 , 0 , 0 } ; for ( int gvixw = 0 ; gvixw < 10 ; gvixw ++ ) { String line = br . readLine ( ) ; int height = Integer . parseInt ( line ) ; if ( height > best [ 0 ] ) { best [ 2 ] = best [ 1 ] ; best [ 1 ] = best [ 0 ] ; best [ 0 ] = height ; } else if ( height > best [ 1 ] ) { best [ 2 ] = best [ 1 ] ; best [ 1 ] = height ; } else if ( height > best [ 2 ] ) { best [ 2 ] = height ; } } for ( int h : best ) { System . out . println ( h ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . * ; public class Xaerr { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int xaerr = in . nextInt ( ) ; String [ ] array = new String [ xaerr ] ; for ( int i = 0 ; i < xaerr ; i ++ ) array [ i ] = in . next ( ) ; List < String > list = new ArrayList < > ( ) ; list . add ( array [ 0 ] ) ; char c = array [ 0 ] . charAt ( array [ 0 ] . length ( ) - 1 ) ; for ( int i = 1 ; i < xaerr ; i ++ ) { if ( list . contains ( array [ i ] ) || array [ i ] . charAt ( 0 ) != c ) { System . out . println ( " No " ) ; return ; } c = array [ i ] . charAt ( array [ i ] . length ( ) - 1 ) ; list . add ( array [ i ] ) ; } System . out . println ( " Yes " ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Lmblxe { private static int prime ( int a ) { if ( a == 2 || a == 3 ) return 1 ; for ( int lmblxe = 2 ; lmblxe < Math . sqrt ( a ) + 1 ; lmblxe ++ ) { if ( a % lmblxe == 0 ) { return 0 ; } } return 1 ; } public static void main ( String [ ] args ) throws Exception { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String line ; int n = 0 , j = 0 , store = 0 ; boolean first = true ; while ( ( line = br . readLine ( ) ) != null ) { if ( first ) { n = Integer . parseInt ( line ) ; first = false ; } else { store += prime ( Integer . parseInt ( line ) ) ; j ++ ; if ( j == n ) { break ; } } } System . out . println ( store ) ; } } } import java . util . * ; public class Qkivs { public static long gcd ( long a , long b ) { while ( a % b != 0 ) { long qkivs = a % b ; a = b ; b = qkivs ; } return b ; } public static long lcm ( long a , long b ) { return a * b / gcd ( a , b ) ; } public static long divnum ( long a , long b , long x ) { return b / x - ( a - 1 ) / x ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; if ( d % c == 0 ) { System . out . println ( b - a + 1 - divnum ( a , b , c ) ) ; } else { System . out . println ( b - a + 1 - divnum ( a , b , c ) - divnum ( a , b , d ) + divnum ( a , b , lcm ( c , d ) ) ) ; } } } import java . util . * ; import java . util . Arrays ; public class Fcubc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fcubc = sc . nextInt ( ) ; int result = 0 ; for ( int i = 1 ; i <= fcubc ; i = i + 2 ) { int count = 0 ; for ( int j = 1 ; j <= i ; j ++ ) { if ( i % j == 0 ) { count ++ ; } if ( count == 8 ) { result ++ ; } } } System . out . println ( result ) ; } } import java . util . Scanner ; public class Araawti { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int araawti = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = Integer . parseInt ( araawti + " " + b ) ; int d = ( int ) Math . sqrt ( c ) ; if ( d * d == c ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Ivonwau { public static void main ( String [ ] args ) { Scanner Ent = new Scanner ( System . in ) ; int ivonwau = Ent . nextInt ( ) ; int Q = Ent . nextInt ( ) ; int R = Ent . nextInt ( ) ; int res1 = ivonwau + Q ; int res2 = R + Q ; int res3 = R + ivonwau ; System . out . println ( Math . min ( res1 , Math . min ( res2 , res3 ) ) ) ; } } import java . util . Scanner ; public class Sudkost { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int sudkost = scan . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= sudkost ; i ++ ) { String mozi = String . valueOf ( i ) ; if ( mozi . length ( ) % 2 == 1 ) { count ++ ; } } System . out . println ( count ) ; scan . close ( ) ; } } import java . util . * ; public class Guskebb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int guskebb = sc . nextInt ( ) ; Integer [ ] list = new Integer [ guskebb ] ; for ( int i = 0 ; i < guskebb ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } Integer [ ] sorted = Arrays . copyOf ( list , guskebb ) ; Arrays . sort ( sorted ) ; String ans = " YES " ; int count = 0 ; for ( int i = 0 ; i < guskebb ; i ++ ) { if ( ! sorted [ i ] . equals ( list [ i ] ) ) { count ++ ; if ( count > 2 ) { ans = " NO " ; break ; } } } System . out . println ( ans ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Stoulmd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int stoulmd = Integer . parseInt ( scan . next ( ) ) ; int m = Integer . parseInt ( scan . next ( ) ) ; Integer [ ] a = new Integer [ stoulmd ] ; for ( int i = 0 ; i < stoulmd ; i ++ ) { a [ i ] = Integer . parseInt ( scan . next ( ) ) ; } scan . close ( ) ; int sum = 0 ; for ( int i : a ) { sum += i ; } int border = ( sum + ( 4 * m ) - 1 ) / ( 4 * m ) ; Arrays . sort ( a , Collections . reverseOrder ( ) ) ; if ( a [ m - 1 ] >= border ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Xnvzg { private static int gcd ( int xnvzg , int b ) { if ( ( xnvzg % b ) == 0 ) return b ; return gcd ( b , xnvzg % b ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xnvzg = sc . nextInt ( ) ; int tmp ; int count = 0 ; for ( int i = 1 ; i < xnvzg + 1 ; i ++ ) { for ( int j = 1 ; j < xnvzg + 1 ; j ++ ) { tmp = gcd ( i , j ) ; for ( int k = 1 ; k < xnvzg + 1 ; k ++ ) { count += gcd ( k , tmp ) ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Rxjmhex { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int rxjmhex = scanner . nextInt ( ) ; String s = scanner . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { System . out . print ( ( char ) ( ( s . charAt ( i ) - 'A' + rxjmhex ) % 26 + 'A' ) ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Iswjmj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iswjmj = sc . nextInt ( ) ; int hp = 0 ; List < Integer > takoyaki = new ArrayList < Integer > ( ) ; takoyaki . add ( sc . nextInt ( ) ) ; for ( int i = 1 ; i < iswjmj ; i ++ ) { takoyaki . add ( sc . nextInt ( ) ) ; for ( int j = 0 ; j < i ; j ++ ) { hp = hp + takoyaki . get ( i ) * takoyaki . get ( j ) ; } } System . out . println ( hp ) ; } } import java . util . * ; class Zkxxfk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] ab = scanner . nextLine ( ) . split ( " " , 2 ) ; int zkxxfk = Integer . parseInt ( ab [ 0 ] ) ; int b = Integer . parseInt ( ab [ 1 ] ) ; String s = scanner . nextLine ( ) ; if ( zkxxfk + b + 1 != s . length ( ) ) { System . out . println ( " No " ) ; return ; } for ( int i = 0 ; i <= zkxxfk + b ; i ++ ) { char ch = s . charAt ( i ) ; if ( i == zkxxfk ) { if ( ch != '-' ) { System . out . println ( " No " ) ; return ; } } else { if ( ! ( '0' <= ch && ch <= '9' ) ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . * ; import java . io . * ; class Jecovu { static boolean jecovu = false ; public static void main ( String [ ] args ) throws IOException { PrintWriter out = new PrintWriter ( System . out ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; long sum = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { sum += Character . getNumericValue ( s . charAt ( i ) ) ; sum = sum % 9 ; } if ( sum % 9 == 0 ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } out . close ( ) ; } } import java . util . Scanner ; public class Unmncn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int unmncn = sc . nextInt ( ) ; int sp = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int [ ] point = new int [ unmncn ] ; for ( int i = 0 ; i < point . length ; i ++ ) { point [ i ] = sp - q ; } int [ ] answer = new int [ q ] ; for ( int i = 0 ; i < answer . length ; i ++ ) { answer [ i ] = sc . nextInt ( ) ; point [ answer [ i ] - 1 ] ++ ; } for ( int i : point ) { if ( i <= 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } } import java . util . * ; public class Zizxhs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int zizxhs = s . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < zizxhs ; i ++ ) { for ( int j = i + 1 ; j <= zizxhs ; j ++ ) { String str = s . substring ( i , j ) ; int cnt = 0 ; for ( int k = 0 ; k < str . length ( ) ; k ++ ) { char ch = str . charAt ( k ) ; if ( ! ( ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T' ) ) { cnt = 0 ; break ; } cnt ++ ; } ans = Math . max ( ans , cnt ) ; } } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Goqed { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { int goqed = Integer . parseInt ( reader . readLine ( ) ) ; int n = Integer . parseInt ( reader . readLine ( ) ) ; int [ ] x = new int [ goqed ] ; for ( int i = 0 ; i < goqed ; i ++ ) { x [ i ] = i + 1 ; } int a ; int b ; for ( int i = 0 ; i < n ; i ++ ) { String line = reader . readLine ( ) ; String [ ] s = line . split ( " , " ) ; a = Integer . parseInt ( s [ 0 ] ) ; b = Integer . parseInt ( s [ 1 ] ) ; int temp = x [ a - 1 ] ; x [ a - 1 ] = x [ b - 1 ] ; x [ b - 1 ] = temp ; } for ( int i = 0 ; i < goqed ; i ++ ) { System . out . println ( x [ i ] ) ; } } catch ( IOException e ) { } } } import java . util . * ; public class Lizimqd { static long lizimqd = 5000000000000000l ; public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int n = str . length ( ) ; int [ ] s = new int [ n ] ; long k = sc . nextLong ( ) ; int answer = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = Integer . parseInt ( String . valueOf ( str . charAt ( i ) ) ) ; if ( s [ i ] == 1 ) { if ( i + 1 == k ) { answer = 1 ; break ; } } else { answer = s [ i ] ; break ; } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Kuuwze { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; char [ ] s = in . next ( ) . toCharArray ( ) ; boolean kuuwze = false ; boolean B = false ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == 'A' ) kuuwze = true ; if ( s [ i ] == 'B' ) B = true ; } if ( kuuwze && B ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class Ddtnf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ddtnf = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] tmp = s . toCharArray ( ) ; for ( int i = 0 ; i < tmp . length ; i ++ ) { int j = ddtnf ; while ( j > 0 ) { if ( tmp [ i ] == 'Z' ) { tmp [ i ] = 'A' ; } else { tmp [ i ] = ( char ) ( tmp [ i ] + 1 ) ; } j -- ; } } for ( char c : tmp ) { System . out . print ( c ) ; } } } import java . util . * ; public class Fihayus { long fihayus = Long . MAX_VALUE ; public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int ans = N / 100 ; int A = ans * 100 + ans * 10 + ans ; if ( A >= N ) { ans = ans ; } else { ans ++ ; } for ( int i = 0 ; i < 3 ; i ++ ) { System . out . print ( ans ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class Acdbfv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int acdbfv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( method ( acdbfv , b , c ) ) ; } static int method ( int acdbfv , int b , int c ) { int divisor = 0 ; for ( int i = acdbfv ; i < b + 1 ; i ++ ) { if ( c % i == 0 ) { divisor ++ ; } } return divisor ; } } import java . util . Scanner ; public class Jomcloa { public static void main ( String [ ] args ) { Main2 cc = new Main2 ( ) ; cc . yesNo ( ) ; } } class Jomcloa { public void yesNo ( ) { Scanner scan = new Scanner ( System . in ) ; int [ ] abc = new int [ 3 ] ; for ( int jomcloa = 0 ; jomcloa < 3 ; jomcloa ++ ) { abc [ jomcloa ] = scan . nextInt ( ) ; } if ( abc [ 0 ] < abc [ 1 ] && abc [ 1 ] < abc [ 2 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Jwqifir { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] arr = new int [ 3 ] ; for ( int jwqifir = 0 ; jwqifir < 3 ; jwqifir ++ ) { arr [ jwqifir ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; System . out . println ( Math . abs ( arr [ 1 ] - arr [ 0 ] ) + Math . abs ( arr [ 2 ] - arr [ 1 ] ) ) ; } } import java . io . * ; import java . util . * ; public class Tqglxwe { private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static StringTokenizer st ; private static int readInt ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return Integer . parseInt ( st . nextToken ( ) ) ; } public static void main ( String [ ] args ) throws IOException { int tqglxwe = readInt ( ) ; long D = readInt ( ) ; long D_squared = D * D ; int count = 0 ; for ( int i = 0 ; i < tqglxwe ; i ++ ) { long dx = readInt ( ) ; long dy = readInt ( ) ; if ( dx * dx + dy * dy <= D_squared ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class Qkhdok { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qkhdok = sc . nextInt ( ) ; String [ ] a = new String [ qkhdok ] ; for ( int i = 0 ; i < qkhdok ; i ++ ) { a [ i ] = sc . next ( ) ; } sc . close ( ) ; Arrays . sort ( a ) ; int yono = 1 ; for ( int i = 1 ; i < qkhdok ; i ++ ) { if ( ! a [ i - 1 ] . equals ( a [ i ] ) ) yono ++ ; } System . out . println ( yono ) ; } } import java . util . Scanner ; public class Nwfekx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int nwfekx = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; String s = scanner . next ( ) ; char conv = Character . toLowerCase ( s . charAt ( k - 1 ) ) ; String pre = ( k == 1 ? " " : s . substring ( 0 , k - 1 ) ) ; String next = ( k == nwfekx ? " " : s . substring ( k ) ) ; System . out . println ( pre + conv + next ) ; } } import java . util . * ; class Wwvgs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wwvgs = sc . nextInt ( ) ; int [ ] a = new int [ wwvgs + 1 ] ; int [ ] w = new int [ wwvgs + 1 ] ; int [ ] s = new int [ wwvgs + 1 ] ; int [ ] indice = new int [ wwvgs ] ; a [ 0 ] = 0 ; for ( int i = 1 ; i <= wwvgs ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int nr_breaks = 0 ; int cur = 1 ; for ( int i = 1 ; i <= wwvgs ; i ++ ) { if ( a [ i ] == cur ) { cur ++ ; } else { nr_breaks ++ ; } } if ( nr_breaks == wwvgs ) { System . out . println ( - 1 ) ; } else { System . out . println ( nr_breaks ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ffnjdhu { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } public void run ( ) { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String line ; String [ ] num ; int ffnjdhu , b , t , gdc ; long lcm ; StringBuilder result = new StringBuilder ( ) ; while ( true ) { if ( ( ( line = br . readLine ( ) ) == null ) || line . isEmpty ( ) ) break ; num = line . split ( " " ) ; ffnjdhu = Integer . parseInt ( num [ 0 ] ) ; b = Integer . parseInt ( num [ 1 ] ) ; if ( ffnjdhu < b ) { t = ffnjdhu ; ffnjdhu = b ; b = t ; } gdc = gdc ( ffnjdhu , b ) ; lcm = lcm ( ffnjdhu , b , gdc ) ; result . append ( gdc ) . append ( " " ) . append ( lcm ) . append ( " \n " ) ; } System . out . print ( result ) ; } catch ( IOException e ) { System . out . println ( " IOException! " ) ; } } private int gdc ( int x , int y ) { int d = x % y ; if ( d == 0 ) return y ; else return gdc ( y , d ) ; } private long lcm ( long x , long y , int gdc ) { return x * y / gdc ; } } import static java . lang . Math . log10 ; import java . util . * ; public class Nnxulwa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nnxulwa = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= nnxulwa ; i ++ ) { int temp = i ; int count = 0 ; while ( temp != 0 ) { temp = temp / 10 ; count ++ ; } if ( count % 2 == 1 ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . io . * ; public class Vmbzfs { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; String ans = " " ; for ( int vmbzfs = 0 ; vmbzfs < line . length ( ) ; vmbzfs ++ ) { String str = line . substring ( vmbzfs , vmbzfs + 1 ) ; if ( str . equals ( str . toUpperCase ( ) ) ) { ans += str . toLowerCase ( ) ; } else { ans += str . toUpperCase ( ) ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Omwzea { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String o = " " ; long omwzea = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; k = k - omwzea ; omwzea = Math . max ( - k , 0 ) ; if ( k > 0 ) b = Math . max ( b - k , 0 ) ; o = Long . toString ( omwzea , 10 ) + " " + Long . toString ( b , 10 ) ; System . out . println ( o ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Qwgirv { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int qwgirv , b ; ArrayList < String > str = new ArrayList < String > ( ) ; String [ ] result ; while ( s . hasNext ( ) ) { qwgirv = s . nextInt ( ) ; b = s . nextInt ( ) ; System . out . println ( String . valueOf ( qwgirv + b ) . length ( ) ) ; } } } import java . util . ArrayList ; import java . util . Comparator ; import java . util . List ; import java . util . Scanner ; class Yuqcz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yuqcz = Integer . parseInt ( sc . next ( ) ) ; List < Integer > numList = new ArrayList < > ( ) ; for ( int i = 0 ; i < yuqcz ; i ++ ) { numList . add ( Integer . parseInt ( sc . next ( ) ) ) ; } numList . sort ( Comparator . reverseOrder ( ) ) ; int preNum = 0 ; List < Integer > removeList = new ArrayList < > ( ) ; for ( int i = 0 ; i < numList . size ( ) ; i ++ ) { int n = numList . get ( i ) . intValue ( ) ; if ( n == preNum ) { removeList . add ( i ) ; } else { preNum = n ; } } removeList . sort ( Comparator . reverseOrder ( ) ) ; for ( Integer i : removeList ) { numList . remove ( i . intValue ( ) ) ; } System . out . println ( numList . size ( ) ) ; } } import java . util . * ; public class Nxhqfru { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nxhqfru = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; int result = nxhqfru * b ; System . out . println ( result ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Ooegvg { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int ooegvg = stdIn . nextInt ( ) ; int [ ] a = new int [ ooegvg ] ; int [ ] b = new int [ ooegvg ] ; int high = 0 ; for ( int i = 0 ; i < ooegvg ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; b [ i ] = a [ i ] ; high = Math . max ( high , a [ i ] ) ; } Arrays . sort ( b ) ; for ( int i = 0 ; i < ooegvg ; i ++ ) { if ( a [ i ] != high ) { System . out . println ( high ) ; } else { System . out . println ( b [ ooegvg - 2 ] ) ; } } } } import java . util . Scanner ; public class Ozeyo { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int ozeyo = sc . nextInt ( ) ; for ( int i = ozeyo ; i <= 110000 ; i ++ ) { if ( isPrime ( i ) ) { System . out . println ( i ) ; return ; } } } public static boolean isPrime ( int n ) { for ( int i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { return false ; } } return true ; } } import java . io . IOException ; import java . util . Scanner ; public class Maxphdy { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int maxphdy = Integer . parseInt ( sc . nextLine ( ) ) ; int counter = 0 ; int [ ] [ ] result = new int [ maxphdy ] [ 2 ] ; for ( int i = 0 ; i < maxphdy ; i ++ ) { result [ i ] [ 0 ] = sc . nextInt ( ) ; result [ i ] [ 1 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < maxphdy ; i ++ ) { if ( result [ i ] [ 0 ] == result [ i ] [ 1 ] ) { counter ++ ; if ( counter == 3 ) { break ; } } else { counter = 0 ; } } if ( counter == 3 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( ( " No " ) ) ; } } } import java . util . Scanner ; public class Fdlux { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int fdlux = scan . nextInt ( ) ; int S = scan . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i <= fdlux ; i ++ ) { for ( int j = 0 ; j <= fdlux ; j ++ ) { if ( S - i - j >= 0 && S - i - j <= fdlux ) count ++ ; } } System . out . println ( count ) ; } } } import java . util . Scanner ; import java . util . HashMap ; import java . util . TreeMap ; import java . util . Arrays ; import java . util . Stack ; public class Rsurudh { static Scanner scn = new Scanner ( System . in ) ; static long rsurudh = 0 , max = 0 ; public static void main ( String [ ] args ) { long n = scn . nextLong ( ) ; long min = Long . MAX_VALUE , a , b ; for ( long i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { a = i ; b = n / i ; if ( ( a + b - 2 ) < min ) min = a + b - 2 ; } } System . out . println ( min ) ; } public static void coin ( int [ ] arr , int sum , int n , int prev ) { if ( sum == n ) { rsurudh ++ ; return ; } if ( sum > n ) return ; for ( int i = prev ; i < arr . length ; i ++ ) { coin ( arr , sum + arr [ i ] , n , i ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class Jsacjba { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String [ ] tmpArray = br . readLine ( ) . split ( " " ) ; int jsacjba = Integer . parseInt ( tmpArray [ 0 ] ) ; int b = Integer . parseInt ( tmpArray [ 1 ] ) ; if ( jsacjba == 0 && b == 0 ) { break ; } for ( int i = 0 ; i < jsacjba ; i ++ ) { for ( int j = 0 ; j < b ; j ++ ) { if ( i != 0 && i != jsacjba - 1 && j != 0 && j != b - 1 ) { System . out . print ( " . " ) ; } else { System . out . print ( " # " ) ; } } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Dvswne { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Integer s = Integer . parseInt ( sc . next ( ) ) ; List < Integer > list = new ArrayList < > ( ) ; list . add ( s ) ; int dvswne = 0 ; boolean doContinue = true ; for ( int i = 0 ; doContinue ; i ++ ) { if ( s % 2 == 0 ) { if ( list . contains ( s / 2 ) ) { dvswne = i + 2 ; doContinue = false ; } else { s = s / 2 ; list . add ( s ) ; } } else { if ( list . contains ( 3 * s + 1 ) ) { dvswne = i + 2 ; doContinue = false ; } else { s = 3 * s + 1 ; list . add ( s ) ; } } } System . out . println ( dvswne ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Meeile { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int meeile = Integer . parseInt ( sc . next ( ) ) ; int D = Integer . parseInt ( sc . next ( ) ) ; int [ ] [ ] arrayTwoDimension = new int [ meeile ] [ D ] ; for ( int i = 0 ; i < meeile ; i ++ ) { for ( int j = 0 ; j < D ; j ++ ) { arrayTwoDimension [ i ] [ j ] = sc . nextInt ( ) ; } } sc . close ( ) ; int count = 0 ; for ( int i = 0 ; i < meeile ; i ++ ) { for ( int j = i + 1 ; j < meeile ; j ++ ) { double squareValue = 0 ; for ( int k = 0 ; k < D ; k ++ ) { double value = Math . abs ( arrayTwoDimension [ i ] [ k ] - arrayTwoDimension [ j ] [ k ] ) ; double square = value * value ; squareValue = squareValue + square ; } double judge = Math . sqrt ( squareValue ) ; if ( judge == Math . floor ( judge ) ) { count ++ ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Bpgrrxv { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String input = stdIn . nextLine ( ) ; String [ ] a = input . split ( " " ) ; int bpgrrxv = Integer . parseInt ( a [ 0 ] ) ; int y = Integer . parseInt ( a [ 1 ] ) ; if ( bpgrrxv > 0 && bpgrrxv < 101 && y > 0 && y < 101 ) { int ans = y - bpgrrxv * 2 ; if ( ans == 0 ) { System . out . println ( " Yes " ) ; } else if ( ans > 0 && ( ans % 2 ) == 0 ) { for ( int i = 0 ; i < bpgrrxv ; i ++ ) { ans = ans - 2 ; if ( ans == 0 ) { System . out . println ( " Yes " ) ; break ; } } if ( ans != 0 ) { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class Ylauar { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ylauar = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int [ ] A = new int [ M ] ; int cnt = 0 ; int [ ] B = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < ylauar ; i ++ ) { int det = 0 ; for ( int j = 0 ; j < M ; j ++ ) { det += B [ j ] * sc . nextInt ( ) ; } det += C ; if ( det > 0 ) { cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Loucov { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int loucov = scanner . nextInt ( ) ; String N = scanner . next ( ) ; if ( N . length ( ) <= loucov ) { System . out . println ( N ) ; } else { System . out . println ( N . substring ( 0 , loucov ) + " ... " ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Aqxww { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aqxww = Integer . parseInt ( sc . next ( ) ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Math . min ( aqxww * a , b ) ; System . out . println ( c ) ; } } import java . util . * ; public class Daajuf { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int daajuf = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = daajuf * a ; if ( ans >= b ) { ans = b ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Cwryc { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int cwryc = reader . nextInt ( ) ; int [ ] arr = new int [ cwryc ] ; int a = 0 ; int b = 0 ; for ( int i = 0 ; i < cwryc ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; } Arrays . sort ( arr ) ; for ( int i = cwryc - 1 ; i >= 0 ; i -= 2 ) { a += arr [ i ] ; if ( i > 0 ) { b += arr [ i - 1 ] ; } } System . out . print ( a - b ) ; reader . close ( ) ; } } import java . util . * ; public class Pejash { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pejash = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int xymin = Math . min ( x , y ) ; long ans = xymin * Math . min ( pejash + b , c * 2 ) ; x -= xymin ; y -= xymin ; if ( x == 0 ) { ans += y * Math . min ( b , c * 2 ) ; } else { ans += x * Math . min ( pejash , c * 2 ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class Qgnerc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qgnerc = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = qgnerc * ( qgnerc - 1 ) / 2 ; int d = b * ( b - 1 ) / 2 ; System . out . println ( c + d ) ; } } import java . util . Scanner ; class Bsdkqa { public static void main ( String [ ] arg ) { Scanner in = new Scanner ( System . in ) ; String input = in . nextLine ( ) ; while ( ! input . equals ( " - " ) ) { String tmp = in . nextLine ( ) ; int bsdkqa = Integer . parseInt ( tmp ) ; StringBuffer sb = new StringBuffer ( input ) ; for ( int i = 0 ; i < bsdkqa ; i ++ ) { tmp = in . nextLine ( ) ; int h_pos = Integer . parseInt ( tmp ) ; String del_str = sb . substring ( 0 , h_pos ) ; sb = sb . delete ( 0 , h_pos ) ; sb . append ( del_str ) ; } System . out . println ( sb . toString ( ) ) ; input = in . nextLine ( ) ; } } } import java . util . Scanner ; public class Ebufb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ebufb = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; int [ ] cnts = new int [ M ] ; for ( int i = 0 ; i < ebufb ; i ++ ) { int k = scanner . nextInt ( ) ; for ( int j = 0 ; j < k ; j ++ ) { int idx = scanner . nextInt ( ) ; idx -- ; cnts [ idx ] ++ ; } } int cnt = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( cnts [ i ] == ebufb ) { cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Lkdyiyj { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int lkdyiyj = scanner . nextInt ( ) ; if ( lkdyiyj < 105 ) { lkdyiyj = 0 ; } else if ( lkdyiyj < 135 ) { lkdyiyj = 1 ; } else if ( lkdyiyj < 165 ) { lkdyiyj = 2 ; } else if ( lkdyiyj < 189 ) { lkdyiyj = 3 ; } else if ( lkdyiyj < 195 ) { lkdyiyj = 4 ; } else { lkdyiyj = 5 ; } System . out . println ( lkdyiyj ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Jbrvwyz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jbrvwyz = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int [ ] times = new int [ 3 ] ; times [ 0 ] = jbrvwyz + q ; times [ 1 ] = q + r ; times [ 2 ] = r + jbrvwyz ; int min = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( i == 0 ) { min = times [ 0 ] ; } else { min = Math . min ( min , times [ i ] ) ; } } System . out . println ( min ) ; } } import java . util . Scanner ; public class Leeuli { public static void main ( String [ ] args ) { Scanner s1 = new Scanner ( System . in ) ; int leeuli = s1 . nextInt ( ) ; int A = s1 . nextInt ( ) ; int B = s1 . nextInt ( ) ; for ( int i = A ; i <= B ; i ++ ) { if ( i % leeuli == 0 ) { System . out . println ( " OK " ) ; return ; } } System . out . println ( " NG " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Fgumu { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = br . readLine ( ) ; String key = br . readLine ( ) ; word = word + word . substring ( 0 , key . length ( ) - 1 ) ; if ( bmStringSearch ( word , key ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } private static boolean bmStringSearch ( String word , String key ) { int [ ] table = new int [ 256 ] ; for ( int fgumu = 0 ; fgumu < table . length ; fgumu ++ ) { table [ fgumu ] = key . length ( ) ; } for ( int fgumu = 0 ; fgumu < key . length ( ) ; fgumu ++ ) { table [ key . charAt ( fgumu ) ] = key . length ( ) - fgumu - 1 ; } int wordIndex = key . length ( ) - 1 ; while ( wordIndex < word . length ( ) ) { int keyIndex = key . length ( ) - 1 ; while ( word . charAt ( wordIndex ) == key . charAt ( keyIndex ) ) { if ( keyIndex == 0 ) { return true ; } wordIndex -- ; keyIndex -- ; } if ( table [ word . charAt ( wordIndex ) ] > key . length ( ) - keyIndex ) { wordIndex += table [ word . charAt ( wordIndex ) ] ; } else { wordIndex += key . length ( ) - keyIndex ; } } return false ; } } import java . util . Scanner ; public class Agmzy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int agmzy = sc . nextInt ( ) ; int [ ] a = new int [ agmzy ] ; for ( int i = 0 ; i < agmzy ; i ++ ) { a [ i ] = sc . nextInt ( ) - 1 ; } int x = 0 ; int c = 0 ; for ( int i = 0 ; i < agmzy ; i ++ ) { c ++ ; x = a [ x ] ; if ( x == 1 ) { System . out . println ( c ) ; return ; } } System . out . println ( " -1 " ) ; } } import java . util . Scanner ; class Zpvwli { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; while ( stdIn . hasNext ( ) ) { System . out . println ( ( int ) Math . log10 ( stdIn . nextInt ( ) + stdIn . nextInt ( ) ) + 1 ) ; } } } import java . util . Scanner ; public class Sobibg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] num = new int [ 3000 ] ; int [ ] num2 = new int [ 3000 ] ; for ( int sobibg = 0 ; sobibg < 3000 ; sobibg ++ ) { String line = sc . nextLine ( ) ; String [ ] ss = line . split ( " " ) ; num [ sobibg ] = Integer . parseInt ( ss [ 0 ] ) ; num2 [ sobibg ] = Integer . parseInt ( ss [ 1 ] ) ; if ( num [ sobibg ] == 0 && num2 [ sobibg ] == 0 ) { break ; } } for ( int sobibg = 0 ; sobibg < num . length ; sobibg ++ ) { if ( num [ sobibg ] == 0 && num2 [ sobibg ] == 0 ) { break ; } if ( num [ sobibg ] < num2 [ sobibg ] ) { System . out . println ( num [ sobibg ] + " " + num2 [ sobibg ] ) ; } if ( num [ sobibg ] > num2 [ sobibg ] ) { System . out . println ( num2 [ sobibg ] + " " + num [ sobibg ] ) ; } if ( num [ sobibg ] == num2 [ sobibg ] ) { System . out . println ( num [ sobibg ] + " " + num2 [ sobibg ] ) ; } } } } import java . util . * ; public class Ggyqv { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " Yes " ; for ( int ggyqv = 0 ; ggyqv < s . length ( ) ; ggyqv ++ ) { if ( ggyqv % 2 == 0 && s . charAt ( ggyqv ) == 'L' ) { ans = " No " ; break ; } else if ( ggyqv % 2 == 1 && s . charAt ( ggyqv ) == 'R' ) { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; class Httdv { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int httdv = scanner . nextInt ( ) ; int t = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; System . out . print ( t * s >= httdv ? " Yes " : " No " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Pmbtro { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int pmbtro = s . nextInt ( ) ; int b = s . nextInt ( ) ; int c = s . nextInt ( ) ; int d = s . nextInt ( ) ; int ans1 = 0 , ans2 = 0 ; if ( pmbtro % d == 0 ) { ans1 = pmbtro / d ; } else { ans1 = pmbtro / d + 1 ; } if ( c % b == 0 ) { ans2 = c / b ; } else { ans2 = c / b + 1 ; } if ( ans1 >= ans2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . * ; class Icbouz { public static void main ( String [ ] args ) { int icbouz = 0 ; int x = 0 ; Scanner scan = new Scanner ( System . in ) ; icbouz = scan . nextInt ( ) ; for ( int i = 1 ; i != icbouz + 1 ; i ++ ) { x = i ; if ( i % 3 == 0 ) { System . out . print ( " " + i ) ; } else { while ( x != 0 ) { if ( x % 10 == 3 ) { System . out . print ( " " + i ) ; break ; } else { x /= 10 ; } } } } System . out . println ( " " ) ; } } import java . util . * ; class Nwxktj { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int nwxktj = s . nextInt ( ) ; String a = s . next ( ) , b = s . next ( ) ; char [ ] c = new char [ nwxktj * 2 ] ; for ( int i = 0 ; i < nwxktj ; ++ i ) { c [ i * 2 ] = a . charAt ( i ) ; c [ i * 2 + 1 ] = b . charAt ( i ) ; } System . out . println ( c ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; public class Uhytn { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long uhytn = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = a * ( uhytn / ( a + b ) ) ; uhytn %= ( a + b ) ; if ( uhytn >= a ) { System . out . println ( ans + a ) ; } else { System . out . println ( ans + uhytn ) ; } } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Iumbxri { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iumbxri = sc . nextInt ( ) ; Integer [ ] arrays = new Integer [ iumbxri ] ; int stepCnt = 0 ; int stepSize = 101 ; for ( int i = 0 ; i < arrays . length ; i ++ ) { arrays [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( arrays , Collections . reverseOrder ( ) ) ; for ( int size : arrays ) { if ( stepSize > size ) { stepCnt ++ ; stepSize = size ; } } System . out . println ( stepCnt ) ; } } import java . util . Scanner ; public class Uyxqs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uyxqs = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( solve ( uyxqs , B ) ) ; sc . close ( ) ; } static int solve ( int uyxqs , int B ) { if ( uyxqs >= 13 ) { return B ; } else if ( uyxqs >= 6 ) { return B / 2 ; } else { return 0 ; } } } import java . util . * ; public class Mozmn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mozmn = sc . nextInt ( ) ; int [ ] arr = new int [ mozmn ] ; for ( int i = 0 ; i < mozmn ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int left = 0 ; int count = 0 ; while ( left < arr . length ) { if ( arr [ left ] == 0 ) left ++ ; else { int right = left ; while ( right < arr . length && arr [ right ] != 0 ) { arr [ right ++ ] -- ; } count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; class Wvbwnzm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; String [ ] str_split = str . split ( " " , 0 ) ; int [ ] nums = new int [ str_split . length ] ; int wvbwnzm = 0 ; for ( int i = 0 ; i < str_split . length ; i ++ ) { switch ( str_split [ i ] . charAt ( 0 ) ) { case '+' : wvbwnzm -- ; nums [ wvbwnzm - 1 ] = nums [ wvbwnzm - 1 ] + nums [ wvbwnzm ] ; break ; case '-' : wvbwnzm -- ; nums [ wvbwnzm - 1 ] = nums [ wvbwnzm - 1 ] - nums [ wvbwnzm ] ; break ; case '*' : wvbwnzm -- ; nums [ wvbwnzm - 1 ] = nums [ wvbwnzm - 1 ] * nums [ wvbwnzm ] ; break ; default : nums [ wvbwnzm ] = Integer . parseInt ( str_split [ i ] ) ; wvbwnzm ++ ; break ; } } System . out . println ( nums [ 0 ] ) ; } } import java . util . Scanner ; public class Pgutd { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long pgutd , c , b , a , mal = 0 , need , sum = 0 ; a = in . nextLong ( ) ; b = in . nextLong ( ) ; c = in . nextLong ( ) ; if ( a >= c ) { sum = a - c ; mal = b ; } else if ( a <= c ) { sum = c - a ; mal = b - sum ; if ( b <= sum ) { mal = 0 ; } if ( a <= c ) { sum = 0 ; } } System . out . println ( sum + " " + mal ) ; } } import java . util . * ; import java . io . * ; public class Sewecan { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; String [ ] input = br . readLine ( ) . split ( " " ) ; int sewecan = Integer . parseInt ( input [ 0 ] ) ; int a = Integer . parseInt ( input [ 1 ] ) ; int b = Integer . parseInt ( input [ 2 ] ) ; int ans = 0 ; for ( int i = 1 ; i <= sewecan ; i ++ ) { int num = i ; int total = 0 ; while ( num > 0 ) { total += num % 10 ; num /= 10 ; } if ( a <= total && total <= b ) { ans += i ; } } out . println ( ans ) ; out . close ( ) ; } } import java . util . * ; public class Hgmhoj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String text ; text = scan . next ( ) ; char [ ] s = text . toCharArray ( ) ; text = scan . next ( ) ; char [ ] p = text . toCharArray ( ) ; func ( s , p , 0 ) ; } static void func ( char [ ] s , char [ ] p , int n ) { for ( int hgmhoj = 0 ; hgmhoj < s . length ; hgmhoj ++ ) { if ( n == s . length ) { System . out . println ( " No " ) ; break ; } else if ( s [ hgmhoj + n >= s . length ? hgmhoj + n - s . length : hgmhoj + n ] != p [ hgmhoj ] ) { n ++ ; func ( s , p , n ) ; break ; } else if ( hgmhoj == p . length - 1 ) { System . out . println ( " Yes " ) ; break ; } } } } import java . util . * ; public class Rpmdnb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rpmdnb = sc . nextInt ( ) ; long [ ] b = new long [ rpmdnb ] ; long MAX = ( long ) Math . pow ( 10 , 18 ) ; long result = 1 ; for ( int i = 0 ; i < rpmdnb ; i ++ ) { b [ i ] = sc . nextLong ( ) ; if ( b [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } for ( int i = 0 ; i < rpmdnb ; i ++ ) { if ( MAX / result < b [ i ] ) { System . out . println ( - 1 ) ; return ; } else { result *= b [ i ] ; } } System . out . println ( result ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Dxlneo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dxlneo = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; Integer [ ] button = { dxlneo , b , dxlneo - 1 , b - 1 } ; Arrays . sort ( button ) ; int result = button [ 3 ] + button [ 2 ] ; System . out . println ( result ) ; } } import java . io . BufferedInputStream ; import java . util . * ; public class Zffxv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( new BufferedInputStream ( System . in ) ) ; int zffxv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( zffxv + b + c >= 22 ) System . out . println ( " bust " ) ; else System . out . println ( " win " ) ; } private static int solve ( String s , int n ) { return n ; } private static int nextInt ( Scanner sc ) { return Integer . valueOf ( sc . nextLine ( ) ) ; } } import java . util . * ; public class Usfhp { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int usfhp = in . nextInt ( ) ; int B = in . nextInt ( ) ; String S = in . next ( ) ; char [ ] s_chars = S . toCharArray ( ) ; int flag = 0 ; if ( s_chars [ usfhp ] == '-' ) { for ( int i = 0 ; i < usfhp + B + 1 ; i ++ ) { if ( s_chars [ i ] == '-' ) { flag ++ ; } } } if ( flag == 1 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; public class Zstaaw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double zstaaw = sc . nextDouble ( ) ; double H = sc . nextDouble ( ) ; double x = sc . nextDouble ( ) ; double y = sc . nextDouble ( ) ; System . out . printf ( " %.6f " , zstaaw * H / 2 ) ; if ( x == zstaaw / 2 && y == H / 2 ) { System . out . println ( 1 ) ; } else { System . out . println ( 0 ) ; } } } import java . util . * ; class Ehicaeb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ehicaeb = sc . next ( ) ; ehicaeb = ehicaeb . replace ( " 1 " , " * " ) . replace ( " 9 " , " 1 " ) . replace ( " * " , " 9 " ) ; System . out . println ( ehicaeb ) ; } } import java . util . Scanner ; public class Qljawp { public static void main ( String ... args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int qljawp = 0 ; String [ ] s = sc . next ( ) . split ( " " ) ; for ( String i : s ) { if ( i . equals ( " + " ) ) { qljawp ++ ; } else { qljawp -- ; } } System . out . println ( qljawp ) ; } } } import java . math . BigDecimal ; import java . math . RoundingMode ; import java . util . HashMap ; import java . util . Scanner ; public class Nnjeif { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigDecimal result = execute ( sc . nextLine ( ) ) ; System . out . println ( result . toPlainString ( ) ) ; } public static BigDecimal execute ( String value ) { BigDecimal totalLength = new BigDecimal ( value ) ; BigDecimal sideLength = totalLength . divide ( BigDecimal . valueOf ( 3 ) , 7 , RoundingMode . HALF_EVEN ) ; return sideLength . multiply ( sideLength ) . multiply ( sideLength ) ; } } import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collection ; import java . util . Collections ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Scanner ; public class Schwaui { public static void main ( String [ ] args ) { solve ( ) ; } public static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int schwaui = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] ans = new int [ schwaui ] ; Arrays . fill ( ans , 0 ) ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; a -- ; b -- ; ans [ a ] ++ ; ans [ b ] ++ ; } sc . close ( ) ; for ( int i = 0 ; i < schwaui ; i ++ ) { out . println ( ans [ i ] ) ; } out . flush ( ) ; } static class Schwaui { int a , b ; public Pair ( int a , int b ) { this . a = a ; this . b = b ; } } } 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 Hxtaeqz { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AStationAndBus solver = new AStationAndBus ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Hxtaeqz { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String x = in . next ( ) ; for ( int hxtaeqz = 0 ; hxtaeqz < 3 ; hxtaeqz ++ ) { if ( x . charAt ( hxtaeqz ) != x . charAt ( ( hxtaeqz + 1 ) % 3 ) ) { out . println ( " Yes " ) ; return ; } } out . println ( " No " ) ; } } static class Hxtaeqz { 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 ( ) ; } } } import java . time . temporal . TemporalUnit ; import java . util . * ; public class Czkxf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String czkxf = sc . next ( ) ; if ( czkxf . equals ( " MON " ) ) { System . out . println ( 6 ) ; } else if ( czkxf . equals ( " TUE " ) ) { System . out . println ( 5 ) ; } else if ( czkxf . equals ( " WED " ) ) { System . out . println ( 4 ) ; } else if ( czkxf . equals ( " THU " ) ) { System . out . println ( 3 ) ; } else if ( czkxf . equals ( " FRI " ) ) { System . out . println ( 2 ) ; } else if ( czkxf . equals ( " SAT " ) ) { System . out . println ( 1 ) ; } else if ( czkxf . equals ( " SUN " ) ) { System . out . println ( 7 ) ; } } } import java . util . * ; public class Thzcg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int thzcg = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; int min = 300 , total = 0 ; for ( int i = 1 ; i <= thzcg ; i ++ ) { total += L + i - 1 ; } if ( L >= 0 ) { System . out . println ( total - L ) ; } else if ( L < 0 ) { if ( L + thzcg > 0 ) { System . out . println ( total ) ; } else { System . out . println ( total - ( L + thzcg - 1 ) ) ; } } } } import java . io . * ; import java . util . * ; import java . lang . * ; class Rcsjy { public static void main ( String [ ] args ) throws java . lang . NumberFormatException { Scanner scan = new Scanner ( System . in ) ; StringBuilder input = new StringBuilder ( ) ; do { input . append ( scan . nextLine ( ) ) ; } while ( scan . hasNext ( ) ) ; for ( char rcsjy = 'a' ; rcsjy <= 'z' ; rcsjy ++ ) { int count = 0 ; for ( int j = 0 ; j < input . length ( ) ; j ++ ) { if ( input . toString ( ) . charAt ( j ) == rcsjy || Character . toUpperCase ( input . toString ( ) . charAt ( j ) ) == Character . toUpperCase ( rcsjy ) ) { count ++ ; } } System . out . println ( rcsjy + " : " + count ) ; } } } import java . util . * ; public class Fcaapzg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int fcaapzg = Integer . MAX_VALUE ; int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < 5 ; i ++ ) { int n = sc . nextInt ( ) ; fcaapzg = Math . fcaapzg ( fcaapzg , n ) ; max = Math . max ( max , n ) ; } int k = sc . nextInt ( ) ; if ( max - fcaapzg > k ) System . out . println ( " :( " ) ; else System . out . println ( " Yay! " ) ; } } import java . util . * ; class Jhatxnw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long jhatxnw = sc . nextInt ( ) ; long quo = jhatxnw / 15 ; long rem = jhatxnw % 15 ; long laps = calcLaps ( quo ) ; long rems = calcRems ( quo , rem ) ; System . out . println ( laps + rems ) ; } private static long calcLaps ( long quo ) { if ( quo == 0 ) { return 0 ; } else { long l = quo * quo ; int aLap = 60 ; return aLap * l ; } } private static long calcRems ( long quo , long rem ) { if ( rem == 0 ) { return 0 ; } else { long lapBottom = 15 * quo ; int i = 1 ; int valid = 0 ; int fraction = 0 ; while ( i <= rem ) { if ( i % 3 == 0 || i % 5 == 0 ) { i ++ ; } else { fraction += i ; valid ++ ; i ++ ; } } return lapBottom * valid + fraction ; } } } import java . util . Scanner ; public class Zftjia { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { while ( sc . hasNext ( ) ) { int zftjia = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( digit ( zftjia , b ) ) ; } } private static int digit ( int zftjia , int b ) { int dg = Integer . toString ( zftjia + b ) . length ( ) ; return dg ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Brjvxhl { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = reader . readLine ( ) . split ( " " ) ; int brjvxhl = Integer . parseInt ( str [ 0 ] ) ; int B = Integer . parseInt ( str [ 1 ] ) ; if ( 1 <= brjvxhl && brjvxhl <= 9 && 1 <= B && B <= 9 ) { System . out . println ( brjvxhl * B ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . Scanner ; public class Hpuadis { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hpuadis = sc . nextInt ( ) ; int [ ] a = new int [ hpuadis ] ; for ( int i = 0 ; i < hpuadis ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int b = 1 ; int c = 0 ; int d = 0 ; while ( b != 2 ) { d += 1 ; c = b ; b = a [ b - 1 ] ; if ( b == 0 ) { System . out . println ( - 1 ) ; return ; } a [ c - 1 ] = 0 ; } System . out . println ( d ) ; } } import java . util . * ; public class Gdkrmfk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int gdkrmfk = scan . nextInt ( ) ; int money = scan . nextInt ( ) ; if ( gdkrmfk >= 13 ) { System . out . print ( money ) ; } else if ( gdkrmfk >= 6 ) { System . out . print ( money / 2 ) ; } else if ( gdkrmfk >= 0 ) { System . out . print ( 0 ) ; } } } import java . util . Scanner ; public class Fvxkyr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fvxkyr = sc . nextInt ( ) ; int [ ] array = new int [ fvxkyr ] ; for ( int i = 1 ; i < fvxkyr ; i ++ ) array [ sc . nextInt ( ) - 1 ] ++ ; sc . close ( ) ; for ( int i = 0 ; i < fvxkyr ; i ++ ) System . out . println ( array [ i ] ) ; } } import java . util . * ; public class Uqzht { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; int uqzht = 0 ; int count1 = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '1' ) count1 ++ ; if ( S . charAt ( i ) == '0' ) uqzht ++ ; } System . out . println ( 2 * Math . min ( count1 , uqzht ) ) ; } } import java . util . * ; public class Vrgvnh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String [ ] line = sc . nextLine ( ) . split ( " " ) ; int vrgvnh = Integer . parseInt ( line [ 0 ] ) ; int buttonB = Integer . parseInt ( line [ 1 ] ) ; int ans = 0 ; if ( vrgvnh > buttonB ) { ans += vrgvnh ; vrgvnh -- ; } else { ans += buttonB ; buttonB -- ; } if ( vrgvnh > buttonB ) { ans += vrgvnh ; } else { ans += buttonB ; } System . out . println ( ans ) ; } } import java . math . BigInteger ; import java . util . * ; public class Gnszuv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigInteger a = BigInteger . valueOf ( sc . nextLong ( ) ) ; BigInteger b = BigInteger . valueOf ( sc . nextLong ( ) ) ; BigInteger c = BigInteger . valueOf ( sc . nextLong ( ) ) ; BigInteger d = BigInteger . valueOf ( sc . nextLong ( ) ) ; BigInteger mul = a . multiply ( c ) ; if ( mul . compareTo ( a . multiply ( d ) ) < 0 ) mul = a . multiply ( d ) ; if ( mul . compareTo ( b . multiply ( c ) ) < 0 ) mul = b . multiply ( c ) ; if ( mul . compareTo ( b . multiply ( d ) ) < 0 ) mul = b . multiply ( d ) ; System . out . println ( mul ) ; } } import java . util . * ; public class Pvkvy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pvkvy = sc . nextInt ( ) ; double a = 2 * pvkvy * Math . PI ; System . out . println ( a ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . List ; public class Fgfwoz { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] tmp = br . readLine ( ) . split ( " " ) ; int fgfwoz = Integer . parseInt ( tmp [ 0 ] ) ; int M = Integer . parseInt ( tmp [ 1 ] ) ; List < Integer > L = new ArrayList < Integer > ( ) ; List < Integer > R = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < M ; i ++ ) { tmp = br . readLine ( ) . split ( " " ) ; L . add ( Integer . parseInt ( tmp [ 0 ] ) ) ; R . add ( Integer . parseInt ( tmp [ 1 ] ) ) ; } L . sort ( null ) ; R . sort ( null ) ; int max = R . get ( 0 ) ; int min = L . get ( L . size ( ) - 1 ) ; if ( max - min + 1 < 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( max - min + 1 ) ; } } } import java . util . Scanner ; public class Xkowne { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int xkowne = sc . nextInt ( ) ; int debt = 100000 ; int roundUpNum = 1000 ; for ( int i = 0 ; i < xkowne ; i ++ ) { debt *= 1.05 ; debt = ( int ) Math . ceil ( ( double ) debt / roundUpNum ) * roundUpNum ; } System . out . println ( debt ) ; } } import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Deque ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Map ; import java . util . Queue ; import java . util . Scanner ; import java . util . Set ; public class Dojjsej { public static void main ( String [ ] args ) { execute16_4 ( ) ; } private static void execute16_4 ( ) { try ( Scanner sc = new Scanner ( System . in ) ) { int dojjsej = sc . nextInt ( ) ; System . out . println ( dojjsej + dojjsej * dojjsej + dojjsej * dojjsej * dojjsej ) ; } } } import java . util . Scanner ; public class Cdanzk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cdanzk = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; if ( cdanzk >= 10 || B >= 10 ) { System . out . println ( - 1 ) ; } else { System . out . println ( cdanzk * B ) ; } } } import java . util . Scanner ; public class Wwblwxp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wwblwxp = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; if ( N <= 99 ) { System . out . print ( N * ( int ) Math . pow ( 100 , wwblwxp ) ) ; } else if ( N == 100 ) { System . out . print ( 101 * ( int ) Math . pow ( 100 , wwblwxp ) ) ; } } } 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 Vqyakol { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; MyScanner in = new MyScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; vqyakol solver = new vqyakol ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Vqyakol { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { int vqyakol = in . Int ( ) ; int B = in . Int ( ) ; out . println ( vqyakol * B ) ; } } static class Vqyakol { private BufferedReader in ; private StringTokenizer st ; public MyScanner ( InputStream stream ) { in = new BufferedReader ( new InputStreamReader ( stream ) ) ; } public String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { String rl = in . readLine ( ) ; if ( rl == null ) { return null ; } st = new StringTokenizer ( rl ) ; } catch ( IOException e ) { return null ; } } return st . nextToken ( ) ; } public int Int ( ) { return Integer . parseInt ( next ( ) ) ; } } } import java . util . * ; public class Ijhemr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ijhemr = sc . nextInt ( ) ; String s = sc . next ( ) ; sc . close ( ) ; boolean sa = false ; boolean sine = false ; if ( ijhemr % 2 != 0 ) { System . out . println ( " No " ) ; sine = true ; } else { int [ ] a = new int [ ijhemr / 2 ] ; int [ ] b = new int [ ijhemr / 2 ] ; for ( int i = 0 ; i < ijhemr / 2 ; i ++ ) { a [ i ] = s . charAt ( i ) ; b [ i ] = s . charAt ( i + ijhemr / 2 ) ; if ( a [ i ] != b [ i ] ) { sa = true ; } } } if ( sa == true ) { System . out . println ( " No " ) ; } else if ( sine == false ) { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class Qxbaeem { static int qxbaeem ; static int [ ] w ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; qxbaeem = scanner . nextInt ( ) ; w = new int [ qxbaeem ] ; for ( int i = 0 ; i < qxbaeem ; i ++ ) { w [ i ] = scanner . nextInt ( ) ; } scanner . close ( ) ; int ans = Integer . MAX_VALUE ; int s1 = 0 ; for ( int i = 0 ; i < qxbaeem - 1 ; i ++ ) { int s2 = 0 ; for ( int j = qxbaeem - 1 ; i + 1 <= j ; j -- ) { s2 += w [ j ] ; } s1 += w [ i ] ; ans = Math . min ( ans , Math . abs ( s1 - s2 ) ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Kmrythw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kmrythw = sc . nextInt ( ) ; long a = 0 ; for ( int i = 0 ; i <= kmrythw ; i ++ ) { if ( i % 3 == 0 && i % 5 == 0 ) { } else if ( i % 3 == 0 && i % 5 != 0 ) { } else if ( i % 3 != 0 && i % 5 == 0 ) { } else if ( i % 3 != 0 || i % 5 != 0 ) { a += i ; } } System . out . println ( a ) ; } } import java . util . Scanner ; public class Xaytlq { public static void main ( String [ ] args ) { Scanner sca = new Scanner ( System . in ) ; String c = sca . next ( ) ; char xaytlq = c . charAt ( 0 ) ; System . out . println ( ( char ) ( xaytlq + 1 ) ) ; sca . close ( ) ; } } import java . util . Scanner ; public class Idriijh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int idriijh = sc . nextInt ( ) ; int strLen = sc . nextInt ( ) ; sc . nextLine ( ) ; String [ ] strs = new String [ idriijh ] ; for ( int i = 0 ; i < idriijh ; i ++ ) { strs [ i ] = sc . nextLine ( ) ; } for ( int i = 0 ; i < idriijh ; i ++ ) { for ( int j = i + 1 ; j < idriijh ; j ++ ) { if ( ! minStr ( strLen , strs [ i ] , strs [ j ] ) ) { String tmp = strs [ i ] ; strs [ i ] = strs [ j ] ; strs [ j ] = tmp ; } } } output ( strs ) ; } private static boolean minStr ( int strLen , String strs , String strt ) { for ( int j = 0 ; j < strLen ; j ++ ) { char sChar = strs . charAt ( j ) ; char tChar = strt . charAt ( j ) ; if ( sChar != tChar ) { return sChar < tChar ; } } return true ; } private static void output ( String [ ] strs ) { for ( int i = 0 ; i < strs . length ; i ++ ) { System . out . print ( strs [ i ] ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class Znwnxs { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int znwnxs = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] m = new int [ znwnxs ] ; for ( int i = 0 ; i < znwnxs ; i ++ ) { m [ i ] = K ; } for ( int i = 0 ; i < Q ; i ++ ) { int c = sc . nextInt ( ) ; m [ c - 1 ] ++ ; } for ( int i = 0 ; i < m . length ; i ++ ) { System . out . println ( ( m [ i ] - Q ) > 0 ? " Yes " : " No " ) ; } sc . close ( ) ; } } import java . math . BigDecimal ; import java . math . RoundingMode ; import java . util . Scanner ; public class Orzsufa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigDecimal a = new BigDecimal ( sc . next ( ) ) ; BigDecimal b = new BigDecimal ( sc . next ( ) ) ; System . out . println ( a . multiply ( b ) . setScale ( 0 , RoundingMode . DOWN ) . toString ( ) ) ; sc . close ( ) ; } } import java . util . Scanner ; import java . util . Arrays ; class Wutgoud { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wutgoud = Integer . parseInt ( scan . nextLine ( ) ) ; String [ ] inputStr = scan . nextLine ( ) . split ( " " ) ; int inputLen = inputStr . length ; int [ ] inputInt = new int [ inputLen ] ; for ( int i = 0 ; i < inputLen ; i ++ ) { inputInt [ i ] = Integer . parseInt ( inputStr [ i ] ) ; } int tmp ; int numExchange = 0 ; int minj ; for ( int i = 0 ; i < inputLen - 1 ; i ++ ) { minj = i ; for ( int j = i + 1 ; j < inputLen ; j ++ ) { if ( inputInt [ minj ] > inputInt [ j ] ) { minj = j ; } } tmp = inputInt [ i ] ; inputInt [ i ] = inputInt [ minj ] ; inputInt [ minj ] = tmp ; if ( i != minj ) numExchange += 1 ; } for ( int i = 0 ; i < inputLen ; i ++ ) { inputStr [ i ] = String . valueOf ( inputInt [ i ] ) ; } System . out . println ( String . join ( " " , inputStr ) ) ; System . out . println ( numExchange ) ; } } import java . util . Scanner ; public class Tpmsua { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long tpmsua = sc . nextLong ( ) ; long start = 100 ; int answer = 0 ; while ( tpmsua > start ) { start += start / 100 ; answer ++ ; } System . out . println ( answer ) ; sc . close ( ) ; } } import java . util . Scanner ; class Zajyhw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zajyhw = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int ans = ( ( zajyhw + ( 2 * K + 1 ) - 1 ) ) / ( 2 * K + 1 ) ; System . out . print ( ans ) ; } } import java . util . * ; class Vjznop { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vjznop = sc . nextInt ( ) ; int [ ] a = new int [ vjznop ] ; for ( int i = 0 ; i < vjznop ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; System . out . println ( a [ ( vjznop - 1 ) / 2 + 1 ] - a [ ( vjznop - 1 ) / 2 ] ) ; } } import java . util . Scanner ; public class Pbswv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int pbswv = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; boolean [ ] judge = new boolean [ pbswv ] ; for ( int i = 0 ; i < k ; i ++ ) { int d = scan . nextInt ( ) ; for ( int j = 0 ; j < d ; j ++ ) { int a = scan . nextInt ( ) ; judge [ a - 1 ] = true ; } } int ans = 0 ; for ( int i = 0 ; i < judge . length ; i ++ ) { if ( judge [ i ] == false ) { ans ++ ; } } System . out . print ( ans ) ; } } import java . util . Scanner ; class Yamuthw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String number ; char [ ] ca ; int yamuthw ; for ( ; ; ) { number = scan . next ( ) ; ca = number . toCharArray ( ) ; yamuthw = 0 ; if ( ca [ 0 ] == '0' ) { break ; } for ( int i = 0 ; i < ca . length ; i ++ ) { yamuthw += ca [ i ] - '0' ; } System . out . println ( yamuthw ) ; } } } import java . util . * ; public class Ltwbbq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ltwbbq = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int end = l + ltwbbq - 1 ; int sum ; if ( l >= 0 ) { sum = ( l + 1 + end ) * ( ltwbbq - 1 ) / 2 ; } else if ( end > 0 ) { sum = ( l + end ) * ltwbbq / 2 ; } else { sum = ( l + end - 1 ) * ( ltwbbq - 1 ) / 2 ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Bgmfo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bgmfo = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; StringBuilder answer = new StringBuilder ( ) ; for ( int i = 0 ; i < bgmfo ; i ++ ) { String a = String . valueOf ( s . charAt ( i ) ) ; if ( ( i + 1 ) == k ) { a = a . toLowerCase ( ) ; } answer . append ( a ) ; } System . out . println ( answer ) ; sc . close ( ) ; } } import java . util . * ; public class Vdgyd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vdgyd = sc . nextInt ( ) ; String ans = " APPROVED " ; int tmp ; for ( int i = 0 ; i < vdgyd ; i ++ ) { tmp = sc . nextInt ( ) ; if ( tmp % 2 == 0 ) { if ( tmp % 3 != 0 && tmp % 5 != 0 ) { ans = " DENIED " ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Mgqyd { Scanner sc = new Scanner ( System . in ) ; void doIt ( ) { sC ( ) ; } void sC ( ) { String s = sc . next ( ) ; int mgqyd = 0 , one = 0 ; char [ ] c = s . toCharArray ( ) ; for ( int i = 0 ; i < c . length ; i ++ ) { if ( c [ i ] == '0' ) mgqyd ++ ; else one ++ ; } if ( one > mgqyd ) { System . out . println ( mgqyd * 2 ) ; } else System . out . println ( one * 2 ) ; } public static void main ( String [ ] args ) { new Main ( ) . doIt ( ) ; } } import java . util . * ; public class Akmvhjn { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int akmvhjn = stdIn . nextInt ( ) ; int [ ] flag = new int [ 101 ] ; Arrays . fill ( flag , 0 ) ; for ( int i = 0 ; i < akmvhjn ; i ++ ) { int d = stdIn . nextInt ( ) ; flag [ d ] = 1 ; } int ans = 0 ; for ( int i = 0 ; i < 101 ; i ++ ) { ans += flag [ i ] ; } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; public class Piyiyjc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter ou = new PrintWriter ( System . out ) ; int piyiyjc = Integer . parseInt ( sc . next ( ) ) ; int h = Integer . parseInt ( sc . next ( ) ) ; boolean ebishu = false ; if ( piyiyjc == 2 * Integer . parseInt ( sc . next ( ) ) && h == 2 * Integer . parseInt ( sc . next ( ) ) ) ebishu = true ; ou . print ( piyiyjc * ( long ) h / 2.0 + " " ) ; if ( ebishu ) ou . print ( 1 + " \n " ) ; else ou . print ( 0 + " \n " ) ; ou . flush ( ) ; } } import java . util . * ; public class Kawuav { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Integer x = scanner . nextInt ( ) ; Integer y = scanner . nextInt ( ) ; String ans = " No " ; for ( int kawuav = 0 ; kawuav < x + 1 ; kawuav ++ ) { Integer sum = 2 * kawuav + 4 * ( x - kawuav ) ; if ( sum == y ) ans = " Yes " ; } System . out . println ( ans ) ; } } import java . util . * ; public class Ojqvmzg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ojqvmzg = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; String postal = sc . next ( ) ; String [ ] decomp = new String [ 3 ] ; decomp [ 0 ] = postal . substring ( 0 , ojqvmzg ) ; decomp [ 1 ] = postal . substring ( ojqvmzg , ojqvmzg + 1 ) ; decomp [ 2 ] = postal . substring ( ojqvmzg + 1 , postal . length ( ) - 1 ) ; for ( int i = 0 ; i < 3 ; i ++ ) { char [ ] array = decomp [ i ] . toCharArray ( ) ; if ( i == 0 || i == 2 ) { for ( char c : array ) { if ( ! Character . isDigit ( c ) ) { System . out . println ( " No " ) ; return ; } } } else { if ( array [ 0 ] != '-' ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Snvawfn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int snvawfn , n ; snvawfn = sc . nextInt ( ) ; n = sc . nextInt ( ) ; int [ ] ans ; ans = new int [ snvawfn + 1 ] ; for ( int i = 0 ; i <= snvawfn ; i ++ ) { ans [ i ] = i ; } for ( int i = 0 ; i < n ; i ++ ) { int a , b ; String [ ] s = sc . next ( ) . split ( " , " ) ; a = Integer . parseInt ( s [ 0 ] ) ; b = Integer . parseInt ( s [ 1 ] ) ; int noise ; noise = ans [ a ] ; ans [ a ] = ans [ b ] ; ans [ b ] = noise ; } for ( int i = 1 ; i <= snvawfn ; i ++ ) { System . out . println ( ans [ i ] ) ; } } } import java . util . Scanner ; public class Indgoy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int indgoy = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; boolean flag = false ; A : for ( int x = 0 ; x <= Math . min ( Y / 10000 , indgoy ) ; x ++ ) { for ( int y = 0 ; y <= Math . min ( ( Y - 10000 * x ) / 5000 , indgoy - x ) ; y ++ ) { int k = Y - 10000 * x - 5000 * y ; if ( k % 1000 == 0 ) { int z = k / 1000 ; if ( z == ( indgoy - x - y ) ) { System . out . printf ( " %d %d %d " , x , y , z ) ; flag = true ; break A ; } } } } if ( ! flag ) System . out . printf ( " -1 -1 -1 " ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; class Tlvujx { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } public class Tlvujx { public static PrintWriter out ; public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int tlvujx = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; if ( w >= tlvujx ) { out . println ( " unsafe " ) ; } else { out . println ( " safe " ) ; } out . close ( ) ; } } import java . util . Scanner ; public class Suupjwz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int suupjwz = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] matrix = new int [ suupjwz ] [ m ] ; int [ ] vector = new int [ m ] ; for ( int i = 0 ; i < suupjwz ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { matrix [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < m ; i ++ ) { vector [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < suupjwz ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < m ; j ++ ) { sum += matrix [ i ] [ j ] * vector [ j ] ; } System . out . println ( sum ) ; } } } import java . util . Scanner ; public class Xsqhpol { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xsqhpol ; double ave , d ; while ( ( xsqhpol = scan . nextInt ( ) ) != 0 ) { int [ ] point = new int [ xsqhpol ] ; ave = 0 ; for ( int i = 0 ; i < xsqhpol ; i ++ ) { point [ i ] = scan . nextInt ( ) ; ave += point [ i ] ; } ave /= ( double ) xsqhpol ; d = 0 ; for ( int i = 0 ; i < xsqhpol ; i ++ ) { d += ( Math . pow ( ( ave - point [ i ] ) , 2 ) ) ; } d /= ( double ) xsqhpol ; d = Math . sqrt ( d ) ; System . out . printf ( " %.8f \n " , d ) ; } scan . close ( ) ; } } import java . util . Scanner ; public class Lpbsd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lpbsd = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] [ ] nm = new int [ lpbsd ] [ m ] ; int [ ] [ ] ml = new int [ m ] [ l ] ; for ( int i = 0 ; i < lpbsd ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { nm [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < l ; j ++ ) { ml [ i ] [ j ] = sc . nextInt ( ) ; } } long ans = 0 ; for ( int i = 0 ; i < lpbsd ; i ++ ) { for ( int j = 0 ; j < l ; j ++ ) { ans = 0 ; for ( int k = 0 ; k < m ; k ++ ) { ans += nm [ i ] [ k ] * ml [ k ] [ j ] ; } if ( j != l - 1 ) { System . out . print ( ans + " " ) ; } else { System . out . print ( ans ) ; } } System . out . println ( ) ; } } } import java . util . Scanner ; public class Royypv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int royypv = sc . nextInt ( ) ; int s = royypv % 60 ; int M = royypv / 60 ; int m = M % 60 ; int H = M / 60 ; int h = H ; System . out . println ( h + " : " + m + " : " + s ) ; } } import java . util . Scanner ; import java . util . * ; public class Axiiji { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int axiiji = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ axiiji ] ; for ( int i = 0 ; i < axiiji ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; int sum = 0 ; for ( int i = 0 ; i < k && i < axiiji ; i ++ ) { sum += arr [ i ] ; } System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Awgyc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] task = new int [ 3 ] ; int awgyc = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { task [ i ] = sc . nextInt ( ) ; } Arrays . sort ( task ) ; for ( int i = 0 ; i < 2 ; i ++ ) { awgyc += Math . abs ( task [ i ] - task [ i + 1 ] ) ; } System . out . println ( awgyc ) ; } } import java . io . * ; class Itgljw { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = reader . readLine ( ) ; int itgljw = Integer . parseInt ( line ) ; int answer = ( int ) Math . pow ( itgljw , 3 ) ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class Bimal { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bimal = sc . nextInt ( ) ; int kind = sc . nextInt ( ) ; int [ ] di = new int [ kind ] ; int [ ] count = new int [ bimal ] ; for ( int i = 0 ; i < bimal ; i ++ ) { count [ i ] = 0 ; } for ( int i = 0 ; i < kind ; i ++ ) { di [ i ] = sc . nextInt ( ) ; for ( int j = 0 ; j < di [ i ] ; j ++ ) { count [ sc . nextInt ( ) - 1 ] ++ ; } } int trickCount = 0 ; for ( int i = 0 ; i < bimal ; i ++ ) { if ( count [ i ] == 0 ) { trickCount ++ ; } } System . out . println ( trickCount ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Oywqhr { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = null ; try { while ( ( line = br . readLine ( ) ) != null ) { char [ ] charArray = line . trim ( ) . toCharArray ( ) ; if ( charArray . length > 20 ) System . exit ( - 1 ) ; for ( int oywqhr = charArray . length - 1 ; oywqhr >= 0 ; oywqhr -- ) { System . out . print ( charArray [ oywqhr ] ) ; } System . out . println ( " " ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . Scanner ; public class Jdbry { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jdbry = sc . nextInt ( ) ; for ( int i = 1 ; i <= jdbry ; i ++ ) { if ( i % 3 == 0 || Integer . toString ( i ) . contains ( " 3 " ) ) { if ( 0 < i ) { System . out . print ( " " + i ) ; } else { System . out . print ( i ) ; } } } System . out . println ( ) ; } } import java . util . * ; public class Votjvp { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int votjvp = sc . nextInt ( ) ; int [ ] [ ] array = new int [ 2 ] [ votjvp ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < votjvp ; j ++ ) { array [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] ans = new int [ 2 ] [ votjvp ] ; ans [ 0 ] [ 0 ] = array [ 0 ] [ 0 ] ; for ( int i = 0 ; i < votjvp - 1 ; i ++ ) { ans [ 0 ] [ i + 1 ] = ans [ 0 ] [ i ] + array [ 0 ] [ i + 1 ] ; } ans [ 1 ] [ 0 ] = array [ 0 ] [ 0 ] + array [ 1 ] [ 0 ] ; for ( int i = 1 ; i < votjvp ; i ++ ) { ans [ 1 ] [ i ] = Math . max ( ans [ 0 ] [ i ] , ans [ 1 ] [ i - 1 ] ) + array [ 1 ] [ i ] ; } System . out . println ( ans [ 1 ] [ votjvp - 1 ] ) ; } } import java . util . Scanner ; public class Khxfy { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long khxfy = scanner . nextLong ( ) ; long answer = khxfy - 1 ; answer = getAnswer ( khxfy , answer ) ; System . out . println ( answer ) ; } private static long getAnswer ( long khxfy , long answer ) { int newStart = ( int ) Math . sqrt ( khxfy ) ; for ( long i = newStart ; i > 1 ; i -- ) { if ( khxfy % i == 0 ) { long divisible = khxfy / i ; long possibleAnswer = ( i - 1 ) + ( divisible - 1 ) ; return possibleAnswer ; } } return answer ; } } import java . util . * ; public class Fdlxq { public static void main ( String [ ] args ) { int fdlxq ; Scanner sc = new Scanner ( System . in ) ; String num = sc . next ( ) ; num = num . replaceAll ( " 0 " , " " ) ; fdlxq = num . fdlxq ( ) ; System . out . println ( fdlxq ) ; } } import java . util . Scanner ; public class Vamkqem { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vamkqem = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int res ; if ( vamkqem <= 5 ) { res = 0 ; } else if ( vamkqem <= 12 ) { res = b / 2 ; } else { res = b ; } System . out . println ( res ) ; } } import java . util . * ; public class Eafzr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eafzr = sc . nextInt ( ) , D = sc . nextInt ( ) , c = 0 ; for ( int i = 0 ; i < eafzr ; i ++ ) { long X = sc . nextInt ( ) , Y = sc . nextInt ( ) ; if ( Math . sqrt ( X * X + Y * Y ) <= D ) { c ++ ; } } System . out . println ( c ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Xrttf { public static void main ( String [ ] args ) { try ( BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int xrttf = 0 ; int hanako = 0 ; int n = Integer . parseInt ( in . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] arr = in . readLine ( ) . split ( " " ) ; int cmp = arr [ 0 ] . compareTo ( arr [ 1 ] ) ; if ( cmp > 0 ) { xrttf += 3 ; } else if ( cmp == 0 ) { xrttf ++ ; hanako ++ ; } else { hanako += 3 ; } } System . out . println ( xrttf + " " + hanako ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class Vukfmvq { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; int vukfmvq = ob . nextInt ( ) ; boolean C = true ; String R = " " ; while ( C ) { vukfmvq %= 10 ; C = false ; } if ( ( vukfmvq == 2 ) || ( vukfmvq == 4 ) || ( vukfmvq == 5 ) || ( vukfmvq == 7 ) || ( vukfmvq == 9 ) ) { R += " hon " ; } else if ( ( vukfmvq == 0 ) || ( vukfmvq == 1 ) || ( vukfmvq == 6 ) || ( vukfmvq == 8 ) ) { R += " pon " ; } else if ( vukfmvq == 3 ) { R += " bon " ; } System . out . println ( R ) ; } } import java . util . * ; public class Bnqjqg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bnqjqg = sc . nextInt ( ) ; int yen = sc . nextInt ( ) ; int s = yen / 1000 - bnqjqg ; for ( int i = 0 ; i <= Math . min ( s / 9 , bnqjqg ) ; i ++ ) { for ( int j = 0 ; j <= Math . min ( bnqjqg - i , s / 4 ) ; j ++ ) { if ( i * 9 + j * 4 == s ) { System . out . println ( i + " " + j + " " + ( bnqjqg - i - j ) ) ; return ; } } } System . out . println ( ( - 1 ) + " " + ( - 1 ) + " " + ( - 1 ) ) ; } public static int lcm ( int x , int y ) { return x * y / gcd ( x , y ) ; } public static int gcd ( int x , int y ) { if ( x < y ) return gcd ( y , x ) ; if ( y == 0 ) return x ; return gcd ( y , x % y ) ; } } import java . util . * ; public class Yvprwx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int yvprwx = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = Math . max ( yvprwx , b ) ; int d = Math . min ( yvprwx , b ) ; int out = 0 ; out += c ; out += Math . max ( c - 1 , d ) ; System . out . println ( out ) ; scan . close ( ) ; } } import java . util . Scanner ; public class Ejuumex { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int ejuumex = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int result = 0 ; switch ( ejuumex ) { case 0 : if ( n == 100 ) { result = 101 ; } else { result = n ; } break ; case 1 : if ( n == 100 ) { result = 10100 ; } else { result = 100 * n ; } break ; case 2 : if ( n == 100 ) { result = 1010000 ; } else { result = 10000 * n ; } break ; } System . out . println ( result ) ; } } } import java . text . MessageFormat ; import java . util . Scanner ; public class Ghanfv { public static void main ( String [ ] args ) { Solve s = new Solve ( ) ; s . solve ( ) ; } } class Ghanfv { public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; double ghanfv = sc . nextInt ( ) ; double K = sc . nextInt ( ) ; double n = 0d ; double res = 0d ; String message ; for ( double i = 1 ; i <= ghanfv ; i ++ ) { for ( int j = 0 ; j < 100000 ; j ++ ) { if ( i * Math . pow ( 2 , j ) >= K ) { n = j ; j = 100000 ; } } res += 1 / ( ghanfv * Math . pow ( 2 , n ) ) ; } message = MessageFormat . format ( " { 0,number,0.000000000000 } " , res ) ; System . out . println ( message ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Bhzgk { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; int bhzgk = Integer . parseInt ( line ) ; int [ ] a = new int [ bhzgk ] ; int k = 0 ; int count = 1 ; boolean fin = false ; for ( int i = 0 ; i < bhzgk ; i ++ ) { a [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } for ( int i = 0 ; i < bhzgk ; i ++ ) { if ( a [ k ] != 2 && ! fin ) { count ++ ; k = a [ k ] - 1 ; } else { fin = true ; } } if ( fin ) { System . out . println ( count ) ; } else { System . out . println ( " -1 " ) ; } } } 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 Avjxgxu { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AWeatherPrediction solver = new AWeatherPrediction ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Avjxgxu { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String avjxgxu = in . next ( ) ; if ( avjxgxu . compareTo ( " Sunny " ) == 0 ) { out . println ( " Cloudy " ) ; } else if ( avjxgxu . compareTo ( " Cloudy " ) == 0 ) { out . println ( " Rainy " ) ; } else { out . println ( " Sunny " ) ; } } } static class Avjxgxu { 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 ( ) ; } } } import java . util . * ; public class Zqgwza { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long zqgwza = sc . nextLong ( ) ; long hh = sc . nextLong ( ) ; long xx = sc . nextLong ( ) ; long yy = sc . nextLong ( ) ; System . out . print ( zqgwza * hh / 2.0 ) ; System . out . print ( " " + ( xx * 2 == zqgwza && yy * 2 == hh ? 1 : 0 ) ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class Toqinmu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; char [ ] t = sc . next ( ) . toCharArray ( ) ; int toqinmu = 0 ; int len = s . length ; for ( int i = 0 ; i < len ; i ++ ) { if ( s [ i ] != t [ i ] ) toqinmu ++ ; } System . out . println ( toqinmu ) ; } } import java . util . Scanner ; public class Qbjes { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String C = scanner . next ( ) ; String [ ] slist = { " a " , " b " , " c " , " d " , " e " , " f " , " g " , " h " , " i " , " j " , " k " , " l " , " m " , " n " , " o " , " p " , " q " , " r " , " s " , " t " , " u " , " v " , " w " , " x " , " y " , " z " } ; for ( int qbjes = 0 ; qbjes < 26 ; qbjes ++ ) { if ( C . equals ( slist [ qbjes ] ) ) { C = slist [ qbjes + 1 ] ; System . out . println ( C ) ; break ; } } } } import java . util . * ; class Fiujgky { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int fiujgky = stdIn . nextInt ( ) ; int x = stdIn . nextInt ( ) ; int count = 1 ; int sum = 0 ; while ( fiujgky -- > 0 ) { sum += stdIn . nextInt ( ) ; if ( x < sum ) break ; count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Vqcut { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double vqcut = sc . nextDouble ( ) ; System . out . println ( ( int ) Math . ceil ( vqcut / 2 ) ) ; } } import java . util . Scanner ; public class Erqyvjn { private static int erqyvjn , x ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; erqyvjn = stdIn . nextInt ( ) ; for ( int i = 1 ; i <= erqyvjn ; i ++ ) { x = i ; if ( x % 3 == 0 ) { System . out . print ( " " + x ) ; continue ; } while ( x > 0 ) { if ( x % 10 == 3 ) { System . out . print ( " " + i ) ; break ; } x /= 10 ; } } System . out . println ( " " ) ; } } import java . io . * ; class Ivfiy { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String nb = buf . readLine ( ) ; int ivfiy = Integer . parseInt ( nb ) ; System . out . println ( ( int ) Math . pow ( ivfiy , 3 ) ) ; } } import java . lang . reflect . Array ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Ibmmnm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; List < String [ ] > list = new ArrayList < > ( ) ; int ibmmnm = 0 ; int N = 0 ; int M = 0 ; while ( scan . hasNext ( ) ) { if ( ibmmnm == 0 ) { N = scan . nextInt ( ) ; M = scan . nextInt ( ) ; ibmmnm ++ ; continue ; } String str = scan . nextLine ( ) ; String [ ] sp = str . split ( " " ) ; list . add ( sp ) ; ibmmnm ++ ; if ( ibmmnm > N + 1 ) { break ; } } int [ ] result = new int [ 30 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= Integer . parseInt ( list . get ( i ) [ 0 ] ) ; j ++ ) { result [ Integer . parseInt ( list . get ( i ) [ j ] ) - 1 ] ++ ; } } int resultCount = 0 ; for ( int r : result ) { if ( r == N ) { resultCount ++ ; } } System . out . print ( resultCount ) ; } } import java . util . Scanner ; public class Mhlirn { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; long mhlirn = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; sc . close ( ) ; long res1 = Math . max ( 0 , mhlirn - k ) ; long res2 = Math . max ( 0 , Math . min ( mhlirn + b - k , b ) ) ; System . out . println ( res1 + " " + res2 ) ; } public static void main ( String [ ] args ) { solve ( ) ; } } import java . util . Scanner ; public class Iqooid { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] s = sc . next ( ) . split ( " " ) ; for ( int iqooid = 0 ; iqooid < s . length ; iqooid ++ ) { sb . append ( s [ iqooid ] . equals ( " 1 " ) ? " 9 " : " 1 " ) ; } System . out . println ( sb ) ; } } import java . util . Scanner ; public class Swdvjl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int swdvjl = sc . nextInt ( ) , b = sc . nextInt ( ) ; StringBuilder a_str = new StringBuilder ( ) ; StringBuilder b_str = new StringBuilder ( ) ; for ( int i = 0 ; i < swdvjl ; i ++ ) { a_str . append ( b ) ; } for ( int i = 0 ; i < b ; i ++ ) { b_str . append ( swdvjl ) ; } System . out . println ( a_str . toString ( ) . compareTo ( b_str . toString ( ) ) < 0 ? a_str . toString ( ) : b_str . toString ( ) ) ; } } import java . util . * ; public class Fizsq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long fizsq = sc . nextInt ( ) ; long total = 0 ; for ( long i = 0 ; i <= fizsq ; i ++ ) { if ( i % 3 != 0 && i % 5 != 0 ) { total += i ; } } System . out . println ( total ) ; } } import java . util . * ; import java . util . Collections ; public class Oudza { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oudza = sc . nextInt ( ) ; String S = sc . next ( ) ; int cnt = 0 ; for ( int i = 0 ; i < oudza - 2 ; i ++ ) { if ( S . charAt ( i ) == 'A' & S . charAt ( i + 1 ) == 'B' & S . charAt ( i + 2 ) == 'C' ) { cnt ++ ; } } System . out . println ( cnt ) ; } public static void primeFactorization ( int num ) { int Z = 0 ; for ( int i = 2 ; num > i ; i ++ ) { while ( num % i == 0 ) { System . out . println ( i ) ; num /= i ; Z = num ; } } System . out . println ( Z ) ; } public static boolean isPrime ( int num ) { if ( num < 2 ) return false ; else if ( num == 2 ) return true ; else if ( num % 2 == 0 ) return false ; for ( int i = 3 ; i < num ; i += 2 ) { if ( num % i == 0 ) { return false ; } } return true ; } } import java . util . Scanner ; public class Xgxhtmk { public static void main ( String [ ] args ) { int xgxhtmk ; int b ; try ( Scanner scanner = new Scanner ( System . in ) ) { xgxhtmk = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; } if ( ( xgxhtmk & b & 1 ) == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Qsipia { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qsipia = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] monsters = new int [ qsipia ] ; for ( int i = 0 ; i < qsipia ; i ++ ) { monsters [ i ] = sc . nextInt ( ) ; } Arrays . sort ( monsters ) ; long hp = 0 ; if ( k >= qsipia ) { System . out . println ( hp ) ; } else { for ( int j = 0 ; j < qsipia - k ; j ++ ) { hp += monsters [ j ] ; } System . out . println ( hp ) ; } } } import java . util . Scanner ; public class Uetkg { public static void main ( String [ ] args ) { Scanner c = new Scanner ( System . in ) ; long uetkg = c . nextInt ( ) ; System . out . println ( ( uetkg + ( uetkg * uetkg ) + ( uetkg * uetkg * uetkg ) ) ) ; } } import java . util . * ; public class Amxuexy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int amxuexy = Integer . parseInt ( sc . next ( ) ) ; int d = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < amxuexy ; i ++ ) { long x = Integer . parseInt ( sc . next ( ) ) ; long y = Integer . parseInt ( sc . next ( ) ) ; if ( Math . sqrt ( x * x + y * y ) <= d ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class Fnhlfw { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int fnhlfw = 0 ; int max = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == 'A' || S . charAt ( i ) == 'G' || S . charAt ( i ) == 'C' || S . charAt ( i ) == 'T' ) { fnhlfw ++ ; if ( max <= fnhlfw ) { max = fnhlfw ; } } else { fnhlfw = 0 ; } } System . out . println ( max ) ; } } import java . util . Scanner ; public class Mkwhjyy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] array = sc . nextLine ( ) . split ( " " ) ; int mkwhjyy = 0 ; for ( String s : array ) { if ( Integer . parseInt ( s ) == 1 ) { mkwhjyy ++ ; } } System . out . println ( mkwhjyy ) ; } } import java . util . Scanner ; public class Mttocx { public static void main ( String [ ] args ) { String mttocx ; Scanner n = new Scanner ( System . in ) ; mttocx = n . next ( ) ; if ( mttocx . equals ( " Sunny " ) ) System . out . print ( " Cloudy " ) ; else if ( mttocx . equals ( " Cloudy " ) ) System . out . print ( " Rainy " ) ; else if ( mttocx . equals ( " Rainy " ) ) System . out . print ( " Sunny " ) ; } } import java . util . Scanner ; public class Mzlam { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mzlam = 0 , b = 0 , c = 0 ; int [ ] n = new int [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { n [ i ] = sc . nextInt ( ) ; if ( n [ i ] > mzlam ) { c = b ; b = mzlam ; mzlam = n [ i ] ; } else if ( n [ i ] > b ) { c = b ; b = n [ i ] ; } else if ( n [ i ] > c ) { c = n [ i ] ; } } System . out . println ( mzlam ) ; System . out . println ( b ) ; System . out . println ( c ) ; } } import java . io . * ; class Wpmlxaj { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; char wpmlxaj ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { wpmlxaj = str . charAt ( i ) ; if ( Character . isUpperCase ( wpmlxaj ) ) wpmlxaj = Character . toLowerCase ( wpmlxaj ) ; else if ( Character . isLowerCase ( wpmlxaj ) ) wpmlxaj = Character . toUpperCase ( wpmlxaj ) ; System . out . print ( wpmlxaj ) ; } System . out . println ( ) ; } catch ( IOException e ) { System . out . println ( " Exception : " + e ) ; } } } import java . util . * ; class Adhxkk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int adhxkk = sc . nextInt ( ) ; int waza = sc . nextInt ( ) ; long ret = 0 ; int [ ] hoge = new int [ adhxkk ] ; if ( adhxkk <= waza ) { System . out . println ( 0 ) ; return ; } for ( int i = 0 ; i < adhxkk ; i ++ ) { hoge [ i ] = sc . nextInt ( ) ; } Arrays . sort ( hoge ) ; for ( int i = 0 ; i < adhxkk - waza ; i ++ ) { ret += hoge [ i ] ; } System . out . print ( ret ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Hdmverd { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int hdmverd = sc . nextInt ( ) ; int maxPotision = 0 ; int maxValue = 0 ; int secondValue = 0 ; boolean maxDup = false ; for ( int i = 0 ; i < hdmverd ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp == maxValue ) { maxDup = true ; } else if ( tmp > maxValue ) { secondValue = maxValue ; maxValue = tmp ; maxPotision = i ; maxDup = false ; } else if ( tmp > secondValue ) { secondValue = tmp ; } } if ( maxDup ) { for ( int i = 0 ; i < hdmverd ; i ++ ) { System . out . println ( maxValue ) ; } } else { for ( int i = 0 ; i < hdmverd ; i ++ ) { if ( i == maxPotision ) { System . out . println ( secondValue ) ; } else { System . out . println ( maxValue ) ; } } } } } import java . util . * ; public class Dpqefl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String dpqefl = scan . nextLine ( ) ; String strings = dpqefl + dpqefl ; String keywords = scan . nextLine ( ) ; System . out . println ( strings . matches ( " .* " + keywords + " .* " ) ? " Yes " : " No " ) ; } } import java . io . FileNotFoundException ; import java . math . BigDecimal ; import java . math . RoundingMode ; import java . util . Scanner ; public class Xudkcmc { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int xudkcmc = sc . nextInt ( ) ; int H = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; boolean flg = false ; BigDecimal S = BigDecimal . valueOf ( xudkcmc ) ; S = S . multiply ( BigDecimal . valueOf ( H ) ) ; S = S . divide ( BigDecimal . valueOf ( 2 ) , 10 , RoundingMode . HALF_UP ) ; if ( 2 * x == xudkcmc && 2 * y == H ) { flg = true ; } System . out . print ( S + " " ) ; if ( flg ) { System . out . println ( " 1 " ) ; } else { System . out . println ( " 0 " ) ; } } } import java . util . Scanner ; public class Nzeirbv { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; loop : while ( true ) { long nzeirbv = scanner . nextInt ( ) ; String op = scanner . next ( ) ; long b = scanner . nextInt ( ) ; switch ( op ) { case " + " : System . out . println ( nzeirbv + b ) ; break ; case " - " : System . out . println ( nzeirbv - b ) ; break ; case " * " : System . out . println ( nzeirbv * b ) ; break ; case " / " : System . out . println ( nzeirbv / b ) ; break ; case " ? " : break loop ; } } scanner . close ( ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Baojpir { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int baojpir = sc . nextInt ( ) ; boolean [ ] isZorome = new boolean [ baojpir ] ; for ( int i = 0 ; i < baojpir ; i ++ ) { int d_1 = sc . nextInt ( ) ; int d_2 = sc . nextInt ( ) ; isZorome [ i ] = ( d_1 == d_2 ) ; } String ans = " No " ; for ( int i = 0 ; i < baojpir - 2 ; i ++ ) { boolean sanren = isZorome [ i ] && isZorome [ i + 1 ] && isZorome [ i + 2 ] ; if ( sanren ) { ans = " Yes " ; } } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ; class Xrycgmk { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int xrycgmk = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int M = 2 * D + 1 ; System . out . println ( ( xrycgmk + M - 1 ) / M ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; import java . util . Arrays ; public class Zftxby { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int zftxby = Integer . parseInt ( str [ 0 ] ) ; int l = Integer . parseInt ( str [ 1 ] ) ; String [ ] s = new String [ zftxby ] ; for ( int i = 0 ; i < zftxby ; i ++ ) { s [ i ] = in . readLine ( ) ; } Arrays . sort ( s ) ; for ( int i = 0 ; i < zftxby ; i ++ ) { System . out . print ( s [ i ] ) ; } System . out . println ( ) ; } } import java . util . * ; import java . io . * ; public class Ythke { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; int ythke = Integer . parseInt ( br . readLine ( ) ) ; long ans = 0 ; for ( int i = 1 ; i <= ythke ; i ++ ) { if ( ( i % 3 != 0 ) && ( i % 5 != 0 ) ) { ans += i ; } } out . println ( ans ) ; out . close ( ) ; } } import java . util . Scanner ; import java . util . ArrayList ; import java . util . List ; public class Usnydh { public static void main ( String [ ] args ) { String [ ] input1 ; String [ ] input2 ; try ( Scanner sc = new Scanner ( System . in ) ) { input1 = sc . nextLine ( ) . split ( " " ) ; input2 = sc . nextLine ( ) . split ( " " ) ; } int usnydh = Integer . parseInt ( input1 [ 0 ] ) ; int x = Integer . parseInt ( input1 [ 1 ] ) ; List < Integer > list = new ArrayList < > ( ) ; for ( String str : input2 ) { list . add ( Integer . parseInt ( str ) ) ; } int d = 0 ; int cnt = 1 ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { int e = d + list . get ( i ) ; if ( e <= x ) { cnt ++ ; } d = e ; } System . out . println ( cnt ) ; } } import java . util . * ; public class Iplvjat { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double iplvjat = sc . nextDouble ( ) ; double ans = iplvjat / 3 ; System . out . printf ( " %.12f \n " , ans * ans * ans ) ; } } import java . util . Scanner ; public class Zwkubn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long zwkubn = sc . nextLong ( ) , a = sc . nextLong ( ) , b = sc . nextLong ( ) ; long sum = a * ( zwkubn / ( a + b ) ) ; sum += a < zwkubn % ( a + b ) ? a : zwkubn % ( a + b ) ; System . out . println ( sum ) ; } } import java . util . Scanner ; public class Ntrhs { public static void main ( String [ ] args ) { Scanner inputscan = new Scanner ( System . in ) ; int ntrhs = inputscan . nextInt ( ) ; int H = inputscan . nextInt ( ) ; int x = inputscan . nextInt ( ) ; int y = inputscan . nextInt ( ) ; int r = inputscan . nextInt ( ) ; int Horizontal1 = x - r ; int Horizontal2 = x + r ; int Vertical1 = y - r ; int Vertical2 = y + r ; if ( Horizontal1 >= 0 && Horizontal2 <= ntrhs && Vertical1 >= 0 && Vertical2 <= H ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . math . * ; public class Tceubs { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String tceubs = sc . next ( ) ; String b = sc . next ( ) ; BigDecimal a1 = new BigDecimal ( tceubs ) ; BigDecimal b1 = new BigDecimal ( b ) ; BigDecimal res = a1 . multiply ( b1 ) ; System . out . println ( res . setScale ( 0 , RoundingMode . DOWN ) ) ; } } import java . io . * ; class Sbjfdu { } class Sbjfdu { public static void main ( String [ ] args ) throws IOException { Program obj = new Program ( ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] ip ; int sbjfdu , M , C ; int [ ] A , B ; ip = in . readLine ( ) . split ( " " ) ; sbjfdu = Integer . parseInt ( ip [ 0 ] ) ; M = Integer . parseInt ( ip [ 1 ] ) ; C = Integer . parseInt ( ip [ 2 ] ) ; int count = 0 , score = 0 ; A = new int [ M ] ; B = new int [ M ] ; ip = in . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < M ; i ++ ) B [ i ] = Integer . parseInt ( ip [ i ] ) ; while ( -- sbjfdu >= 0 ) { ip = in . readLine ( ) . split ( " " ) ; score = 0 ; for ( int i = 0 ; i < M ; i ++ ) { A [ i ] = Integer . parseInt ( ip [ i ] ) ; score += B [ i ] * A [ i ] ; } if ( score + C > 0 ) count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Ibzkqze { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; boolean [ ] [ ] cardHasFlag = new boolean [ 4 ] [ 13 ] ; int ibzkqze = sc . nextInt ( ) ; for ( int i = 0 ; i < ibzkqze ; i ++ ) { String make = sc . next ( ) ; int card = sc . nextInt ( ) ; switch ( make ) { case " S " : cardHasFlag [ 0 ] [ card - 1 ] = true ; break ; case " H " : cardHasFlag [ 1 ] [ card - 1 ] = true ; break ; case " C " : cardHasFlag [ 2 ] [ card - 1 ] = true ; break ; case " D " : cardHasFlag [ 3 ] [ card - 1 ] = true ; break ; } } for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 13 ; j ++ ) { if ( cardHasFlag [ i ] [ j ] == false ) { switch ( i ) { case 0 : System . out . printf ( " S %d \n " , j + 1 ) ; break ; case 1 : System . out . printf ( " H %d \n " , j + 1 ) ; break ; case 2 : System . out . printf ( " C %d \n " , j + 1 ) ; break ; case 3 : System . out . printf ( " D %d \n " , j + 1 ) ; break ; } } } } } } import java . util . * ; public class Pfnst { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int pfnst = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int sum = 0 ; if ( d <= pfnst ) { System . out . println ( d ) ; return ; } sum = pfnst ; d -= pfnst ; if ( d <= b ) { System . out . println ( sum ) ; return ; } d -= b ; sum -= d ; System . out . println ( sum ) ; } } import java . util . * ; public class Dlshpi { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int dlshpi = s . nextInt ( ) ; long [ ] monsters = new long [ dlshpi + 1 ] ; long [ ] strength = new long [ dlshpi ] ; long count = 0 ; for ( int i = 0 ; i < dlshpi + 1 ; i ++ ) { monsters [ i ] = s . nextInt ( ) ; } for ( int i = 0 ; i < dlshpi ; i ++ ) { strength [ i ] = s . nextInt ( ) ; } for ( int i = 0 ; i < dlshpi ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { if ( monsters [ i + j ] >= strength [ i ] ) { count += strength [ i ] ; monsters [ i + j ] = monsters [ i + j ] - strength [ i ] ; strength [ i ] = 0 ; } else { count += monsters [ j + i ] ; strength [ i ] = strength [ i ] - monsters [ i + j ] ; monsters [ i + j ] = 0 ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; class Hzych { public static void main ( final String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { String s = scanner . nextLine ( ) ; int hzych = 0 ; boolean flag = true ; for ( int i = 0 ; i < 4 ; i ++ ) { String s1 = s . substring ( i , i + 1 ) ; for ( int k = 0 ; k < 4 ; k ++ ) { String s2 = s . substring ( k , k + 1 ) ; if ( s1 . equals ( s2 ) ) { hzych ++ ; } } if ( hzych == 2 ) { hzych = 0 ; } else { System . out . println ( " No " ) ; flag = false ; break ; } } if ( flag ) { System . out . println ( " Yes " ) ; } } } } import java . util . * ; class Qoaxdv { public static void main ( String [ ] args ) { printAns ( ) ; } static void isRightTriangle ( int a , int b , int c ) { if ( a * a + b * b == c * c ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } static void printAns ( ) { Scanner sc = new Scanner ( System . in ) ; int qoaxdv = sc . nextInt ( ) ; int [ ] triangle = new int [ 3 ] ; for ( int cnt = 0 ; cnt < qoaxdv ; cnt ++ ) { for ( int i = 0 ; i < triangle . length ; i ++ ) { triangle [ i ] = sc . nextInt ( ) ; } sort ( triangle ) ; isRightTriangle ( triangle [ 0 ] , triangle [ 1 ] , triangle [ 2 ] ) ; } } static void sort ( int [ ] data ) { int min , tmp ; for ( int i = 0 ; i < data . length ; i ++ ) { min = i ; for ( int j = i + 1 ; j < data . length ; j ++ ) if ( data [ min ] > data [ j ] ) min = j ; tmp = data [ i ] ; data [ i ] = data [ min ] ; data [ min ] = tmp ; } } } import java . util . Scanner ; public class Vuhiho { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long vuhiho = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long answer = vuhiho * B / calcGcd ( vuhiho , B ) ; System . out . println ( answer ) ; sc . close ( ) ; } static long calcGcd ( long m , long n ) { if ( m < n ) { long tmp = m ; m = n ; n = tmp ; } long remainder = 0 ; while ( ( remainder = m % n ) != 0 ) { m = n ; n = remainder ; } return n ; } } import java . util . * ; class Cmioix { public static void main ( String [ ] args ) { int cmioix ; int stacksize = 100 ; String temp ; int calc ; int a , b ; Deque < Integer > stack = new ArrayDeque < Integer > ( ) ; String separator = System . getProperty ( " line.separator " ) ; Scanner sc1 = new Scanner ( System . in ) ; String str = sc1 . nextLine ( ) ; Scanner sc2 = new Scanner ( str ) ; sc2 . useDelimiter ( " " ) ; while ( sc2 . hasNext ( ) ) { temp = sc2 . next ( ) ; if ( temp . equals ( " + " ) ) { calc = stack . removeFirst ( ) + stack . removeFirst ( ) ; stack . addFirst ( calc ) ; } else if ( temp . equals ( " - " ) ) { a = stack . removeFirst ( ) ; b = stack . removeFirst ( ) ; calc = b - a ; stack . addFirst ( calc ) ; } else if ( temp . equals ( " * " ) ) { calc = stack . removeFirst ( ) * stack . removeFirst ( ) ; stack . addFirst ( calc ) ; } else { stack . addFirst ( Integer . parseInt ( temp ) ) ; } } System . out . println ( stack . removeFirst ( ) ) ; } } import java . io . * ; import java . util . * ; public class Injery { static long injery = ( long ) 1e9 + 7 ; public static void main ( String [ ] args ) throws IOException { Reader . init ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = Reader . nextInt ( ) , x = Reader . nextInt ( ) , t = Reader . nextInt ( ) ; long ans = ( n + x - 1 ) / x ; ans *= t ; out . println ( ans ) ; out . flush ( ) ; } } class Injery { static BufferedReader reader ; static StringTokenizer tokenizer ; static void init ( ) throws IOException { reader = new BufferedReader ( new FileReader ( " C: \\ Users \\ samee \\ Desktop \\ GRE prep \\ confusion.txt " ) ) ; tokenizer = new StringTokenizer ( " " ) ; } static void init ( InputStream input ) { reader = new BufferedReader ( new InputStreamReader ( input ) ) ; tokenizer = new StringTokenizer ( " " ) ; } static String nextLine ( ) throws IOException { return reader . readLine ( ) ; } static String next ( ) throws IOException { while ( ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } static long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } static double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } } import java . io . * ; import java . util . * ; public class Pujsix { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int pujsix = in . nextInt ( ) , b = in . nextInt ( ) , c = in . nextInt ( ) , n = in . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i <= pujsix ; i ++ ) { int x = 500 * i ; for ( int j = 0 ; j <= b ; j ++ ) { int y = 100 * j ; if ( n - x - y >= 0 && ( n - x - y ) % 50 == 0 && ( n - x - y ) / 50 <= c ) count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Jzvxqk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; for ( int jzvxqk = 1 ; jzvxqk <= 10000 ; jzvxqk ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( x == 0 && y == 0 ) { break ; } else { System . out . println ( Math . min ( x , y ) + " " + Math . max ( x , y ) ) ; } } sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Wzeqp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wzeqp = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean [ ] clash = new boolean [ wzeqp + 1 ] ; Arrays . fill ( clash , true ) ; for ( int i = 0 ; i < m ; i ++ ) clash [ sc . nextInt ( ) ] = false ; int [ ] dp = new int [ wzeqp + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 0 ; i < wzeqp ; i ++ ) { for ( int j = i + 1 ; j <= Math . min ( i + 2 , wzeqp ) ; j ++ ) { if ( clash [ j ] ) { dp [ j ] += dp [ i ] ; dp [ j ] %= 1000000007 ; } } } System . out . println ( dp [ wzeqp ] ) ; sc . close ( ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Vvrhp { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Vvrhp { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String str = in . next ( ) ; int vvrhp = 0 ; for ( char c : str . toCharArray ( ) ) { if ( c == '1' ) { vvrhp ++ ; } } out . print ( vvrhp ) ; } } } import java . util . Scanner ; public class Xhcvw { public static int getGcd ( int a , int b ) { if ( a == b ) return b ; int xhcvw = Math . max ( a , b ) ; int smaller = Math . min ( a , b ) ; int modded = xhcvw % smaller ; if ( modded == 0 ) return smaller ; return getGcd ( smaller , xhcvw % smaller ) ; } public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int a = s . nextInt ( ) ; int b = s . nextInt ( ) ; int result = getGcd ( a , b ) ; System . out . println ( result ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; class Coltxue { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; int coltxue = s . nextInt ( ) ; int [ ] a = new int [ coltxue ] ; for ( int i = 0 ; i < coltxue ; i ++ ) a [ i ] = s . nextInt ( ) ; int count = 0 ; boolean flag = false ; int j = 1 ; for ( int i = 0 ; i < coltxue ; i ++ ) { if ( a [ i ] == j ) { j ++ ; flag = true ; } else count ++ ; } if ( flag ) System . out . println ( count ) ; else { System . out . println ( " -1 " ) ; } } } import java . util . Scanner ; public class Teveax { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int teveax = sc . nextInt ( ) ; int [ ] s = new int [ teveax ] ; for ( int i = 0 ; i < teveax ; i ++ ) { s [ i ] = sc . nextInt ( ) ; } int q = sc . nextInt ( ) ; int t , mid , r , l , cnt = 0 ; for ( int i = 0 ; i < q ; i ++ ) { t = sc . nextInt ( ) ; l = 0 ; r = teveax - 1 ; while ( l <= r ) { mid = ( l + r ) / 2 ; if ( s [ mid ] == t ) { cnt ++ ; break ; } else if ( s [ mid ] > t ) { r = mid - 1 ; } else { l = mid + 1 ; } } } System . out . printf ( " %d%n " , cnt ) ; } } import java . util . * ; public class Oqjchd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String someString = sc . next ( ) ; char oqjchd = 'R' ; int rCount = 0 ; for ( int i = 0 ; i < someString . length ( ) ; i ++ ) { if ( rCount == 0 && someString . charAt ( i ) == oqjchd ) { rCount = 1 ; } if ( someString . charAt ( i ) == oqjchd ) { if ( i > 0 && someString . charAt ( i - 1 ) == oqjchd ) { rCount ++ ; } } } System . out . println ( rCount ) ; } } import java . util . * ; public class Ntgffrj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ntgffrj = sc . nextInt ( ) ; int [ ] L = new int [ ntgffrj ] ; for ( int i = 0 ; i < ntgffrj ; i ++ ) { L [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( L ) ; int sum = 0 ; for ( int i = ntgffrj - 2 ; 0 <= i ; i -- ) { sum += L [ i ] ; } if ( L [ ntgffrj - 1 ] < sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Iryvj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iryvj = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( ! ( e - iryvj > k ) ) { System . out . print ( " Yay! " ) ; } else { System . out . print ( " :( " ) ; } } } import java . util . Scanner ; public class Woijqy { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int woijqy = in . nextInt ( ) ; int n = in . nextInt ( ) ; int [ ] a = new int [ 200009 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; } a [ n ] = woijqy + a [ 0 ] ; int ans = 1000000009 ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . min ( ans , woijqy - ( a [ i + 1 ] - a [ i ] ) ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Smidis { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int smidis = Integer . parseInt ( s . next ( ) ) ; int b = Integer . parseInt ( s . next ( ) ) ; System . out . printf ( " %d %d %.5f " , smidis / b , smidis % b , ( double ) smidis / ( double ) b ) ; } } import java . io . BufferedInputStream ; import java . io . BufferedOutputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Evozx { public static void main ( String [ ] args ) throws Exception { try ( BufferedInputStream in = new BufferedInputStream ( System . in ) ; PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ) { Scanner sc = new Scanner ( in ) ; String s = sc . next ( ) ; int [ ] [ ] dp = new int [ 2 ] [ s . length ( ) ] ; char evozx = s . charAt ( 0 ) ; dp [ 0 ] [ 0 ] = ( evozx == '1' ? 1 : 0 ) ; dp [ 1 ] [ 0 ] = ( evozx == '0' ? 1 : 0 ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { char x = s . charAt ( i ) ; dp [ 0 ] [ i ] = ( x == '1' ? 1 : 0 ) + dp [ 1 ] [ i - 1 ] ; dp [ 1 ] [ i ] = ( x == '0' ? 1 : 0 ) + dp [ 0 ] [ i - 1 ] ; } out . println ( Math . min ( dp [ 0 ] [ s . length ( ) - 1 ] , dp [ 1 ] [ s . length ( ) - 1 ] ) ) ; } } } import java . io . * ; import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Obmvtq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] s = br . readLine ( ) . split ( " " ) ; long obmvtq = Long . parseLong ( s [ 0 ] ) ; long B = Long . parseLong ( s [ 1 ] ) ; long C = Long . parseLong ( s [ 2 ] ) ; long K = Long . parseLong ( s [ 3 ] ) ; long sum = 0 ; boolean flag = true ; if ( K > obmvtq && flag == true ) { K -= obmvtq ; sum += obmvtq ; } else if ( K <= obmvtq && flag == true ) { sum += K ; K = 0 ; flag = false ; } if ( K > B && flag == true ) { K -= B ; } else if ( K <= B && flag == true ) { K = 0 ; flag = false ; } if ( K > C && flag == true ) { K -= C ; sum -= C ; } else if ( K <= C && flag == true ) { sum -= K ; K = 0 ; flag = false ; } out . println ( sum ) ; } } import java . util . Scanner ; public class Lkdxzdb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lkdxzdb = sc . nextInt ( ) ; int [ ] p = new int [ lkdxzdb ] ; for ( int i = 0 ; i < lkdxzdb ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int c = 0 ; for ( int i = 0 ; i < lkdxzdb ; i ++ ) { if ( p [ i ] != i + 1 ) c ++ ; } if ( c > 2 ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Infcx { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; while ( true ) { String [ ] str = br . readLine ( ) . split ( " " ) ; int infcx = Integer . parseInt ( str [ 0 ] ) ; int W = Integer . parseInt ( str [ 1 ] ) ; if ( infcx == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < infcx ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { if ( i == 0 || j == 0 || i == infcx - 1 || j == W - 1 ) { sb . append ( " # " ) ; } else { sb . append ( " . " ) ; } } sb . append ( " \n " ) ; } sb . append ( " \n " ) ; } System . out . print ( sb ) ; } } import java . util . Scanner ; public class Tmxkk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tmxkk = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( tmxkk > 0 && tmxkk <= 9 && b > 0 && b <= 9 ) System . out . println ( tmxkk * b ) ; else System . out . println ( " -1 " ) ; } } import java . util . Scanner ; public class Bykaycz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bykaycz = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; System . out . println ( solve ( bykaycz , Q , R ) ) ; sc . close ( ) ; } static int solve ( int bykaycz , int Q , int R ) { return bykaycz + Q + R - Math . max ( Math . max ( bykaycz , Q ) , R ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Pymgp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > A = new ArrayList < Integer > ( ) ; for ( int pymgp = 0 ; pymgp < 3 ; pymgp ++ ) { A . add ( Integer . parseInt ( sc . next ( ) ) ) ; } Collections . sort ( A ) ; System . out . println ( A . get ( 2 ) - A . get ( 0 ) ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; class Spxjnhm { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int spxjnhm = sc . nextInt ( ) ; ArrayList < Integer > a = new ArrayList < Integer > ( spxjnhm ) ; for ( int i = 0 ; i < spxjnhm ; i ++ ) { int x = sc . nextInt ( ) ; a . add ( x ) ; } int ans = Integer . MAX_VALUE ; for ( int k = 1 ; k <= 100 ; k ++ ) { int mans = 0 ; for ( int i = 0 ; i < spxjnhm ; i ++ ) { mans += ( ( a . get ( i ) - k ) * ( a . get ( i ) - k ) ) ; } ans = Math . min ( ans , mans ) ; } System . out . println ( ans ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Plflt { static long plflt = 1000000007 ; static long INF = Long . MAX_VALUE ; static long chmin ( long a , long b ) { return Math . min ( a , b ) ; } static long chmax ( long a , long b ) { return Math . max ( a , b ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] P = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { P [ i ] = sc . nextInt ( ) ; } Arrays . sort ( P ) ; int ans = 0 ; for ( int i = 0 ; i < K ; i ++ ) { ans += P [ i ] ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class Ehfrc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] t = { " eraser " , " erase " , " dreamer " , " dream " } ; for ( int ehfrc = 0 ; ehfrc < 4 ; ehfrc ++ ) s = s . replace ( t [ ehfrc ] , " " ) ; System . out . println ( s . equals ( " " ) ? " YES " : " NO " ) ; } } import java . util . Scanner ; class Rgpizw { private final int rgpizw ; Solver ( Scanner in ) { int N = in . nextInt ( ) ; rgpizw = in . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( in . nextInt ( ) >= rgpizw ) count ++ ; } System . out . println ( count ) ; } void solve ( ) { } } class Rgpizw { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; new Solver ( in ) . solve ( ) ; in . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Wnonni { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int wnonni = 100000 ; int n = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { wnonni *= 1.05 ; if ( ( wnonni - ( ( wnonni / 1000 ) * 1000 ) ) != 0 ) { wnonni = ( wnonni / 1000 ) * 1000 + 1000 ; } else { wnonni = ( wnonni / 1000 ) * 1000 ; } } System . out . println ( wnonni ) ; } } import java . util . Scanner ; class Udihvd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] chars = new int [ 256 ] ; for ( int udihvd = 0 ; udihvd < 256 ; udihvd ++ ) chars [ udihvd ] = 0 ; while ( scan . hasNextLine ( ) ) { String line = scan . nextLine ( ) ; for ( int udihvd = 0 ; udihvd < line . length ( ) ; udihvd ++ ) { char ch = Character . toLowerCase ( line . charAt ( udihvd ) ) ; if ( ch >= 'a' && ch <= 'z' ) chars [ ch ] ++ ; } } for ( char ch = 'a' ; ch <= 'z' ; ch ++ ) System . out . println ( ch + " : " + chars [ ch ] ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Razpwx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int razpwx = Integer . parseInt ( sc . next ( ) ) ; int X = Integer . parseInt ( sc . next ( ) ) ; int [ ] M = new int [ razpwx ] ; for ( int i = 0 ; i < razpwx ; i ++ ) { M [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; Arrays . sort ( M ) ; int sum = 0 ; int cnt = razpwx ; for ( int i = 0 ; i < razpwx ; i ++ ) { sum += M [ i ] ; } if ( X - sum >= M [ 0 ] ) { do { sum += M [ 0 ] ; cnt ++ ; } while ( X - sum >= M [ 0 ] ) ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Ztlzb { static Scanner sc = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { while ( sc . hasNext ( ) ) { long ztlzb = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; long x = ztlzb ; long y = b ; long max = y ; while ( x % y != 0 ) { max = x % y ; x = y ; y = max ; } long min = ztlzb * b / max ; System . out . println ( max + " " + min ) ; } } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class Obnkicr { public static void main ( String [ ] args ) throws Exception { solve ( System . in , System . out ) ; } static void solve ( InputStream is , PrintStream os ) { Scanner scan = new Scanner ( is ) ; int obnkicr = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; os . println ( obnkicr * B ) ; } } import java . util . * ; public class Huweh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String dow = sc . next ( ) ; ArrayList < String > week = new ArrayList < > ( Arrays . asList ( " SUN " , " MON " , " TUE " , " WED " , " THU " , " FRI " , " SAT " ) ) ; int huweh = 7 - week . indexOf ( dow ) ; System . out . println ( huweh ) ; } } import java . util . Scanner ; public class Hqesxo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int hqesxo = scan . nextInt ( ) ; System . out . println ( hqesxo / 500 * 1000 + hqesxo % 500 / 5 * 5 ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Xqxzl { private static Scanner sc = new Scanner ( System . in ) ; static void p ( String ans ) { System . out . println ( ans ) ; } static void p ( int ans ) { System . out . println ( ans ) ; } static void p ( long ans ) { System . out . println ( ans ) ; } static void p ( double ans ) { System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String s = sc . next ( ) ; int xqxzl = 0 ; for ( int i = 0 ; i < s . length ( ) / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( s . length ( ) - i - 1 ) ) { xqxzl ++ ; } } p ( xqxzl ) ; } } import java . util . * ; class Kfqbke { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kfqbke = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; Integer [ ] h = new Integer [ kfqbke ] ; int c = 0 ; for ( int i = 0 ; i < kfqbke ; i ++ ) { h [ i ] = Integer . parseInt ( sc . next ( ) ) ; if ( h [ i ] >= K ) c ++ ; } System . out . println ( c ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Plkyk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int plkyk = sc . nextInt ( ) ; int [ ] a = new int [ plkyk ] ; for ( int i = 0 ; i < plkyk ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; int alice = 0 ; int bob = 0 ; int check = 0 ; for ( int i = plkyk - 1 ; i > - 1 ; i -- ) { if ( check == 0 ) { alice += a [ i ] ; check = 1 ; } else { bob += a [ i ] ; check = 0 ; } } System . out . println ( alice - bob ) ; } } import java . util . Scanner ; public class Tbqbqjh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int tbqbqjh = sc . nextInt ( ) ; int [ ] [ ] dp = new int [ 201 ] [ 201 ] ; long res = 0 ; for ( int i = 1 ; i <= tbqbqjh ; i ++ ) { for ( int j = 1 ; j <= tbqbqjh ; j ++ ) { int gcd ; if ( dp [ i ] [ j ] == 0 ) { gcd = gcd ( i , j ) ; dp [ i ] [ j ] = gcd ; } else { gcd = dp [ i ] [ j ] ; } for ( int k = 1 ; k <= tbqbqjh ; k ++ ) { int gcd3 ; if ( dp [ gcd ] [ k ] == 0 ) { gcd3 = gcd ( gcd , k ) ; dp [ gcd ] [ k ] = gcd3 ; } else { gcd3 = dp [ gcd ] [ k ] ; } res += gcd3 ; } } } System . out . println ( res ) ; } private static int gcd ( int i , int j ) { while ( i != 0 && j != 0 ) { if ( i < j ) { j %= i ; } else { i %= j ; } } return Math . max ( i , j ) ; } } import java . util . * ; public class Tyafl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int tyafl = Integer . parseInt ( S . substring ( 5 , 7 ) ) ; if ( tyafl < 5 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Nyeflr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nyeflr = sc . nextInt ( ) ; ArrayList < Integer > deckList = new ArrayList < > ( ) ; for ( int i = 1 ; i <= nyeflr ; i ++ ) { deckList . add ( sc . nextInt ( ) ) ; } Collections . sort ( deckList , Collections . reverseOrder ( ) ) ; int first_player = 0 ; int second_player = 0 ; for ( int i = 0 ; i < deckList . size ( ) ; i ++ ) { if ( i % 2 == 0 ) { first_player += deckList . get ( i ) ; } else { second_player += deckList . get ( i ) ; } } sc . close ( ) ; System . out . println ( first_player - second_player ) ; } } import java . util . Scanner ; public class Qszktwi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; scanner . close ( ) ; int qszktwi = 0 , minus = 0 ; for ( int n = 0 ; n < S . length ( ) ; n ++ ) { String s = S . substring ( n , n + 1 ) ; if ( s . equals ( " + " ) ) { qszktwi ++ ; } else if ( s . equals ( " - " ) ) { minus ++ ; } } int A = qszktwi - minus ; System . out . println ( A ) ; } } import java . util . Scanner ; public class Uawdcr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int uawdcr = scan . nextInt ( ) ; int n = scan . nextInt ( ) ; int [ ] array = new int [ 200000 ] ; for ( int i = 0 ; i < n ; i ++ ) { array [ i ] = scan . nextInt ( ) ; } int distance = 0 ; int max = array [ 0 ] + ( uawdcr - array [ n - 1 ] ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { distance = array [ i + 1 ] - array [ i ] ; if ( distance >= max ) { max = distance ; } } System . out . println ( uawdcr - max ) ; scan . close ( ) ; } } import java . util . Scanner ; class Isrhfw { public static void main ( String [ ] args ) { int isrhfw = 0 , i , j , yaku = 0 , n , m ; Scanner scan = new Scanner ( System . in ) ; n = scan . nextInt ( ) ; if ( 1 > n || n > 10000 ) { System . exit ( 0 ) ; } for ( i = 0 ; i < n ; i ++ ) { m = scan . nextInt ( ) ; if ( 2 > m || m > 100000000 ) { System . exit ( 0 ) ; } for ( j = 2 ; j <= Math . sqrt ( m ) ; j ++ ) { if ( m % j == 0 ) { yaku ++ ; } } if ( yaku == 0 ) { isrhfw ++ ; } yaku = 0 ; } System . out . println ( isrhfw ) ; } } import java . util . Scanner ; public class Ufekcr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; int ufekcr = S . ufekcr ( ) ; int count = 0 ; for ( int i = 0 ; i < ufekcr / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( ufekcr - 1 - i ) ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class Ynrpdr { public static void main ( String [ ] args ) { int ynrpdr ; Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; for ( ynrpdr = 0 ; ynrpdr < n ; ynrpdr ++ ) { a . add ( Integer . parseInt ( sc . next ( ) ) ) ; } sc . close ( ) ; Collections . sort ( a , Comparator . reverseOrder ( ) ) ; int ans = 0 ; for ( ynrpdr = 0 ; ynrpdr < n ; ynrpdr ++ ) { if ( ynrpdr % 2 == 0 ) ans += a . get ( ynrpdr ) ; else ans -= a . get ( ynrpdr ) ; } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . text . ParseException ; import java . text . SimpleDateFormat ; import java . util . Date ; public class Imyqu { public static void main ( String [ ] args ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String imyqu = null ; try { imyqu = br . readLine ( ) ; br . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } SimpleDateFormat sdf = new SimpleDateFormat ( " yyyy/MM/dd " ) ; Date formatDate = null ; try { formatDate = sdf . parse ( imyqu ) ; } catch ( ParseException e ) { e . printStackTrace ( ) ; } Date compareDate = null ; try { compareDate = sdf . parse ( " 2019/04/30 " ) ; } catch ( ParseException e ) { } if ( formatDate . after ( compareDate ) ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } } } import java . util . Scanner ; public class Dakam { public static void main ( String ... args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String a = sc . next ( ) ; String b = sc . next ( ) ; int dakam = Integer . parseInt ( a + b ) ; int tmp = ( int ) Math . sqrt ( dakam ) ; if ( Math . pow ( tmp , 2 ) == dakam ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Jvqie { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; Map < Character , Integer > map = new HashMap < > ( ) ; for ( int jvqie = 0 ; jvqie < s . length ( ) ; jvqie ++ ) { if ( map . containsKey ( s . charAt ( jvqie ) ) ) { map . put ( s . charAt ( jvqie ) , map . get ( s . charAt ( jvqie ) ) + 1 ) ; } else { map . put ( s . charAt ( jvqie ) , 1 ) ; } } String ans = " Yes " ; if ( map . keySet ( ) . size ( ) != 2 ) { ans = " No " ; } for ( Character ch : map . keySet ( ) ) { if ( map . get ( ch ) != 2 ) { ans = " No " ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Ncrtxpm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ncrtxpm = sc . nextInt ( ) ; String S = sc . next ( ) ; int s = S . length ( ) ; String [ ] P = S . split ( " " ) ; String [ ] Q = { " A " , " B " , " C " , " D " , " E " , " F " , " G " , " H " , " I " , " J " , " K " , " L " , " M " , " N " , " O " , " P " , " Q " , " R " , " S " , " T " , " U " , " V " , " W " , " X " , " Y " , " Z " } ; String [ ] R = new String [ s + 1 ] ; R [ 0 ] = " " ; for ( int i = 0 ; i < s ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) { if ( P [ i ] . equals ( Q [ j ] ) ) { R [ i + 1 ] = R [ i ] + Q [ ( j + ncrtxpm ) % 26 ] ; } } } System . out . println ( R [ s ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Rovvc { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = new String ( in . readLine ( ) ) ; String [ ] ss = s . split ( " " ) ; int rovvc = Integer . parseInt ( ss [ 0 ] ) ; int b = Integer . parseInt ( ss [ 1 ] ) ; System . out . print ( rovvc * b ) ; System . out . print ( " " ) ; System . out . println ( 2 * rovvc + 2 * b ) ; } } import java . util . * ; class Krdxcv { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] aaa = scanner . nextLine ( ) . split ( " " , 3 ) ; int [ ] arr = new int [ 3 ] ; for ( int krdxcv = 0 ; krdxcv < 3 ; krdxcv ++ ) { arr [ krdxcv ] = Integer . parseInt ( aaa [ krdxcv ] ) ; } Arrays . sort ( arr ) ; System . out . println ( arr [ 2 ] - arr [ 0 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Fpkdi { public static void main ( String [ ] args ) throws IOException { final int fpkdi = 10 ; int [ ] a = new int [ fpkdi ] ; InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( is ) ; for ( int i = 0 ; i < fpkdi ; i ++ ) { a [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } for ( int i = 0 ; i < fpkdi ; i ++ ) { for ( int j = i + 1 ; j < fpkdi ; j ++ ) { if ( a [ i ] < a [ j ] ) { int tmp = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = tmp ; } } } for ( int i = 0 ; i < 3 ; i ++ ) { System . out . println ( a [ i ] ) ; } } } import java . util . Scanner ; public class Wfwlg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long wfwlg = Long . parseLong ( sc . next ( ) ) ; long yokin = 100 ; int counter = 0 ; while ( ! ( yokin >= wfwlg ) ) { yokin *= 1.01 ; counter ++ ; } System . out . println ( counter ) ; } } import java . util . Scanner ; public class Luqqdyg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int luqqdyg = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int divisor = 0 ; for ( int i = 0 ; i <= ( b - luqqdyg ) ; i ++ ) { if ( c % ( luqqdyg + i ) == 0 ) { divisor += 1 ; } } System . out . println ( divisor ) ; sc . close ( ) ; } } import java . util . * ; public class Qnitav { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int qnitav = in . nextInt ( ) ; long [ ] mo = new long [ qnitav + 1 ] ; for ( int i = 0 ; i < qnitav + 1 ; i ++ ) { mo [ i ] = in . nextInt ( ) ; } long sum = 0 ; long yu = 0 ; for ( int i = 0 ; i < qnitav ; i ++ ) { yu = in . nextInt ( ) ; if ( yu > mo [ i ] ) { sum += mo [ i ] ; yu -= mo [ i ] ; sum += Math . min ( mo [ i + 1 ] , yu ) ; mo [ i + 1 ] = Math . max ( 0 , mo [ i + 1 ] - yu ) ; } else { sum += yu ; } } System . out . print ( sum ) ; } } import java . util . * ; import java . util . function . * ; import java . math . * ; public class Vqaya { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String vqaya = sc . next ( ) ; System . out . println ( " ABC " . equals ( vqaya ) ? " ARC " : " ABC " ) ; } } import java . util . * ; public class Mixmri { private static void prin ( String ans ) { System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mixmri = sc . nextInt ( ) ; int upp = mixmri / 100 ; int downn = mixmri % 100 ; boolean my = ( ( 1 <= upp ) && ( upp <= 12 ) ) ; boolean ym = ( ( 1 <= downn ) && ( downn <= 12 ) ) ; if ( my && ym ) prin ( " AMBIGUOUS " ) ; else if ( my ) prin ( " MMYY " ) ; else if ( ym ) prin ( " YYMM " ) ; else prin ( " NA " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Fiwylk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = br . readLine ( ) . toLowerCase ( ) ; int fiwylk = 0 ; String line ; while ( ! ( ( line = br . readLine ( ) ) . equals ( " END_OF_TEXT " ) ) ) { line = line . toLowerCase ( ) ; StringTokenizer st = new StringTokenizer ( line , " " ) ; while ( st . hasMoreTokens ( ) ) { if ( st . nextToken ( ) . equals ( W ) ) fiwylk ++ ; } } System . out . println ( fiwylk ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Qldcn { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int qldcn = Integer . parseInt ( in . readLine ( ) ) ; if ( qldcn < 0 || Math . pow ( 10 , 4 ) < qldcn ) throw new RuntimeException ( " error:range " ) ; String [ ] nums = new String [ qldcn ] ; nums = in . readLine ( ) . split ( " " ) ; int min = Integer . parseInt ( nums [ 0 ] ) , max = Integer . parseInt ( nums [ 0 ] ) ; long sum = 0 ; for ( int i = 0 ; i < qldcn ; i += 1 ) { max = Math . max ( max , Integer . parseInt ( nums [ i ] ) ) ; min = Math . min ( min , Integer . parseInt ( nums [ i ] ) ) ; if ( Integer . parseInt ( nums [ i ] ) < - Math . pow ( 10 , 6 ) || Math . pow ( 10 , 6 ) < Integer . parseInt ( nums [ i ] ) ) throw new RuntimeException ( " error:nums " ) ; sum = sum + Integer . parseInt ( nums [ i ] ) ; } System . out . println ( min + " " + max + " " + sum ) ; } } import java . util . Scanner ; public class Vscnd { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int vscnd = input . nextInt ( ) ; int M = input . nextInt ( ) ; int cnt = 0 ; System . out . println ( vscnd * ( vscnd - 1 ) / 2 + M * ( M - 1 ) / 2 ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class Hkbow { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; final String hkbow = sc . next ( ) ; sc . close ( ) ; String ans = null ; switch ( hkbow ) { case " Sunny " : ans = " Cloudy " ; break ; case " Cloudy " : ans = " Rainy " ; break ; case " Rainy " : ans = " Sunny " ; break ; } out . println ( ans ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Esyzez { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B121 solver = new B121 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Esyzez { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int esyzez = Integer . parseInt ( in . next ( ) + in . next ( ) ) ; for ( int i = 1 ; i < 10000 ; i ++ ) { if ( esyzez == i * i ) { out . println ( " Yes " ) ; return ; } } out . println ( " No " ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Naxmirw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > x = new ArrayList < > ( ) ; for ( int naxmirw = 0 ; naxmirw < 5 ; naxmirw ++ ) { x . add ( sc . nextInt ( ) ) ; } for ( Integer naxmirw : x ) { if ( naxmirw == 0 ) { System . out . println ( x . indexOf ( naxmirw ) + 1 ) ; } } sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Swkmg { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int swkmg = s . nextInt ( ) ; int N = s . nextInt ( ) ; int [ ] p = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { p [ i ] = s . nextInt ( ) ; } int ans = 0 ; Arrays . sort ( p ) ; for ( int i = 0 ; i <= 101 ; i ++ ) { boolean include = false ; for ( int k = 0 ; k < p . length ; k ++ ) { if ( i == p [ k ] ) { include = true ; break ; } } if ( ! include && Math . abs ( swkmg - ans ) > Math . abs ( swkmg - i ) ) { ans = i ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Vkxode { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int vkxode = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int C = scan . nextInt ( ) ; boolean flag = false ; if ( vkxode == B && B != C ) { flag = true ; } if ( B == C && C != vkxode ) { flag = true ; } if ( vkxode == C && B != vkxode ) { flag = true ; } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . IOException ; import java . util . Scanner ; public class Akecw { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; while ( true ) { final String [ ] data = sc . nextLine ( ) . split ( " " ) ; final int akecw = Integer . parseInt ( data [ 0 ] ) ; final int x = Integer . parseInt ( data [ 1 ] ) ; if ( akecw == 0 && x == 0 ) break ; int count = 0 ; for ( int i = 1 ; i <= akecw - 2 ; i ++ ) { for ( int j = i + 1 ; j <= akecw - 1 ; j ++ ) { for ( int k = j + 1 ; k <= akecw ; k ++ ) { if ( ( i + j + k ) == x ) count ++ ; } } } System . out . println ( count ) ; } } } import java . util . * ; class Bsril { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String bsril = scan . next ( ) ; System . out . println ( bsril . matches ( " [A][a-z][a-z]*[C][a-z]*[a-z] " ) ? " AC " : " WA " ) ; } } import java . util . Scanner ; public class Zyrdyx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zyrdyx = sc . nextInt ( ) ; int [ ] d1 = new int [ zyrdyx ] ; int [ ] d2 = new int [ zyrdyx ] ; for ( int i = 0 ; i <= zyrdyx - 1 ; i ++ ) { d1 [ i ] = sc . nextInt ( ) ; d2 [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i <= zyrdyx - 3 ; i ++ ) { if ( d1 [ i ] == d2 [ i ] && d1 [ i + 1 ] == d2 [ i + 1 ] && d1 [ i + 2 ] == d2 [ i + 2 ] ) { System . out . println ( " Yes " ) ; break ; } else if ( i == zyrdyx - 3 ) { System . out . println ( " No " ) ; } } sc . close ( ) ; } } import java . util . * ; public class Afkxe { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solveB ( ) ; } private void solveA ( ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int afkxe = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == 'o' ) afkxe += 100 ; } System . out . println ( 700 + afkxe ) ; } private void solveB ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int cnt = 0 ; int [ ] m = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { m [ i ] = sc . nextInt ( ) ; } Arrays . sort ( m ) ; for ( int i = 0 ; i < n ; i ++ ) { x -= m [ i ] ; cnt ++ ; } System . out . println ( cnt + x / m [ 0 ] ) ; } } import java . util . Scanner ; public class Phwaxe { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int phwaxe = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; int [ ] dp = new int [ phwaxe ] ; for ( int i = 1 ; i < phwaxe ; i ++ ) { dp [ i ] = dp [ i - 1 ] ; if ( S . substring ( i - 1 , i + 1 ) . equals ( " AC " ) ) { dp [ i ] ++ ; } } for ( int i = 0 ; i < q ; i ++ ) { int L = Integer . parseInt ( sc . next ( ) ) ; int R = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( ( dp [ R - 1 ] - dp [ L - 1 ] ) ) ; } sc . close ( ) ; } } import java . util . * ; public class Kraij { public static void main ( String [ ] args ) { Scanner Input = new Scanner ( System . in ) ; String A = Input . next ( ) ; String B = Input . next ( ) ; int kraij = 0 ; for ( int I = Integer . parseInt ( A ) ; I <= Integer . parseInt ( B ) ; I ++ ) { String J = I + " " ; if ( J . charAt ( 0 ) == J . charAt ( 4 ) && J . charAt ( 1 ) == J . charAt ( 3 ) ) { kraij ++ ; } } System . out . println ( kraij ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; public class Xpeen { public static boolean xpeen = true ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; HashMap < String , Long > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { char [ ] array = sc . next ( ) . toCharArray ( ) ; Arrays . sort ( array ) ; String result = new String ( array ) ; long temp = 0 ; if ( map . containsKey ( result ) ) { temp = map . get ( result ) ; } map . put ( result , temp + 1 ) ; } long count = 0 ; for ( long c : map . values ( ) ) { count += c * ( c - 1 ) / 2 ; } System . out . println ( count ) ; } } import java . util . * ; public class Rebeyg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rebeyg = sc . nextInt ( ) ; int A_2 = sc . nextInt ( ) ; int A_3 = sc . nextInt ( ) ; int [ ] S = new int [ ] { rebeyg , A_2 , A_3 } ; Arrays . sort ( S ) ; System . out . println ( ( S [ 2 ] - S [ 1 ] ) + ( S [ 1 ] - S [ 0 ] ) ) ; } } import java . util . * ; public class Epioca { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int epioca = sc . nextInt ( ) ; int [ ] x = new int [ epioca ] ; int [ ] y = new int [ epioca ] ; int sum = 0 ; for ( int i = 0 ; i < epioca ; i ++ ) { x [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < epioca ; i ++ ) { y [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < epioca ; i ++ ) { if ( x [ i ] >= y [ i ] ) { sum += x [ i ] - y [ i ] ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Pixod { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pixod = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int Z = sc . nextInt ( ) ; System . out . printf ( " %d %d %d " , Z , pixod , Y ) ; } } import java . io . * ; class Xqqiqe { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String str1 = br . readLine ( ) ; int [ ] digit = new int [ str1 . length ( ) ] ; int xqqiqe = 0 ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { digit [ i ] = Character . getNumericValue ( str1 . charAt ( i ) ) ; xqqiqe += digit [ i ] ; } if ( xqqiqe == 0 ) { break ; } else System . out . println ( xqqiqe ) ; } } } import java . util . Scanner ; class Bxttpw { public static void main ( String [ ] args ) { Scanner S = new Scanner ( System . in ) ; while ( true ) { int bxttpw = S . nextInt ( ) ; int y = S . nextInt ( ) ; if ( bxttpw == 0 && y == 0 ) break ; if ( bxttpw < y ) System . out . printf ( " %d %d \n " , bxttpw , y ) ; else System . out . printf ( " %d %d \n " , y , bxttpw ) ; } } } import java . util . * ; public class Acpfwlt { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int acpfwlt = in . nextInt ( ) ; StringBuilder ans ; int cnt = 0 ; for ( int i = 1 ; i <= acpfwlt ; i ++ ) { ans = new StringBuilder ( " " + i ) ; if ( ans . length ( ) % 2 != 0 ) { cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Wutbtij { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wutbtij = scan . nextInt ( ) ; int Y = scan . nextInt ( ) ; for ( int x = 0 ; x <= wutbtij ; x ++ ) { for ( int y = 0 ; y <= wutbtij - x ; y ++ ) { int total = x * 10000 + y * 5000 + 1000 * ( wutbtij - x - y ) ; if ( total == Y ) { System . out . println ( x + " " + y + " " + ( wutbtij - x - y ) ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . util . Scanner ; public class Gzxdl { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; String lower = " abcdefghijklmnopqrstuvwxyz " ; if ( s . charAt ( 0 ) != 'A' ) { System . out . println ( " WA " ) ; } else { if ( ! lower . contains ( s . charAt ( 1 ) + " " ) ) { System . out . println ( " WA " ) ; return ; } int gzxdl = 0 ; for ( int i = 2 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == 'C' ) { gzxdl ++ ; } else { if ( ! lower . contains ( s . charAt ( i ) + " " ) ) { System . out . println ( " WA " ) ; return ; } } } if ( ! lower . contains ( s . charAt ( s . length ( ) - 1 ) + " " ) ) { System . out . println ( " WA " ) ; return ; } if ( gzxdl == 1 ) { System . out . println ( " AC " ) ; } else { System . out . println ( " WA " ) ; } } } } import java . util . * ; public class Oorikg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oorikg , i , j , count = 0 ; oorikg = Integer . parseInt ( sc . next ( ) ) ; int [ ] height = new int [ oorikg ] ; for ( i = 0 ; i < oorikg ; i ++ ) { height [ i ] = Integer . parseInt ( sc . next ( ) ) ; for ( j = 0 ; j < i ; j ++ ) { if ( height [ j ] > height [ i ] ) { break ; } } if ( j == i ) count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Fmkxatc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long fmkxatc = scanner . nextLong ( ) ; String result = new String ( ) ; while ( fmkxatc > 0 ) { int nums = ( int ) ( 'a' + ( fmkxatc - 1 ) % 26 ) ; char temporal = ( char ) nums ; result = temporal + result ; fmkxatc = fmkxatc / 26 ; if ( temporal == 'z' ) fmkxatc -- ; } System . out . print ( result ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Nmorh { public static boolean isPalindrome ( int n ) { String s = " " + n ; String a = " " ; for ( int nmorh = s . length ( ) - 1 ; nmorh >= 0 ; nmorh -- ) { a += s . charAt ( nmorh ) ; } return s . equals ( a ) ; } public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int count = 0 ; for ( int nmorh = a ; nmorh <= b ; nmorh ++ ) { if ( isPalindrome ( nmorh ) ) count ++ ; } System . out . println ( count ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Mzxkwcf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < String > list = new ArrayList < String > ( ) ; while ( true ) { String mzxkwcf = sc . nextLine ( ) ; if ( mzxkwcf . equals ( " 0 0 " ) ) { break ; } list . add ( mzxkwcf ) ; } for ( String mzxkwcf : list ) { String [ ] string = mzxkwcf . split ( " " ) ; int [ ] is = new int [ 2 ] ; is [ 0 ] = Integer . parseInt ( string [ 0 ] ) ; is [ 1 ] = Integer . parseInt ( string [ 1 ] ) ; if ( is [ 0 ] <= is [ 1 ] ) { System . out . println ( is [ 0 ] + " " + is [ 1 ] ) ; } else { System . out . println ( is [ 1 ] + " " + is [ 0 ] ) ; } if ( is [ 0 ] == 0 && is [ 1 ] == 0 ) { break ; } } } } import java . util . Scanner ; public class Hasgmsr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int hasgmsr = sc . nextInt ( ) ; String input = sc . next ( ) ; if ( hasgmsr % 2 == 1 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < hasgmsr / 2 ; i ++ ) { if ( input . charAt ( i ) != input . charAt ( hasgmsr / 2 + i ) ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Uswvciq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String uswvciq = sc . next ( ) ; char [ ] ss = uswvciq . toCharArray ( ) ; if ( ss [ 0 ] + 0 >= 65 && ss [ 0 ] + 0 <= 90 ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . * ; public class Pmmjte { public static void main ( String [ ] args ) { int pmmjte = 0 ; int count7 = 0 ; Scanner sc = new Scanner ( System . in ) ; String [ ] line = sc . nextLine ( ) . split ( " " ) ; for ( String n : line ) { if ( n . equals ( " 5 " ) ) { pmmjte ++ ; } if ( n . equals ( " 7 " ) ) { count7 ++ ; } } if ( pmmjte == 2 && count7 == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; class Ssilbvk { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int ssilbvk = scn . nextInt ( ) ; String a = scn . next ( ) ; String b = scn . next ( ) ; String result = " " ; String [ ] c = new String [ ssilbvk ] ; String [ ] d = new String [ ssilbvk ] ; for ( int i = 0 ; i < ssilbvk ; i ++ ) { c [ i ] = a . charAt ( i ) + " " ; d [ i ] = b . charAt ( i ) + " " ; result += c [ i ] + d [ i ] ; } System . out . println ( result ) ; } } import java . util . * ; public class Dqwmfk { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int dqwmfk = scn . nextInt ( ) ; int k = scn . nextInt ( ) ; int [ ] h = new int [ dqwmfk ] ; for ( int i = 0 ; i < dqwmfk ; i ++ ) { h [ i ] = scn . nextInt ( ) ; } Arrays . sort ( h ) ; long att = 0 ; for ( int i = 0 ; i < dqwmfk - k ; i ++ ) { att = att + h [ i ] ; } System . out . println ( att ) ; } } import java . util . * ; public class Jcfbh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jcfbh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int x = 0 ; if ( jcfbh <= b ) { x = x + b ; if ( jcfbh <= b - 1 ) { x = x + b - 1 ; } else { x = x + jcfbh ; } } else { x = x + jcfbh ; if ( b <= jcfbh - 1 ) { x = x + jcfbh - 1 ; } else { x = x + b ; } } System . out . println ( x ) ; } } import java . util . Scanner ; public class Wpbll { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wpbll = scan . nextInt ( ) ; int h = wpbll / 3600 ; int d = ( wpbll % 3600 ) / 60 ; int s = ( wpbll % 3600 ) % 60 ; System . out . println ( h + " : " + d + " : " + s ) ; scan . close ( ) ; } } import java . util . Scanner ; import java . util . ArrayList ; public class Yelex { public static void main ( String [ ] args ) { String [ ] lines = getStdin ( ) ; String [ ] inputs = lines [ 0 ] . split ( " " ) ; int yelex = Integer . parseInt ( inputs [ 0 ] ) ; int y = Integer . parseInt ( inputs [ 1 ] ) ; System . out . println ( yelex * y ) ; } private static String [ ] getStdin ( ) { Scanner scanner = new Scanner ( System . in ) ; ArrayList < String > lines = new ArrayList < > ( ) ; while ( scanner . hasNext ( ) ) { lines . add ( scanner . nextLine ( ) ) ; } return lines . toArray ( new String [ lines . size ( ) ] ) ; } } import java . util . * ; import java . io . * ; public class Ucbkqti { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; OutputStream pr = System . out ; PrintWriter out = new PrintWriter ( pr ) ; int ucbkqti = sc . nextInt ( ) ; double d = 0.0 ; for ( int i = 0 ; i < ucbkqti ; i ++ ) { double val = sc . nextDouble ( ) ; double ans = 1 / val ; d += ans ; } d = 1 / d ; out . print ( d ) ; out . close ( ) ; } public static long gcd ( long a , long b ) { if ( a == 0 ) { return b ; } else { return gcd ( b % a , a ) ; } } } import java . util . Scanner ; import java . util . ArrayDeque ; import java . util . Queue ; class Brfjh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Queue < Integer > queue = new ArrayDeque < > ( ) ; int brfjh = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; String [ ] name = new String [ brfjh ] ; int [ ] time = new int [ brfjh ] ; for ( int i = 0 ; i < brfjh ; i ++ ) { name [ i ] = sc . next ( ) ; time [ i ] = sc . nextInt ( ) ; queue . add ( i ) ; } int x = 0 ; while ( ! queue . isEmpty ( ) ) { int y = queue . poll ( ) ; if ( time [ y ] <= q ) { x += time [ y ] ; System . out . println ( name [ y ] + " " + x ) ; } else { x += q ; time [ y ] -= q ; queue . add ( y ) ; } } } } import java . util . Scanner ; public class Xkxcl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xkxcl = sc . nextInt ( ) ; int i = 1 ; int x = i ; int start = 0 ; while ( i <= xkxcl ) { if ( start == 0 ) { x = i ; if ( x % 3 == 0 ) { System . out . print ( " " + i ) ; start = 2 ; } } if ( start <= 1 ) { if ( x % 10 == 3 ) { System . out . print ( " " + i ) ; start = 2 ; } if ( start <= 1 ) { x /= 10 ; if ( 0 < x ) { start = 1 ; continue ; } } } i ++ ; start = 0 ; } System . out . println ( ) ; } } import java . io . * ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Rzudyz { static String a ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int rzudyz = stdIn . nextInt ( ) ; int [ ] a = new int [ rzudyz ] ; for ( int i = 0 ; i < rzudyz ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; } show ( a , rzudyz ) ; insertionSort ( a , rzudyz ) ; } static void show ( int [ ] a , int rzudyz ) { System . out . print ( a [ 0 ] ) ; for ( int i = 1 ; i < rzudyz ; i ++ ) { System . out . print ( " " + a [ i ] ) ; } System . out . println ( ) ; } static void insertionSort ( int [ ] a , int rzudyz ) { for ( int i = 1 ; i < rzudyz ; i ++ ) { int v = a [ i ] ; int j = i - 1 ; while ( j >= 0 && a [ j ] > v ) { a [ j + 1 ] = a [ j ] ; j -- ; } a [ j + 1 ] = v ; show ( a , rzudyz ) ; } } } import java . util . Scanner ; public class Zroetd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = null ; int [ ] count = new int [ 26 ] ; while ( sc . hasNext ( ) ) { str = sc . nextLine ( ) ; str = str . toLowerCase ( ) ; char [ ] ch = str . toCharArray ( ) ; for ( int zroetd = 0 ; zroetd < ch . length ; zroetd ++ ) { if ( Character . isAlphabetic ( ch [ zroetd ] ) ) { int x = ch [ zroetd ] - 'a' ; count [ x ] ++ ; } } } for ( int zroetd = 0 ; zroetd < count . length ; zroetd ++ ) { char x = ( char ) ( 'a' + zroetd ) ; System . out . print ( x + " : " ) ; System . out . println ( count [ zroetd ] ) ; } } } import java . util . * ; public class Vbligj { private static final int vbligj = Integer . MAX_VALUE ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; String [ ] strArray = str . split ( " " ) ; List < String > list = new ArrayList < > ( ) ; for ( int tmp = 0 ; tmp < strArray . length ; tmp ++ ) { list . add ( strArray [ tmp ] ) ; } boolean flagfirst = false ; String a = list . get ( 0 ) ; for ( int tmp = 1 ; tmp < list . size ( ) ; tmp ++ ) { if ( list . get ( tmp ) . equals ( list . get ( 0 ) ) ) { list . remove ( tmp ) ; list . remove ( 0 ) ; flagfirst = true ; } } boolean secondflag = false ; if ( list . size ( ) == 2 ) { if ( list . get ( 0 ) . equals ( list . get ( 1 ) ) ) { secondflag = true ; } } if ( a . equals ( list . get ( 0 ) ) ) secondflag = false ; if ( flagfirst && secondflag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Vlbcmel { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int vlbcmel = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( vlbcmel * b % 2 == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } scan . close ( ) ; } } import java . util . * ; public class Chkzl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int chkzl = sc . nextInt ( ) ; int [ ] h = new int [ chkzl ] ; for ( int i = 0 ; i < chkzl ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } if ( chkzl == 2 ) { System . out . println ( Math . abs ( h [ 0 ] - h [ 1 ] ) ) ; return ; } int [ ] cost = new int [ chkzl ] ; cost [ 0 ] = 0 ; cost [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < chkzl ; i ++ ) { cost [ i ] = Math . min ( cost [ i - 2 ] + Math . abs ( h [ i ] - h [ i - 2 ] ) , cost [ i - 1 ] + Math . abs ( h [ i ] - h [ i - 1 ] ) ) ; } System . out . println ( cost [ chkzl - 1 ] ) ; } } import java . util . * ; public class Emzewzg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double emzewzg = sc . nextDouble ( ) ; double B = sc . nextDouble ( ) ; double rA = 0.08 ; double rB = 0.1 ; for ( int i = 12 ; i < 1001 ; i ++ ) { if ( Math . floor ( i * rA ) == emzewzg && Math . floor ( i * rB ) == B ) { System . out . println ( i ) ; return ; } } System . out . println ( - 1 ) ; } } import java . util . Scanner ; class Ctdwto { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ctdwto = scan . nextInt ( ) ; int [ ] a = new int [ ctdwto + 1 ] ; int [ ] b = new int [ ctdwto ] ; for ( int i = 0 ; i < ctdwto + 1 ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < ctdwto ; i ++ ) { b [ i ] = scan . nextInt ( ) ; } long ans = 0 ; for ( int j = 0 ; j < ctdwto ; j ++ ) { int x = Math . min ( a [ j ] , b [ j ] ) ; ans += x ; b [ j ] -= x ; int y = Math . min ( a [ j + 1 ] , b [ j ] ) ; ans += y ; a [ j + 1 ] -= y ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Bcabyv { public static void main ( String [ ] arges ) { Scanner sc = new Scanner ( System . in ) ; List < String > klist = new ArrayList < String > ( ) ; while ( true ) { String line = sc . nextLine ( ) ; klist . add ( line ) ; if ( line . equals ( " 0 0 " ) ) { break ; } } for ( String string : klist ) { if ( string . equals ( " 0 0 " ) ) { break ; } String [ ] k = string . split ( " " ) ; int [ ] v = new int [ 2 ] ; v [ 0 ] = Integer . parseInt ( k [ 0 ] ) ; v [ 1 ] = Integer . parseInt ( k [ 1 ] ) ; int bcabyv = 0 ; for ( int i = 1 ; i <= v [ 0 ] - 2 ; i ++ ) { for ( int j = i + 1 ; j <= v [ 0 ] - 1 ; j ++ ) { for ( int j2 = j + 1 ; j2 <= v [ 0 ] ; j2 ++ ) { int sum = i + j + j2 ; if ( sum == v [ 1 ] ) { bcabyv ++ ; } } } } System . out . println ( bcabyv ) ; } } } import java . util . Scanner ; public class Qvpfffo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qvpfffo = sc . nextInt ( ) ; for ( ; qvpfffo > 1 ; qvpfffo -- ) { for ( int i = 2 ; i < qvpfffo ; i ++ ) { int n = i * i ; if ( n > qvpfffo ) break ; while ( n <= qvpfffo ) { if ( n == qvpfffo ) { System . out . println ( qvpfffo ) ; return ; } n *= i ; } } } System . out . println ( qvpfffo ) ; } } import java . util . Scanner ; public class Ynazt { public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int ynazt , b , c , hozon ; ynazt = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; if ( ynazt > b ) { hozon = ynazt ; ynazt = b ; b = hozon ; } if ( b > c ) { hozon = b ; b = c ; c = hozon ; } if ( ynazt > b ) { hozon = ynazt ; ynazt = b ; b = hozon ; } System . out . println ( ynazt + " " + b + " " + c ) ; } public static void main ( String [ ] args ) { Main obj = new Main ( ) ; obj . solve ( ) ; } } import java . util . * ; import static java . lang . Integer . * ; import static java . lang . System . * ; public class Ktydmf { public static void main ( String [ ] args ) { int ktydmf , j ; Scanner sc = new Scanner ( in ) ; int n = parseInt ( sc . next ( ) ) ; String [ ] s = new String [ n ] ; for ( ktydmf = 0 ; ktydmf < n ; ktydmf ++ ) { s [ ktydmf ] = sc . next ( ) ; } sc . close ( ) ; String [ ] s2 ; for ( ktydmf = 0 ; ktydmf < n ; ktydmf ++ ) { s2 = s [ ktydmf ] . split ( " " ) ; Arrays . sort ( s2 ) ; s [ ktydmf ] = String . join ( " " , s2 ) ; } HashMap < String , Integer > c = new HashMap < > ( ) ; for ( ktydmf = 0 ; ktydmf < n ; ktydmf ++ ) { if ( c . containsKey ( s [ ktydmf ] ) ) { c . put ( s [ ktydmf ] , c . get ( s [ ktydmf ] ) + 1 ) ; } else { c . put ( s [ ktydmf ] , 1 ) ; } } long ans = 0 ; for ( Integer ii : c . values ( ) ) { ans += ( long ) ii * ( ii - 1 ) / 2 ; } out . println ( ans ) ; } } import java . util . * ; public class Sntoy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long sntoy = Long . parseLong ( sc . next ( ) ) ; int sqrt = ( int ) Math . sqrt ( sntoy ) ; for ( int i = sqrt ; i >= 1 ; i -- ) { if ( sntoy % i == 0 ) { System . out . println ( i + sntoy / i - 2 ) ; break ; } } } } import java . util . * ; public class Jxeqxk { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String jxeqxk = sc . next ( ) ; String ff = jxeqxk . substring ( 2 , 4 ) ; String ee = jxeqxk . substring ( 4 , 6 ) ; if ( ff . substring ( 0 , 1 ) . equals ( ff . substring ( 1 , 2 ) ) && ee . substring ( 0 , 1 ) . equals ( ee . substring ( 1 , 2 ) ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ; import java . io . StreamTokenizer ; import java . util . * ; public class Vxnafr { public static long [ ] num = new long [ 1023 ] ; public static int vxnafr = 0 ; public static void main ( String [ ] args ) throws IOException { StreamTokenizer in = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; in . nextToken ( ) ; int a = ( int ) in . nval ; in . nextToken ( ) ; int b = ( int ) in . nval ; out . println ( a * b ) ; out . flush ( ) ; } } import java . util . * ; public class Olvkgu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int olvkgu = sc . nextInt ( ) ; int [ ] d = new int [ olvkgu ] ; long sum = 0 ; d [ 0 ] = sc . nextInt ( ) ; for ( int i = 1 ; i < olvkgu ; i ++ ) { d [ i ] = sc . nextInt ( ) ; for ( int j = 0 ; j < i ; j ++ ) { sum = sum + d [ j ] * d [ i ] ; } } System . out . println ( sum ) ; } private static long lcm ( long m , long n ) { return m * n / gcd ( m , n ) ; } private static long gcd ( long m , long n ) { if ( m < n ) return gcd ( n , m ) ; if ( n == 0 ) return m ; return gcd ( n , m % n ) ; } } import java . util . * ; class Eoadptf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eoadptf = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; int [ ] l = new int [ M + 1 ] ; int [ ] r = new int [ M + 1 ] ; l [ 0 ] = Integer . parseInt ( sc . next ( ) ) ; r [ 0 ] = Integer . parseInt ( sc . next ( ) ) ; int max = r [ 0 ] ; int min = l [ 0 ] ; for ( int i = 1 ; i < M ; i ++ ) { l [ i ] = Integer . parseInt ( sc . next ( ) ) ; r [ i ] = Integer . parseInt ( sc . next ( ) ) ; if ( l [ i ] > min ) { min = l [ i ] ; } if ( r [ i ] < max ) { max = r [ i ] ; } if ( max - min < 0 ) { max = - 1 ; min = 0 ; break ; } } System . out . println ( max - min + 1 ) ; } } import java . util . Scanner ; public class Zzxab { public static void main ( String [ ] args ) { long zzxab = 1000000007L ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; long [ ] S = new long [ n + 1 ] ; S [ 0 ] = 1 ; S [ 1 ] = 1 ; for ( int i = 0 ; i < m ; i ++ ) S [ Integer . parseInt ( sc . next ( ) ) ] -- ; for ( int i = 2 ; i <= n ; i ++ ) { if ( S [ i ] == - 1 ) S [ i ] = 0 ; else S [ i ] = ( S [ i - 1 ] + S [ i - 2 ] ) % zzxab ; } System . out . println ( S [ n ] ) ; } } import java . io . * ; import java . util . * ; class Afzhs { public static void main ( String [ ] args ) throws IOException { int afzhs , h , x , y , r ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] input = br . readLine ( ) . split ( " " ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( String f : input ) { list . add ( Integer . parseInt ( f ) ) ; } afzhs = list . get ( 0 ) ; h = list . get ( 1 ) ; x = list . get ( 2 ) ; y = list . get ( 3 ) ; r = list . get ( 4 ) ; if ( x <= 0 || y <= 0 ) { System . out . println ( " No " ) ; } else if ( 0 <= ( x + r ) && ( x + r ) <= afzhs && 0 <= ( y + r ) && ( y + r ) <= h ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Fpfvxrj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new java . io . InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int fpfvxrj = Integer . parseInt ( st . nextToken ( ) ) ; int ac = 0 , wa = 0 , tle = 0 , re = 0 ; for ( int i = 0 ; i < fpfvxrj ; i ++ ) { st = new StringTokenizer ( br . readLine ( ) ) ; String target = st . nextToken ( ) ; switch ( target ) { case " AC " : ac ++ ; break ; case " WA " : wa ++ ; break ; case " TLE " : tle ++ ; break ; case " RE " : re ++ ; break ; } } pw . println ( " AC x " + ac ) ; pw . println ( " WA x " + wa ) ; pw . println ( " TLE x " + tle ) ; pw . println ( " RE x " + re ) ; br . close ( ) ; pw . close ( ) ; } } import java . util . Scanner ; public class Moqzda { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int moqzda = sc . nextInt ( ) ; int [ ] A = new int [ moqzda ] ; for ( int i = 0 ; i < moqzda ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int sortCount = 0 ; for ( int i = 0 ; i < moqzda ; i ++ ) { int flag = 0 ; int minj = i ; for ( int j = i ; j < moqzda ; j ++ ) { if ( A [ j ] < A [ minj ] ) { minj = j ; flag = 1 ; } } if ( flag == 1 ) { int tmp = A [ i ] ; A [ i ] = A [ minj ] ; A [ minj ] = tmp ; sortCount ++ ; } } String delimiter = " " ; for ( int a : A ) { System . out . print ( delimiter + a ) ; delimiter = " " ; } System . out . println ( ) ; System . out . println ( sortCount ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Kvkjqo { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; long kvkjqo = stdIn . nextInt ( ) ; long b = stdIn . nextInt ( ) ; long c = stdIn . nextInt ( ) ; long d = stdIn . nextInt ( ) ; System . out . println ( Math . max ( kvkjqo * c , Math . max ( kvkjqo * d , Math . max ( b * c , b * d ) ) ) ) ; } } import java . util . Scanner ; public class Hadqkw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long hadqkw = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; if ( K <= hadqkw ) { hadqkw = hadqkw - K ; K = 0 ; } else { K = K - hadqkw ; hadqkw = 0 ; } if ( K <= B ) { B = B - K ; K = 0 ; } else { K = K - B ; B = 0 ; } System . out . println ( hadqkw + " " + B ) ; } } import java . util . Scanner ; public class Uoiaevl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; String [ ] Sarr = new String [ S . length ( ) ] ; for ( int uoiaevl = 0 ; uoiaevl < S . length ( ) ; uoiaevl ++ ) { Sarr [ uoiaevl ] = S . substring ( uoiaevl ) + S . substring ( 0 , uoiaevl ) ; } boolean result = false ; for ( int uoiaevl = 0 ; uoiaevl < S . length ( ) ; uoiaevl ++ ) { if ( Sarr [ uoiaevl ] . equals ( T ) ) { result = true ; break ; } } System . out . println ( result ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Agxug { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int agxug = sc . nextInt ( ) ; String S = sc . next ( ) ; char [ ] cs = S . toCharArray ( ) ; int count = 0 ; for ( int i = 0 ; i < agxug - 2 ; i ++ ) { if ( cs [ i ] == 'A' && cs [ i + 1 ] == 'B' && cs [ i + 2 ] == 'C' ) { count ++ ; } } System . out . println ( count ) ; } } } import java . util . * ; public class Expcpu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int expcpu = Integer . parseInt ( sc . next ( ) ) ; int [ ] ary = new int [ expcpu ] ; for ( int i = 0 ; i < ary . length ; i ++ ) { ary [ i ] = Integer . parseInt ( sc . next ( ) ) ; } if ( isAscendingOrder ( ary ) ) { System . out . print ( " YES " ) ; } else { System . out . print ( " NO " ) ; } } public static boolean isAscendingOrder ( int [ ] ary ) { int x = 0 ; int y = 0 ; int k = 0 ; for ( int i = 0 ; i < ary . length - 1 ; i ++ ) { if ( ary [ i ] > ary [ i + 1 ] ) { if ( x == 0 ) { x = ary [ i ] ; } else if ( y == 0 ) { y = ary [ i + 1 ] ; } } } for ( int i = 0 ; i < ary . length - 1 ; i ++ ) { if ( ary [ i ] > ary [ i + 1 ] ) { if ( k == 0 ) { ary [ i ] = y ; k += 1 ; } else if ( k == 1 ) { ary [ i + 1 ] = x ; k += 1 ; } } } for ( int i = 0 ; i < ary . length - 1 ; i ++ ) { if ( ary [ i ] > ary [ i + 1 ] ) { return false ; } } return true ; } } import java . util . * ; public class Gxgqen { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gxgqen = sc . nextInt ( ) ; int [ ] hairetu = new int [ gxgqen ] ; for ( int i = 0 ; i < hairetu . length ; i ++ ) { int c = sc . nextInt ( ) ; hairetu [ i ] = c ; } int count = 0 ; int champ = hairetu [ 0 ] ; for ( int k = 0 ; k < hairetu . length ; k ++ ) { if ( champ >= hairetu [ k ] ) { champ = hairetu [ k ] ; count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class Vadkutg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vadkutg = 0 ; int numberCount = sc . nextInt ( ) ; long [ ] numbers = new long [ numberCount ] ; for ( int i = 0 ; i < numbers . length ; i ++ ) { numbers [ i ] = sc . nextLong ( ) ; } while ( true ) { boolean end = false ; for ( int i = 0 ; i < numbers . length ; i ++ ) { if ( numbers [ i ] % 2 == 1 ) { end = true ; break ; } numbers [ i ] = numbers [ i ] / 2 ; } if ( end ) break ; vadkutg ++ ; } System . out . println ( vadkutg ) ; } } import java . util . Scanner ; public class Dkgvt { void run ( ) { Scanner scan = new Scanner ( System . in ) ; double dkgvt = scan . nextDouble ( ) ; System . out . printf ( " %f %f \n " , dkgvt * dkgvt * Math . PI , 2 * Math . PI * dkgvt ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Deque ; public class Kecqhx { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int kecqhx = Integer . parseInt ( br . readLine ( ) ) ; int b = Integer . parseInt ( br . readLine ( ) ) ; int c = Integer . parseInt ( br . readLine ( ) ) ; int x = Integer . parseInt ( br . readLine ( ) ) ; int count = 0 ; for ( int i = 0 ; i <= kecqhx ; i ++ ) { for ( int j = 0 ; j <= b ; j ++ ) { for ( int k = 0 ; k <= c ; k ++ ) { if ( x == ( i * 500 + j * 100 + k * 50 ) ) { count ++ ; } } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Ltiuzr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . nextLine ( ) ; String alp = " abcdefghijklmnopqrstuvwxyz " ; int ltiuzr = alp . indexOf ( C ) ; System . out . println ( alp . charAt ( ltiuzr + 1 ) ) ; } } import java . util . * ; public class Fterr { public static void main ( String [ ] args ) { Scanner obj = new Scanner ( System . in ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; for ( int fterr = 0 ; fterr < 3 ; fterr ++ ) { a . add ( obj . nextInt ( ) ) ; } Collections . sort ( a ) ; int sum = a . get ( 0 ) + a . get ( 1 ) ; System . out . println ( sum ) ; } } import java . util . * ; class Zjkhhsb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long zjkhhsb = sc . nextLong ( ) - 1 ; List < Integer > list = new ArrayList < > ( ) ; while ( zjkhhsb > 25 ) { list . add ( ( int ) ( zjkhhsb % 26 ) ) ; zjkhhsb = zjkhhsb / 26 - 1 ; } list . add ( ( int ) zjkhhsb ) ; char [ ] alphabet = " abcdefghijklmnopqrstuvwxyz " . toCharArray ( ) ; String ans = " " ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { int index = list . get ( list . size ( ) - i - 1 ) ; ans += alphabet [ index ] ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Hlciy { public static void main ( String [ ] argv ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String t = scan . next ( ) ; int hlciy = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; String u = scan . next ( ) ; if ( u . equals ( s ) ) hlciy -- ; if ( u . equals ( t ) ) b -- ; System . out . println ( hlciy + " " + b ) ; scan . close ( ) ; } } import java . util . * ; class Giwmqh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ns = sc . next ( ) ; String [ ] s = ns . split ( " " ) ; int giwmqh = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( Integer . parseInt ( s [ i ] ) == 1 ) { giwmqh ++ ; } } System . out . println ( giwmqh ) ; } } import java . util . Scanner ; public class Ywywbu { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int ywywbu = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; sc . nextLine ( ) ; int [ ] BArray = new int [ M ] ; int answer = 0 ; for ( int i = 0 ; i < BArray . length ; i ++ ) { BArray [ i ] = sc . nextInt ( ) ; } sc . nextLine ( ) ; for ( int i = 0 ; i < ywywbu ; i ++ ) { int result = 0 ; for ( int j = 0 ; j < M ; j ++ ) { result += sc . nextInt ( ) * BArray [ j ] ; } if ( 0 < ( result + C ) ) { answer ++ ; } sc . nextLine ( ) ; } System . out . println ( answer ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class Mledwfa { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mledwfa = scan . nextInt ( ) ; int ans = 0 ; int b = 1 ; ArrayList < Integer > list = new ArrayList ( ) ; while ( mledwfa > 0 ) { list . add ( mledwfa % 10 ) ; mledwfa /= 10 ; } for ( int i = 0 ; i < 3 ; i ++ ) { if ( list . get ( i ) == 9 ) { ans += 1 * b ; } else if ( list . get ( i ) == 1 ) { ans += 9 * b ; } b *= 10 ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Lfjwf { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String st = s . nextLine ( ) ; int lfjwf = 0 ; for ( int i = 0 ; i < st . length ( ) ; i ++ ) { if ( st . charAt ( i ) == 'R' ) lfjwf += 1 ; else if ( lfjwf != 0 ) break ; } System . out . println ( lfjwf ) ; } } import java . util . * ; public class Uaamrv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uaamrv = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; Set < Integer > set = new HashSet < > ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int snack = sc . nextInt ( ) ; for ( int j = 0 ; j < snack ; j ++ ) { int people = sc . nextInt ( ) ; set . add ( people ) ; } } System . out . println ( uaamrv - set . size ( ) ) ; } } import java . util . * ; public class Samqdci { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } private void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; int samqdci = scanner . nextInt ( ) ; int T = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; double nearOndo = 0 ; int nearIndex = 26 ; for ( int index = 0 ; index < samqdci ; index ++ ) { int temp = scanner . nextInt ( ) ; double ondo = T - ( temp * 0.006 ) ; if ( index == 0 ) { nearOndo = ondo ; nearIndex = index ; } else if ( Math . abs ( ondo - A ) < Math . abs ( nearOndo - A ) ) { nearOndo = ondo ; nearIndex = index ; } } System . out . println ( nearIndex + 1 ) ; } } import java . util . * ; public class Hpdxx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hpdxx = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int pos = hpdxx ; hpdxx *= - 1 ; hpdxx += 1 ; while ( hpdxx < pos ) { System . out . print ( x + hpdxx + " " ) ; hpdxx ++ ; } } } import java . util . Scanner ; class Rcnte { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String rcnte = sc . next ( ) ; if ( rcnte . matches ( " (dream|dreamer|erase|eraser)+? " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Bocmdbs { public static int bocmdbs ; public static int y ; public static int z ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; bocmdbs = sc . nextInt ( ) ; y = sc . nextInt ( ) ; if ( bocmdbs > y ) { solve ( bocmdbs , y ) ; } else { solve ( y , bocmdbs ) ; } System . out . println ( z ) ; } public static void solve ( int big , int small ) { z = big % small ; if ( z == 0 ) { z = small ; } else { solve ( small , z ) ; } } } import java . util . * ; public class Gbdmu { static Scanner sc = new Scanner ( System . in ) ; static Scanner sc2 = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int gbdmu = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] c = new int [ gbdmu ] ; int [ ] t = new int [ gbdmu ] ; int min = 10000 ; for ( int i = 0 ; i < gbdmu ; i ++ ) { c [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < gbdmu ; i ++ ) { if ( T >= t [ i ] ) { min = min > c [ i ] ? c [ i ] : min ; } } if ( min == 10000 ) { System . out . println ( " TLE " ) ; } else { System . out . println ( min ) ; } } } import java . util . * ; class Zrjzkrh { public static void main ( String ... args ) { final Scanner sc = new Scanner ( System . in ) ; final int zrjzkrh = sc . nextInt ( ) ; final int b = sc . nextInt ( ) ; System . out . printf ( " %d %d \n " , zrjzkrh * b , ( zrjzkrh + b ) * 2 ) ; } } public class Zrjzkrh { public static void main ( String ... args ) { Rectangle . main ( ) ; } } import java . util . * ; import java . io . * ; public class Ehjcu { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int ehjcu = Integer . parseInt ( br . readLine ( ) ) ; String [ ] Bstr = br . readLine ( ) . split ( " " ) ; int [ ] B = new int [ ehjcu - 1 ] ; for ( int i = 0 ; i < ehjcu - 1 ; i ++ ) { B [ i ] = Integer . parseInt ( Bstr [ i ] ) ; } int [ ] A = new int [ ehjcu ] ; int sum = 0 ; for ( int i = 0 ; i < ehjcu - 1 ; i ++ ) { if ( i == 0 ) { A [ i ] = B [ i ] ; } else { A [ i ] = Math . min ( A [ i ] , B [ i ] ) ; } sum += A [ i ] ; A [ i + 1 ] = B [ i ] ; if ( i == ehjcu - 2 ) sum += A [ ehjcu - 1 ] ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Hhbngq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int hhbngq = S . length ( ) ; int lastIndex = S . length ( ) ; char [ ] sArray = S . toCharArray ( ) ; for ( int i = 0 ; i < sArray . length ; i ++ ) { if ( sArray [ i ] == 'A' ) { hhbngq = i ; break ; } } for ( int i = 0 ; i < sArray . length ; i ++ ) { if ( sArray [ i ] == 'Z' ) lastIndex = i ; } System . out . println ( S . substring ( hhbngq , lastIndex + 1 ) . length ( ) ) ; sc . close ( ) ; } } import java . util . Scanner ; class Wsqzugb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wsqzugb = sc . nextInt ( ) , sum = 0 ; double ave , tmpsum = 0 ; while ( wsqzugb != 0 ) { int [ ] s = new int [ wsqzugb ] ; for ( int i = 0 ; i < wsqzugb ; i ++ ) { s [ i ] = sc . nextInt ( ) ; sum += s [ i ] ; } ave = ( double ) sum / wsqzugb ; for ( int i = 0 ; i < wsqzugb ; i ++ ) tmpsum += ( s [ i ] - ave ) * ( s [ i ] - ave ) ; ave = tmpsum / wsqzugb ; System . out . println ( Math . sqrt ( ave ) ) ; sum = 0 ; tmpsum = 0 ; wsqzugb = sc . nextInt ( ) ; } } } import java . util . Scanner ; public class Ihxyt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 5 ] ; boolean ihxyt = true ; for ( int i = 0 ; i < 5 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int k = sc . nextInt ( ) ; out : for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = i + 1 ; j < 5 ; j ++ ) { if ( a [ j ] - a [ i ] <= k ) ihxyt = true ; else { ihxyt = false ; break out ; } } } if ( ihxyt == true ) System . out . print ( " Yay! " ) ; else System . out . print ( " :( " ) ; } } import java . util . * ; public class Nukgmml { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nukgmml = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; double [ ] h = new double [ nukgmml ] ; for ( int i = 0 ; i < nukgmml ; i ++ ) { int b = sc . nextInt ( ) ; h [ i ] = t - b * 0.006 ; } double min = 1000000000 ; int ans = - 1 ; for ( int i = 0 ; i < nukgmml ; i ++ ) { double x ; if ( h [ i ] >= a ) { x = h [ i ] - a ; } else { x = a - h [ i ] ; } if ( x <= min ) { ans = i ; min = x ; } } System . out . println ( ans + 1 ) ; } } import java . io . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; class Mvphnin { static class Mvphnin { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } public static void main ( String [ ] args ) { FastReader ob = new FastReader ( ) ; String w = ob . next ( ) ; int [ ] arr = new int [ 26 ] ; for ( int mvphnin = 0 ; mvphnin < w . length ( ) ; mvphnin ++ ) { int k = w . charAt ( mvphnin ) - 'a' ; arr [ k ] = arr [ k ] + 1 ; } for ( int mvphnin = 0 ; mvphnin < 26 ; mvphnin ++ ) { if ( arr [ mvphnin ] % 2 != 0 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Wwdrvqj { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int wwdrvqj = sc . nextInt ( ) ; int t , x , y , dis ; String ans = " Yes " ; for ( int i = 0 ; i < wwdrvqj ; i ++ ) { t = sc . nextInt ( ) ; x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; dis = x + y ; if ( dis > t ) { ans = " No " ; break ; } else { if ( ( t - dis ) % 2 == 1 ) { ans = " No " ; break ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Kbpidt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kbpidt = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] L = new int [ M ] ; int [ ] R = new int [ M ] ; int cnt = 0 ; int Lmax = 0 ; int Rmin = 100000 ; for ( int i = 0 ; i < M ; i ++ ) { L [ i ] = sc . nextInt ( ) ; if ( L [ i ] > Lmax ) Lmax = L [ i ] ; R [ i ] = sc . nextInt ( ) ; if ( R [ i ] < Rmin ) Rmin = R [ i ] ; } for ( int i = Lmax ; i <= Rmin ; i ++ ) { cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . * ; public class Buubaqv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int buubaqv = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; double [ ] Temp = new double [ buubaqv ] ; double min = ( double ) Integer . MAX_VALUE ; int minNum = - 1 ; for ( int i = 0 ; i < buubaqv ; i ++ ) { double temp = sc . nextDouble ( ) ; if ( Math . abs ( A - ( T - temp * 0.006 ) ) < min ) { min = Math . abs ( A - ( T - temp * 0.006 ) ) ; minNum = i + 1 ; } } System . out . println ( minNum ) ; } } import java . util . Scanner ; public class Mvyqq { public static void main ( String [ ] hides ) { Scanner s = new Scanner ( System . in ) ; String mvyqq = s . next ( ) ; switch ( mvyqq ) { case " MON " : System . out . print ( " 6 " ) ; break ; case " TUE " : System . out . print ( " 5 " ) ; break ; case " WED " : System . out . print ( " 4 " ) ; break ; case " THU " : System . out . print ( " 3 " ) ; break ; case " FRI " : System . out . print ( " 2 " ) ; break ; case " SAT " : System . out . print ( " 1 " ) ; break ; case " SUN " : System . out . print ( " 7 " ) ; break ; } } } import java . util . Scanner ; class Qeepvn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; char [ ] c = s . toCharArray ( ) ; int qeepvn = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) if ( c [ i ] == '1' ) qeepvn = qeepvn + 1 ; System . out . println ( qeepvn ) ; } } import java . util . * ; public class Rwymhqg { Scanner sc = new Scanner ( System . in ) ; final int rwymhqg = 1000000007 ; final int MAX = Integer . MAX_VALUE ; final long LMAX = Long . MAX_VALUE ; int max3 ( int a , int b , int c ) { int max = ( ( a < b ) ? b : a ) ; return ( max < c ) ? c : max ; } void doIt ( ) { int n = sc . nextInt ( ) + 1 ; int m = sc . nextInt ( ) ; boolean [ ] b = new boolean [ n ] ; Arrays . fill ( b , true ) ; for ( int i = 0 ; i < m ; i ++ ) b [ sc . nextInt ( ) ] = false ; int [ ] dp = new int [ n ] ; Arrays . fill ( dp , 0 ) ; dp [ 0 ] = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( b [ i ] ) { if ( i + 1 < n ) { dp [ i + 1 ] = ( dp [ i + 1 ] + dp [ i ] ) % rwymhqg ; } if ( i + 2 < n ) { dp [ i + 2 ] = ( dp [ i + 2 ] + dp [ i ] ) % rwymhqg ; } } } System . out . println ( dp [ n - 1 ] ) ; } public static void main ( String [ ] args ) { new Main ( ) . doIt ( ) ; } } import java . util . * ; import java . lang . * ; public class Rpkgppf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String rpkgppf = sc . nextLine ( ) ; if ( rpkgppf . charAt ( 1 ) == 'R' ) System . out . println ( " ABC " ) ; else System . out . println ( " ARC " ) ; } } import java . util . * ; public class Tyowa { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long tyowa = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long divc = b / c - ( tyowa - 1 ) / c ; long divd = b / d - ( tyowa - 1 ) / d ; long lcmcd = lcm ( c , d ) ; long divcd = b / lcmcd - ( tyowa - 1 ) / lcmcd ; System . out . println ( ( b - tyowa + 1 ) - divc - divd + divcd ) ; } private static long gcd ( long tyowa , long b ) { while ( b > 0 ) { long temp = b ; b = tyowa % b ; tyowa = temp ; } return tyowa ; } private static long lcm ( long tyowa , long b ) { return tyowa * ( b / gcd ( tyowa , b ) ) ; } } import java . util . Scanner ; public class Hrxfymy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hrxfymy = sc . nextInt ( ) ; int ans = 0 ; sc . close ( ) ; for ( int i = 1 ; i <= hrxfymy ; i += 2 ) { if ( numYaku8 ( i ) ) ans += 1 ; } System . out . println ( ans ) ; } private static boolean numYaku8 ( int hrxfymy ) { int yaku = 0 ; for ( int i = 1 ; i <= hrxfymy ; i ++ ) { if ( hrxfymy % i == 0 ) yaku += 1 ; } if ( yaku == 8 ) return true ; return false ; } } import java . util . * ; class Pgdajej { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pgdajej = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sho = 0 ; int amrS = 0 ; int ans = 0 ; for ( int i = 1 ; i < pgdajej + 1 ; i ++ ) { sho = i ; amrS = 0 ; while ( sho != 0 ) { amrS += sho % 10 ; sho /= 10 ; } if ( amrS >= a && amrS <= b ) { ans += i ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; class Gloxmzh { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; String [ ] strArraySub = str . split ( " " ) ; int gloxmzh ; int val = strArraySub . length ; for ( int i = 1 ; i <= val ; i ++ ) { gloxmzh = val - i ; System . out . print ( strArraySub [ gloxmzh ] ) ; } System . out . println ( " " ) ; } } import java . util . * ; public class Zvytwg { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; int zvytwg = ob . nextInt ( ) ; int T = ob . nextInt ( ) ; int S = ob . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= T ; i ++ ) { sum += S ; } System . out . println ( ( sum < zvytwg ) ? " No " : " Yes " ) ; ob . close ( ) ; } } import java . util . * ; public class Vgcjrr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vgcjrr = Integer . parseInt ( sc . nextLine ( ) ) ; StringTokenizer dates = new StringTokenizer ( sc . nextLine ( ) ) ; StringTokenizer dates2 = new StringTokenizer ( sc . nextLine ( ) ) ; int mayor = 0 ; for ( int i = 0 ; i < vgcjrr ; i ++ ) { int a = Integer . parseInt ( dates . nextToken ( ) ) ; int b = Integer . parseInt ( dates2 . nextToken ( ) ) ; if ( a - b > 0 ) { mayor += a - b ; } } System . out . println ( mayor ) ; } } import java . util . Scanner ; class Pildkp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pildkp = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; long i = pildkp * x + b * y ; long ii = c * 2 * Math . max ( x , y ) ; long iii = 0 ; if ( x > y ) { iii = c * 2 * y + pildkp * ( x - y ) ; } else { iii = c * 2 * x + b * ( y - x ) ; } System . out . println ( Math . min ( Math . min ( i , ii ) , iii ) ) ; } } import java . util . Scanner ; public class Enkuf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int enkuf = sc . nextInt ( ) ; int [ ] a = new int [ enkuf ] ; for ( int i = 0 ; i < enkuf ; i ++ ) { a [ i ] = i + 1 ; } int s = sc . nextInt ( ) ; for ( int i = 0 ; i < s ; i ++ ) { String str = sc . next ( ) ; String [ ] Str = str . split ( " , " ) ; int p = Integer . parseInt ( Str [ 0 ] ) - 1 ; int q = Integer . parseInt ( Str [ 1 ] ) - 1 ; int temp ; temp = a [ p ] ; a [ p ] = a [ q ] ; a [ q ] = temp ; } for ( int j = 0 ; j < enkuf ; j ++ ) { System . out . println ( a [ j ] ) ; } } } } import java . util . * ; public class Hhdskrh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hhdskrh = sc . nextInt ( ) ; char [ ] [ ] s = new char [ hhdskrh ] [ 10 ] ; HashMap < String , Long > h = new HashMap < > ( ) ; long ans = 0 ; for ( int i = 0 ; i < hhdskrh ; i ++ ) { s [ i ] = sc . next ( ) . toCharArray ( ) ; Arrays . parallelSort ( s [ i ] ) ; String st = String . valueOf ( s [ i ] ) ; if ( h . containsKey ( st ) ) { long temp = h . get ( st ) ; ans += temp ; h . put ( st , temp + 1 ) ; } else h . put ( st , ( long ) 1 ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Intjsla { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long intjsla = scan . nextInt ( ) ; scan . close ( ) ; System . out . println ( intjsla / 2 + intjsla % 2 ) ; } } import java . util . Scanner ; public class Sfchouz { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int sfchouz , b , c ; Scanner sc = new Scanner ( System . in ) ; String [ ] input = sc . nextLine ( ) . split ( " " ) ; sfchouz = Integer . parseInt ( input [ 0 ] ) ; b = Integer . parseInt ( input [ 1 ] ) ; c = Integer . parseInt ( input [ 2 ] ) ; int cnt = 0 ; for ( int i = sfchouz ; i <= b ; i ++ ) { if ( c % i == 0 ) cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . * ; public class Cnbgx { private static final Scanner scn = new Scanner ( System . in ) ; private static final String WALL = " #################### " ; public static void main ( String [ ] args ) { int [ ] [ ] [ ] tbl = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int cnbgx = scn . nextInt ( ) ; cnbgx > 0 ; cnbgx -- ) { int b = load ( ) , f = load ( ) , r = load ( ) ; tbl [ b ] [ f ] [ r ] += scn . nextInt ( ) ; } for ( int i = 0 ; i < 4 ; i ++ ) { if ( i > 0 ) { System . out . println ( WALL ) ; } print ( tbl [ i ] ) ; } } private static int load ( ) { return scn . nextInt ( ) - 1 ; } private static void print ( int [ ] [ ] tbl ) { for ( int [ ] ary : tbl ) { for ( int elm : ary ) { System . out . format ( " %2d " , elm ) ; } System . out . println ( ) ; } } } import java . util . * ; public class Dknfqm { public static void main ( String [ ] args ) { Scanner Sc = new Scanner ( System . in ) ; String dknfqm = Sc . next ( ) ; if ( dknfqm . contains ( " 7 " ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Wncva { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long wncva = scan . nextLong ( ) ; long value2 = ( long ) ( scan . nextDouble ( ) * 100 + 0.001 ) ; long sum = wncva * value2 / 100 ; scan . close ( ) ; System . out . println ( sum ) ; } } import java . util . * ; public class Axigx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] str = sc . next ( ) . toCharArray ( ) ; int axigx = 0 ; if ( str [ 0 ] != 'A' || Character . isUpperCase ( str [ 1 ] ) || Character . isUpperCase ( str [ str . length - 1 ] ) ) { System . out . println ( " WA " ) ; return ; } for ( int i = 2 ; i < str . length - 1 ; i ++ ) { if ( Character . isUpperCase ( str [ i ] ) && str [ i ] == 'C' ) { axigx ++ ; } } System . out . println ( axigx == 1 ? " AC " : " WA " ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Ycutsdw { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AHarmonyABC135 solver = new AHarmonyABC135 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Ycutsdw { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int ycutsdw = in . nextInt ( ) ; int b = in . nextInt ( ) ; if ( ycutsdw == b ) out . println ( 0 ) ; else if ( ( ycutsdw + b ) % 2 == 1 ) out . println ( " IMPOSSIBLE " ) ; else out . println ( ( ycutsdw + b ) / 2 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Pztam { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] input = new int [ 10 ] ; boolean [ ] checked = new boolean [ 10 ] ; for ( int pztam = 0 ; pztam < 10 ; pztam ++ ) { input [ pztam ] = Integer . parseInt ( br . readLine ( ) ) ; checked [ pztam ] = false ; } for ( int pztam = 0 ; pztam < 3 ; pztam ++ ) { int maxIndex = - 1 ; int max = - 1 ; for ( int j = 0 ; j < 10 ; j ++ ) { if ( input [ j ] > max && checked [ j ] == false ) { max = input [ j ] ; maxIndex = j ; } } checked [ maxIndex ] = true ; System . out . println ( input [ maxIndex ] ) ; } } } import java . util . Scanner ; public class Raffwvd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] line_S = sc . nextLine ( ) . split ( " " , 0 ) ; String [ ] line_T = sc . nextLine ( ) . split ( " " , 0 ) ; int raffwvd = 0 ; for ( int i = 0 ; i < line_S . length ; i ++ ) { if ( line_S [ i ] . compareTo ( line_T [ i ] ) != 0 ) { raffwvd ++ ; } } System . out . println ( raffwvd ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class Pturpp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pturpp = sc . nextInt ( ) ; ArrayList < Integer > arr = new ArrayList < > ( ) ; int ans = 0 ; for ( int i = 0 ; i < pturpp ; i ++ ) { int a = sc . nextInt ( ) ; arr . add ( a ) ; } for ( int i = 1 ; i < ( pturpp - 1 ) ; i ++ ) { if ( arr . get ( i ) > arr . get ( i - 1 ) && ( arr . get ( i ) < arr . get ( i + 1 ) ) ) { ans ++ ; } else if ( arr . get ( i ) < arr . get ( i - 1 ) && ( arr . get ( i ) > arr . get ( i + 1 ) ) ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; class Sbrrkzr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int sbrrkzr = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { for ( int j = i ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( i ) == t . charAt ( j ) ) sbrrkzr ++ ; break ; } } System . out . print ( sbrrkzr ) ; } } import java . util . Scanner ; public class Domer { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long domer = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long lcm = c * d / gcd ( c , d ) ; long u = b - domer + 1 ; long cs = b / c - ( domer - 1 ) / c ; long ds = b / d - ( domer - 1 ) / d ; long lcms = b / lcm - ( domer - 1 ) / lcm ; sc . close ( ) ; System . out . println ( u - cs - ds + lcms ) ; } public static long gcd ( long num1 , long num2 ) { if ( num2 == 0 ) return num1 ; else return gcd ( num2 , num1 % num2 ) ; } } import java . util . Scanner ; public class Hxpovkf { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String hxpovkf = stdIn . next ( ) ; if ( hxpovkf . equals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } else { System . out . println ( " ABC " ) ; } stdIn . close ( ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class Wssso { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int wssso = scanner . nextInt ( ) ; int next = 1 ; int [ ] a = new int [ wssso ] ; HashSet < Integer > hSet = new HashSet < > ( ) ; for ( int i = 0 ; i < wssso ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < wssso ; i ++ ) { next = a [ next - 1 ] ; if ( next == 2 ) { System . out . println ( i + 1 ) ; return ; } if ( hSet . contains ( next ) ) { System . out . println ( - 1 ) ; return ; } else { hSet . add ( next ) ; } } } } import java . util . * ; public class Bmpgw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bmpgw = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) , d = sc . nextInt ( ) , e = sc . nextInt ( ) , k = sc . nextInt ( ) ; String res = " Yay! " ; if ( e - bmpgw > k ) { res = " :( " ; } System . out . println ( res ) ; } } import java . util . Scanner ; public class Akgdsx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int akgdsx = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int plus = akgdsx + b ; int minus = akgdsx - b ; int multiplied = akgdsx * b ; int result = 0 ; if ( plus > minus ) { if ( plus > multiplied ) { result = plus ; } else { result = multiplied ; } } else if ( minus > multiplied ) { result = minus ; } else { result = multiplied ; } System . out . println ( result ) ; } } import java . util . Scanner ; import java . util . List ; import java . util . ArrayList ; public class Njwehkk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int njwehkk = 10000 ; int loop = a . length ( ) - b . length ( ) + 1 ; if ( a . contains ( b ) ) { System . out . println ( 0 ) ; } else { for ( int i = 0 ; i < loop ; i ++ ) { int tmp = 0 ; String sub = a . substring ( i , i + b . length ( ) ) ; for ( int j = 0 ; j < sub . length ( ) ; j ++ ) { if ( sub . charAt ( j ) != b . charAt ( j ) ) { tmp ++ ; } } if ( njwehkk > tmp ) { njwehkk = tmp ; } } System . out . println ( njwehkk ) ; } } } import java . util . * ; class Igkvp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int igkvp = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] L = new int [ igkvp ] ; int [ ] D = new int [ igkvp + 1 ] ; D [ 0 ] = 0 ; for ( int i = 0 ; i < igkvp ; i ++ ) { L [ i ] = sc . nextInt ( ) ; } int ans = 1 ; for ( int i = 1 ; i <= igkvp ; i ++ ) { D [ i ] = D [ i - 1 ] + L [ i - 1 ] ; if ( D [ i ] <= X ) { ans += 1 ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Dmkfrxv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long dmkfrxv = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long C = sc . nextLong ( ) ; long D = sc . nextLong ( ) ; System . out . println ( count ( B , C , D ) - count ( dmkfrxv - 1 , C , D ) ) ; sc . close ( ) ; } static long gcd ( long a , long b ) { return a == 0 ? b : gcd ( b % a , a ) ; } static long lcm ( long a , long b ) { return a * b / gcd ( a , b ) ; } static long count ( long x , long c , long d ) { return x - x / c - x / d + x / lcm ( c , d ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Prizy { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int prizy = Integer . parseInt ( str [ 0 ] ) ; int M = Integer . parseInt ( str [ 1 ] ) ; int [ ] L = new int [ M ] ; int [ ] R = new int [ M ] ; int Lmax = 0 ; int Rmin = 0 ; for ( int i = 0 ; i < M ; i ++ ) { String [ ] str1 = br . readLine ( ) . split ( " " ) ; L [ i ] = Integer . parseInt ( str1 [ 0 ] ) ; R [ i ] = Integer . parseInt ( str1 [ 1 ] ) ; if ( L [ i ] > Lmax ) { Lmax = L [ i ] ; } if ( i == 0 ) { Rmin = R [ i ] ; } if ( R [ i ] < Rmin ) { Rmin = R [ i ] ; } } int ans = Rmin - Lmax + 1 ; if ( ans > 0 ) { System . out . print ( ans ) ; } else { System . out . print ( 0 ) ; } } } import java . util . Scanner ; public class Dcxzukg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dcxzukg = scan . nextInt ( ) ; while ( dcxzukg > 0 ) { int sum = 0 ; int [ ] s = new int [ dcxzukg ] ; for ( int i = 0 ; i < dcxzukg ; i ++ ) { s [ i ] = scan . nextInt ( ) ; sum += s [ i ] ; } double ave = ( double ) sum / dcxzukg ; double HF = 0 ; for ( int i = 0 ; i < dcxzukg ; i ++ ) { HF += ( ave - s [ i ] ) * ( ave - s [ i ] ) ; } HF /= ( double ) dcxzukg ; HF = Math . pow ( HF , 0.5 ) ; System . out . println ( HF ) ; dcxzukg = scan . nextInt ( ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Onylw { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int onylw = scn . nextInt ( ) ; int b = scn . nextInt ( ) ; int c = scn . nextInt ( ) ; int [ ] arr = { onylw , b , c } ; Arrays . parallelSort ( arr ) ; if ( arr [ 0 ] == 5 && arr [ 1 ] == 5 && arr [ 2 ] == 7 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Ntgrh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ntgrh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; double v = t + 0.5 ; int p = 0 ; p = ( int ) v / ntgrh ; int r = 0 ; r = ( int ) p * b ; System . out . println ( r ) ; } } import java . util . * ; public class Zixzzuy { Scanner sc ; int zixzzuy ; int [ ] v ; public Main ( ) { sc = new Scanner ( System . in ) ; } private void calc ( ) { zixzzuy = sc . nextInt ( ) ; v = new int [ zixzzuy ] ; for ( int i = 0 ; i < zixzzuy ; i ++ ) v [ i ] = sc . nextInt ( ) ; Arrays . sort ( v ) ; double ans = ( double ) v [ 0 ] ; for ( int i = 1 ; i < zixzzuy ; i ++ ) ans = ( ans + v [ i ] ) / 2d ; System . out . println ( ans ) ; System . out . flush ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . Scanner ; public class Tlcxu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tlcxu = sc . nextInt ( ) ; if ( tlcxu == 1 ) { System . out . println ( 0 ) ; } else { int Ans = 0 ; int Temp = 0 ; int [ ] H = new int [ tlcxu ] ; for ( int i = 0 ; i < tlcxu ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < tlcxu - 1 ; i ++ ) { if ( H [ i ] >= H [ i + 1 ] ) { Temp += 1 ; } if ( ( H [ i ] < H [ i + 1 ] ) | ( i == tlcxu - 2 ) ) { if ( Ans < Temp ) { Ans = Temp ; } Temp = 0 ; } } System . out . println ( Ans ) ; } sc . close ( ) ; } } import java . io . * ; class Nchzig { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String taro , hanako , str ; int nchzig = 0 , sh = 0 ; int n = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { str = br . readLine ( ) ; taro = str . substring ( 0 , str . indexOf ( ' ' ) ) ; hanako = str . substring ( str . indexOf ( ' ' ) + 1 ) ; if ( taro . compareTo ( hanako ) < 0 ) sh += 3 ; else if ( taro . compareTo ( hanako ) > 0 ) nchzig += 3 ; else { nchzig ++ ; sh ++ ; } } System . out . println ( nchzig + " " + sh ) ; } } import java . util . Scanner ; public class Sztpnb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sztpnb = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int product = sztpnb * l ; int around = 2 * ( sztpnb + l ) ; System . out . println ( product + " " + around ) ; } } import java . util . Scanner ; public class Xbruqi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xbruqi = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = 1 ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i - 1 ) ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . HashSet ; import java . util . LinkedList ; import java . util . Queue ; import java . util . Scanner ; import java . util . Set ; public class Aomohp { public static void main ( String [ ] args ) { int aomohp ; int [ ] A1i ; int [ ] A2i ; Set < Integer > searched = new HashSet < > ( ) ; Queue < Integer > queue = new LinkedList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ) { aomohp = sc . nextInt ( ) ; A1i = new int [ aomohp ] ; A2i = new int [ aomohp ] ; for ( int i = 0 ; i < aomohp ; i ++ ) { A1i [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < aomohp ; i ++ ) { A2i [ i ] = sc . nextInt ( ) ; } } int [ ] Sum1 = new int [ aomohp ] ; int sum1 = 0 ; for ( int i = 0 ; i < aomohp ; i ++ ) { sum1 += A1i [ i ] ; Sum1 [ i ] = sum1 ; } int [ ] Sum2 = new int [ aomohp ] ; int sum2 = 0 ; for ( int i = aomohp - 1 ; i >= 0 ; i -- ) { sum2 += A2i [ i ] ; Sum2 [ i ] = sum2 ; } int result = 0 ; for ( int i = 0 ; i < aomohp ; i ++ ) { if ( result < Sum1 [ i ] + Sum2 [ i ] ) { result = Sum1 [ i ] + Sum2 [ i ] ; } } System . out . println ( result ) ; } } import java . util . * ; public class Whhljt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int whhljt = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; if ( whhljt <= C && B <= C ) { System . out . println ( " 0 " ) ; } else if ( whhljt <= C && B <= D ) { System . out . println ( B - C ) ; } else if ( whhljt <= C && B > D ) { System . out . println ( D - C ) ; } else if ( whhljt > C && D <= whhljt ) { System . out . println ( " 0 " ) ; } else if ( whhljt > C && B >= D ) { System . out . println ( D - whhljt ) ; } else { System . out . println ( B - whhljt ) ; } } } import java . util . Scanner ; public class Xvtzpm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; char [ ] s = scanner . next ( ) . toCharArray ( ) ; for ( int xvtzpm = 1 ; xvtzpm < 3 ; xvtzpm ++ ) { if ( s [ xvtzpm ] != s [ xvtzpm - 1 ] ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Gxozkug { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gxozkug = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int sum = l * gxozkug ; int [ ] aji = new int [ gxozkug ] ; for ( int i = 0 ; i < gxozkug ; i ++ ) { sum += i ; aji [ i ] = l + i ; } int min = Integer . MAX_VALUE / 2 ; int aji2 = 0 ; for ( int i = 0 ; i < gxozkug ; i ++ ) { int apple_pie = sum - aji [ i ] ; int sa = Math . abs ( sum - apple_pie ) ; if ( min > sa ) { aji2 = apple_pie ; min = sa ; } } sc . close ( ) ; System . out . println ( aji2 ) ; } } import java . util . * ; public class Qzmjbb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String alpha = " abcdefghijklmnopqrstuvwxyz " ; String target = sc . next ( ) ; for ( int qzmjbb = 0 ; qzmjbb <= 24 ; qzmjbb ++ ) { if ( String . valueOf ( alpha . charAt ( qzmjbb ) ) . equals ( target ) ) { System . out . println ( alpha . charAt ( qzmjbb + 1 ) ) ; } } } } import java . util . * ; public class Kmjsgvc { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int kmjsgvc = s . nextInt ( ) , x = s . nextInt ( ) , t = s . nextInt ( ) ; int count = 0 ; count = kmjsgvc / x * t ; if ( kmjsgvc % x > 0 ) count += t ; System . out . println ( count ) ; } } import java . util . Scanner ; public class Buitthq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int buitthq = scan . nextInt ( ) ; int taro = 0 ; int hanako = 0 ; for ( int i = 0 ; i < buitthq ; i ++ ) { String taros = scan . next ( ) ; String hanakos = scan . next ( ) ; int result = taros . compareTo ( hanakos ) ; if ( result > 0 ) { taro += 3 ; } else if ( result < 0 ) { hanako += 3 ; } else { taro ++ ; hanako ++ ; } } System . out . println ( taro + " " + hanako ) ; } } import java . io . * ; import java . util . * ; public class Qffykz { public static void main ( String [ ] argst ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; while ( str != null ) { String [ ] line = str . split ( " \\ s " ) ; int qffykz = Integer . parseInt ( line [ 0 ] ) ; int W = Integer . parseInt ( line [ 1 ] ) ; if ( qffykz != 0 && W != 0 ) { String yoko = Wwrite ( W ) ; Hwrite ( qffykz , yoko ) ; System . out . println ( " " ) ; str = br . readLine ( ) ; } else { break ; } } } public static String Wwrite ( int W ) { StringBuilder buff = new StringBuilder ( ) ; for ( int i = 0 ; i < W ; i ++ ) { buff . append ( " # " ) ; } return buff . toString ( ) ; } public static void Hwrite ( int qffykz , String yoko ) { for ( int i = 0 ; i < qffykz ; i ++ ) { System . out . println ( yoko ) ; } } } import java . util . * ; public class Rjgxnod { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int rjgxnod = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( rjgxnod + rjgxnod * rjgxnod + rjgxnod * rjgxnod * rjgxnod ) ; } } import java . util . * ; public class Ujmuzu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ujmuzu = sc . nextInt ( ) ; int [ ] res = new int [ ujmuzu ] ; for ( int i = 0 ; i < res . length - 1 ; i ++ ) { int index = sc . nextInt ( ) - 1 ; res [ index ] ++ ; } for ( int i : res ) { System . out . println ( i ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Ijsefhm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ijsefhm = sc . next ( ) ; String [ ] ar = ijsefhm . split ( " " ) ; for ( String s : ar ) { if ( s . equals ( " 1 " ) ) { System . out . print ( 9 ) ; } else { System . out . print ( 1 ) ; } } } } import java . util . Scanner ; public class Ledmofb { static void putArray ( int [ ] array ) { System . out . print ( array [ 0 ] ) ; for ( int ledmofb = 1 ; ledmofb < array . length ; ledmofb ++ ) { System . out . print ( " " + array [ ledmofb ] ) ; } System . out . println ( ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; int [ ] array = new int [ num ] ; for ( int ledmofb = 0 ; ledmofb < array . length ; ledmofb ++ ) { array [ ledmofb ] = sc . nextInt ( ) ; } putArray ( array ) ; for ( int ledmofb = 1 ; ledmofb < array . length ; ledmofb ++ ) { int v = array [ ledmofb ] ; int j = ledmofb - 1 ; while ( j >= 0 && array [ j ] > v ) { array [ j + 1 ] = array [ j ] ; j -- ; } array [ j + 1 ] = v ; putArray ( array ) ; } } } import java . util . Scanner ; public class Ezqjy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ezqjy = scan . nextInt ( ) ; int i = 0 ; int taro_count = 0 ; int hana_count = 0 ; for ( i = 0 ; i < ezqjy ; i ++ ) { String a = scan . next ( ) ; String b = scan . next ( ) ; if ( a . compareTo ( b ) == 0 ) { taro_count += 1 ; hana_count += 1 ; } else if ( a . compareTo ( b ) < 0 ) { hana_count += 3 ; } else { taro_count += 3 ; } } System . out . println ( taro_count + " " + hana_count ) ; } } import java . util . * ; public class Ipcqfg { public static int [ ] ans ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ipcqfg = sc . nextInt ( ) ; int [ ] list = new int [ ipcqfg ] ; for ( int i = 0 ; i < ipcqfg ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } int count = 0 ; boolean flag = true ; while ( flag ) { for ( int i = 0 ; i < ipcqfg ; i ++ ) { if ( list [ i ] % 2 == 1 ) { flag = false ; } list [ i ] = list [ i ] / 2 ; if ( i == ipcqfg - 1 && flag ) { count ++ ; } } } System . out . println ( count ) ; } } import java . math . BigInteger ; import java . util . * ; public class Chvoof { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; long chvoof = sc . nextLong ( ) ; BigInteger K = BigInteger . valueOf ( chvoof ) ; BigInteger b = BigInteger . ZERO ; for ( char c : S . toCharArray ( ) ) { if ( c == '1' ) { b = b . add ( BigInteger . ONE ) ; } else { long val = Long . valueOf ( String . valueOf ( c ) ) ; BigInteger tmp = BigInteger . valueOf ( val ) . pow ( 100_000_0 ) ; BigInteger tmp2 = BigInteger . valueOf ( val ) . pow ( 10 ) ; b = b . add ( tmp . multiply ( tmp ) . multiply ( BigInteger . valueOf ( 5L ) . multiply ( tmp2 ) ) ) ; } if ( b . compareTo ( K ) >= 0 ) { System . out . println ( c ) ; return ; } } } } import java . util . Scanner ; public class Cdztzi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cdztzi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long x = 1 ; long n = 0 ; while ( true ) { n = cdztzi * x ; if ( n % b == 0 ) { break ; } x ++ ; } System . out . println ( n ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Imsecs { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line ; while ( ( line = br . readLine ( ) ) != null ) { String [ ] arr = line . split ( " " ) ; int imsecs = Integer . parseInt ( arr [ 0 ] ) ; int x = Integer . parseInt ( arr [ 1 ] ) ; if ( imsecs == 0 && x == 0 ) break ; int cnt = 0 ; for ( int i = 1 ; i <= imsecs ; i ++ ) { for ( int j = i + 1 ; j <= imsecs ; j ++ ) { for ( int k = j + 1 ; k <= imsecs ; k ++ ) { if ( i + j + k == x ) cnt ++ ; } } } System . out . println ( cnt ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . Collections ; import java . util . ArrayList ; import java . util . List ; import java . util . HashSet ; public class Rlomb { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static int [ ] inputval ( ) throws Exception { String [ ] strarray = br . readLine ( ) . trim ( ) . split ( " " ) ; int [ ] intarray = new int [ strarray . length ] ; for ( int rlomb = 0 ; rlomb < intarray . length ; rlomb ++ ) { intarray [ rlomb ] = Integer . parseInt ( strarray [ rlomb ] ) ; } return intarray ; } static Integer [ ] inputvalInteger ( ) throws Exception { String [ ] strarray = br . readLine ( ) . trim ( ) . split ( " " ) ; Integer [ ] intarray = new Integer [ strarray . length ] ; for ( int rlomb = 0 ; rlomb < intarray . length ; rlomb ++ ) { intarray [ rlomb ] = Integer . parseInt ( strarray [ rlomb ] ) ; } return intarray ; } public static void main ( String [ ] args ) throws Exception { int n = Integer . parseInt ( br . readLine ( ) . trim ( ) ) ; HashSet < Integer > st = new HashSet < > ( ) ; for ( int rlomb = 0 ; rlomb < n ; rlomb ++ ) { int d = Integer . parseInt ( br . readLine ( ) . trim ( ) ) ; st . add ( d ) ; } System . out . println ( st . size ( ) ) ; } } import java . util . Scanner ; public class Dionhqx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String dionhqx = scanner . next ( ) ; switch ( dionhqx ) { case " Sunny " : System . out . println ( " Cloudy " ) ; break ; case " Rainy " : System . out . println ( " Sunny " ) ; break ; case " Cloudy " : System . out . println ( " Rainy " ) ; break ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ztgojr { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = null ; while ( ( line = br . readLine ( ) ) != null ) { char [ ] input = line . toCharArray ( ) ; for ( int ztgojr = input . length ; ztgojr > 0 ; ztgojr -- ) { System . out . print ( input [ ztgojr - 1 ] ) ; } System . out . println ( ) ; } } } public class Fckwxt { public static void main ( String [ ] args ) { java . util . Scanner cin = new java . util . Scanner ( System . in ) ; int fckwxt ; for ( fckwxt = cin . nextInt ( ) ; fckwxt != 0 ; -- fckwxt ) { int [ ] a = { cin . nextInt ( ) , cin . nextInt ( ) , cin . nextInt ( ) } ; java . util . Arrays . sort ( a ) ; System . out . println ( a [ 0 ] * a [ 0 ] + a [ 1 ] * a [ 1 ] == a [ 2 ] * a [ 2 ] ? " YES " : " NO " ) ; } return ; } } import java . util . Scanner ; public class Mpmdg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int mpmdg = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; if ( mpmdg == - 1 && f == - 1 && r == - 1 ) { break ; } if ( mpmdg == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } else { int S = mpmdg + f ; if ( S >= 80 ) { System . out . println ( " A " ) ; } else if ( S < 80 && S >= 65 ) { System . out . println ( " B " ) ; } else if ( S < 65 && S >= 50 ) { System . out . println ( " C " ) ; } else if ( S < 50 && S >= 30 ) { if ( r >= 50 ) { System . out . println ( " C " ) ; } else if ( r < 50 ) { System . out . println ( " D " ) ; } } else if ( S < 30 ) { System . out . println ( " F " ) ; } } } } } import java . io . * ; import java . util . * ; import java . lang . * ; class Cjmbg { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; while ( true ) { StringBuilder sb = new StringBuilder ( scan . next ( ) ) ; if ( sb . toString ( ) . equals ( " - " ) ) break ; int cjmbg = Integer . parseInt ( scan . next ( ) ) ; for ( int i = 0 ; i < cjmbg ; i ++ ) { int h = Integer . parseInt ( scan . next ( ) ) ; String buf = sb . substring ( 0 , h ) ; sb . delete ( 0 , h ) ; sb . append ( buf ) ; } System . out . println ( sb ) ; } } } import java . util . * ; public class Wavdppk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wavdppk = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String q = " Odd " ; if ( wavdppk % 2 == 0 || b % 2 == 0 ) { q = " Even " ; } System . out . println ( q ) ; } } import java . util . Scanner ; public class Vxmxkx { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int vxmxkx = scn . nextInt ( ) ; int ans = 0 ; int num = 0 ; while ( vxmxkx / ( int ) Math . pow ( 10 , num ) > 0 ) { num ++ ; } for ( int i = 0 ; i < num - 1 ; i += 2 ) { ans += 9 * Math . pow ( 10 , i ) ; } if ( num % 2 == 1 ) { ans += vxmxkx - Math . pow ( 10 , num - 1 ) + 1 ; } System . out . println ( ans ) ; } } import java . util . * ; public class Opcbv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int opcbv = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; int sum = L * opcbv + ( opcbv * ( opcbv - 1 ) ) / 2 ; if ( L > 0 ) sum -= L ; else if ( L + opcbv - 1 < 0 ) sum -= L + opcbv - 1 ; System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Wjmgj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; a [ 0 ] = sc . nextInt ( ) ; a [ 1 ] = sc . nextInt ( ) ; a [ 2 ] = sc . nextInt ( ) ; int wjmgj = sc . nextInt ( ) ; sc . close ( ) ; Arrays . parallelSort ( a ) ; for ( int i = 0 ; i < wjmgj ; i ++ ) { a [ 2 ] *= 2 ; } System . out . println ( a [ 0 ] + a [ 1 ] + a [ 2 ] ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; public class Jzuva { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jzuva = sc . nextInt ( ) ; List < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; jzuva > i ; i ++ ) { String s = sc . next ( ) ; list . add ( s ) ; } List < String > listB = new ArrayList < String > ( new HashSet < > ( list ) ) ; if ( listB . size ( ) != list . size ( ) ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } for ( int i = 0 ; list . size ( ) - 1 > i ; i ++ ) { String s = list . get ( i ) ; String t = list . get ( i + 1 ) ; List < String > list_s = new ArrayList < String > ( Arrays . asList ( s . split ( " " ) ) ) ; List < String > list_t = new ArrayList < String > ( Arrays . asList ( t . split ( " " ) ) ) ; s = list_s . get ( list_s . size ( ) - 1 ) ; t = list_t . get ( 0 ) ; if ( ! s . equals ( t ) ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; class Vjujl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] a = new int [ 3 ] [ 3 ] ; for ( int vjujl = 0 ; vjujl < 3 ; vjujl ++ ) for ( int j = 0 ; j < 3 ; j ++ ) a [ vjujl ] [ j ] = sc . nextInt ( ) ; int _1 = a [ 0 ] [ 1 ] + a [ 0 ] [ 2 ] + a [ 1 ] [ 2 ] ; int _2 = a [ 1 ] [ 0 ] + a [ 2 ] [ 0 ] + a [ 2 ] [ 1 ] ; int _3 = a [ 0 ] [ 0 ] + a [ 1 ] [ 1 ] + a [ 2 ] [ 2 ] ; if ( _1 + _2 == 2 * _3 ) { System . out . println ( " Yes " ) ; } else System . out . println ( " No " ) ; } } import java . util . * ; public class Vypxjo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int vypxjo = scan . nextInt ( ) ; int cnt = 0 ; boolean a = vypxjo > 99 ; if ( a ) { cnt ++ ; vypxjo = vypxjo - 100 ; } boolean b = vypxjo > 9 ; if ( b ) { vypxjo = vypxjo - 10 ; cnt ++ ; } boolean c = vypxjo == 1 ; if ( c ) { cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Qzgigd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int [ ] list = new int [ 9 ] ; int qzgigd = scanner . nextInt ( ) ; for ( int i = 0 ; i < qzgigd ; i ++ ) { int value = scanner . nextInt ( ) / 400 ; if ( value >= 8 ) { list [ 8 ] ++ ; } else { list [ value ] ++ ; } } int minAns = 0 ; for ( int i = 0 ; i < 8 ; i ++ ) { if ( list [ i ] > 0 ) { minAns ++ ; } } int maxAns = minAns ; if ( list [ 8 ] > 0 ) { minAns = Math . max ( minAns , 1 ) ; maxAns += list [ 8 ] ; } System . out . println ( minAns + " " + maxAns ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; public class Pusnkj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pusnkj = sc . nextInt ( ) ; int max = 1 ; String w = " " ; Map < String , Integer > map = new HashMap < > ( ) ; List < String > strArr = new ArrayList < > ( ) ; for ( int i = 0 ; i < pusnkj ; i ++ ) { w = sc . next ( ) ; if ( map . get ( w ) == null ) { map . put ( w , 1 ) ; } else { map . put ( w , map . get ( w ) + 1 ) ; if ( map . get ( w ) > max ) { max = map . get ( w ) ; } } } for ( Entry < String , Integer > entry : map . entrySet ( ) ) { if ( entry . getValue ( ) == max ) { strArr . add ( entry . getKey ( ) ) ; } } Collections . sort ( strArr ) ; for ( String str : strArr ) { System . out . println ( str ) ; } } } import java . util . * ; public class Bjagg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int bjagg = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int A = 0 ; for ( int i = 0 ; i < N ; i ++ ) { A += sc . nextInt ( ) ; } System . out . println ( bjagg > A ? " No " : " Yes " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Dkdvda { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . dkdvda ) ) ) { int dkdvda = Integer . parseInt ( br . readLine ( ) ) ; System . out . println ( dkdvda * 2 * Math . PI ) ; } } } import java . util . * ; public class Kcghlux { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int kcghlux = s . length ( ) ; int tlen = t . length ( ) ; int min = 10000 ; for ( int i = 0 ; i < kcghlux - tlen + 1 ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < tlen ; j ++ ) { if ( s . charAt ( i + j ) == t . charAt ( j ) ) { count ++ ; } } if ( tlen - count < min ) { min = tlen - count ; } } System . out . println ( min ) ; } } import java . util . Scanner ; public class Toqna { public static void main ( String ... args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int toqna = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ toqna ] ; for ( int i = 0 ; i < toqna ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int [ ] dp = new int [ toqna ] ; for ( int i = 0 ; i < toqna ; i ++ ) { if ( i == 0 ) dp [ i ] = 0 ; else dp [ i ] = Integer . MAX_VALUE ; for ( int j = 1 ; j <= k ; j ++ ) { if ( i >= j ) dp [ i ] = mindp ( dp [ i ] , dp [ i - j ] + Math . abs ( h [ i ] - h [ i - j ] ) ) ; } } System . out . println ( dp [ toqna - 1 ] ) ; } } public static int mindp ( int a , int b ) { if ( a > b ) { a = b ; } return a ; } } import java . util . Arrays ; import java . util . Scanner ; public class Cjifhr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cjifhr = scan . nextInt ( ) ; int q = scan . nextInt ( ) ; int r = scan . nextInt ( ) ; int [ ] a = { cjifhr , q , r } ; Arrays . sort ( a ) ; System . out . println ( a [ 0 ] + a [ 1 ] ) ; } } import java . util . * ; public class Hbrzcd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hbrzcd = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int [ ] [ ] X = new int [ hbrzcd ] [ D ] ; for ( int i = 0 ; i < hbrzcd ; i ++ ) { for ( int j = 0 ; j < D ; j ++ ) { X [ i ] [ j ] = sc . nextInt ( ) ; } } sc . close ( ) ; int count = 0 ; double distance = 0.0 ; for ( int i = 0 ; i < hbrzcd ; i ++ ) { for ( int j = i ; j < hbrzcd ; j ++ ) { if ( i != j ) { distance = 0.0 ; for ( int k = 0 ; k < D ; k ++ ) { distance += ( X [ i ] [ k ] - X [ j ] [ k ] ) * ( X [ i ] [ k ] - X [ j ] [ k ] ) ; } if ( Math . sqrt ( distance ) % 1 == 0 ) { count ++ ; } } } } System . out . println ( count ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . * ; public class Hkwhh { public static void main ( String [ ] args ) throws java . lang . Exception { PrintWriter out = new PrintWriter ( System . out ) ; FastScanner fs = new FastScanner ( ) ; long hkwhh = fs . nextLong ( ) ; double b = fs . nextDouble ( ) ; BigDecimal bg1 = BigDecimal . valueOf ( hkwhh ) ; BigDecimal bg2 = BigDecimal . valueOf ( b ) ; out . println ( bg1 . multiply ( bg2 ) . setScale ( 0 , RoundingMode . DOWN ) ) ; out . close ( ) ; } static class Hkwhh { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] readArray ( int n ) { int [ ] hkwhh = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) hkwhh [ i ] = nextInt ( ) ; return hkwhh ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } } import java . util . Scanner ; public class Inlyk { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; int inlyk = kb . nextInt ( ) ; int [ ] [ ] a = new int [ inlyk ] [ 3 ] ; int x , y , z ; for ( int i = 0 ; i < inlyk ; i ++ ) { a [ i ] [ 0 ] = kb . nextInt ( ) ; a [ i ] [ 1 ] = kb . nextInt ( ) ; a [ i ] [ 2 ] = kb . nextInt ( ) ; } for ( int i = 0 ; i < inlyk ; i ++ ) { x = a [ i ] [ 0 ] ; y = a [ i ] [ 1 ] ; z = a [ i ] [ 2 ] ; if ( x * x + y * y == z * z || y * y + z * z == x * x || z * z + x * x == y * y ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } } import java . util . Scanner ; public class Nqphux { public static void main ( String [ ] args ) { run ( ) ; } static void run ( ) { Scanner sc = new Scanner ( System . in ) ; int nqphux = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int ans = isDivisor ( nqphux , b , c ) ; System . out . println ( ans ) ; } static int isDivisor ( int nqphux , int b , int c ) { int ans = 0 ; for ( int i = nqphux ; i <= b ; i ++ ) { if ( c % i == 0 ) { ans ++ ; } } return ans ; } } import java . util . HashMap ; import java . util . Scanner ; public class Amsxole { public static void main ( String [ ] args ) { HashMap < String , String > map = new HashMap < String , String > ( ) ; Scanner sc = new Scanner ( System . in ) ; int amsxole = sc . nextInt ( ) ; String str = sc . nextLine ( ) ; for ( int i = 0 ; i < amsxole ; i ++ ) { map . put ( sc . nextLine ( ) , " " ) ; } sc . close ( ) ; System . out . println ( map . size ( ) ) ; } } import java . util . * ; public class Elaxx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int elaxx = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] [ ] mat = new int [ elaxx ] [ M ] ; for ( int i = 0 ; i < elaxx ; i ++ ) { int tmp = sc . nextInt ( ) ; for ( int j = 0 ; j < tmp ; j ++ ) { mat [ i ] [ j ] = sc . nextInt ( ) ; } } int answer = 0 ; for ( int i = 1 ; i <= M ; i ++ ) { if ( isAllLike ( mat , i , elaxx , M ) ) { answer = answer + 1 ; } } System . out . println ( answer ) ; } public static boolean isAllLike ( int [ ] [ ] mat , int x , int elaxx , int M ) { boolean isLike = false ; for ( int i = 0 ; i < elaxx ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( mat [ i ] [ j ] == x ) { isLike = true ; } } if ( ! isLike ) { return false ; } isLike = false ; } return true ; } } import java . util . * ; class Adagvy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int adagvy = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int C = Integer . parseInt ( sc . next ( ) ) ; int X = Integer . parseInt ( sc . next ( ) ) ; int ans = 0 ; for ( int a = 0 ; a <= adagvy ; a ++ ) { for ( int b = 0 ; b <= B ; b ++ ) { for ( int c = 0 ; c <= C ; c ++ ) { if ( a * 500 + b * 100 + c * 50 == X ) { ans ++ ; } } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Hzvlm { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String token = sc . next ( ) ; String [ ] strArray = token . split ( " " ) ; int hzvlm = 0 ; if ( strArray [ 0 ] . equals ( " 1 " ) ) { hzvlm ++ ; } if ( strArray [ 1 ] . equals ( " 1 " ) ) { hzvlm += 1 ; } if ( strArray [ 2 ] . equals ( " 1 " ) ) { hzvlm += 1 ; } System . out . println ( hzvlm ) ; sc . close ( ) ; } } import java . util . * ; public class Vaokhs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vaokhs = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int min = 10001 ; for ( int i = 0 ; i < vaokhs ; i ++ ) { int cost = sc . nextInt ( ) ; if ( sc . nextInt ( ) <= T ) { min = Math . min ( min , cost ) ; } } if ( min == 10001 ) { System . out . println ( " TLE " ) ; } else { System . out . println ( min ) ; } } } import java . util . Scanner ; public class Unnoleu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int unnoleu = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] mArray = new int [ m + 1 ] ; for ( int i = 0 ; i < unnoleu ; i ++ ) { int k = sc . nextInt ( ) ; int [ ] aArray = new int [ k ] ; for ( int j = 0 ; j < k ; j ++ ) { aArray [ j ] = sc . nextInt ( ) ; mArray [ aArray [ j ] ] ++ ; } } int result = 0 ; for ( int i = 1 ; i < m + 1 ; i ++ ) { if ( mArray [ i ] == unnoleu ) result ++ ; } System . out . println ( result ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; public class Pjpofs { public static void main ( String [ ] args ) throws Exception { Scanner cin = new Scanner ( System . in ) ; int pjpofs = cin . nextInt ( ) , b = cin . nextInt ( ) ; System . out . println ( GCD ( pjpofs , b ) ) ; } public static int GCD ( int pjpofs , int b ) { if ( b == 0 ) return pjpofs ; return GCD ( b , pjpofs % b ) ; } } import java . util . Scanner ; import java . util . Stack ; public class Tkutwvh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String [ ] A = scan . nextLine ( ) . split ( " " ) ; Stack < Integer > num = new Stack < Integer > ( ) ; int tkutwvh = 0 ; int b = 0 ; for ( int i = 0 ; i < A . length ; i ++ ) { if ( A [ i ] . equals ( " + " ) ) { tkutwvh = num . pop ( ) ; b = num . pop ( ) ; num . add ( b + tkutwvh ) ; continue ; } if ( A [ i ] . equals ( " - " ) ) { tkutwvh = num . pop ( ) ; b = num . pop ( ) ; num . add ( b - tkutwvh ) ; continue ; } if ( A [ i ] . equals ( " * " ) ) { tkutwvh = num . pop ( ) ; b = num . pop ( ) ; num . add ( b * tkutwvh ) ; continue ; } if ( A [ i ] . equals ( " / " ) ) { tkutwvh = num . pop ( ) ; b = num . pop ( ) ; num . add ( b / tkutwvh ) ; continue ; } num . push ( Integer . parseInt ( A [ i ] ) ) ; } System . out . println ( num . pop ( ) ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Map ; import java . util . HashMap ; import java . util . List ; import java . util . ArrayList ; import java . util . Collections ; public class Uedyu { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long uedyu , b = 0 ; long n = Long . parseLong ( br . readLine ( ) ) ; int digits , mindigits = 11 ; for ( uedyu = 1 ; uedyu <= Math . sqrt ( n ) ; uedyu ++ ) { if ( n % uedyu == 0 ) { b = n / uedyu ; digits = String . valueOf ( Math . max ( uedyu , b ) ) . length ( ) ; if ( digits < mindigits ) mindigits = digits ; } } System . out . println ( mindigits ) ; } } import java . util . * ; import java . lang . Double ; public class Cpljkyb { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; String cpljkyb = reader . nextLine ( ) ; if ( cpljkyb . equals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } else { System . out . println ( " ABC " ) ; } } } import java . util . Scanner ; public class Gwzaavl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String gwzaavl = sc . nextLine ( ) ; StringBuffer sb = new StringBuffer ( gwzaavl ) ; String rv = sb . reverse ( ) . toString ( ) ; System . out . println ( rv ) ; } } import java . util . Scanner ; public class Rwqvaey { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int rwqvaey = stdIn . nextInt ( ) ; int [ ] a = new int [ rwqvaey + 1 ] ; for ( int i = 1 ; i <= rwqvaey ; i ++ ) a [ i ] = i ; int s = stdIn . nextInt ( ) ; for ( ; s != 0 ; s -- ) { String [ ] S = stdIn . next ( ) . split ( " , " ) ; int l = Integer . parseInt ( S [ 0 ] ) ; int r = Integer . parseInt ( S [ 1 ] ) ; int t = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = t ; } for ( int i = 1 ; i <= rwqvaey ; i ++ ) System . out . println ( a [ i ] ) ; } } import java . util . Scanner ; public class Ylzzavl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ylzzavl = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int A = 10000 ; int B = 5000 ; int C = 1000 ; for ( int ai = 0 ; ai <= ylzzavl ; ai ++ ) { for ( int bi = 0 ; bi <= ylzzavl - ai ; bi ++ ) { int ci = ylzzavl - ai - bi ; int sum = ai * A + bi * B + ci * 1000 ; if ( sum == Y ) { System . out . println ( ai + " " + bi + " " + ci ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . util . * ; public class Cpxhjxj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cpxhjxj = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( y % 2 == 1 ) { System . out . println ( " No " ) ; return ; } if ( y >= 2 * cpxhjxj && y <= 4 * cpxhjxj ) { System . out . println ( " Yes " ) ; return ; } System . out . println ( " No " ) ; } } import java . util . * ; public class Vnsckb { static int vnsckb = ( int ) Math . pow ( 10 , 9 ) + 7 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a1 = sc . nextInt ( ) ; int a = a1 ; int count = 0 ; int [ ] bucket = new int [ 1000010 ] ; while ( true ) { count ++ ; if ( bucket [ a ] > 0 ) { break ; } bucket [ a ] ++ ; a = func ( a ) ; } System . out . println ( count ) ; } public static int func ( int n ) { return n % 2 == 0 ? n / 2 : n * 3 + 1 ; } } import java . util . Scanner ; class Osfehg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { String [ ] str = scan . nextLine ( ) . split ( " " ) ; int osfehg = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 2 ] ) ; if ( " ? " . equals ( str [ 1 ] ) ) break ; if ( " + " . equals ( str [ 1 ] ) ) { System . out . println ( osfehg + b ) ; } else if ( " - " . equals ( str [ 1 ] ) ) { System . out . println ( osfehg - b ) ; } else if ( " * " . equals ( str [ 1 ] ) ) { System . out . println ( osfehg * b ) ; } else if ( " / " . equals ( str [ 1 ] ) ) { System . out . println ( osfehg / b ) ; } } } } import java . util . Scanner ; public class Rdbtr { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String N = in . next ( ) ; int rdbtr = 0 ; for ( int i = 1 ; i <= Integer . parseInt ( N ) ; i ++ ) if ( String . valueOf ( i ) . length ( ) % 2 == 1 ) rdbtr ++ ; System . out . println ( rdbtr ) ; } } import java . util . * ; public class Orhid { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . next ( ) ; char [ ] alpha = new char [ 26 ] ; String str = " abcdefghijklmnopqrstuvwxyz " ; for ( int orhid = 0 ; orhid < 26 ; orhid ++ ) { alpha [ orhid ] = str . charAt ( orhid ) ; } int [ ] count = new int [ 26 ] ; for ( int orhid = 0 ; orhid < w . length ( ) ; orhid ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) { if ( w . charAt ( orhid ) == alpha [ j ] ) count [ j ] ++ ; } } for ( int orhid = 0 ; orhid < 26 ; orhid ++ ) { if ( count [ orhid ] % 2 != 0 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; class Zsxrj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zsxrj = sc . nextInt ( ) ; int [ ] t = new int [ zsxrj + 1 ] ; t [ 0 ] = 0 ; int [ ] x = new int [ zsxrj + 1 ] ; x [ 0 ] = 0 ; int [ ] y = new int [ zsxrj + 1 ] ; x [ 0 ] = 0 ; for ( int i = 1 ; i <= zsxrj ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < zsxrj ; i ++ ) { int abs_t = t [ i + 1 ] - t [ i ] ; int abs_x = Math . abs ( x [ i + 1 ] - x [ i ] ) ; int abs_y = Math . abs ( y [ i + 1 ] - y [ i ] ) ; if ( abs_t < abs_x + abs_y || abs_t % 2 != ( abs_x + abs_y ) % 2 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; public class Pvaxhjz { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int pvaxhjz = Integer . parseInt ( br . readLine ( ) ) ; Map < String , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < pvaxhjz ; i ++ ) { String s = br . readLine ( ) ; if ( map . containsKey ( s ) ) { map . put ( s , map . get ( s ) + 1 ) ; } else { map . put ( s , 1 ) ; } } br . close ( ) ; int max = 0 ; for ( int i : map . values ( ) ) { max = Math . max ( max , i ) ; } List < String > list = new ArrayList < > ( ) ; for ( String s : map . keySet ( ) ) { if ( map . get ( s ) == max ) { list . add ( s ) ; } } Collections . sort ( list ) ; for ( String s : list ) { System . out . println ( s ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Hlwnc { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int hlwnc = s . nextInt ( ) ; int m = s . nextInt ( ) ; int x = s . nextInt ( ) ; char [ ] road = new char [ hlwnc ] ; int countFromStart = 0 ; int countToEnd = 0 ; int countC = 0 ; Arrays . fill ( road , 'a' ) ; road [ x ] = 'x' ; for ( int i = 0 ; i < m ; i ++ ) { int tmp = s . nextInt ( ) ; road [ tmp ] = 'c' ; } for ( int j = 0 ; j < x ; j ++ ) { if ( road [ j ] == 'c' ) { ++ countFromStart ; } } for ( int k = x + 1 ; k < hlwnc ; k ++ ) { if ( road [ k ] == 'c' ) { ++ countToEnd ; } } if ( countToEnd > countFromStart ) { for ( int p = 0 ; p < x ; p ++ ) { if ( road [ p ] == 'c' ) ++ countC ; } } else { for ( int q = x + 1 ; q < hlwnc ; q ++ ) { if ( road [ q ] == 'c' ) { ++ countC ; } } } System . out . println ( countC ) ; } } import java . util . * ; public class Qijhv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] split = s . split ( " " ) ; int qijhv ; int count = 0 , ans = 0 ; for ( qijhv = 0 ; qijhv < s . length ( ) ; qijhv ++ ) { if ( split [ qijhv ] . equals ( " A " ) || split [ qijhv ] . equals ( " C " ) || split [ qijhv ] . equals ( " G " ) || split [ qijhv ] . equals ( " T " ) ) { count += 1 ; } else { if ( ans < count ) { ans = count ; } count = 0 ; } } if ( ans < count ) { ans = count ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Qytjao { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; int qytjao = Integer . parseInt ( s . replaceAll ( " " , " " ) ) ; int sqrt = ( int ) Math . sqrt ( qytjao ) ; System . out . println ( ( sqrt * sqrt == qytjao ) ? " Yes " : " No " ) ; } } import java . util . * ; public class Lnvwoop { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Random rand = new Random ( ) ; int lnvwoop = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += sc . nextInt ( ) ; } if ( lnvwoop <= sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Myzys { static int myzys = 1 ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long h = Long . parseLong ( scan . nextLine ( ) ) ; test ( h ) ; System . out . println ( ( long ) Math . pow ( 2 , myzys ) - 1 ) ; } public static void test ( long hp ) { hp = hp / 2 ; if ( hp == 0 ) return ; myzys ++ ; test ( hp ) ; } } import java . io . * ; public class Nwhune { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; while ( true ) { String str = input . readLine ( ) ; String [ ] arr = str . split ( " " ) ; int nwhune = Integer . parseInt ( arr [ 0 ] ) ; int w = Integer . parseInt ( arr [ 1 ] ) ; if ( nwhune == 0 && w == 0 ) { break ; } for ( int i = 0 ; i < nwhune ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( i == 0 || i == nwhune - 1 || j == 0 || j == w - 1 ) { sb . append ( " # " ) ; } else { sb . append ( " . " ) ; } } sb . append ( " \n " ) ; } sb . append ( " \n " ) ; } System . out . print ( sb ) ; } } import java . util . Scanner ; public class Itkwp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int itkwp = sc . nextInt ( ) ; int len = String . valueOf ( itkwp ) . length ( ) ; int res = 0 ; for ( int i = 1 ; i < len ; i += 2 ) { res += 9 * ( int ) Math . pow ( 10 , i - 1 ) ; } if ( len % 2 == 1 ) { res += itkwp - ( int ) Math . pow ( 10 , len - 1 ) + 1 ; } System . out . println ( res ) ; } } import java . util . * ; public class Nvkbypw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nvkbypw = sc . nextInt ( ) ; String S = sc . next ( ) ; char Si = S . charAt ( 0 ) ; int count = 1 ; for ( int i = 1 ; i < nvkbypw ; i ++ ) { if ( S . charAt ( i ) == Si ) ; else { count ++ ; Si = S . charAt ( i ) ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Jhndqk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jhndqk = sc . nextInt ( ) ; int [ ] a = new int [ jhndqk ] ; float sum = 0 ; for ( int y = 0 ; y < jhndqk ; y ++ ) { a [ y ] = sc . nextInt ( ) ; sum += a [ y ] ; } int p = Math . round ( sum / jhndqk ) ; int res = 0 ; for ( int i = 0 ; i < jhndqk ; i ++ ) { res += ( a [ i ] - p ) * ( a [ i ] - p ) ; } System . out . println ( res ) ; sc . close ( ) ; } } import java . util . Scanner ; class Xkhnn { private static int gcd ( int a , int b ) { while ( b != 0 ) { int xkhnn = a % b ; a = b ; b = xkhnn ; } return a ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; int res = 0 ; int temp = 0 ; for ( int i = 1 ; i < N + 1 ; i ++ ) { for ( int j = 1 ; j < N + 1 ; j ++ ) { temp = gcd ( i , j ) ; for ( int k = 1 ; k < N + 1 ; k ++ ) { res += gcd ( k , temp ) ; } } } System . out . println ( res ) ; } } import java . util . Scanner ; public class Axnwxx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] tmp = sc . nextLine ( ) . split ( " " ) ; int axnwxx = Integer . valueOf ( tmp [ 0 ] ) ; int b = Integer . valueOf ( tmp [ 1 ] ) ; int sum = judge ( axnwxx , b ) ; if ( axnwxx < b ) { b -- ; } else { axnwxx -- ; } sum += judge ( axnwxx , b ) ; System . out . println ( sum ) ; } public static int judge ( int axnwxx , int b ) { int res = 0 ; if ( axnwxx < b ) { res = b ; } else { res = axnwxx ; } return res ; } } import java . util . Scanner ; public class Pwymgak { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int pwymgak = scan . nextInt ( ) ; int A = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int cnt = 0 ; for ( int i = A ; i <= B ; i ++ ) { if ( i % pwymgak == 0 ) { cnt = cnt + 1 ; } } if ( cnt >= 1 ) { System . out . println ( " OK " ) ; } else { System . out . println ( " NG " ) ; } scan . close ( ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Qdonnp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int qdonnp = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int resultCount = 0 ; for ( int i = 0 ; i < qdonnp ; i ++ ) { final int num = sc . nextInt ( ) ; if ( num % 2 == 0 ) { list . add ( num ) ; } else { break ; } } if ( list . size ( ) != qdonnp ) { System . out . print ( resultCount ) ; return ; } boolean continueFlag = true ; while ( continueFlag ) { int count = 0 ; for ( int j = 0 ; j < qdonnp ; j ++ ) { int num = list . get ( j ) ; if ( num % 2 == 0 ) { list . set ( j , num / 2 ) ; count ++ ; } else { continueFlag = false ; break ; } } if ( count == qdonnp ) { resultCount ++ ; } } System . out . print ( resultCount ) ; sc . close ( ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Vglod { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int vglod = scanner . nextInt ( ) ; int count = 0 ; boolean flg = true ; List < Integer > numList = new ArrayList < > ( ) ; scanner . nextLine ( ) ; for ( int i = 0 ; i < vglod ; i ++ ) { int j = scanner . nextInt ( ) ; if ( j % 2 == 1 ) { flg = false ; break ; } numList . add ( j ) ; } while ( flg ) { List < Integer > nextNumList = new ArrayList < > ( ) ; for ( Integer i : numList ) { if ( i % 2 == 1 ) { flg = false ; break ; } nextNumList . add ( i / 2 ) ; } if ( ! flg ) { break ; } numList = nextNumList ; count ++ ; } System . out . println ( count ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Pndykw { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] array = br . readLine ( ) . split ( " " ) ; int pndykw = Integer . parseInt ( array [ 0 ] ) ; int y = Integer . parseInt ( array [ 1 ] ) ; int z = y % 4 ; if ( ( z == 0 || z % 2 == 0 ) && 4 * pndykw >= y && 2 * pndykw <= y ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . IOException ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Hatzn { public static void main ( String [ ] args ) throws NumberFormatException , IOException { try ( Scanner sc = new Scanner ( System . in ) ) { int hatzn = Integer . parseInt ( sc . nextLine ( ) ) ; String a = sc . nextLine ( ) ; String [ ] b = a . split ( " " ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < b . length ; i ++ ) { list . add ( Integer . parseInt ( b [ i ] ) ) ; } Collections . sort ( list ) ; System . out . println ( list . get ( list . size ( ) - 1 ) - list . get ( 0 ) ) ; } } } import java . util . Scanner ; public class Jnttb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; try { final int jnttb = sc . nextInt ( ) ; final int B = sc . nextInt ( ) ; int kuchi = 1 ; if ( B == 1 ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } for ( int i = 1 ; i <= B ; i ++ ) { kuchi = kuchi - 1 + jnttb ; if ( kuchi >= B ) { System . out . println ( i ) ; System . exit ( 0 ) ; } } } finally { sc . close ( ) ; } } } import java . lang . reflect . Array ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Ysaxeth { public static void main ( String [ ] args ) { Scanner sc = new java . util . Scanner ( System . in ) ; int ysaxeth = 0 ; int bob = 0 ; int N = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] sCards = sc . nextLine ( ) . split ( " " ) ; List < Integer > iCards = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { iCards . add ( Integer . parseInt ( sCards [ i ] ) ) ; } for ( int n = 0 ; n < N ; n ++ ) { int max = 0 ; for ( int c : iCards ) { max = Math . max ( max , c ) ; } if ( n == 0 || n % 2 == 0 ) { ysaxeth += max ; } else { bob += max ; } iCards . remove ( iCards . indexOf ( max ) ) ; } System . out . println ( ysaxeth - bob ) ; } } import java . util . * ; public class Jpicxag { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . next ( ) ; char jpicxag = C . charAt ( 0 ) ; System . out . println ( ++ jpicxag ) ; } } import java . util . Scanner ; public class Dmpjecy { public static int Int ( int a ) { int dmpjecy = 0 ; if ( a == 9 ) { dmpjecy = 1 ; } else { dmpjecy = 9 ; } return dmpjecy ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = Int ( a % 10 ) ; a /= 10 ; int c = Int ( a % 10 ) ; a /= 10 ; int d = Int ( a % 10 ) ; System . out . println ( d + " " + c + " " + b ) ; } } import java . util . Scanner ; public class Wshqpyy { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long wshqpyy = scanner . nextLong ( ) ; long R = scanner . nextLong ( ) ; if ( R - wshqpyy >= 2018L ) { System . out . println ( 0 ) ; return ; } long m1 = wshqpyy % 2019L ; long m2 = R % 2019L ; if ( m1 > m2 ) { System . out . println ( 0 ) ; return ; } long ans = 2019 ; for ( long i = m1 ; i < m2 ; ++ i ) { for ( long j = i + 1 ; j <= m2 ; ++ j ) { long current = ( ( i % 2019L ) * ( j ) % 2019L ) % 2019L ; ans = Math . min ( ans , current ) ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Wmnpwf { public static void main ( String [ ] args ) { int wmnpwf = 0 ; int K = 0 ; String S ; Scanner sc = new Scanner ( System . in ) ; wmnpwf = Integer . parseInt ( sc . next ( ) ) ; K = Integer . parseInt ( sc . next ( ) ) ; S = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( S ) ; char s ; String lower ; s = sb . charAt ( K - 1 ) ; lower = String . valueOf ( s ) ; sb . setCharAt ( K - 1 , ( lower . toLowerCase ( ) ) . toCharArray ( ) [ 0 ] ) ; System . out . println ( sb . toString ( ) ) ; } } import java . util . Scanner ; public class Xccbjd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xccbjd = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int count = 0 ; int [ ] array_b = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { array_b [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < xccbjd ; i ++ ) { int [ ] array_a = new int [ m ] ; int ans = 0 ; for ( int j = 0 ; j < m ; j ++ ) { int temp = sc . nextInt ( ) ; ans += array_b [ j ] * temp ; } ans += c ; if ( ans > 0 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class Lyirjp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lyirjp = sc . nextInt ( ) ; int [ ] arr = new int [ lyirjp ] ; for ( int i = 0 ; i < lyirjp ; i ++ ) { arr [ sc . nextInt ( ) - 1 ] = i + 1 ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < lyirjp ; i ++ ) { if ( i != 0 ) { sb . append ( " " ) ; } sb . append ( arr [ i ] ) ; } System . out . println ( sb ) ; } } import java . io . * ; import java . math . * ; import java . util . * ; public class Byqfmw { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int byqfmw = input . nextInt ( ) ; String S = input . next ( ) ; if ( S . length ( ) <= byqfmw ) System . out . println ( S ) ; else System . out . println ( S . substring ( 0 , byqfmw ) + " ... " ) ; } } public class Yvhfnb { public void run ( java . util . Scanner sc ) { int [ ] a ; int yvhfnb , j ; a = new int [ sc . nextInt ( ) ] ; for ( yvhfnb = 0 ; yvhfnb < a . length ; ++ yvhfnb ) a [ yvhfnb ] = sc . nextInt ( ) ; for ( yvhfnb = 0 ; yvhfnb < a . length ; ++ yvhfnb ) { final int t = a [ yvhfnb ] ; for ( j = yvhfnb - 1 ; j >= 0 ; -- j ) { if ( t < a [ j ] ) { a [ j + 1 ] = a [ j ] ; a [ j ] = t ; } } printArray ( a ) ; } } private void printArray ( int [ ] a ) { int yvhfnb ; for ( yvhfnb = 0 ; yvhfnb < a . length ; ++ yvhfnb ) { System . out . print ( a [ yvhfnb ] ) ; if ( yvhfnb + 1 < a . length ) System . out . print ( " " ) ; else System . out . println ( ) ; } } public static void main ( String [ ] args ) { ( new Main ( ) ) . run ( new java . util . Scanner ( System . in ) ) ; } } import java . util . Scanner ; public class Ahgucb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ahgucb = 0 , H , A ; H = scan . nextInt ( ) ; A = scan . nextInt ( ) ; while ( H > 0 ) { H = H - A ; ahgucb ++ ; } System . out . println ( ahgucb ) ; } } import java . util . * ; class Pzenk { int max ( int pzenk , int b ) { if ( pzenk < b ) return b ; else return pzenk ; } int min ( int pzenk , int b ) { if ( pzenk > b ) return b ; else return pzenk ; } Main ( ) { Scanner sc = new Scanner ( System . in ) ; int pzenk , c , d ; pzenk = sc . nextInt ( ) ; d = - 1000000000 ; c = sc . nextInt ( ) ; for ( int i = 0 ; i < pzenk - 1 ; i ++ ) { int f = sc . nextInt ( ) ; d = max ( d , f - c ) ; c = min ( c , f ) ; } System . out . println ( d ) ; } public static void main ( String [ ] arg ) { new Main ( ) ; } } import java . util . Scanner ; class Yrzpow { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double yrzpow = scan . nextDouble ( ) ; double b = scan . nextDouble ( ) ; double h = scan . nextDouble ( ) ; double m = scan . nextDouble ( ) ; double naga = m * 360 / 60 ; double miji = ( h * 60 + m ) * 360 / ( 12 * 60 ) ; double kaku = miji - naga ; double result = Math . sqrt ( yrzpow * yrzpow + b * b - 2 * yrzpow * b * Math . cos ( Math . toRadians ( kaku ) ) ) ; System . out . println ( result ) ; } } import java . io . * ; import java . util . * ; class Mdhxbs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mdhxbs = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; while ( mdhxbs != 0 || W != 0 ) { for ( int i = 0 ; i < mdhxbs ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { System . out . printf ( " # " ) ; } System . out . printf ( " \n " ) ; } System . out . printf ( " \n " ) ; mdhxbs = sc . nextInt ( ) ; W = sc . nextInt ( ) ; } } } import java . math . BigInteger ; import java . util . Scanner ; public class Mkgvtso { public static void main ( String [ ] args ) { Long K ; Scanner sc = new Scanner ( System . in ) ; K = sc . nextLong ( ) ; Long bank = 100L ; int mkgvtso = 0 ; while ( bank < K ) { bank = ( long ) ( bank * 1.01 ) ; mkgvtso ++ ; } System . out . println ( mkgvtso ) ; } } import java . util . * ; public class Evnfuzd { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int evnfuzd = sc . nextInt ( ) ; if ( evnfuzd / 10 == 0 ) { System . out . println ( evnfuzd % 10 ) ; } else if ( evnfuzd / 100 == 0 ) { System . out . println ( 9 ) ; } else if ( evnfuzd / 1000 == 0 ) { System . out . println ( evnfuzd % 1000 - 99 + 9 ) ; } else if ( evnfuzd / 10000 == 0 ) { System . out . println ( 909 ) ; } else if ( evnfuzd / 100000 == 0 ) { System . out . println ( evnfuzd % 100000 - 9999 + 900 + 9 ) ; } else { System . out . println ( 90909 ) ; } } } import java . util . * ; public class Ytghzl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ytghzl = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; if ( c - ( ytghzl - b ) >= 0 ) { System . out . println ( c - ( ytghzl - b ) ) ; } else { System . out . println ( 0 ) ; } } } import java . util . Scanner ; public class Pcmsu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pcmsu = sc . nextInt ( ) ; int [ ] A ; A = new int [ pcmsu ] ; int count = 0 ; for ( int i = 0 ; i < pcmsu ; ++ i ) { A [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < pcmsu - 1 ; ++ i ) { for ( int j = 0 ; j < pcmsu - 1 ; ++ j ) { if ( A [ j ] > A [ j + 1 ] ) { int c ; c = A [ j ] ; A [ j ] = A [ j + 1 ] ; A [ j + 1 ] = c ; count ++ ; } } } print ( A , pcmsu ) ; System . out . println ( count ) ; } public static void print ( int [ ] A , int pcmsu ) { for ( int i = 0 ; i < pcmsu ; ++ i ) { System . out . print ( A [ i ] ) ; if ( i < pcmsu - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } import java . util . * ; public class Fyxyeek { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fyxyeek = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= fyxyeek ; i ++ ) { int sumOfDigits = findSumOfDigits ( i ) ; if ( a <= sumOfDigits && sumOfDigits <= b ) { sum += i ; } } System . out . println ( sum ) ; } public static int findSumOfDigits ( int num ) { int sum = 0 ; while ( num > 0 ) { sum += num % 10 ; num /= 10 ; } return sum ; } } import java . util . Scanner ; public class Emhvfs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int emhvfs = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; for ( int i = 1 ; i <= K ; i ++ ) { if ( K - emhvfs == 0 ) { System . out . println ( emhvfs * 1 ) ; return ; } if ( K - emhvfs < 0 ) { System . out . println ( K * 1 ) ; return ; } if ( ( K - emhvfs ) - B <= 0 ) { System . out . println ( emhvfs * 1 + B * 0 ) ; return ; } if ( ( K - emhvfs ) - B > 0 ) { System . out . println ( emhvfs * 1 + B * 0 + ( ( ( K - emhvfs ) - B ) * ( - 1 ) ) ) ; return ; } } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Adldgq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; for ( int adldgq = 0 ; adldgq < 10 ; adldgq ++ ) { list . add ( scan . nextInt ( ) ) ; } Collections . sort ( list , Collections . reverseOrder ( ) ) ; System . out . println ( list . get ( 0 ) ) ; System . out . println ( list . get ( 1 ) ) ; System . out . println ( list . get ( 2 ) ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Gtttk { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; String [ ] boxstr = new String [ line . length ( ) ] ; int [ ] box = new int [ line . length ( ) ] ; int gtttk = Integer . parseInt ( line ) ; int ans = 0 ; for ( int i = 0 ; i < line . length ( ) ; i ++ ) { boxstr [ i ] = String . valueOf ( line . charAt ( i ) ) ; box [ i ] = Integer . parseInt ( boxstr [ i ] ) ; ans += box [ i ] ; } if ( gtttk % ans == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Gimhns { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gimhns = sc . nextInt ( ) ; int cnt = 0 ; if ( gimhns % 2 == 0 ) { cnt = gimhns / 2 ; System . out . println ( cnt ) ; } else { cnt = ( int ) ( gimhns / 2 ) + 1 ; System . out . println ( cnt ) ; } } } import java . util . Scanner ; public class Fynefq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String fynefq = sc . next ( ) ; String str = sc . next ( ) ; sc . close ( ) ; fynefq += fynefq ; if ( fynefq . contains ( str ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Ulscrho { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ulscrho = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int [ ] H = new int [ ulscrho ] ; for ( int i = 0 ; i < ulscrho ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } double min = Double . MAX_VALUE ; int minPotision = 0 ; for ( int i = 0 ; i < ulscrho ; i ++ ) { if ( Math . abs ( T - H [ i ] * 0.006 - A ) < min ) { min = Math . abs ( T - H [ i ] * 0.006 - A ) ; minPotision = i ; } } System . out . print ( minPotision + 1 ) ; } } import java . io . * ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; class Loayk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int loayk = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sc . nextLine ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < loayk ; i ++ ) list . add ( sc . nextInt ( ) ) ; List < Integer > dyn = new ArrayList < Integer > ( ) ; dyn . add ( 0 ) ; dyn . add ( ( int ) ( Math . abs ( list . get ( 1 ) - list . get ( 0 ) ) ) ) ; for ( int i = 2 ; i < loayk ; i ++ ) { int min = Integer . MAX_VALUE ; for ( int j = 1 ; j <= K ; j ++ ) { if ( i - j >= 0 ) { min = ( int ) Math . min ( min , Math . abs ( list . get ( i ) - list . get ( i - j ) ) + dyn . get ( i - j ) ) ; } if ( i - j < 0 ) break ; } dyn . add ( min ) ; } System . out . println ( dyn . get ( loayk - 1 ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Fyegncf { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int fyegncf = stdIn . nextInt ( ) ; int n1 = fyegncf / 100 ; fyegncf = fyegncf - n1 * 100 ; int n2 = fyegncf / 10 ; fyegncf = fyegncf - n2 * 10 ; if ( fyegncf == 2 || fyegncf == 4 || fyegncf == 5 || fyegncf == 7 || fyegncf == 9 ) { System . out . println ( " hon " ) ; } else if ( fyegncf == 0 || fyegncf == 1 || fyegncf == 6 || fyegncf == 8 ) { System . out . println ( " pon " ) ; } else { System . out . println ( " bon " ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class Mizctvv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mizctvv = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < > ( ) ; String newWord ; for ( int i = 0 ; i < mizctvv ; i ++ ) { newWord = sc . next ( ) ; if ( list . contains ( newWord ) || ( ! list . isEmpty ( ) && ! ( list . get ( list . size ( ) - 1 ) ) . endsWith ( String . valueOf ( newWord . charAt ( 0 ) ) ) ) ) { System . out . println ( " No " ) ; return ; } else { list . add ( newWord ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Tsjaqc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String str = sc . next ( ) ; if ( str . equals ( " - " ) ) break ; int tsjaqc = sc . nextInt ( ) ; int [ ] array = new int [ tsjaqc ] ; String result = str ; for ( int i = 0 ; i < tsjaqc ; i ++ ) { int shuffleNum = sc . nextInt ( ) ; result = result . substring ( shuffleNum ) + result . substring ( 0 , shuffleNum ) ; } System . out . println ( result ) ; } } } import java . util . * ; public class Xgqqw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xgqqw = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; Integer [ ] p = new Integer [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int min = Integer . MAX_VALUE ; for ( int j = - 1000 ; j < 1000 ; j ++ ) { if ( Arrays . asList ( p ) . contains ( j ) ) { continue ; } min = Math . min ( min , Math . abs ( xgqqw - j ) ) ; } int a = xgqqw - min ; if ( Arrays . asList ( p ) . contains ( a ) ) { System . out . println ( xgqqw + min ) ; } else { System . out . println ( a ) ; } } } import java . util . * ; public class Rvevhsy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rvevhsy = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int day = 0 ; for ( int i = 0 ; i < M ; i ++ ) { day += scan . nextInt ( ) ; } if ( day > rvevhsy ) { System . out . println ( - 1 ) ; } else { System . out . println ( rvevhsy - day ) ; } } } import java . util . Scanner ; public class Bhmkpx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bhmkpx = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= bhmkpx ; i ++ ) { for ( int j = 1 ; j <= bhmkpx ; j ++ ) { for ( int k = 1 ; k <= bhmkpx ; k ++ ) { sum += gcd ( i , gcd ( j , k ) ) ; } } } System . out . println ( sum ) ; } static int gcd ( int a , int b ) { int temp ; while ( ( temp = a % b ) != 0 ) { a = b ; b = temp ; } return b ; } } import java . util . * ; public class Ttbvsqi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ttbvsqi = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= ttbvsqi ; i ++ ) { if ( String . valueOf ( i ) . length ( ) % 2 == 1 ) count ++ ; } System . out . println ( count ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Vwgtc { public static void main ( String [ ] args ) { BufferedReader inMsg = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String vwgtc = " " ; try { while ( ( vwgtc = inMsg . readLine ( ) ) != null ) { String [ ] ab = vwgtc . split ( " " ) ; Integer a = 0 ; Integer b = 0 ; Integer sqr = 0 ; Integer liner = 0 ; a = Integer . parseInt ( ab [ 0 ] ) ; b = Integer . parseInt ( ab [ 1 ] ) ; sqr = a * b ; liner = a * 2 + b * 2 ; System . out . println ( sqr + " " + liner ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class Aqwnyk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] s = S . toCharArray ( ) ; int aqwnyk = 0 ; for ( int i = 1 ; i <= s . length - 1 ; i ++ ) { if ( ( s [ i - 1 ] == '0' && s [ i ] == '1' ) || ( s [ i ] == '0' && s [ i - 1 ] == '1' ) ) { aqwnyk += 2 ; s [ i - 1 ] = '5' ; s [ i ] = '5' ; } } int count1 = 0 ; int count0 = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == '1' ) { count1 ++ ; } else if ( s [ i ] == '0' ) { count0 ++ ; } } if ( count1 > count0 ) { aqwnyk += count0 * 2 ; } else { aqwnyk += count1 * 2 ; } System . out . println ( aqwnyk ) ; } } import java . util . Scanner ; public class Pffhhwb { static float roundUp ( float value ) { float pffhhwb = value % 1000 ; if ( pffhhwb > 0 ) { value = value + ( 1000 - pffhhwb ) ; } return value ; } public static void main ( String [ ] args ) { float gankin = 100_000f ; Scanner sc = new Scanner ( System . in ) ; int nweek = sc . nextInt ( ) ; float debt = gankin ; for ( int i = 0 ; i < nweek ; i ++ ) { debt = roundUp ( debt * 1.05f ) ; } System . out . printf ( " %d \n " , Math . round ( debt ) ) ; } } import java . util . Scanner ; class Ovksd { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ovksd = in . nextInt ( ) ; int i = 10 , res = 0 , sign = 1 ; while ( ovksd >= i ) { res += ( i - 1 ) * sign ; sign *= - 1 ; i *= 10 ; } if ( res <= 0 ) res += ovksd ; System . out . println ( res ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Tvwxooc { public static void main ( String [ ] args ) throws Exception { BufferedReader stdIn = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s ; int tvwxooc = 0 ; while ( ( s = stdIn . readLine ( ) ) != null ) { String [ ] se = s . split ( " " ) ; int in1 = Integer . valueOf ( se [ 0 ] ) ; int in2 = Integer . valueOf ( se [ 1 ] ) ; if ( in1 == 0 && in2 == 0 ) break ; doMain ( ++ tvwxooc , in1 , in2 ) ; } System . exit ( 0 ) ; } private static void doMain ( int tvwxooc , int in1 , int in2 ) { if ( in1 < in2 ) System . out . println ( in1 + " " + in2 ) ; else System . out . println ( in2 + " " + in1 ) ; } } import java . util . * ; class Yxuaxi { static int yxuaxi = 1000000000 + 7 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int s = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; if ( w >= s ) { System . out . println ( " unsafe " ) ; } else { System . out . println ( " safe " ) ; } } } import java . util . * ; public class Xfoiba { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int xfoiba = sc . nextInt ( ) ; int [ ] a = new int [ 100 ] ; for ( int i = 0 ; i < xfoiba ; i ++ ) a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; int Alice = 0 ; int Bob = 0 ; for ( int i = 99 ; i > 99 - xfoiba ; i -- ) if ( i % 2 == 1 ) Alice += a [ i ] ; else Bob += a [ i ] ; System . out . println ( Alice - Bob ) ; } } import java . util . * ; public class Snitvu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int snitvu = sc . nextInt ( ) ; int ans = 0 ; for ( int i = snitvu ; i <= 999 ; i ++ ) { String s = String . valueOf ( i ) ; if ( ( s . charAt ( 0 ) == s . charAt ( 1 ) ) && ( s . charAt ( 1 ) == s . charAt ( 2 ) ) ) { ans = i ; break ; } } System . out . println ( ans ) ; } } import java . lang . reflect . Array ; import java . util . * ; public class Efsdwlx { class Efsdwlx { int efsdwlx , y , t ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] a = new int [ n + 1 ] [ 3 ] ; for ( int i = 1 ; i <= n ; ++ i ) { a [ i ] [ 0 ] = sc . nextInt ( ) ; a [ i ] [ 1 ] = sc . nextInt ( ) ; a [ i ] [ 2 ] = sc . nextInt ( ) ; } a [ 0 ] [ 0 ] = 0 ; a [ 0 ] [ 1 ] = 0 ; a [ 0 ] [ 2 ] = 0 ; boolean ok = true ; for ( int i = 1 ; i <= n ; ++ i ) { int dt = a [ i ] [ 0 ] - a [ i - 1 ] [ 0 ] ; int dx = Math . abs ( a [ i ] [ 1 ] - a [ i - 1 ] [ 1 ] ) ; int dy = Math . abs ( a [ i ] [ 2 ] - a [ i - 1 ] [ 2 ] ) ; if ( dx + dy > dt || ( dt - dx - dy ) % 2 != 0 ) { ok = false ; System . out . println ( " No " ) ; break ; } } if ( ok ) System . out . println ( " Yes " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Szhddrq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long szhddrq = Long . parseLong ( br . readLine ( ) ) ; int i = 10000000 ; long O = 0 ; long T = 0 ; int o = 0 ; int t = 0 ; for ( long l = 1 ; l < ( long ) Math . sqrt ( szhddrq ) + 10 ; l ++ ) { if ( szhddrq % l == 0 ) { O = l ; T = szhddrq / l ; o = ( int ) Math . log10 ( O ) + 1 ; t = ( int ) Math . log10 ( T ) + 1 ; if ( i > ( o > t ? o : t ) ) i = ( o > t ? o : t ) ; } } System . out . println ( i ) ; } } import java . util . Scanner ; public class Nkvpcvx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int nkvpcvx = Integer . parseInt ( scanner . next ( ) ) ; int Y = Integer . parseInt ( scanner . next ( ) ) ; scanner . close ( ) ; for ( int x = 0 ; x <= nkvpcvx ; x ++ ) { for ( int y = 0 ; y <= nkvpcvx ; y ++ ) { int z = nkvpcvx - x - y ; if ( z < 0 ) continue ; if ( ( x * 10000 + y * 5000 + z * 1000 ) == Y ) { System . out . println ( String . format ( " %d %d %d " , x , y , z ) ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Rpisor { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rpisor = scan . nextInt ( ) ; int strlenge = scan . nextInt ( ) ; String [ ] output = new String [ rpisor ] ; for ( int i = 0 ; i < rpisor ; i ++ ) { output [ i ] = scan . next ( ) ; } Arrays . sort ( output ) ; for ( int i = 0 ; i < rpisor ; i ++ ) { System . out . print ( output [ i ] ) ; } scan . close ( ) ; } } import java . util . * ; public class Wdbbcy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wdbbcy = sc . nextInt ( ) ; String n = String . valueOf ( wdbbcy ) ; char [ ] a = n . toCharArray ( ) ; char b = a [ 0 ] ; char [ ] c = { b , b , b } ; int ans = Integer . parseInt ( String . valueOf ( c ) ) ; if ( ans >= wdbbcy ) { System . out . println ( ans ) ; } else { ans += 111 ; System . out . println ( ans ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Wpozrrr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wpozrrr = scan . nextInt ( ) ; String S = scan . next ( ) ; int S_length = S . length ( ) ; if ( wpozrrr < S_length ) { for ( int i = 0 ; i < wpozrrr ; i ++ ) { System . out . print ( S . charAt ( i ) ) ; } System . out . print ( " ... " ) ; } else { System . out . print ( S ) ; } } } import java . util . * ; public class Fjcumqe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fjcumqe = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int x = fjcumqe * A ; int y = B ; if ( x < y ) { System . out . println ( x ) ; } else if ( x > y ) { System . out . println ( y ) ; } else if ( x == y ) { System . out . println ( y ) ; } } } import java . util . Scanner ; public class Uhrecq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int uhrecq = scanner . nextInt ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) { if ( uhrecq <= 111 * i ) { System . out . println ( 111 * i ) ; break ; } } } } import java . util . * ; public class Rpermfe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rpermfe = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= rpermfe ; i ++ ) { int ii = i ; int iii = 0 ; int sum2 = 0 ; for ( int j = 0 ; j < 5 ; j ++ ) { iii = ii % 10 ; sum2 += iii ; ii = ii / 10 ; } if ( sum2 >= A && sum2 <= B ) { sum += i ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Juejb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int juejb = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ juejb ] ; int counter = 0 ; for ( int i = 0 ; i < h . length ; i ++ ) { h [ i ] = sc . nextInt ( ) ; if ( h [ i ] >= k ) { counter ++ ; } } System . out . println ( counter ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . HashMap ; import java . util . Map ; public class Fjjayw { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int fjjayw = Integer . parseInt ( br . readLine ( ) ) ; int count = 0 ; for ( int i = 0 ; i < fjjayw ; i ++ ) { String [ ] str = br . readLine ( ) . split ( " " ) ; int a = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 1 ] ) ; if ( a == b ) { count ++ ; } else { count = 0 ; } if ( count >= 3 ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Nvlfo { final static String [ ] suits = { " S " , " H " , " C " , " D " } ; final static int [ ] ranks = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 } ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; boolean [ ] [ ] exist = new boolean [ suits . length ] [ ranks . length ] ; int nvlfo = scan . nextInt ( ) ; for ( int i = 0 ; i < nvlfo ; i ++ ) { String suit = scan . next ( ) ; int rank = scan . nextInt ( ) ; for ( int j = 0 ; j < suits . length ; j ++ ) { if ( suits [ j ] . equals ( suit ) ) { exist [ j ] [ rank - 1 ] = true ; } } } for ( int i = 0 ; i < suits . length ; i ++ ) { for ( int j = 0 ; j < ranks . length ; j ++ ) { if ( ! exist [ i ] [ j ] ) { System . out . println ( suits [ i ] + " " + ranks [ j ] ) ; } } } scan . close ( ) ; } } import java . util . Scanner ; public class Fwnhnrm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int fwnhnrm = scan . nextInt ( ) ; int [ ] P = new int [ fwnhnrm ] ; int countI = 1 ; for ( int i = 0 ; i < fwnhnrm ; i ++ ) { int b = scan . nextInt ( ) ; P [ i ] = b ; } int j = 1 ; int Min = P [ 0 ] ; while ( j < fwnhnrm ) { if ( P [ j ] < Min ) { Min = P [ j ] ; countI ++ ; } j ++ ; } System . out . println ( countI ) ; } } import java . util . * ; import java . io . * ; public class Xekuv { public static void main ( String [ ] args ) throws Exception { int xekuv = 998244353 ; BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = Integer . parseInt ( bf . readLine ( ) ) ; ArrayList < Integer > array = new ArrayList < Integer > ( ) ; int min = Integer . MAX_VALUE ; StringTokenizer st = new StringTokenizer ( bf . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { array . add ( Integer . parseInt ( st . nextToken ( ) ) ) ; } for ( int i = 1 ; i <= 100 ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < array . size ( ) ; j ++ ) { sum += ( array . get ( j ) - i ) * ( array . get ( j ) - i ) ; } min = Math . min ( sum , min ) ; } out . println ( min ) ; out . close ( ) ; } } import java . util . * ; public class Kzhtqxl { public static void main ( String [ ] args ) { int kzhtqxl ; try ( Scanner sc = new Scanner ( System . in ) ) { kzhtqxl = sc . nextInt ( ) ; } int maxKeta = ( int ) Math . floor ( Math . log10 ( ( double ) kzhtqxl ) + 1 ) ; int answer = 0 ; if ( maxKeta >= 2 ) { int n = ( int ) Math . floor ( ( maxKeta - 2 ) / 2 ) ; int M = 2 * n + 1 ; answer += ( ( int ) ( Math . pow ( - 10 , ( M + 1 ) ) ) - 1 ) / 11 ; } if ( maxKeta % 2 == 1 ) { answer += kzhtqxl - ( int ) ( Math . pow ( 10 , maxKeta - 1 ) ) + 1 ; } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Cnzchmv { static Scanner sc = new Scanner ( System . in ) ; static int cnzchmv = Integer . parseInt ( sc . next ( ) ) ; static int [ ] a = new int [ 100000 ] ; public static void main ( String [ ] args ) { int q , key , sum = 0 ; for ( int i = 0 ; i < cnzchmv ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } q = Integer . parseInt ( sc . next ( ) ) ; for ( int i = 0 ; i < q ; i ++ ) { key = Integer . parseInt ( sc . next ( ) ) ; if ( binarySearch ( key ) ) sum ++ ; } System . out . println ( sum ) ; } static boolean binarySearch ( int key ) { int left = 0 ; int right = cnzchmv ; int mid ; while ( left < right ) { mid = ( left + right ) / 2 ; if ( key == a [ mid ] ) return true ; if ( key > a [ mid ] ) left = mid + 1 ; else if ( key < a [ mid ] ) right = mid ; } return false ; } } import java . util . * ; class Exyacs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int exyacs = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int i = 1 ; int sum = 0 ; while ( exyacs * i <= t ) { sum += b ; i += 1 ; } System . out . println ( sum ) ; } } import java . util . * ; public class Ceygg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int ceygg = 0 ; int leftIdx = 0 ; Set < Character > set = new HashSet < > ( ) ; set . add ( 'A' ) ; set . add ( 'C' ) ; set . add ( 'G' ) ; set . add ( 'T' ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( ! set . contains ( s . charAt ( i ) ) ) { ceygg = Math . max ( ceygg , i - leftIdx ) ; leftIdx = i + 1 ; } } ceygg = Math . max ( ceygg , s . length ( ) - leftIdx ) ; System . out . println ( ceygg ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Tfkzp { static BufferedReader reader ; public static void main ( String [ ] args ) { reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strings = readLine ( ) ; int tfkzp = Integer . parseInt ( strings [ 0 ] ) ; int A = Integer . parseInt ( strings [ 1 ] ) ; print ( ( tfkzp + A - 1 ) / A ) ; } private static String [ ] readLine ( ) { try { return reader . readLine ( ) . split ( " " ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return new String [ ] { e . getMessage ( ) } ; } } private static void print ( Object o ) { System . out . println ( o ) ; } private static void print ( ) { System . out . println ( ) ; } } import java . util . Scanner ; public class Khqbqg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int khqbqg = scan . nextInt ( ) ; int num2 = scan . nextInt ( ) ; int num3 = scan . nextInt ( ) ; int count = 0 ; if ( khqbqg != num2 ) { count ++ ; } if ( num2 != num3 ) { count ++ ; } if ( khqbqg != num3 ) { count ++ ; } if ( count == 1 || count == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . lang . * ; public class Vmgnstl { public static void solve ( long vmgnstl , long b , long c , long d ) { while ( vmgnstl > 0 && c > 0 ) { c -= b ; if ( c <= 0 ) { System . out . println ( " Yes " ) ; return ; } vmgnstl -= d ; } if ( c == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void gora ( ) { Scanner scn = new Scanner ( System . in ) ; long vmgnstl = scn . nextLong ( ) ; long b = scn . nextLong ( ) ; long c = scn . nextLong ( ) ; long d = scn . nextLong ( ) ; solve ( vmgnstl , b , c , d ) ; } public static void main ( String [ ] args ) { gora ( ) ; } } import java . util . Scanner ; public class Fwjcsgg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fwjcsgg = sc . nextInt ( ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; int i = 0 ; char [ ] Schar = S . toCharArray ( ) ; char [ ] Tchar = T . toCharArray ( ) ; for ( i = 0 ; i < fwjcsgg ; i ++ ) { System . out . print ( Schar [ i ] ) ; System . out . print ( Tchar [ i ] ) ; } return ; } } import java . util . * ; class Rfuhn { public static void main ( String [ ] args ) { int rfuhn = 0 ; Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S = sc . next ( ) ; for ( int i = 0 ; i < ( N - 2 ) ; i ++ ) { if ( S . charAt ( i ) == 'A' && S . charAt ( i + 1 ) == 'B' ) { if ( S . charAt ( i + 2 ) == 'C' ) { rfuhn += 1 ; } } } System . out . println ( rfuhn ) ; } } import java . util . Scanner ; class Vmbsm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int vmbsm = scan . nextInt ( ) ; int kimatu = scan . nextInt ( ) ; int saisiken = scan . nextInt ( ) ; while ( vmbsm != - 1 || kimatu != - 1 || saisiken != - 1 ) { int y ; y = vmbsm + kimatu ; if ( vmbsm == - 1 || kimatu == - 1 ) { System . out . println ( " F " ) ; } else if ( y >= 80 ) { System . out . println ( " A " ) ; } else if ( y >= 65 && y < 80 ) { System . out . println ( " B " ) ; } else if ( y >= 50 && y < 65 ) { System . out . println ( " C " ) ; } else if ( y >= 30 && y < 50 ) { if ( saisiken >= 50 ) { System . out . println ( " C " ) ; } else { System . out . println ( " D " ) ; } } else { System . out . println ( " F " ) ; } vmbsm = scan . nextInt ( ) ; kimatu = scan . nextInt ( ) ; saisiken = scan . nextInt ( ) ; } } } import java . util . Scanner ; public class Fatepw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; char [ ] a = s . toCharArray ( ) ; char [ ] b = t . toCharArray ( ) ; boolean fatepw = true ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { fatepw = true ; for ( int j = 0 ; j < n - i ; j ++ ) { if ( a [ j ] != b [ j + i ] ) { fatepw = false ; break ; } } for ( int j = n - i ; j < n ; j ++ ) { if ( a [ j ] != b [ j - n + i ] ) { fatepw = false ; break ; } } if ( fatepw ) break ; } System . out . println ( fatepw ? " Yes " : " No " ) ; } } import java . util . ArrayList ; import static java . util . Collections . reverse ; import java . util . List ; import java . util . Scanner ; public class Gxmfg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int gxmfg = scanner . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < gxmfg ; i ++ ) { int a = scanner . nextInt ( ) ; list . add ( a ) ; } reverse ( list ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { Integer get = list . get ( i ) ; if ( i == list . size ( ) - 1 ) { System . out . print ( get ) ; } else { System . out . print ( get + " " ) ; } } System . out . println ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ufxqymv { public static void main ( String [ ] args ) throws IOException { int ufxqymv , b , f , r , v ; String [ ] list ; int [ ] [ ] [ ] building ; StringBuilder builder = new StringBuilder ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; ufxqymv = Integer . parseInt ( br . readLine ( ) ) ; building = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int i = 0 ; i < ufxqymv ; i ++ ) { list = br . readLine ( ) . split ( " " ) ; b = Integer . parseInt ( list [ 0 ] ) ; f = Integer . parseInt ( list [ 1 ] ) ; r = Integer . parseInt ( list [ 2 ] ) ; v = Integer . parseInt ( list [ 3 ] ) ; building [ b - 1 ] [ f - 1 ] [ r - 1 ] += v ; } for ( int i = 0 ; i < 4 ; i ++ ) { if ( i != 0 ) builder . append ( " #################### \n " ) ; for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { builder . append ( " " + building [ i ] [ j ] [ k ] ) ; } builder . append ( " \n " ) ; } } builder . delete ( builder . length ( ) - 1 , builder . length ( ) ) ; System . out . println ( builder ) ; br . close ( ) ; } } import java . io . BufferedReader ; import java . io . * ; import java . util . * ; import java . util . ArrayList ; import java . util . Iterator ; import java . util . List ; import java . util . Collections ; import java . util . Arrays ; public class Hkksaoh { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hkksaoh = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; int count1 = 0 ; int count2 = 0 ; int count3 = 0 ; int count4 = 0 ; for ( int i = 0 ; i < hkksaoh ; i ++ ) { list . add ( sc . next ( ) ) ; } for ( int i = 0 ; i < hkksaoh ; i ++ ) { if ( list . get ( i ) . equals ( " AC " ) ) { count1 ++ ; } else if ( list . get ( i ) . equals ( " WA " ) ) { count2 ++ ; } else if ( list . get ( i ) . equals ( " TLE " ) ) { count3 ++ ; } else { count4 ++ ; } } System . out . println ( " AC x " + count1 ) ; System . out . println ( " WA x " + count2 ) ; System . out . println ( " TLE x " + count3 ) ; System . out . println ( " RE x " + count4 ) ; } } import java . util . Scanner ; class Dwhhup { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; int dwhhup = scan . nextInt ( ) ; int x = 1 ; int y = 0 ; if ( dwhhup >= 3 && dwhhup <= 10000 ) { for ( int count = 0 ; count < dwhhup ; count ++ ) { y = x / 10 ; if ( x % 3 == 0 ) { sb . append ( " " ) . append ( x ) ; } else { y = x ; while ( y != 0 ) { if ( y % 10 == 3 ) { sb . append ( " " ) . append ( x ) ; break ; } y /= 10 ; } } x ++ ; } System . out . println ( sb ) ; } } } import java . io . * ; class Htkqrej { public static void main ( String [ ] args ) throws IOException { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; for ( ; ; ) { String [ ] str = br . readLine ( ) . split ( " " ) ; int htkqrej = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 2 ] ) ; if ( str [ 1 ] . equals ( " ? " ) ) break ; switch ( str [ 1 ] ) { case " + " : System . out . println ( htkqrej + b ) ; break ; case " - " : System . out . println ( htkqrej - b ) ; break ; case " * " : System . out . println ( htkqrej * b ) ; break ; case " / " : System . out . println ( htkqrej / b ) ; break ; default : break ; } } br . close ( ) ; } catch ( Exception e ) { System . exit ( - 1 ) ; } } } import java . util . * ; public class Skswqqj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int skswqqj = sc . nextInt ( ) ; String S = sc . next ( ) ; sc . close ( ) ; char [ ] ans = new char [ S . length ( ) ] ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { int c = ( int ) S . charAt ( i ) - 'A' ; c = ( c + skswqqj ) % 26 ; ans [ i ] = ( char ) ( 'A' + c ) ; } System . out . println ( new String ( ans ) ) ; } } import java . util . Scanner ; public class Wppblc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s , t ; int wppblc ; s = scan . next ( ) ; t = scan . next ( ) ; wppblc = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) wppblc += 1 ; } System . out . println ( wppblc ) ; } } import java . io . * ; import java . util . * ; class Imzjioq { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int imzjioq = Integer . parseInt ( br . readLine ( ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; String [ ] str_1 = str [ 0 ] . split ( " " ) ; String [ ] str_2 = str [ 1 ] . split ( " " ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < imzjioq ; i ++ ) { sb . append ( str_1 [ i ] ) ; sb . append ( str_2 [ i ] ) ; } System . out . println ( sb ) ; } } } import java . util . * ; public class Gwzbszu { static int gwzbszu = 1000000007 ; static int INF = Integer . MAX_VALUE ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Long a = sc . nextLong ( ) ; Long b = sc . nextLong ( ) ; Long k = sc . nextLong ( ) ; if ( a >= 1 && a >= k ) { a = a - k ; } else if ( a >= 1 && a < k ) { k = k - a ; a = ( long ) 0 ; if ( b >= k ) { b = b - k ; } else { b = ( long ) 0 ; } } else if ( a < 1 ) { if ( b >= k ) { b = b - k ; } else { b = ( long ) 0 ; } } System . out . println ( a + " " + b ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . Collections ; public class Qufrak { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader sb = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Integer [ ] hList = new Integer [ 10 ] ; for ( int qufrak = 0 ; qufrak < 10 ; qufrak ++ ) { int h = Integer . parseInt ( sb . readLine ( ) ) ; hList [ qufrak ] = h ; } Arrays . sort ( hList , Collections . reverseOrder ( ) ) ; for ( int rank = 0 ; rank < 3 ; rank ++ ) { System . out . println ( hList [ rank ] ) ; } } } import java . util . Scanner ; public class Juqum { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int juqum = sc . nextInt ( ) ; int ans = ( 10000 - juqum ) % 1000 ; System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; public class Nbjettq { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int nbjettq = sc . nextInt ( ) ; System . out . println ( ( nbjettq / 3600 ) + " : " + ( nbjettq % 3600 / 60 ) + " : " + ( nbjettq % 60 ) ) ; } } import java . util . * ; class Raztz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int raztz = sc . nextInt ( ) ; int k = sc . nextInt ( ) - 1 ; StringBuilder sb = new StringBuilder ( sc . next ( ) ) ; sb . setCharAt ( k , ( char ) ( sb . charAt ( k ) + 32 ) ) ; System . out . println ( sb . toString ( ) ) ; } } import java . util . Scanner ; class Ahjjhxb { public static void main ( String [ ] args ) { int ahjjhxb ; int b ; Scanner sc = new Scanner ( System . in ) ; ahjjhxb = sc . nextInt ( ) ; b = sc . nextInt ( ) ; int area = ahjjhxb * b ; int syu = 2 * ( ahjjhxb + b ) ; System . out . println ( area + " " + syu ) ; } } import java . util . * ; public class Gqdpek { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int gqdpek = scanner . nextInt ( ) ; int a = 0 ; int b = 0 ; for ( int i = 1 ; i <= gqdpek ; i += 2 ) { for ( int j = 1 ; j <= gqdpek ; j += 2 ) { if ( i % j == 0 && i >= j ) { a ++ ; if ( a == 8 ) { b ++ ; } } } a = 0 ; } System . out . print ( b ) ; } } import java . util . Scanner ; public class Qyumsi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int qyumsi = 1 , b = 1 ; while ( qyumsi != 0 && b != 0 ) { qyumsi = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; if ( qyumsi == 0 && b == 0 ) { break ; } for ( int i = 1 ; i <= qyumsi ; i ++ ) { for ( int j = 1 ; j <= b ; j ++ ) { if ( i == 1 && j != b ) { System . out . print ( " # " ) ; } else if ( i == qyumsi && j != b ) { System . out . print ( " # " ) ; } else if ( j == b ) { System . out . println ( " # " ) ; } else if ( j == 1 ) { System . out . print ( " # " ) ; } else { System . out . print ( " . " ) ; } } } System . out . println ( " " ) ; } } } import java . util . Scanner ; public class Mddjt { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int mddjt = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; scanner . close ( ) ; String ans = null ; if ( mddjt < b && b < c ) { ans = " Yes " ; } else { ans = " No " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Gmxhe { public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . answer ( ) ; } private Scanner scan = new Scanner ( System . in ) ; private int gmxhe ; private int b ; public Main ( ) { gmxhe = Integer . parseInt ( scan . next ( ) ) ; b = Integer . parseInt ( scan . next ( ) ) ; scan . close ( ) ; } public final void answer ( ) { String ans = gmxhe * b % 2 == 0 ? " Even " : " Odd " ; System . out . println ( ans ) ; } } import java . util . Scanner ; class Bdloy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bdloy , Q , R ; int max = 0 ; bdloy = sc . nextInt ( ) ; Q = sc . nextInt ( ) ; R = sc . nextInt ( ) ; if ( bdloy >= Q ) { if ( bdloy >= R ) { max = Q + R ; } else { max = bdloy + Q ; } } else if ( Q >= R ) { if ( Q >= bdloy ) { max = bdloy + R ; } else { max = Q + R ; } } else if ( R >= bdloy ) { if ( R >= Q ) { max = bdloy + Q ; } else { max = bdloy + R ; } } System . out . println ( max ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Hsitk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; String hsitk = st . nextToken ( ) ; System . out . println ( hsitk . charAt ( 2 ) == hsitk . charAt ( 3 ) && hsitk . charAt ( 4 ) == hsitk . charAt ( 5 ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Ggdxtm { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . start ( ) ; } private void start ( ) { Scanner scanner = new Scanner ( System . in ) ; int ggdxtm = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; if ( ggdxtm < b && b < c ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Wbdhkvm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; String [ ] s = S . split ( " / " ) ; int wbdhkvm = Integer . parseInt ( s [ 0 ] ) ; int month = Integer . parseInt ( s [ 1 ] ) ; int day = Integer . parseInt ( s [ 2 ] ) ; if ( month > 4 ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } } } import java . util . * ; public class Cmuturs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cmuturs = sc . nextInt ( ) ; String [ ] W = new String [ cmuturs ] ; for ( int i = 0 ; i < cmuturs ; i ++ ) { W [ i ] = sc . next ( ) ; } sc . close ( ) ; String result = " Yes " ; for ( int i = 0 ; i < cmuturs ; i ++ ) { for ( int j = i + 1 ; j < cmuturs ; j ++ ) { if ( W [ i ] . equals ( W [ j ] ) ) { result = " No " ; break ; } } if ( result == " No " ) { break ; } } String start = " " ; if ( result == " Yes " ) { for ( int i = 0 ; i < cmuturs ; i ++ ) { if ( i != 0 ) { String [ ] s_ = W [ i ] . split ( " " ) ; if ( s_ [ 0 ] . equals ( start ) ) { start = s_ [ s_ . length - 1 ] ; } else { result = " No " ; break ; } } else { String [ ] s_ = W [ i ] . split ( " " ) ; start = s_ [ s_ . length - 1 ] ; } } } System . out . println ( result ) ; } } import java . util . * ; import java . lang . * ; import java . math . * ; public class Zpagu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zpagu = sc . nextInt ( ) ; int variety = sc . nextInt ( ) ; int [ ] k = new int [ zpagu ] ; int [ ] preference = new int [ variety ] ; int ans = 0 ; for ( int i = 0 ; i < zpagu ; i ++ ) { k [ i ] = sc . nextInt ( ) ; for ( int j = 0 ; j < k [ i ] ; j ++ ) { int tmp = sc . nextInt ( ) ; preference [ tmp - 1 ] ++ ; } } for ( int i = 0 ; i < variety ; i ++ ) { if ( preference [ i ] == zpagu ) { ans ++ ; } } System . out . println ( ans ) ; sc . close ( ) ; } private static int gcd ( int m , int zpagu ) { if ( m < zpagu ) { return gcd ( zpagu , m ) ; } if ( zpagu == 0 ) { return m ; } return gcd ( zpagu , m % zpagu ) ; } } import java . util . Scanner ; public class Peocy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String peocy = sc . next ( ) ; String ans ; if ( peocy . equals ( " Sunny " ) ) { ans = " Cloudy " ; } else if ( peocy . equals ( " Cloudy " ) ) { ans = " Rainy " ; } else { ans = " Sunny " ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Nfepymc { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int nfepymc = stdIn . nextInt ( ) ; int Y = stdIn . nextInt ( ) / 1000 ; int ans10 = - 1 ; int ans5 = - 1 ; int ans1 = - 1 ; for ( int i = 0 ; i <= nfepymc ; i ++ ) { for ( int j = 0 ; j <= nfepymc - i ; j ++ ) { if ( 10 * i + 5 * j + ( nfepymc - i - j ) == Y ) { ans10 = i ; ans5 = j ; ans1 = nfepymc - i - j ; break ; } } } System . out . println ( ans10 + " " + ans5 + " " + ans1 ) ; } } import java . util . * ; class Gtpjt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gtpjt = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 1 ; for ( int i = 1 ; i <= gtpjt ; i ++ ) { sum = sum * 100 ; } System . out . println ( sum * ( n + n / 100 ) ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class Ihgoqiw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ihgoqiw = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; HashSet h = new HashSet ( ) ; h . add ( ihgoqiw ) ; h . add ( b ) ; h . add ( c ) ; if ( h . size ( ) == 2 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class Fpwfxgi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fpwfxgi = sc . nextInt ( ) ; int yen = 1000 ; while ( yen < fpwfxgi ) { yen = yen + 1000 ; } System . out . println ( yen - fpwfxgi ) ; } } import java . util . Scanner ; public class Sdbyl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sdbyl = sc . nextInt ( ) ; int sum = 100000 ; for ( int i = 0 ; i < sdbyl ; i ++ ) { sum += Main . DeptMaker ( sum ) ; } System . out . println ( sum ) ; } private static int DeptMaker ( int sum ) { int dept = ( int ) Math . ceil ( ( sum * 0.05 ) / 1000 ) * 1000 ; return dept ; } } import java . awt . print . Printable ; import java . util . Scanner ; import javax . sound . midi . SysexMessage ; public class Mkcga { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] strs = new String [ 100 ] ; int mkcga = 0 ; while ( true ) { String str = sc . next ( ) ; if ( str . equals ( " - " ) ) { for ( int j = 0 ; j < mkcga ; j ++ ) { System . out . println ( strs [ j ] ) ; } sc . close ( ) ; break ; } int num = sc . nextInt ( ) ; for ( int i = 0 ; i < num ; i ++ ) { int count = sc . nextInt ( ) ; String str1 = str . substring ( 0 , count ) ; String str2 = str . substring ( count , str . length ( ) ) ; str = str2 + str1 ; } strs [ mkcga ] = str ; mkcga ++ ; } } } import java . util . * ; public class Vqmoyz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " " ; for ( int vqmoyz = 0 ; vqmoyz < s . length ( ) ; vqmoyz ++ ) { String temp = s . substring ( vqmoyz , vqmoyz + 1 ) ; if ( temp . equals ( " 0 " ) ) { ans += " 0 " ; } else if ( temp . equals ( " 1 " ) ) { ans += " 1 " ; } else { if ( ans . length ( ) > 0 ) { ans = ans . substring ( 0 , ans . length ( ) - 1 ) ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Lsohog { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String lsohog = sc . next ( ) ; String B = sc . next ( ) ; String C = sc . next ( ) ; System . out . println ( C + " " + lsohog + " " + B ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Enbkeir { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] items = reader . readLine ( ) . split ( " " ) ; int enbkeir = Integer . parseInt ( items [ 0 ] ) ; int b = Integer . parseInt ( items [ 1 ] ) ; int c = Integer . parseInt ( items [ 2 ] ) ; int counter = 0 ; for ( int i = enbkeir ; i <= b ; i ++ ) { if ( c % i == 0 ) { counter ++ ; } } System . out . println ( counter ) ; } } import java . util . * ; public class Zviyzi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] line = sc . nextLine ( ) . split ( " " ) ; ArrayDeque < Integer > stack = new ArrayDeque < > ( ) ; for ( String x : line ) { char zviyzi = x . charAt ( 0 ) ; if ( zviyzi == '+' || zviyzi == '-' || zviyzi == '*' ) { int second = stack . pop ( ) ; int first = stack . pop ( ) ; if ( zviyzi == '+' ) { first += second ; } else if ( zviyzi == '-' ) { first -= second ; } else { first *= second ; } stack . push ( first ) ; } else { stack . push ( Integer . parseInt ( x ) ) ; } } System . out . println ( stack . pop ( ) ) ; } } import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; class Aquueb { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; while ( ! ( str . equals ( " - " ) ) ) { String repStr = br . readLine ( ) ; int aquueb = Integer . parseInt ( repStr ) ; for ( int i = 0 ; i < aquueb ; i ++ ) { String posStr = br . readLine ( ) ; int pos = Integer . parseInt ( posStr ) ; String left = str . substring ( 0 , pos ) ; String right = str . substring ( pos ) ; str = right + left ; } System . out . println ( str ) ; str = br . readLine ( ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Iepuff { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int iepuff = stdIn . nextInt ( ) ; int k = stdIn . nextInt ( ) ; int [ ] h = new int [ iepuff ] ; for ( int i = 0 ; i < iepuff ; i ++ ) { h [ i ] = stdIn . nextInt ( ) ; } int [ ] dp = new int [ iepuff ] ; Arrays . fill ( dp , Integer . MAX_VALUE ) ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 0 ; i < iepuff ; i ++ ) { for ( int j = i + 1 ; j <= i + k ; j ++ ) { if ( j >= iepuff ) { break ; } dp [ j ] = Math . min ( dp [ i ] + Math . abs ( h [ j ] - h [ i ] ) , dp [ j ] ) ; } } System . out . println ( dp [ iepuff - 1 ] ) ; } } import java . util . * ; public class Wttkd { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; String s = scn . next ( ) ; int wttkd = 0 ; int nans = 0 ; int i = 0 ; while ( i < s . length ( ) ) { if ( s . charAt ( i ) == 'A' || s . charAt ( i ) == 'G' || s . charAt ( i ) == 'C' || s . charAt ( i ) == 'T' ) { nans ++ ; i ++ ; } else { wttkd = Math . max ( nans , wttkd ) ; nans = 0 ; i ++ ; } } wttkd = Math . max ( nans , wttkd ) ; System . out . println ( wttkd ) ; } } import java . util . Scanner ; public class Dnfwxod { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dnfwxod = sc . nextInt ( ) ; int ans = 1 ; for ( int i = 2 ; i < dnfwxod ; i ++ ) { int j = i ; if ( dnfwxod >= Math . pow ( j , 2 ) ) { while ( j <= dnfwxod ) { j *= i ; } j /= i ; ans = Math . max ( ans , j ) ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Aqcxsqi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aqcxsqi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int max = Math . max ( aqcxsqi , c ) ; int min = Math . min ( b , d ) ; System . out . println ( Math . max ( 0 , min - max ) ) ; } } import java . util . Scanner ; public class Lveyb { public static void main ( String [ ] args ) { int [ ] list ; int lveyb ; int primes = 0 ; Scanner keyboard = new Scanner ( System . in ) ; lveyb = keyboard . nextInt ( ) ; list = new int [ lveyb ] ; for ( int i = 0 ; i < lveyb ; i ++ ) { list [ i ] = keyboard . nextInt ( ) ; } for ( int i = 0 ; i < lveyb ; i ++ ) { if ( isPrime ( list [ i ] ) ) primes ++ ; } System . out . println ( primes ) ; } public static boolean isPrime ( int a ) { if ( a == 2 || a == 3 || a == 5 || a == 7 ) { return true ; } if ( a % 2 == 0 ) { return false ; } for ( int j = 3 ; j <= Math . sqrt ( a ) ; j ++ ) { if ( a % j == 0 ) { return false ; } } return true ; } } import java . util . * ; public class Wefqf { public static void main ( String [ ] args ) { int wefqf ; Scanner sc = new Scanner ( System . in ) ; wefqf = sc . nextInt ( ) ; int c = 0 ; int [ ] b = new int [ wefqf ] ; for ( int i = 0 ; i < wefqf ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } Arrays . sort ( b ) ; for ( int j = 0 ; j < wefqf - 1 ; j ++ ) { if ( b [ j ] == b [ j + 1 ] ) { c = c + 1 ; } } if ( c > 0 ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } } import java . math . * ; import java . util . * ; public class Ueici { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ueici = sc . nextInt ( ) ; while ( true ) { if ( BigInteger . valueOf ( ueici ) . isProbablePrime ( 100 ) ) { System . out . println ( ueici ) ; return ; } ueici ++ ; } } } import java . util . Scanner ; public class Tvaroso { public static void main ( String [ ] args ) { int tvaroso ; Scanner sc = new Scanner ( System . in ) ; tvaroso = sc . nextInt ( ) ; System . out . println ( ( tvaroso / 500 ) * 1000 + ( tvaroso % 500 ) / 5 * 5 ) ; } } import java . util . Scanner ; class Eiqta { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int eiqta = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int lower ; int bigger ; if ( eiqta > b ) { lower = b ; bigger = eiqta ; } else { lower = eiqta ; bigger = b ; } int tmp = bigger % lower ; while ( lower != 0 ) { tmp = bigger % lower ; bigger = lower ; lower = tmp ; } System . out . println ( bigger ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Aeeewo { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int aeeewo = scanner . nextInt ( ) ; Integer [ ] nums = new Integer [ aeeewo ] ; for ( int i = 0 ; i < aeeewo ; i ++ ) { nums [ i ] = scanner . nextInt ( ) ; } int diff = 0 ; boolean isEven = ( aeeewo % 2 ) == 0 ; Arrays . sort ( nums , Collections . reverseOrder ( ) ) ; int pairLastIndex = isEven ? aeeewo - 1 : aeeewo - 2 ; for ( int i = 0 ; i < pairLastIndex ; i = i + 2 ) { diff += nums [ i ] - nums [ i + 1 ] ; } if ( ! isEven ) diff += nums [ aeeewo - 1 ] ; System . out . println ( diff ) ; } } import java . util . Scanner ; public class Pzutz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pzutz = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] A = new int [ pzutz ] ; int wa = 0 ; for ( int i = 0 ; i < pzutz ; i ++ ) { A [ i ] = sc . nextInt ( ) ; wa += A [ i ] ; } sc . close ( ) ; int ok = 0 ; for ( int i = pzutz - 1 ; i >= 0 ; i -- ) { ok += A [ i ] * ( 4 * M ) >= wa ? 1 : 0 ; } System . out . println ( ok >= M ? " Yes " : " No " ) ; } } import java . util . * ; public class Zdhmezy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zdhmezy = sc . nextInt ( ) ; int o = 0 ; int [ ] a = new int [ zdhmezy ] ; PriorityQueue < Integer > num = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < zdhmezy ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( i > 0 && a [ i ] == a [ i - 1 ] + 1 ) { num . add ( a [ i - 1 ] - 1 ) ; } } for ( int i = 0 ; i < zdhmezy ; i ++ ) { int b = sc . nextInt ( ) ; o += b ; } for ( int i = 0 ; i < zdhmezy - 1 ; i ++ ) { int c = sc . nextInt ( ) ; if ( num . peek ( ) != null && i == num . peek ( ) ) { o += c ; num . poll ( ) ; } } System . out . println ( o ) ; } } import java . io . * ; class Jkssdb { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; while ( true ) { String [ ] a = br . readLine ( ) . split ( " " ) ; if ( a [ 0 ] . equals ( " 0 " ) && a [ 1 ] . equals ( " 0 " ) ) break ; int jkssdb = Integer . parseInt ( a [ 0 ] ) ; int y = Integer . parseInt ( a [ 1 ] ) ; if ( jkssdb > y ) { sb . append ( y + " " + jkssdb + " \n " ) ; } else { sb . append ( jkssdb + " " + y + " \n " ) ; } } System . out . print ( sb ) ; } } import java . util . * ; public class Lgepf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lgepf = sc . nextInt ( ) ; int gates = sc . nextInt ( ) ; Integer [ ] start = new Integer [ gates ] ; Integer [ ] end = new Integer [ gates ] ; for ( Integer i = 0 ; i < gates ; i ++ ) { start [ i ] = sc . nextInt ( ) ; end [ i ] = sc . nextInt ( ) ; } Arrays . sort ( start , Collections . reverseOrder ( ) ) ; Arrays . sort ( end ) ; Integer result = end [ 0 ] - start [ 0 ] + 1 ; if ( result < 0 ) { result = 0 ; } System . out . println ( result ) ; } } import java . util . * ; public class Mdeax { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] weather = new String [ ] { " Sunny " , " Cloudy " , " Rainy " } ; String tw = sc . next ( ) ; for ( int mdeax = 0 ; mdeax < weather . length ; ++ mdeax ) { if ( tw . equals ( weather [ mdeax ] ) ) { System . out . println ( weather [ ( mdeax + 1 ) % 3 ] ) ; break ; } } } } import java . util . Scanner ; public class Mbtibx { private void calc ( ) { Scanner scanner = new Scanner ( System . in ) ; int mbtibx = scanner . nextInt ( ) ; int y = scanner . nextInt ( ) ; int d = mbtibx / y ; int r = mbtibx % y ; double f = ( double ) mbtibx / ( double ) y ; System . out . printf ( " %d %d %05f " , d , r , f ) ; } public static void main ( String [ ] args ) { Main run = new Main ( ) ; run . calc ( ) ; } } import java . util . * ; public class Uvtdl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] A = new int [ 3 ] ; A [ 0 ] = sc . nextInt ( ) ; A [ 1 ] = sc . nextInt ( ) ; A [ 2 ] = sc . nextInt ( ) ; Arrays . sort ( A ) ; System . out . print ( A [ 2 ] - A [ 0 ] ) ; } } import java . util . Scanner ; public class Utbvpi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long utbvpi = scan . nextInt ( ) ; long y = scan . nextInt ( ) ; scan . close ( ) ; if ( utbvpi < y ) { long tmp = y ; y = utbvpi ; utbvpi = tmp ; } long ans = ( utbvpi * y ) / gcd ( utbvpi , y ) ; System . out . println ( ans ) ; } static long gcd ( long utbvpi , long y ) { if ( utbvpi % y == 0 ) return y ; else return gcd ( y , utbvpi % y ) ; } } import java . util . Scanner ; class Tayiw { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int tayiw = scanner . nextInt ( ) ; int taroPoint = 0 ; int hanakoPoint = 0 ; scanner . nextLine ( ) ; for ( int i = 1 ; i <= tayiw ; i ++ ) { String input = scanner . nextLine ( ) ; String [ ] inputArr = input . split ( " " ) ; int check = inputArr [ 0 ] . compareTo ( inputArr [ 1 ] ) ; if ( check > 0 ) { taroPoint += 3 ; } else if ( check == 0 ) { taroPoint += 1 ; hanakoPoint += 1 ; } else { hanakoPoint += 3 ; } } System . out . println ( Integer . toString ( taroPoint ) + " " + Integer . toString ( hanakoPoint ) ) ; } } import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Lgwkiyb { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; while ( ! ( line . equals ( " 0 0 " ) ) ) { String [ ] inputs = line . split ( " " ) ; int lgwkiyb = Integer . valueOf ( inputs [ 0 ] ) ; int width = Integer . valueOf ( inputs [ 1 ] ) ; StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < lgwkiyb ; i ++ ) { if ( i == 0 || i == lgwkiyb - 1 ) { for ( int j = 0 ; j < width ; j ++ ) result . append ( " # " ) ; } else { for ( int j = 0 ; j < width ; j ++ ) { if ( j == 0 || j == width - 1 ) result . append ( " # " ) ; else result . append ( " . " ) ; } } result . append ( " \n " ) ; } System . out . println ( result ) ; line = br . readLine ( ) ; } } } import java . util . * ; class Huvqkrh { static int huvqkrh = 1_000_000_007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long cnt = 0 ; int flg = 0 ; long N = sc . nextInt ( ) ; long L = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) { cnt = cnt + L + i ; if ( L + i == 0 ) { flg = 1 ; } } if ( flg == 0 ) { if ( L < 0 ) { cnt = cnt - ( L + N - 1 ) ; } else { cnt = cnt - ( L ) ; } } System . out . println ( cnt ) ; } } import java . util . * ; public class Lbuihg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int lbuihg = Integer . parseInt ( a + b ) ; boolean bl = false ; for ( int i = 1 ; i * i <= lbuihg ; i ++ ) { if ( i * i == lbuihg ) { bl = true ; break ; } } System . out . println ( bl == true ? " Yes " : " No " ) ; } } import java . util . * ; public class Ottkz { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; ArrayList < Character > caca = new ArrayList < Character > ( ) ; String n = scn . next ( ) ; for ( int ottkz = 0 ; ottkz < n . length ( ) ; ottkz ++ ) { if ( n . charAt ( ottkz ) == '1' ) caca . add ( '1' ) ; else if ( n . charAt ( ottkz ) == '0' ) caca . add ( '0' ) ; else if ( n . charAt ( ottkz ) == 'B' ) { if ( ! caca . isEmpty ( ) ) caca . remove ( caca . size ( ) - 1 ) ; } } for ( int ottkz = 0 ; ottkz < caca . size ( ) ; ottkz ++ ) System . out . print ( caca . get ( ottkz ) ) ; System . out . println ( ) ; scn . close ( ) ; } } import javax . print . DocFlavor ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . nio . charset . StandardCharsets ; import java . util . * ; import java . util . function . BiConsumer ; public class Tiabgvs { public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int tiabgvs = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= tiabgvs ; i += 2 ) { int count = 0 ; for ( int j = 1 ; j <= i ; j += 2 ) { if ( i % j == 0 ) { count ++ ; } } if ( count == 8 ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . util . * ; public class Wvsnm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wvsnm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; String ans ; if ( ( wvsnm == b && b == c ) || ( wvsnm != b && b != c && c != wvsnm ) ) ans = " No " ; else ans = " Yes " ; System . out . println ( ans ) ; } } import java . util . Scanner ; class Ongci { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int ongci = sc . nextInt ( ) ; long sum = 0 , left = 0 ; int [ ] A = new int [ ongci + 1 ] ; for ( int i = 0 ; i <= ongci ; i ++ ) { A [ i ] = sc . nextInt ( ) ; sum += A [ i ] ; } for ( int i = 0 ; i < ongci ; i ++ ) { int temp = sc . nextInt ( ) ; if ( temp >= A [ i ] ) { temp -= A [ i ] ; if ( A [ i + 1 ] > temp ) A [ i + 1 ] -= temp ; else A [ i + 1 ] = 0 ; A [ i ] = 0 ; } else A [ i ] -= temp ; } for ( int i = 0 ; i <= ongci ; i ++ ) left += A [ i ] ; System . out . println ( sum - left ) ; } } import java . math . BigDecimal ; import java . math . MathContext ; import java . math . RoundingMode ; import java . util . Scanner ; public class Fscsfj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigDecimal L = new BigDecimal ( sc . nextLine ( ) ) ; BigDecimal div = new BigDecimal ( 3.0 ) ; MathContext mc = new MathContext ( 10 , RoundingMode . HALF_UP ) ; BigDecimal cutNum = L . divide ( div , mc ) ; System . out . println ( cutNum . multiply ( cutNum ) . multiply ( cutNum ) ) ; } } import java . util . * ; public class Aygixsn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aygixsn = sc . nextInt ( ) ; int [ ] h = new int [ aygixsn ] ; int max = 0 ; int idx = 0 ; for ( int i = 0 ; i < aygixsn ; i ++ ) { h [ i ] = sc . nextInt ( ) ; if ( h [ i ] > max ) { max = h [ i ] ; idx = i ; } } int max2 = 0 ; for ( int i = 0 ; i < aygixsn ; i ++ ) { if ( i != idx ) { if ( h [ i ] > max2 ) { max2 = h [ i ] ; } } } for ( int i = 0 ; i < aygixsn ; i ++ ) { if ( i != idx ) { System . out . println ( max ) ; } else { System . out . println ( max2 ) ; } } } } import static java . lang . System . out ; import java . io . File ; import java . util . Scanner ; public class Eiiwhsd { public static void main ( String [ ] args ) { new Main ( ) . reverse ( ) ; } public void reverse ( ) { try ( Scanner scan = new Scanner ( System . in ) ) { reverseStr ( scan ) ; } catch ( Exception e ) { System . exit ( 0 ) ; } } public void reverse ( String inputDataPath ) { try ( Scanner scan = new Scanner ( new File ( inputDataPath ) ) ) { reverseStr ( scan ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } private void reverseStr ( Scanner scan ) { StringBuffer str = new StringBuffer ( scan . nextLine ( ) ) ; out . println ( str . reverse ( ) ) ; } } import java . util . Scanner ; public class Symlam { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int symlam = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] people = new int [ symlam ] ; for ( int i = 0 ; i < symlam ; i ++ ) { people [ i ] = sc . nextInt ( ) ; } int ok = 0 ; for ( int h : people ) { ok += h >= k ? 1 : 0 ; } System . out . println ( ok ) ; } } import java . util . * ; public class Odjqrc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int odjqrc = sc . nextInt ( ) ; int check = 1 ; for ( int i = 1 ; i < 10 ; i ++ ) { int f = odjqrc % i ; if ( f == 0 ) { int a = odjqrc / i ; if ( a > 0 && a < 10 ) { check = 2 ; System . out . println ( " Yes " ) ; return ; } } if ( i == 9 && check == 1 ) System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Xrtku { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xrtku = sc . nextInt ( ) ; int [ ] a = new int [ xrtku + 1 ] ; for ( int i = 1 ; i <= xrtku ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int cnt = 1 ; int point_now = 1 ; while ( cnt <= xrtku ) { point_now = a [ point_now ] ; if ( point_now == 2 ) { System . out . print ( cnt ) ; return ; } cnt ++ ; } System . out . println ( - 1 ) ; } } import java . util . * ; import static java . lang . Math . * ; class Rmsqc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rmsqc = sc . nextInt ( ) ; int ans = ( int ) pow ( rmsqc , 3 ) ; System . out . println ( ans ) ; } } import java . util . * ; public class Bdvzly { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long bdvzly = Long . parseLong ( sc . next ( ) ) ; long k = Long . parseLong ( sc . next ( ) ) ; System . out . println ( Math . min ( bdvzly % k , k - ( bdvzly % k ) ) ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Ukpfg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . next ( ) ; sc . close ( ) ; Map < Character , Integer > map = new HashMap < > ( ) ; for ( int ukpfg = 0 ; ukpfg < w . length ( ) ; ++ ukpfg ) { if ( map . containsKey ( w . charAt ( ukpfg ) ) ) { Integer cap = map . get ( w . charAt ( ukpfg ) ) ; map . remove ( w . charAt ( ukpfg ) ) ; map . put ( w . charAt ( ukpfg ) , cap + 1 ) ; } else { map . put ( w . charAt ( ukpfg ) , 1 ) ; } } boolean flag = true ; for ( Character c : map . keySet ( ) ) { if ( map . get ( c ) % 2 != 0 ) { flag = false ; break ; } } if ( flag ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Wkbpp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wkbpp = sc . nextInt ( ) ; int [ ] a = new int [ wkbpp ] ; for ( int i = 0 ; i < wkbpp ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; int alice = 0 ; int bob = 0 ; boolean isAlice = true ; for ( int i = a . length - 1 ; i != - 1 ; i -- ) { if ( isAlice ) { alice += a [ i ] ; } else { bob += a [ i ] ; } isAlice = ! isAlice ; } System . out . println ( alice - bob ) ; } } import java . util . * ; import java . util . InputMismatchException ; public class Oevaiar { public static void main ( String [ ] args ) { try { Scanner sc = new Scanner ( System . in ) ; int oevaiar = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k ; if ( oevaiar == b ) { System . out . println ( " IMPOSSIBLE " ) ; } else if ( oevaiar < 0 ) { System . out . println ( " IMPOSSIBLE " ) ; } else if ( b > 1000000000 ) { System . out . println ( " IMPOSSIBLE " ) ; } else { k = ( b + oevaiar ) / 2 ; if ( ( k * 2 ) != ( oevaiar + b ) ) { System . out . println ( " IMPOSSIBLE " ) ; } else { System . out . println ( k ) ; } } } catch ( InputMismatchException e ) { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . util . * ; import static java . lang . Math . ceil ; class Kpuolsx { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int kpuolsx = input . nextInt ( ) ; int n = input . nextInt ( ) ; Vector < Integer > a = new Vector < > ( n ) ; int sum = 0 ; for ( int i = 0 ; i < n ; ++ i ) { int x = input . nextInt ( ) ; a . add ( x ) ; } for ( int i = 0 ; i < n ; ++ i ) { sum += a . get ( i ) ; } if ( sum >= kpuolsx ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Ilpgisz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ilpgisz = sc . nextInt ( ) ; int [ ] p = new int [ ilpgisz ] ; int flg = 0 ; String ans = " NO " ; for ( int i = 0 ; i < ilpgisz ; i ++ ) { p [ i ] = sc . nextInt ( ) ; if ( p [ i ] != i + 1 ) { flg += 1 ; } } if ( flg == 0 || flg == 2 ) { ans = " YES " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Fmsseiu { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int fmsseiu = sc . nextInt ( ) ; int [ ] p = new int [ fmsseiu ] ; for ( int i = 0 ; i < fmsseiu ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int min = 10000000 ; int count = 0 ; for ( int i = 0 ; i < fmsseiu ; i ++ ) { if ( p [ i ] < min ) { count ++ ; min = p [ i ] ; } } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; class Iqrpai { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iqrpai = sc . nextInt ( ) ; int [ ] a = new int [ iqrpai ] ; for ( int i = 0 ; i < iqrpai ; i ++ ) a [ i ] = sc . nextInt ( ) ; int [ ] dp = new int [ iqrpai + 1 ] ; for ( int i = 2 ; i <= iqrpai ; i ++ ) { dp [ i ] = dp [ i - 1 ] + Math . abs ( a [ i - 1 ] - a [ i - 2 ] ) ; if ( i >= 3 ) dp [ i ] = Math . min ( dp [ i ] , dp [ i - 2 ] + Math . abs ( a [ i - 3 ] - a [ i - 1 ] ) ) ; } System . out . println ( dp [ iqrpai ] ) ; } } import java . util . Scanner ; import java . util . Arrays ; class Oinfshc { boolean [ ] primeTable ; public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; PrimeNum prime = new PrimeNum ( 100000010 ) ; prime . createTable ( ) ; int oinfshc = cin . nextInt ( ) , ct = 0 ; for ( int i = 0 ; i < oinfshc ; i ++ ) { int num = cin . nextInt ( ) ; if ( prime . judge ( num ) ) ct ++ ; } System . out . println ( ct ) ; } } class Oinfshc { private boolean [ ] primeTable ; private int maxNum ; PrimeNum ( int oinfshc ) { primeTable = new boolean [ oinfshc ] ; Arrays . fill ( primeTable , true ) ; this . maxNum = oinfshc ; } protected void createTable ( ) { final double sqrt_max = Math . sqrt ( maxNum ) ; for ( int i = 2 ; i < sqrt_max ; i ++ ) { if ( primeTable [ i ] ) { for ( int j = i * 2 ; j < maxNum ; j += i ) primeTable [ j ] = false ; } } } protected boolean judge ( int oinfshc ) { return ( primeTable [ oinfshc ] ) ; } protected int serch ( int oinfshc ) { for ( int i = 2 ; i < maxNum ; i ++ ) { if ( primeTable [ i ] ) oinfshc -- ; if ( oinfshc == 0 ) return ( i ) ; } return ( - 1 ) ; } } import java . util . Scanner ; public class Jtmyie { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jtmyie = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int r = Integer . parseInt ( sc . next ( ) ) ; int result = Math . min ( Math . min ( jtmyie + q , q + r ) , jtmyie + r ) ; System . out . println ( result ) ; } } import java . util . Scanner ; public class Rvtjghe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rvtjghe = sc . nextInt ( ) ; for ( int i = 9 ; i >= 0 ; i -- ) { if ( rvtjghe > i * 111 ) { System . out . println ( ( i + 1 ) * 111 ) ; break ; } } } } import java . util . * ; import java . io . * ; public class Iglhfkl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iglhfkl = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int ans = 0 ; int able = 2 * d + 1 ; for ( int i = 1 ; i < 20 ; i ++ ) { if ( i * able >= iglhfkl ) { ans = i ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; public class Rzzxg { public static void main ( String [ ] omkar ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; int rzzxg = Integer . parseInt ( st . nextToken ( ) ) ; int res = rzzxg / 500 ; res *= 1000 ; int lol = rzzxg % 500 - rzzxg % 5 ; System . out . println ( res + lol ) ; } } import java . util . * ; public class Sjjwz { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int sjjwz = s . nextInt ( ) ; int m = s . nextInt ( ) ; int ans = 10000 ; for ( int i = 0 ; i < sjjwz ; i ++ ) { int k = s . nextInt ( ) ; int b = s . nextInt ( ) ; if ( b <= m && k < ans ) { ans = k ; } } if ( ans == 10000 ) { System . out . println ( " TLE " ) ; } else System . out . println ( ans ) ; } } import java . util . * ; public class Ezulot { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ezulot = sc . nextInt ( ) ; int ans = 0 ; if ( ezulot >= 195 ) { ans = 5 ; } else if ( ezulot >= 189 ) { ans = 4 ; } else if ( ezulot >= 165 ) { ans = 3 ; } else if ( ezulot >= 135 ) { ans = 2 ; } else if ( ezulot >= 105 ) { ans = 1 ; } System . out . println ( ans ) ; } } import java . util . * ; public class Zmrrhqp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zmrrhqp = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; int max = 1 ; for ( int i = 0 ; i < zmrrhqp ; i ++ ) { String temp = sc . next ( ) ; if ( map . containsKey ( temp ) ) { int value = map . get ( temp ) + 1 ; map . put ( temp , value ) ; if ( value > max ) { max = value ; } } else { map . put ( temp , 1 ) ; } } List maxstr = new ArrayList < String > ( ) ; for ( String key : map . keySet ( ) ) { if ( map . get ( key ) == max ) { maxstr . add ( key ) ; } } Collections . sort ( maxstr ) ; for ( int i = 0 ; i < maxstr . size ( ) ; i ++ ) { System . out . println ( maxstr . get ( i ) ) ; } } } import java . io . * ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; class Weshfh { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; ArrayList < Integer > intArr = new ArrayList < Integer > ( ) ; for ( int weshfh = 0 ; weshfh < 3 ; weshfh ++ ) intArr . add ( in . nextInt ( ) ) ; Collections . sort ( intArr ) ; System . out . printf ( " %d %d %d \n " , intArr . get ( 0 ) , intArr . get ( 1 ) , intArr . get ( 2 ) ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class Hkhkltn { public static void main ( String [ ] args ) { ( new Main ( ) ) . execute ( ) ; } public void execute ( ) { ; Scanner sc = new Scanner ( System . in ) ; BigDecimal W = new BigDecimal ( sc . next ( ) ) ; BigDecimal H = new BigDecimal ( sc . next ( ) ) ; BigDecimal x = new BigDecimal ( sc . next ( ) ) ; BigDecimal y = new BigDecimal ( sc . next ( ) ) ; BigDecimal s = W . multiply ( H ) . divide ( new BigDecimal ( " 2 " ) ) ; System . out . print ( s + " " ) ; BigDecimal wd = W . divide ( new BigDecimal ( " 2 " ) ) ; BigDecimal hd = H . divide ( new BigDecimal ( " 2 " ) ) ; if ( x . equals ( wd ) && y . equals ( hd ) ) { System . out . println ( 1 ) ; } else { System . out . println ( 0 ) ; } } } import java . util . Scanner ; public class Kijxjny { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String kijxjny = sc . next ( ) ; if ( kijxjny . equals ( " AAA " ) || kijxjny . equals ( " BBB " ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; import java . io . * ; import java . math . * ; public class Vyotkuj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int vyotkuj = sc . nextInt ( ) ; int odd = sc . nextInt ( ) ; int ans = vyotkuj * ( vyotkuj - 1 ) / 2 + odd * ( odd - 1 ) / 2 ; System . out . println ( ans ) ; } } import java . util . * ; public class Xaxba { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xaxba = sc . nextInt ( ) ; boolean cantReducedAnyMore = false ; int previous = sc . nextInt ( ) ; int current ; String result = " Yes " ; while ( sc . hasNext ( ) ) { current = sc . nextInt ( ) ; int diff = current - previous ; if ( diff > 0 ) { cantReducedAnyMore = false ; } else if ( diff == - 1 ) { if ( cantReducedAnyMore ) { result = " No " ; break ; } else { cantReducedAnyMore = true ; } } else if ( diff < - 1 ) { result = " No " ; break ; } previous = current ; } System . out . println ( result ) ; } } import java . util . Arrays ; import java . util . Scanner ; class Scsnt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int scsnt = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int abprice = scsnt * X + B * Y ; int target1 = 0 ; int target1_2 = 0 ; int target2 = 0 ; int dif = 0 ; if ( X < Y ) { target1 = X ; target1_2 = Y ; target2 = B ; dif = Y - X ; } else { target1 = Y ; target1_2 = X ; target2 = scsnt ; dif = X - Y ; } int cprice1 = C * target1 * 2 + dif * target2 ; int cprice2 = C * target1_2 * 2 ; int cprice = cprice1 > cprice2 ? cprice2 : cprice1 ; if ( abprice > cprice ) { System . out . println ( cprice ) ; } else { System . out . println ( abprice ) ; } } } import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import java . util . Queue ; import java . util . Scanner ; import java . util . Set ; public class Ewolrir { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { solve_abc158_c ( ) ; } public static void solve_abc158_c ( ) { Scanner sc = new Scanner ( System . in ) ; int ewolrir = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = - 1 ; for ( int i = 1 ; i <= 1250 ; i ++ ) { int c = ( int ) Math . floor ( i * 0.08 ) ; int d = ( int ) Math . floor ( i * 0.1 ) ; if ( c == ewolrir && d == B ) { ans = i ; break ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Nizoh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nizoh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = nizoh ; i <= b ; i ++ ) { int num = i ; int dig1 = num % 10 ; int dig2 = ( num / 10 ) % 10 ; int dig4 = ( num / 1000 ) % 10 ; int dig5 = num / 10000 ; if ( dig1 == dig5 && dig2 == dig4 ) cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Jftyrev { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; Main m = new Main ( sc ) ; m . show ( m . solve ( ) ) ; sc . close ( ) ; } Scanner sc ; int [ ] x ; Main ( Scanner sc ) { this . sc = sc ; this . x = new int [ 5 ] ; } private int solve ( ) { int jftyrev = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { x [ i ] = sc . nextInt ( ) ; if ( x [ i ] == 0 ) { jftyrev = i + 1 ; } } return jftyrev ; } public void show ( int jftyrev ) { System . out . println ( jftyrev ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Tscborp { private static Scanner sc = new Scanner ( System . in ) ; static void p ( String ans ) { System . out . println ( ans ) ; } static void p ( int ans ) { System . out . println ( ans ) ; } static void p ( long ans ) { System . out . println ( ans ) ; } static void p ( double ans ) { System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String aa = sc . next ( ) ; char tscborp = ( char ) ( aa . charAt ( 0 ) + 1 ) ; String vv = tscborp + " " ; p ( vv ) ; } } import java . util . Scanner ; public class Chbgwhq { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; double chbgwhq = in . nextDouble ( ) ; double d = in . nextDouble ( ) ; int ans = 0 ; while ( chbgwhq -- > 0 ) { double x = in . nextDouble ( ) ; double y = in . nextDouble ( ) ; if ( Math . sqrt ( x * x + y * y ) <= d ) ans ++ ; } System . out . println ( ans ) ; in . close ( ) ; } } import java . util . * ; class Nxjhsnq { final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int nxjhsnq = sc . nextInt ( ) ; if ( nxjhsnq % 2 == 1 ) { System . out . println ( " No " ) ; return ; } String s = sc . next ( ) ; int l = ( int ) ( nxjhsnq / 2 ) ; for ( int i = 0 ; i < l ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( l + i ) ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Hscwv { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int hscwv = Integer . parseInt ( br . readLine ( ) ) ; int [ ] seqS = new int [ hscwv ] ; String [ ] line = br . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < hscwv ; i ++ ) seqS [ i ] = Integer . parseInt ( line [ i ] ) ; int q = Integer . parseInt ( br . readLine ( ) ) ; line = br . readLine ( ) . split ( " " ) ; int cnt = 0 ; for ( String ref : line ) { if ( isExistSeachByBinary ( seqS , Integer . parseInt ( ref ) ) ) cnt ++ ; } System . out . println ( cnt ) ; } } static boolean isExistSeachByBinary ( int [ ] tar , int ref ) { int left = 0 ; int right = tar . length ; int mid ; while ( left < right ) { mid = ( left + right ) / 2 ; if ( tar [ mid ] == ref ) return true ; else if ( tar [ mid ] > ref ) right = mid ; else left = mid + 1 ; } return false ; } } import java . util . Scanner ; public class Kzfoi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kzfoi = sc . nextInt ( ) ; int T_attack = sc . nextInt ( ) ; int A_hp = sc . nextInt ( ) ; int A_attack = sc . nextInt ( ) ; int A_turn = 0 ; int T_turn = 1 ; while ( kzfoi > 0 && A_hp > 0 ) { if ( T_turn == 1 ) { A_hp = A_hp - T_attack ; A_turn = 1 ; T_turn = 0 ; } else if ( A_turn == 1 ) { kzfoi = kzfoi - A_attack ; T_turn = 1 ; A_turn = 0 ; } } if ( kzfoi > 0 ) { System . out . println ( " Yes " ) ; } else if ( kzfoi <= 0 ) { System . out . println ( " No " ) ; } } } import java . util . * ; public class Fdilo { static int gcd ( int a , int b ) { return b > 0 ? gcd ( b , a % b ) : a ; } static long fdilo = 1000000007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] S = sc . next ( ) . toCharArray ( ) ; char [ ] T = sc . next ( ) . toCharArray ( ) ; int ans = 1001 ; for ( int i = 0 ; i < S . length - T . length + 1 ; i ++ ) { int tempAns = 0 ; for ( int j = 0 ; j < T . length ; j ++ ) { if ( S [ i + j ] != T [ j ] ) { tempAns ++ ; } } ans = Math . min ( ans , tempAns ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Pqgzd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long pqgzd = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long x = scan . nextLong ( ) ; long y = scan . nextLong ( ) ; long c = pqgzd * x ; long d = pqgzd * y ; long e = b * x ; long f = b * y ; long res = Math . max ( Math . max ( c , e ) , Math . max ( d , f ) ) ; System . out . println ( res ) ; } } import java . util . Scanner ; class Xquvowu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String s1 = sc . next ( ) ; int xquvowu = Integer . parseInt ( s1 ) ; String sop = sc . next ( ) ; char op = sop . charAt ( 0 ) ; String s2 = sc . next ( ) ; int b = Integer . parseInt ( s2 ) ; if ( op == '?' ) { break ; } if ( 0 <= xquvowu && xquvowu <= 20000 ) { if ( 0 <= b && b <= 20000 ) { if ( op == '+' ) { System . out . println ( xquvowu + b ) ; } else if ( op == '-' ) { System . out . println ( xquvowu - b ) ; } else if ( op == '*' ) { System . out . println ( xquvowu * b ) ; } else if ( op == '/' ) { System . out . println ( xquvowu / b ) ; } } } } } } import java . util . * ; public class Glktsmu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int glktsmu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int plus = glktsmu + b ; int minus = glktsmu - b ; int mult = glktsmu * b ; if ( plus > minus ) { if ( plus > mult ) { System . out . println ( plus ) ; } else { System . out . println ( mult ) ; } } else if ( minus > plus ) { if ( minus > mult ) { System . out . println ( minus ) ; } else { System . out . println ( mult ) ; } } else { System . out . println ( plus ) ; } } } import java . util . Scanner ; public class Vxeyws { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int vxeyws = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean [ ] ac = new boolean [ vxeyws + 1 ] ; long [ ] wa = new long [ vxeyws + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { int p = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( ac [ p ] ) continue ; if ( s . equals ( " AC " ) ) { ac [ p ] = true ; } else { wa [ p ] ++ ; } } long sum1 = 0 ; long sum2 = 0 ; for ( int i = 1 ; i <= vxeyws ; i ++ ) { if ( ac [ i ] ) { sum1 ++ ; sum2 += wa [ i ] ; } } System . out . println ( sum1 + " " + sum2 ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Qctnt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qctnt = sc . nextInt ( ) ; int [ ] d = new int [ qctnt ] ; for ( int i = 0 ; i < qctnt ; i ++ ) { String line = sc . next ( ) ; d [ i ] = Integer . parseInt ( line ) ; } int K = 0 ; int count = 0 ; int countLeft = 0 ; int countRight = qctnt ; Arrays . sort ( d ) ; for ( int i = 0 ; i < qctnt ; i ++ ) { countLeft ++ ; countRight -- ; if ( countLeft == countRight ) { K = d [ i ] ; while ( d [ i ] <= K && K < d [ i + 1 ] ) { K ++ ; count ++ ; } break ; } } System . out . println ( count ) ; } } import java . util . * ; public class Fmzfqa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fmzfqa = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] work = new int [ m ] ; int ans = 0 ; for ( int i = 0 ; i < m ; ++ i ) { work [ i ] = sc . nextInt ( ) ; ans += work [ i ] ; } ans = fmzfqa - ans ; if ( ans < 0 ) ans = - 1 ; sc . close ( ) ; System . out . println ( ans ) ; } } import java . util . * ; import java . math . * ; import java . io . * ; public class Ifojzc { public static void main ( String [ ] args ) throws Exception { int ifojzc = 998244353 ; BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = Integer . parseInt ( bf . readLine ( ) ) ; StringTokenizer st = new StringTokenizer ( bf . readLine ( ) ) ; ArrayList < BigInteger > array = new ArrayList < BigInteger > ( ) ; boolean found = false ; for ( int i = 0 ; i < n ; i ++ ) { array . add ( new BigInteger ( st . nextToken ( ) ) ) ; if ( array . get ( i ) . equals ( new BigInteger ( " 0 " ) ) ) { out . println ( 0 ) ; out . close ( ) ; found = true ; } } if ( found == false ) { BigInteger prod = new BigInteger ( " 1 " ) ; boolean found1 = true ; for ( int i = 0 ; i < n ; i ++ ) { prod = prod . multiply ( array . get ( i ) ) ; if ( prod . compareTo ( new BigInteger ( " 1000000000000000000 " ) ) > 0 ) { out . println ( - 1 ) ; found1 = false ; break ; } } if ( found1 == true ) { out . println ( prod ) ; } } out . close ( ) ; } } import java . util . Scanner ; class Lmbkuw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . nextLine ( ) ; String result = " " ; for ( int lmbkuw = 0 ; lmbkuw < str . length ( ) ; lmbkuw ++ ) { String s = str . substring ( lmbkuw , lmbkuw + 1 ) ; if ( s . equals ( s . toLowerCase ( ) ) ) { result += s . toUpperCase ( ) ; } else { result += s . toLowerCase ( ) ; } } System . out . println ( result ) ; } } import java . util . * ; public class Backw { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int backw ; backw = in . nextInt ( ) ; SortedMap < String , Integer > poll = new TreeMap < String , Integer > ( ) ; int maxvote = 0 ; for ( long i = 0 ; i < backw ; i ++ ) { String candidate = in . next ( ) ; if ( poll . containsKey ( candidate ) ) { poll . put ( candidate , poll . get ( candidate ) + 1 ) ; } else { poll . put ( candidate , 1 ) ; } maxvote = Math . max ( maxvote , poll . get ( candidate ) ) ; } for ( String candidate : poll . keySet ( ) ) { if ( poll . get ( candidate ) == maxvote ) System . out . println ( candidate ) ; } } } import java . util . Scanner ; public class Qirqrmr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qirqrmr = sc . nextInt ( ) ; int [ ] A = new int [ qirqrmr ] ; for ( int i = 0 ; i < qirqrmr ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } boolean ok = true ; for ( int i = 0 ; i < qirqrmr ; i ++ ) { if ( A [ i ] % 2 == 0 ) { if ( A [ i ] % 3 != 0 && A [ i ] % 5 != 0 ) ok = false ; } } if ( ok ) { System . out . println ( " APPROVED " ) ; } else { System . out . println ( " DENIED " ) ; } } } import java . util . Scanner ; public class Ikvlw { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ikvlw = scanner . nextInt ( ) ; long sum = 0 ; for ( long i = 1 ; i < ikvlw + 1 ; i ++ ) { if ( ! ( i % 3 == 0 || i % 5 == 0 ) ) { sum = sum + i ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Ngvkyv { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int ngvkyv = scanner . nextInt ( ) , y = scanner . nextInt ( ) ; System . out . println ( ( ( ngvkyv * 2 <= y ) && ( ngvkyv * 4 >= y ) && ( 0 == ( y & 1 ) ) ) ? " Yes " : " No " ) ; } } } import java . util . * ; import java . util . Collections ; public class Bbcdtoe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int bbcdtoe = 0 ; bbcdtoe <= 2 ; bbcdtoe ++ ) { list . add ( sc . nextInt ( ) ) ; } int K = sc . nextInt ( ) ; Collections . sort ( list , Collections . reverseOrder ( ) ) ; for ( int bbcdtoe = 0 ; bbcdtoe < K ; bbcdtoe ++ ) { list . set ( 0 , list . get ( 0 ) * 2 ) ; } System . out . println ( list . get ( 0 ) + list . get ( 1 ) + list . get ( 2 ) ) ; } } import java . util . * ; public class Jlovja { Scanner sc = new Scanner ( System . in ) ; final int jlovja = 1000000007 ; final int MAX = Integer . MAX_VALUE ; final long LMAX = Long . MAX_VALUE ; void doIt ( ) { int n = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; int len = n ; for ( int i = 1 ; i < n ; i ++ ) { if ( c [ i - 1 ] == c [ i ] ) len -- ; } System . out . println ( len ) ; } public static void main ( String [ ] args ) { new Main ( ) . doIt ( ) ; } } import java . util . Scanner ; public class Ijeyi { static String a ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int ijeyi = stdIn . nextInt ( ) ; int count = 0 ; IN : for ( int i = 0 ; i < ijeyi ; i ++ ) { int x = stdIn . nextInt ( ) ; for ( int j = 2 ; j * j <= x ; j ++ ) { if ( x % j == 0 ) continue IN ; } count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Yofzjow { static long yofzjow = Long . MIN_VALUE ; static long [ ] C ; static int [ ] P ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String string = sc . next ( ) ; if ( N % 2 == 1 ) { System . out . println ( " No " ) ; } else { if ( string . substring ( 0 , N / 2 ) . equals ( string . substring ( N / 2 , N ) ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; class Kifaw { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int kifaw = stdIn . nextInt ( ) ; String S = stdIn . next ( ) ; String answer = " Yes " ; if ( kifaw % 2 != 0 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < kifaw / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( kifaw / 2 + i ) ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Ssnphdz { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; String answer = " " ; final int ssnphdz = scan . nextInt ( ) ; int len = scan . nextInt ( ) ; String [ ] words = new String [ ssnphdz ] ; for ( int i = 0 ; i < ssnphdz ; i ++ ) { words [ i ] = scan . next ( ) ; } for ( int i = 1 ; i < ssnphdz ; i ++ ) { String temp = words [ i ] ; int j = i - 1 ; while ( j >= 0 && words [ j ] . compareTo ( temp ) > 0 ) { words [ j + 1 ] = words [ j ] ; j -- ; } words [ j + 1 ] = temp ; } for ( int i = 0 ; i < ssnphdz ; i ++ ) { answer = answer . concat ( words [ i ] ) ; } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Pxait { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pxait = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int x = 1 ; int result = 0 ; while ( x < B ) { x += ( pxait - 1 ) ; result ++ ; } System . out . println ( result ) ; } } import java . util . * ; public class Dddflqv { static final long dddflqv = ( long ) ( 1e9 + 7 ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean [ ] oks = new boolean [ n + 1 ] ; Arrays . fill ( oks , true ) ; for ( int i = 0 ; i < m ; i ++ ) { int a = sc . nextInt ( ) ; oks [ a ] = false ; } long [ ] dp = new long [ n + 1 ] ; dp [ 0 ] = 1 ; for ( int now = 0 ; now < n ; now ++ ) { for ( int next = now + 1 ; next <= Math . min ( n , now + 2 ) ; next ++ ) { if ( oks [ next ] ) { dp [ next ] += dp [ now ] ; dp [ next ] %= dddflqv ; } } } System . out . println ( dp [ n ] ) ; sc . close ( ) ; } } import java . util . * ; import java . lang . Math ; public class Azhtui { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int azhtui = sc . nextInt ( ) ; int count = 0 ; int count2 = 0 ; if ( azhtui == 1 ) count -- ; if ( azhtui == 2 ) count -= 2 ; while ( count2 < 2 ) { count ++ ; if ( azhtui == 4 ) count2 ++ ; if ( azhtui % 2 == 0 ) azhtui /= 2 ; else azhtui = azhtui * 3 + 1 ; } System . out . println ( count ) ; } } import java . util . * ; public class Iojaq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int iojaq = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] price = new int [ iojaq ] ; for ( int i = 0 ; i < iojaq ; i ++ ) { price [ i ] = sc . nextInt ( ) ; } Arrays . sort ( price ) ; int money = 0 ; for ( int i = 0 ; i < K ; i ++ ) { money = money + price [ i ] ; } System . out . println ( String . valueOf ( money ) ) ; } } import java . util . * ; public class Cchgpl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cchgpl = sc . nextInt ( ) ; int ac = 0 , wa = 0 , tle = 0 , re = 0 ; while ( cchgpl -- > 0 ) { String s = sc . next ( ) ; if ( s . equals ( " WA " ) ) { wa ++ ; } if ( s . equals ( " AC " ) ) { ac ++ ; } if ( s . equals ( " TLE " ) ) { tle ++ ; } if ( s . equals ( " RE " ) ) { re ++ ; } } System . out . println ( " AC x " + ac ) ; System . out . println ( " WA x " + wa ) ; System . out . println ( " TLE x " + tle ) ; System . out . println ( " RE x " + re ) ; } } import java . util . Arrays ; import java . util . Scanner ; import java . util . Set ; public class Wqmhl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wqmhl = Integer . parseInt ( sc . next ( ) ) ; int [ ] d = new int [ wqmhl ] ; for ( int i = 0 ; i < wqmhl ; i ++ ) { d [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( d ) ; System . out . println ( d [ wqmhl / 2 ] - d [ wqmhl / 2 - 1 ] ) ; } } import java . util . Scanner ; public class Jctxol { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jctxol = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; int ans = 0 ; for ( int i = 0 ; i < jctxol ; i ++ ) { int digit = sc . nextInt ( ) ; if ( min > digit ) { min = digit ; ans ++ ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Hicxgpa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hicxgpa , j , t ; int cnt = 0 ; int check = 0 ; int mini , minikey ; int n = sc . nextInt ( ) ; int [ ] num ; num = new int [ n ] ; for ( hicxgpa = 0 ; hicxgpa < n ; hicxgpa ++ ) { num [ hicxgpa ] = sc . nextInt ( ) ; } for ( hicxgpa = 0 ; hicxgpa < n - 1 ; hicxgpa ++ ) { mini = hicxgpa ; minikey = num [ hicxgpa ] ; for ( j = hicxgpa + 1 ; j < n ; j ++ ) { if ( num [ j ] < minikey ) { mini = j ; minikey = num [ j ] ; check ++ ; } } t = num [ hicxgpa ] ; num [ hicxgpa ] = num [ mini ] ; num [ mini ] = t ; if ( check > 0 ) cnt ++ ; check = 0 ; } for ( hicxgpa = 0 ; hicxgpa < n - 1 ; hicxgpa ++ ) { System . out . print ( num [ hicxgpa ] + " " ) ; } System . out . println ( num [ n - 1 ] ) ; System . out . println ( cnt ) ; sc . close ( ) ; } } import java . util . * ; class Jkdfpww { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jkdfpww = 1 ; int count = 0 ; int x = 0 ; int n = sc . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) { x = countHalf ( i ) ; if ( count < x ) { count = x ; jkdfpww = i ; } } } System . out . println ( jkdfpww ) ; sc . close ( ) ; } public static int countHalf ( int i ) { int count = 0 ; boolean a = true ; while ( a ) { if ( i % 2 == 0 ) { i /= 2 ; count ++ ; } else { a = false ; } } return count ; } } import java . util . Scanner ; public class Jdzqecf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jdzqecf = 0 ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; while ( ( A - 1 ) * ( jdzqecf - 1 ) + A < B ) { jdzqecf ++ ; } System . out . println ( jdzqecf ) ; sc . close ( ) ; } } import java . util . * ; class Mzjvoq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mzjvoq = sc . nextInt ( ) ; int ans = 0 ; for ( int i = mzjvoq ; i < 1000 ; i ++ ) { int k = i / 10 ; int l = i - ( int ) ( ( i / 100 ) * 100 ) ; if ( k == l ) { ans = i ; break ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Mpydecn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mpydecn = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( mpydecn <= b ) { if ( b <= c ) { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * c + mpydecn + b ) ) ; } else { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * b + mpydecn + c ) ) ; } } else { if ( mpydecn <= c ) { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * c + mpydecn + b ) ) ; } else { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * mpydecn + b + c ) ) ; } } } } import java . util . Scanner ; public class Krrqb { private static int countPower ( int n ) { int krrqb = 0 ; while ( n % 2 == 0 ) { ++ krrqb ; n /= 2 ; } return krrqb ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int ans = 100 ; for ( int i = 0 ; i < n ; ++ i ) { int a = sc . nextInt ( ) ; ans = Math . min ( ans , countPower ( a ) ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Bkxnuox { public static int bkxnuox ; public static int [ ] List ; public static int Count = 0 ; public static int min_j ; public static int tmp ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; bkxnuox = scan . nextInt ( ) ; List = new int [ bkxnuox ] ; for ( int i = 0 ; i < bkxnuox ; i ++ ) { List [ i ] = scan . nextInt ( ) ; } SelectionSort ( ) ; if ( bkxnuox == 1 ) System . out . println ( List [ 0 ] ) ; else { for ( int i = 0 ; i < bkxnuox ; i ++ ) { if ( i == bkxnuox - 1 ) System . out . println ( List [ bkxnuox - 1 ] ) ; else System . out . print ( List [ i ] + " " ) ; } } System . out . println ( Count ) ; } public static void SelectionSort ( ) { for ( int i = 0 ; i < bkxnuox ; i ++ ) { min_j = i ; for ( int j = i ; j < bkxnuox ; j ++ ) { if ( List [ j ] < List [ min_j ] ) { min_j = j ; } } if ( min_j != i ) { tmp = List [ i ] ; List [ i ] = List [ min_j ] ; List [ min_j ] = tmp ; Count ++ ; } } } } import java . util . * ; public class Rczae { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rczae = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; int i = 0 ; int cnt = 0 ; do { i = s . indexOf ( " ABC " , i ) ; if ( i != - 1 ) { cnt ++ ; i ++ ; } } while ( i >= 0 ) ; System . out . println ( cnt ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public final class Tkocs { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner in = new Scanner ( System . in ) ; int tkocs = in . nextInt ( ) ; int m = in . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) sum += in . nextInt ( ) ; int re = tkocs - sum ; if ( re < 0 ) { System . out . println ( - 1 ) ; } else { System . out . println ( re ) ; } } } import java . util . Scanner ; public class Ehaylbk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ehaylbk = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] a = sc . nextLine ( ) . split ( " " ) ; int [ ] array = new int [ ehaylbk ] ; for ( int i = 0 ; i < ehaylbk ; i ++ ) { array [ i ] = Integer . parseInt ( a [ i ] ) ; } int changeCount = 0 ; int minj ; for ( int i = 0 ; i < ehaylbk ; i ++ ) { minj = i ; for ( int j = i ; j < ehaylbk ; j ++ ) { if ( array [ j ] < array [ minj ] ) { minj = j ; } } if ( i != minj ) { int tmp = array [ i ] ; array [ i ] = array [ minj ] ; array [ minj ] = tmp ; changeCount ++ ; } } for ( int i = 0 ; i < array . length ; i ++ ) { System . out . print ( array [ i ] ) ; if ( i != array . length - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; System . out . println ( changeCount ) ; } } import java . util . Scanner ; public class Zcvqsn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int zcvqsn = scanner . nextInt ( ) ; int [ ] a = new int [ 10000 ] ; int max = - 1000000 ; int min = 1000000 ; long sum = 0 ; for ( int i = 0 ; i < zcvqsn ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; if ( i == 0 ) { max = a [ 0 ] ; min = a [ 0 ] ; } else { if ( a [ i ] > max ) { max = a [ i ] ; } else if ( a [ i ] < min ) { min = a [ i ] ; } } sum += a [ i ] ; } System . out . printf ( " %1$d %2$d %3$d \n " , min , max , sum ) ; } } import java . util . Scanner ; public class Jtjpnv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jtjpnv = sc . nextInt ( ) ; int [ ] h = new int [ jtjpnv + 2 ] ; int maxh = 0 ; int zero1 = 0 ; int zero2 = jtjpnv ; int ret = 0 ; for ( int i = 1 ; i < jtjpnv + 1 ; i ++ ) { h [ i ] = sc . nextInt ( ) ; maxh = Math . max ( maxh , h [ i ] ) ; } h [ 0 ] = 0 ; h [ jtjpnv + 1 ] = 0 ; for ( int i = 1 ; i <= maxh ; i ++ ) { zero1 = 0 ; zero2 = jtjpnv ; for ( int j = 0 ; j < jtjpnv + 2 ; j ++ ) { if ( h [ j ] == 0 ) { zero2 = j ; if ( zero2 - zero1 > 1 ) { ret ++ ; } zero1 = zero2 ; } } for ( int k = 0 ; k < jtjpnv + 2 ; k ++ ) { if ( h [ k ] > 0 ) { h [ k ] -- ; } } } System . out . println ( ret ) ; } } import java . util . * ; public class Khxsxk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int khxsxk = sc . nextInt ( ) ; int attack1 = sc . nextInt ( ) ; int hp2 = sc . nextInt ( ) ; int attack2 = sc . nextInt ( ) ; while ( khxsxk > 0 && hp2 > 0 ) { hp2 -= attack1 ; if ( hp2 <= 0 ) { System . out . println ( " Yes " ) ; continue ; } khxsxk -= attack2 ; if ( khxsxk <= 0 ) { System . out . println ( " No " ) ; continue ; } } } } import java . util . * ; public class Orhyke { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int orhyke = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int [ ] p = new int [ orhyke ] ; for ( int i = 0 ; i < q ; i ++ ) p [ sc . nextInt ( ) - 1 ] ++ ; for ( int i = 0 ; i < orhyke ; i ++ ) { if ( k - q + p [ i ] > 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Ppsphw { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int ppsphw = Integer . parseInt ( str [ 0 ] ) ; int k = Integer . parseInt ( str [ 1 ] ) ; int q = Integer . parseInt ( str [ 2 ] ) ; int [ ] a = new int [ q ] ; int [ ] count = new int [ ppsphw ] ; for ( int i = 0 ; i < q ; i ++ ) { a [ i ] = Integer . parseInt ( in . readLine ( ) ) ; count [ a [ i ] - 1 ] ++ ; } for ( int i = 0 ; i < ppsphw ; i ++ ) { if ( k - ( q - count [ i ] ) <= 0 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } } import java . util . * ; public class Qcsypq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int qcsypq = sc . nextInt ( ) ; int [ ] d = new int [ qcsypq ] ; for ( int i = 0 ; i < qcsypq ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; int count = 0 ; for ( int i = 1 ; i < qcsypq ; i ++ ) { if ( d [ i ] == d [ i - 1 ] ) count ++ ; } System . out . println ( qcsypq - count ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . math . BigDecimal ; import java . util . Scanner ; public class Xuthtg { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; long xuthtg = sc . nextInt ( ) ; long H = sc . nextInt ( ) ; long x = sc . nextInt ( ) ; long y = sc . nextInt ( ) ; sc . close ( ) ; String a = BigDecimal . valueOf ( ( ( double ) xuthtg * H ) / 2.0 ) . toPlainString ( ) ; out . print ( a ) ; out . print ( " " ) ; if ( xuthtg == x * 2 && H == y * 2 ) { out . println ( " 1 " ) ; } else { out . println ( " 0 " ) ; } } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } } import java . util . Scanner ; public class Gojlbz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gojlbz = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int h = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; double Mangle = ( m * 360.0 ) / 60.0 ; double Hangle = ( h * 60.0 + m ) * 360.0 / ( 12.0 * 60.0 ) ; double MHangle = 0 ; MHangle = Hangle - Mangle ; double cosA = Math . cos ( MHangle * ( Math . PI / 180.0 ) ) ; double answer = Math . sqrt ( ( gojlbz * gojlbz ) + ( b * b ) - ( 2 * gojlbz * b * cosA ) ) ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class Rwirho { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rwirho = sc . nextInt ( ) ; for ( ; ; rwirho ++ ) { if ( isPrime ( rwirho ) ) break ; } System . out . println ( rwirho ) ; } public static boolean isPrime ( int rwirho ) { if ( ( rwirho % 2 == 0 && rwirho != 2 || rwirho == 1 ) ) return false ; for ( int i = 3 ; i <= Math . sqrt ( rwirho ) ; i += 2 ) { if ( rwirho % i == 0 ) return false ; } return true ; } } import java . util . * ; public class Ivknzgn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ivknzgn = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; if ( Y % 2 == 1 ) { System . out . println ( " No " ) ; } else { int y = Y / 2 ; if ( y - ivknzgn < 0 ) { System . out . println ( " No " ) ; } else if ( y - 2 * ivknzgn > 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } } import java . util . Scanner ; class Qqvzteg { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int qqvzteg , b , c ; qqvzteg = scn . nextInt ( ) ; b = scn . nextInt ( ) ; c = scn . nextInt ( ) ; System . out . printf ( ( qqvzteg + b + c ) <= 21 ? " win " : " bust " ) ; } } import java . util . * ; class Jxkgd { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String jxkgd = in . nextLine ( ) ; if ( jxkgd . equals ( " ABC " ) ) System . out . println ( " ARC " ) ; else if ( jxkgd . equals ( " ARC " ) ) System . out . println ( " ABC " ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Sdqow { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sdqow = sc . nextInt ( ) ; Integer [ ] a = new Integer [ sdqow ] ; Integer [ ] tmpA = new Integer [ sdqow ] ; for ( int i = 0 ; i < sdqow ; i ++ ) { a [ i ] = sc . nextInt ( ) ; tmpA [ i ] = a [ i ] ; } Arrays . sort ( tmpA , Collections . reverseOrder ( ) ) ; int first = tmpA [ 0 ] ; int second = tmpA [ 1 ] ; for ( int i = 0 ; i < sdqow ; i ++ ) { if ( a [ i ] == first ) { System . out . println ( second ) ; } else { System . out . println ( first ) ; } } sc . close ( ) ; } } import java . util . Scanner ; class Khhnwam { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String s1 = sc . next ( ) ; int khhnwam = Integer . parseInt ( s1 ) ; String s2 = sc . next ( ) ; int W = Integer . parseInt ( s2 ) ; if ( khhnwam <= 300 && W <= 300 ) { if ( khhnwam == 0 && W == 0 ) { break ; } for ( int i = 1 ; i <= khhnwam ; i ++ ) { if ( i == 1 || i == khhnwam ) { for ( int j = 1 ; j <= W ; j ++ ) { System . out . print ( " # " ) ; } } else { for ( int j = 1 ; j <= W ; j ++ ) { if ( j == 1 || j == W ) { System . out . print ( " # " ) ; } else { System . out . print ( " . " ) ; } } } System . out . println ( " " ) ; } System . out . println ( " " ) ; } } } } import java . util . Scanner ; public class Mleca { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int mleca = s . length ; int res = 0 ; for ( int i = 0 ; i < ( mleca - 1 - i ) ; i ++ ) { if ( s [ i ] != s [ mleca - 1 - i ] ) { res ++ ; } } System . out . println ( res ) ; } } import java . util . * ; public class Fczdnlq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fczdnlq = 0 ; int W = 0 ; while ( true ) { fczdnlq = sc . nextInt ( ) ; W = sc . nextInt ( ) ; if ( fczdnlq != 0 && W != 0 ) { for ( int i = 0 ; i < fczdnlq ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { System . out . print ( " # " ) ; } System . out . print ( " \n " ) ; } System . out . println ( " " ) ; } else { return ; } } } } import java . util . * ; public class Dkblqz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String cards = sc . next ( ) ; if ( cards . equals ( " - " ) ) { break ; } int dkblqz = sc . nextInt ( ) ; for ( int i = 0 ; i < dkblqz ; i ++ ) { int count = sc . nextInt ( ) ; String move = cards . substring ( 0 , count ) ; String move2 = cards . substring ( count ) ; cards = move2 + move ; } System . out . println ( cards ) ; } } } import java . util . Scanner ; public class Qcndtmn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qcndtmn = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int counter = 0 ; for ( int i = qcndtmn ; i <= b ; i ++ ) { if ( c % i == 0 ) { counter ++ ; } } System . out . println ( counter ) ; scan . close ( ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Abtkzia { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int abtkzia = scanner . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; long total = 0 ; for ( int i = 0 ; i < abtkzia ; i ++ ) { list . add ( scanner . nextInt ( ) ) ; } Collections . sort ( list ) ; System . out . print ( list . get ( 0 ) + " " ) ; System . out . print ( list . get ( list . size ( ) - 1 ) + " " ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { total += list . get ( i ) ; } System . out . println ( total ) ; } } import java . util . Scanner ; public class Nblvr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nblvr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] array = { 1 , 1 , 1 } ; array [ nblvr - 1 ] = 0 ; array [ b - 1 ] = 0 ; for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] == 1 ) { System . out . println ( i + 1 ) ; } } } } import java . util . Scanner ; class Ukvlzim { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int ukvlzim = in . nextInt ( ) ; if ( ukvlzim == 0 ) break ; int [ ] numbers = new int [ ukvlzim ] ; for ( int i = 0 ; i < ukvlzim ; i ++ ) numbers [ i ] = in . nextInt ( ) ; long double_sum = 0 ; for ( int i = 0 ; i < ukvlzim ; i ++ ) double_sum += numbers [ i ] ; double_sum = double_sum * double_sum ; long sum_double = 0 ; for ( int i = 0 ; i < ukvlzim ; i ++ ) sum_double += ( numbers [ i ] * numbers [ i ] ) ; double sd = Math . sqrt ( ( sum_double - double_sum / ( double ) ukvlzim ) / ( double ) ukvlzim ) ; System . out . printf ( " %5.8f " , sd ) ; System . out . println ( ) ; } } } import java . util . Scanner ; public class Nvlinh { public static void main ( String [ ] args ) { int nvlinh = 0 ; Scanner scan = new Scanner ( System . in ) ; ; while ( true ) { nvlinh ++ ; int a = scan . nextInt ( ) ; if ( a == 0 ) { break ; } System . out . println ( " Case " + nvlinh + " : " + a ) ; } scan . close ( ) ; } } import javax . swing . * ; import java . io . * ; import java . util . * ; import java . math . * ; import static java . util . Comparator . * ; public class Bvibwbg { public static void main ( String [ ] args ) throws IOException { FastReader s = new FastReader ( ) ; int bvibwbg = s . nextInt ( ) ; int b = s . nextInt ( ) ; int numOfSock = 1 ; int count = 0 ; while ( numOfSock < b ) { numOfSock -= 1 ; numOfSock += bvibwbg ; count ++ ; } System . out . println ( count ) ; } } class Bvibwbg { 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 . Scanner ; public class Qifbp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qifbp = sc . nextInt ( ) ; boolean flg = true ; int i = 1 ; while ( flg ) { int cg = 1000 * i - qifbp ; if ( cg >= 0 ) { flg = false ; System . out . println ( cg ) ; } i ++ ; } } } import java . util . Scanner ; import java . util . Arrays ; public class Cqwyol { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cqwyol = scan . nextInt ( ) ; long [ ] a = new long [ cqwyol ] ; for ( int i = 0 ; i < cqwyol ; i ++ ) { a [ i ] = scan . nextLong ( ) ; if ( a [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } Arrays . sort ( a ) ; long ans = 1 ; for ( int i = cqwyol - 1 ; i >= 0 ; i -- ) { if ( a [ i ] > 1000000000000000000L / ans ) { System . out . println ( - 1 ) ; return ; } else { ans *= a [ i ] ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Prbjbib { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int prbjbib = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int left = 0 ; int right = prbjbib ; for ( int i = 0 ; i < M ; i ++ ) { left = Math . max ( sc . nextInt ( ) , left ) ; right = Math . min ( sc . nextInt ( ) , right ) ; } if ( left <= right ) { System . out . println ( right - left + 1 ) ; } else { System . out . println ( 0 ) ; } } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Ardfjz { static int ardfjz = 0 ; public static void main ( String [ ] args ) { int anser = 100000000 ; Scanner scan = new Scanner ( System . in ) ; ardfjz = scan . nextInt ( ) ; ArrayList < Integer > address = new ArrayList < > ( ) ; for ( int i = 0 ; i < ardfjz ; i ++ ) { address . add ( scan . nextInt ( ) ) ; } Collections . sort ( address ) ; for ( int i = address . get ( 0 ) ; i <= address . get ( ardfjz - 1 ) ; i ++ ) { int sum = sumList ( address , i ) ; if ( anser > sum ) { anser = sum ; } } System . out . println ( anser ) ; } private static int sumList ( ArrayList < Integer > array , int j ) { int sum = 0 ; for ( int i = 0 ; i < ardfjz ; i ++ ) { sum = sum + ( j - array . get ( i ) ) * ( j - array . get ( i ) ) ; } return sum ; } } import java . util . Scanner ; public class Echjjzo { public static void main ( String [ ] args ) { int echjjzo = 0 ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int hako = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a == b ) { echjjzo ++ ; if ( echjjzo == 3 ) { hako = 1 ; } } else { echjjzo = 0 ; } } if ( hako == 1 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; import java . util . stream . * ; class Jrvfbfv { static final List < String > RESULT_TYPE = Collections . unmodifiableList ( Arrays . asList ( " AC " , " WA " , " TLE " , " RE " ) ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Map < String , Integer > result = new HashMap < > ( ) ; int jrvfbfv = sc . nextInt ( ) ; for ( int i = 0 ; i < jrvfbfv ; i ++ ) { String judge = sc . next ( ) ; result . put ( judge , result . get ( judge ) == null ? 1 : result . get ( judge ) + 1 ) ; } dispResult ( result ) ; } static void dispResult ( Map < String , Integer > result ) { for ( String R : RESULT_TYPE ) { System . out . println ( R + " x " + ( result . get ( R ) == null ? 0 : result . get ( R ) ) ) ; } } } import java . util . * ; class Adoagsk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int adoagsk = scan . nextInt ( ) ; int last = adoagsk % 100 ; int first = ( adoagsk - last ) / 100 ; if ( jadmon ( last ) * jadmon ( first ) == 1 ) { System . out . println ( " AMBIGUOUS " ) ; } else if ( jadmon ( first ) == 1 && jadmon ( last ) == 0 ) { System . out . println ( " MMYY " ) ; } else if ( jadmon ( first ) == 0 && jadmon ( last ) == 1 ) { System . out . println ( " YYMM " ) ; } else { System . out . println ( " NA " ) ; } } public static int jadmon ( int n ) { if ( n > 0 && n < 13 ) { return 1 ; } else { return 0 ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Hftpx { public static void main ( String [ ] args ) { try { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String a = br . readLine ( ) ; int hftpx = 0 ; String b = br . readLine ( ) ; int bCount = 0 ; String c = br . readLine ( ) ; int cCount = 0 ; ; String now = " a " ; while ( true ) { if ( " a " . equals ( now ) ) { if ( hftpx >= a . length ( ) ) { System . out . println ( " A " ) ; break ; } now = a . substring ( hftpx , hftpx + 1 ) ; hftpx ++ ; } else if ( " b " . equals ( now ) ) { if ( bCount >= b . length ( ) ) { System . out . println ( " B " ) ; break ; } now = b . substring ( bCount , bCount + 1 ) ; bCount ++ ; } else if ( " c " . equals ( now ) ) { if ( cCount >= c . length ( ) ) { System . out . println ( " C " ) ; break ; } now = c . substring ( cCount , cCount + 1 ) ; cCount ++ ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . Scanner ; public class Rapzn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final long rapzn = sc . nextLong ( ) ; final long B = sc . nextLong ( ) ; final long C = sc . nextLong ( ) ; final long D = sc . nextLong ( ) ; final long L = lcm ( C , D ) ; System . out . println ( ( B - B / C - B / D + B / L ) - ( ( rapzn - 1 ) - ( rapzn - 1 ) / C - ( rapzn - 1 ) / D + ( rapzn - 1 ) / L ) ) ; } private static long lcm ( long a , long b ) { return a * b / gcd ( a , b ) ; } private static long gcd ( long a , long b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } } import java . util . * ; public class Rrguvrf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rrguvrf = sc . nextInt ( ) ; int ans = 0 ; while ( rrguvrf >= 5 ) { if ( rrguvrf >= 500 ) { rrguvrf -= 500 ; ans += 1000 ; } else { rrguvrf -= 5 ; ans += 5 ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Qvxhzm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int qvxhzm = Integer . parseInt ( a ) ; int B = Integer . parseInt ( b ) ; String ax = " " ; String bx = " " ; for ( int i = 0 ; i < B ; i ++ ) { ax += a ; } for ( int i = 0 ; i < qvxhzm ; i ++ ) { bx += b ; } if ( ax . compareTo ( bx ) < 0 ) { System . out . println ( ax ) ; } else { System . out . println ( bx ) ; } } } import java . util . HashMap ; import java . util . Iterator ; import java . util . Map ; import java . util . Scanner ; public class Hfinj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; try { String w = sc . nextLine ( ) ; int hfinj = w . length ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < hfinj ; i ++ ) { String s = w . substring ( i , i + 1 ) ; if ( map . containsKey ( s ) ) { map . put ( s , map . get ( s ) + 1 ) ; } else { map . put ( s , 1 ) ; } } for ( Iterator < String > iter = map . keySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { if ( map . get ( iter . next ( ) ) . intValue ( ) % 2 != 0 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } finally { sc . close ( ) ; } } } import java . util . Scanner ; public class Acenl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; sc . useDelimiter ( " \\ s " ) ; int acenl = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int d = acenl / b ; int r = acenl % b ; double A = acenl ; double B = b ; double f = A / B ; System . out . println ( d + " " + r + " " + String . format ( " %.5f " , f ) ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Gzieoi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gzieoi = sc . nextInt ( ) ; Integer [ ] a = new Integer [ gzieoi ] ; for ( int i = 0 ; i < gzieoi ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( a , Collections . reverseOrder ( ) ) ; int A = a [ 0 ] , B = 0 ; for ( int i = 1 ; i < gzieoi ; i ++ ) { if ( i % 2 == 0 ) { A += a [ i ] ; } else { B += a [ i ] ; } } System . out . println ( A - B ) ; } } import java . util . Scanner ; public class Voolcnx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int voolcnx = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; sc . close ( ) ; if ( voolcnx * b >= voolcnx + b && voolcnx * b >= voolcnx - b ) { System . out . println ( voolcnx * b ) ; } else if ( voolcnx + b >= voolcnx - b && voolcnx + b >= voolcnx * b ) { System . out . println ( voolcnx + b ) ; } else { System . out . println ( voolcnx - b ) ; } } } import java . util . Scanner ; public class Lonnyer { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; scan . close ( ) ; boolean lonnyer = true ; if ( S . charAt ( 2 ) != S . charAt ( 3 ) ) lonnyer = false ; else if ( S . charAt ( 4 ) != S . charAt ( 5 ) ) lonnyer = false ; if ( lonnyer ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Bihot { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long bihot = sc . nextLong ( ) ; long sum = 0 ; for ( int a = 1 ; a <= bihot ; ++ a ) { for ( int b = 1 ; b <= bihot ; ++ b ) { long g1 = findGcd ( a , b ) ; for ( int c = 1 ; c <= bihot ; ++ c ) { long g2 = findGcd ( g1 , c ) ; sum += g2 ; } } } System . out . println ( sum ) ; } public static long findGcd ( long a , long b ) { if ( b == 0L ) { return a ; } return findGcd ( b , a % b ) ; } } import java . util . Scanner ; public class Mwqozf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mwqozf = sc . nextInt ( ) ; int [ ] [ ] A = new int [ 2 ] [ mwqozf ] ; for ( int i = 0 ; i < mwqozf ; i ++ ) { A [ 0 ] [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < mwqozf ; i ++ ) { A [ 1 ] [ i ] = sc . nextInt ( ) ; } int ans ; int tempofans = 0 ; int num = 0 ; for ( int k = 0 ; k < mwqozf ; k ++ ) { num = 0 ; for ( int j = 0 ; j < mwqozf ; j ++ ) { if ( j <= k ) { num += A [ 0 ] [ j ] ; } if ( j >= k ) { num += A [ 1 ] [ j ] ; } } if ( num > tempofans ) { tempofans = num ; } } ans = tempofans ; System . out . println ( ans ) ; } } import java . util . * ; public class Cqcnec { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cqcnec = sc . nextInt ( ) ; int xx = 0 ; int yy = 0 ; int time = 0 ; for ( int i = 0 ; i < cqcnec ; i ++ ) { int t = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int d = Math . abs ( x - xx ) + Math . abs ( y - yy ) ; int spent = t - time ; if ( d > spent || ( spent - d ) % 2 != 0 ) { System . out . println ( " No " ) ; return ; } xx = x ; yy = y ; time = t ; } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Sgccrw { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final String color1 = sc . next ( ) ; final String color2 = sc . next ( ) ; int sgccrw = sc . nextInt ( ) ; int color2_n = sc . nextInt ( ) ; final String target = sc . next ( ) ; if ( target . equals ( color1 ) ) { sgccrw -- ; } else if ( target . equals ( color2 ) ) { color2_n -- ; } System . out . println ( sgccrw + " " + color2_n ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Sqfli { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sqfli = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; sc . close ( ) ; int C = 1 ; int D = 0 ; while ( B > C ) { C += sqfli - 1 ; D ++ ; } System . out . println ( D ) ; } } import java . util . Scanner ; public class Zzbooh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zzbooh = sc . nextInt ( ) ; int [ ] l = new int [ zzbooh ] ; for ( int i = 0 ; i < zzbooh ; i ++ ) { l [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int max = 0 ; int sum = 0 ; for ( int i = 0 ; i < zzbooh ; i ++ ) { if ( max < l [ i ] ) { max = l [ i ] ; } sum += l [ i ] ; } if ( sum - 2 * max > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . math . * ; public class Yjtng { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yjtng = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int tap = 1 ; int atap = 0 ; while ( tap < b ) { tap -- ; tap += yjtng ; atap ++ ; } System . out . println ( atap ) ; } } import java . io . * ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . * ; import java . io . * ; class Lzkeotl { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int lzkeotl = Integer . parseInt ( str [ 0 ] ) ; int y = Integer . parseInt ( str [ 1 ] ) ; System . out . println ( lzkeotl * y + " " + ( 2 * lzkeotl + 2 * y ) ) ; } } import java . io . Closeable ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . NoSuchElementException ; import java . util . Scanner ; public class Ioupv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ioupv = 0 ; long A = Long . parseLong ( sc . next ( ) ) ; long B = Long . parseLong ( sc . next ( ) ) ; long C = Long . parseLong ( sc . next ( ) ) ; long D = Long . parseLong ( sc . next ( ) ) ; int [ ] g = new int [ 100 ] ; for ( int i = ( int ) A ; i < ( int ) B ; i ++ ) { g [ i ] ++ ; } for ( int i = ( int ) C ; i < ( int ) D ; i ++ ) { g [ i ] ++ ; } for ( int i = 0 ; i < 100 ; i ++ ) { if ( g [ i ] == 2 ) ioupv ++ ; } System . out . print ( ioupv ) ; System . out . println ( ) ; } } import java . util . Scanner ; public class Lymolqo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; int lymolqo = Integer . parseInt ( line ) ; String result = " No " ; for ( int i = 1 ; i <= 9 ; i ++ ) { for ( int j = 1 ; j <= 9 ; j ++ ) { int tmp = i * j ; if ( lymolqo == tmp ) { result = " Yes " ; } } } System . out . println ( result ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Kolfjl { public static void main ( String [ ] args ) throws Exception { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int kolfjl = Integer . parseInt ( reader . readLine ( ) ) ; String [ ] array = reader . readLine ( ) . split ( " " ) ; int [ ] H = new int [ kolfjl ] ; for ( int i = 0 ; i < kolfjl ; i ++ ) { H [ i ] = Integer . parseInt ( array [ i ] ) ; } boolean ret = true ; for ( int i = kolfjl - 1 ; i > 0 ; i -- ) { if ( H [ i ] <= H [ i - 1 ] - 2 ) { ret = false ; break ; } if ( H [ i ] == H [ i - 1 ] - 1 ) { H [ i - 1 ] -- ; } } System . out . println ( ret ? " Yes " : " No " ) ; } } } import java . util . Scanner ; class Dcozymo { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int dcozymo = 1 ; while ( true ) { String str = input . nextLine ( ) ; if ( ! str . equals ( " 0 " ) ) { System . out . println ( " Case " + dcozymo + " : " + str ) ; dcozymo = dcozymo + 1 ; } else { break ; } } } } import java . util . Scanner ; public class Qdgqth { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qdgqth = Integer . parseInt ( sc . next ( ) ) ; int [ ] p = new int [ qdgqth ] ; int idx ; for ( idx = 0 ; idx < qdgqth ; idx ++ ) { p [ idx ] = Integer . parseInt ( sc . next ( ) ) ; } int cnt = 0 ; for ( idx = 1 ; idx < qdgqth - 1 ; idx ++ ) { if ( p [ idx ] <= p [ idx - 1 ] ) { if ( p [ idx ] > p [ idx + 1 ] ) { ++ cnt ; } } else { if ( p [ idx ] <= p [ idx + 1 ] ) { ++ cnt ; } } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Pdghikp { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int pdghikp = in . nextInt ( ) ; int [ ] [ ] A = new int [ 2 ] [ pdghikp ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < pdghikp ; j ++ ) { A [ i ] [ j ] = in . nextInt ( ) ; } } int ans = 0 ; for ( int i = 0 ; i < pdghikp ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j <= i ; j ++ ) { sum += A [ 0 ] [ j ] ; } for ( int j = i ; j < pdghikp ; j ++ ) { sum += A [ 1 ] [ j ] ; } ans = Math . max ( ans , sum ) ; } System . out . println ( ans ) ; in . close ( ) ; } } import java . util . * ; public class Mthsa { public static Scanner in = new Scanner ( System . in ) ; public static int mthsa = 0 , k = 2 ; public static int [ ] h = new int [ 100001 ] ; public static long [ ] dp = new long [ 100001 ] ; public final static long oo = 10000000000l ; public static long solve ( int idx ) { if ( idx == mthsa - 1 ) { return 0 ; } else { if ( dp [ idx ] == - 1 ) { long c1 = solve ( idx + 1 ) + Math . abs ( h [ idx ] - h [ idx + 1 ] ) ; long c2 = oo ; if ( mthsa - idx > 2 ) { c2 = solve ( idx + 2 ) + Math . abs ( h [ idx ] - h [ idx + 2 ] ) ; } return dp [ idx ] = Math . min ( c1 , c2 ) ; } else { return dp [ idx ] ; } } } public static void main ( String [ ] args ) { for ( int i = 0 ; i < 100001 ; i ++ ) { dp [ i ] = - 1 ; } mthsa = in . nextInt ( ) ; for ( int i = 0 ; i < mthsa ; i ++ ) { h [ i ] = in . nextInt ( ) ; } System . out . println ( solve ( 0 ) ) ; } } import java . util . * ; public class Ybzdq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ybzdq = sc . nextInt ( ) ; String [ ] S = new String [ ybzdq ] ; for ( int i = 0 ; i < ybzdq ; ++ i ) { S [ i ] = sc . next ( ) ; } int [ ] C = new int [ 4 ] ; for ( int i = 0 ; i < ybzdq ; ++ i ) { if ( S [ i ] . equals ( " AC " ) ) { C [ 0 ] ++ ; } else if ( S [ i ] . equals ( " WA " ) ) { C [ 1 ] ++ ; } else if ( S [ i ] . equals ( " TLE " ) ) { C [ 2 ] ++ ; } else if ( S [ i ] . equals ( " RE " ) ) { C [ 3 ] ++ ; } } System . out . println ( " AC x " + C [ 0 ] ) ; System . out . println ( " WA x " + C [ 1 ] ) ; System . out . println ( " TLE x " + C [ 2 ] ) ; System . out . println ( " RE x " + C [ 3 ] ) ; } } import java . util . * ; public class Msytiqe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int msytiqe = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; sc . close ( ) ; int a = T / msytiqe ; System . out . println ( a * B ) ; } } import java . util . * ; public class Zujsly { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int zujsly = scn . nextInt ( ) ; int b = scn . nextInt ( ) ; int ans = zujsly * b ; int ans2 = 0 ; for ( int i = 0 ; i < b ; i ++ ) { ans2 += zujsly ; } System . out . println ( ans2 ) ; } } import java . util . Scanner ; class Yapuvc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String yapuvc = sc . next ( ) ; System . out . println ( yapuvc . replaceAll ( " \\ - " , " " ) . length ( ) - ( 4 - yapuvc . replaceAll ( " \\ - " , " " ) . length ( ) ) ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Cuwzaby { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cuwzaby = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; int [ ] A = new int [ cuwzaby ] ; for ( int i = 0 ; i < cuwzaby ; i ++ ) { int a = sc . nextInt ( ) ; map . put ( i , a ) ; A [ i ] = a ; } sc . close ( ) ; Arrays . sort ( A ) ; for ( int i = 0 ; i < cuwzaby ; i ++ ) { int except = map . get ( i ) ; System . out . println ( A [ cuwzaby - 1 ] == except ? A [ cuwzaby - 2 ] : A [ cuwzaby - 1 ] ) ; } } } import java . util . * ; import java . io . * ; public class Jblrbnu { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int jblrbnu = in . nextInt ( ) ; System . out . println ( Math . min ( jblrbnu * in . nextInt ( ) , in . nextInt ( ) ) ) ; } } import java . util . Scanner ; public class Ynknzz { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int ynknzz = scanner . nextInt ( ) ; int ans = 0 ; if ( ynknzz == 0 ) { ans = 1 ; } System . out . println ( ans ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class Xvgfw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xvgfw = sc . nextInt ( ) ; int [ ] nums = new int [ xvgfw ] ; for ( int i = 0 ; i < xvgfw ; i ++ ) { nums [ i ] = sc . nextInt ( ) ; } Arrays . sort ( nums ) ; int aliceSum = 0 ; int bobSum = 0 ; boolean isAliceTurn = true ; for ( int i = nums . length - 1 ; i >= 0 ; i -- ) { if ( isAliceTurn ) { aliceSum += nums [ i ] ; isAliceTurn = false ; } else { bobSum += nums [ i ] ; isAliceTurn = true ; } } System . out . println ( aliceSum - bobSum ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class Yuhpl { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int yuhpl = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( yuhpl * B ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Galbi { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . galbi ) ) ) { String galbi = br . readLine ( ) ; System . out . println ( galbi . equals ( " Sunny " ) ? " Cloudy " : galbi . equals ( " Cloudy " ) ? " Rainy " : " Sunny " ) ; } } } import java . util . * ; class Vvyxles { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vvyxles = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; System . out . println ( Math . max ( Math . min ( b , d ) - Math . max ( vvyxles , c ) , 0 ) ) ; } } import java . util . Scanner ; public class Xjkxh { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int xjkxh = 0 ; int maxCount = 0 ; int N = in . nextInt ( ) ; int actual = in . nextInt ( ) ; for ( int i = 1 ; i < N ; i ++ ) { int siguiente = in . nextInt ( ) ; if ( actual >= siguiente ) { xjkxh ++ ; } else { if ( maxCount < xjkxh ) { maxCount = xjkxh ; } xjkxh = 0 ; } actual = siguiente ; } if ( maxCount < xjkxh ) { maxCount = xjkxh ; } System . out . println ( maxCount ) ; } } import java . util . Scanner ; import java . lang . Math ; public class Ymzpmi { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int ymzpmi = sc . nextInt ( ) ; int [ ] [ ] grid = new int [ 2 ] [ ymzpmi ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < ymzpmi ; j ++ ) { grid [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] ans = new int [ 2 ] [ ymzpmi ] ; ans [ 0 ] [ 0 ] = grid [ 0 ] [ 0 ] ; ans [ 1 ] [ 0 ] = grid [ 1 ] [ 0 ] + ans [ 0 ] [ 0 ] ; for ( int j = 1 ; j < ymzpmi ; j ++ ) { ans [ 0 ] [ j ] = grid [ 0 ] [ j ] + ans [ 0 ] [ j - 1 ] ; } for ( int j = 1 ; j < ymzpmi ; j ++ ) { ans [ 1 ] [ j ] = grid [ 1 ] [ j ] + Math . max ( ans [ 1 ] [ j - 1 ] , ans [ 0 ] [ j ] ) ; } System . out . println ( ans [ 1 ] [ ymzpmi - 1 ] ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; public class Vnsqa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vnsqa = sc . nextInt ( ) ; double t = sc . nextDouble ( ) ; double a = sc . nextDouble ( ) ; double [ ] h = new double [ vnsqa ] ; double [ ] dist = new double [ vnsqa ] ; int answer = 0 ; double tmp = 10000000 ; for ( int i = 0 ; i < vnsqa ; i ++ ) { h [ i ] = sc . nextDouble ( ) ; } for ( int i = 0 ; i < vnsqa ; i ++ ) { dist [ i ] = Math . abs ( a - ( t - h [ i ] * 0.006 ) ) ; } for ( int i = 0 ; i < vnsqa ; i ++ ) { if ( tmp > dist [ i ] ) { answer = i ; tmp = dist [ i ] ; } } System . out . println ( answer + 1 ) ; } } import java . util . * ; public class Cizvv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cizvv = sc . nextInt ( ) ; int x = 0 ; while ( true ) { if ( cizvv <= 1000 ) { x = 1000 - cizvv ; break ; } else { cizvv = cizvv - 1000 ; } } System . out . println ( x ) ; } } import java . util . * ; public class Yqyxuu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String yqyxuu = sc . next ( ) ; String [ ] str2 = yqyxuu . split ( " " ) ; if ( " 7 " . equals ( str2 [ 0 ] ) || " 7 " . equals ( str2 [ 1 ] ) || " 7 " . equals ( str2 [ 2 ] ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Itsvqa { public static void main ( String [ ] args ) { try { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String a = reader . readLine ( ) ; String [ ] b = a . split ( " " ) ; int itsvqa = Integer . parseInt ( b [ 0 ] ) ; int d = Integer . parseInt ( b [ 1 ] ) ; String [ ] e = new String [ d ] ; int [ ] [ ] f = new int [ itsvqa ] [ d ] ; for ( int g = 0 ; g < itsvqa ; g ++ ) { a = reader . readLine ( ) ; e = a . split ( " " ) ; for ( int h = 0 ; h < d ; h ++ ) { f [ g ] [ h ] = Integer . parseInt ( e [ h ] ) ; } } int [ ] i = new int [ d ] ; for ( int j = 0 ; j < d ; j ++ ) { a = reader . readLine ( ) ; i [ j ] = Integer . parseInt ( a ) ; } int k = 0 ; for ( int l = 0 ; l < itsvqa ; l ++ ) { for ( int m = 0 ; m < d ; m ++ ) { k += f [ l ] [ m ] * i [ m ] ; } System . out . println ( k ) ; k = 0 ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . io . * ; class Bckaz { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; while ( true ) { String [ ] line = br . readLine ( ) . split ( " " ) ; int bckaz = Integer . parseInt ( line [ 0 ] ) ; int y = Integer . parseInt ( line [ 1 ] ) ; if ( bckaz == 0 && y == 0 ) { break ; } else { sb . append ( Integer . toString ( bckaz < y ? bckaz : y ) ) . append ( " " ) . append ( Integer . toString ( bckaz < y ? y : bckaz ) ) . append ( " \n " ) ; } } System . out . print ( sb ) ; } } import java . util . Scanner ; public class Uomrl { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uomrl = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; if ( k <= uomrl + b ) { if ( k >= uomrl ) { System . out . println ( uomrl ) ; } else { System . out . println ( k ) ; } } else { System . out . println ( uomrl - ( k - uomrl - b ) ) ; } sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Ambgyiv { public static void main ( String [ ] args ) { Scanner inData = new Scanner ( System . in ) ; int ambgyiv = inData . nextInt ( ) ; int K = inData . nextInt ( ) ; int [ ] P = new int [ ambgyiv ] ; for ( int i = 0 ; i < ambgyiv ; i ++ ) P [ i ] = inData . nextInt ( ) ; Arrays . sort ( P ) ; int kin = 0 ; for ( int i = 0 ; i < K ; i ++ ) { kin += P [ i ] ; } System . out . println ( kin ) ; inData . close ( ) ; } } import java . io . * ; import java . util . Scanner ; public class Kvdaqg { public static void main ( String [ ] args ) { try { int kvdaqg ; int paper ; Scanner scan = new Scanner ( System . in ) ; String N = scan . next ( ) ; kvdaqg = Integer . parseInt ( N ) ; if ( kvdaqg % 2 == 0 ) { paper = kvdaqg / 2 ; } else { paper = kvdaqg / 2 + 1 ; } System . out . println ( paper ) ; } catch ( Exception e ) { System . out . println ( " error " ) ; } } } import java . util . Scanner ; public class Qaihmg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( ( System . in ) ) ; int qaihmg = sc . nextInt ( ) ; int [ ] a = new int [ qaihmg ] ; int ans = 0 , o = 0 , e = 0 ; for ( int i = 0 ; i < qaihmg ; i ++ ) { int x = sc . nextInt ( ) ; if ( x % 2 == 0 ) { a [ e ] = x ; e ++ ; } else { o ++ ; } } if ( o != qaihmg ) { for ( int i = 0 ; i < e ; i ++ ) { while ( a [ i ] % 2 == 0 ) { ans ++ ; a [ i ] = a [ i ] / 2 ; } } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Myggkuf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long myggkuf = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long t = sc . nextLong ( ) ; if ( myggkuf <= x ) { System . out . println ( t ) ; return ; } long ans = 0 ; ans += ( myggkuf / x ) * t ; myggkuf %= x ; if ( myggkuf > 0 ) { ans += t ; } sc . close ( ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Zoncmll { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String a = scan . next ( ) ; char zoncmll = a . charAt ( 0 ) ; char c = a . charAt ( 1 ) ; char d = a . charAt ( 2 ) ; char f = 'R' ; if ( zoncmll == c && c == d && d == f ) { System . out . println ( " 3 " ) ; } else if ( ( zoncmll == c && c == f ) || ( c == d && d == f ) ) { System . out . println ( " 2 " ) ; } else if ( ! ( zoncmll == f || c == f || d == f ) ) { System . out . println ( " 0 " ) ; } else { System . out . println ( " 1 " ) ; } } } class Jsmbins { public static void main ( String [ ] args ) { java . util . Scanner sc = new java . util . Scanner ( System . in ) ; final int jsmbins = sc . nextInt ( ) ; final int L = sc . nextInt ( ) ; int output = 0 ; if ( - 1 <= L - 1 ) { output -= L ; } else if ( L - 1 <= - jsmbins ) { output -= L + jsmbins - 1 ; } output += jsmbins * ( L - 1 ) + jsmbins * ( jsmbins + 1 ) / 2 ; System . out . println ( output ) ; } } import java . util . * ; public class Hnuws { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hnuws = 1 ; int n = Integer . parseInt ( sc . nextLine ( ) ) ; Integer [ ] d = new Integer [ n ] ; int i = 0 ; while ( sc . hasNext ( ) ) { int val = Integer . parseInt ( sc . nextLine ( ) ) ; d [ i ] = val ; i ++ ; } Arrays . sort ( d , Comparator . reverseOrder ( ) ) ; int nowSize = d [ 0 ] ; for ( Integer size : d ) { if ( size < nowSize ) { nowSize = size ; hnuws ++ ; } } System . out . println ( hnuws ) ; } } import java . util . Scanner ; public class Rzbvc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] ary = sc . next ( ) . toCharArray ( ) ; int rzbvc = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( ary [ i ] == '+' ) { rzbvc ++ ; } else { rzbvc -- ; } } sc . close ( ) ; System . out . println ( rzbvc ) ; } } import java . util . Scanner ; public class Jcpepph { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; String W = scn . nextLine ( ) ; int jcpepph = 0 ; final String LAST_DATA = " END_OF_TEXT " ; while ( scn . hasNextLine ( ) ) { String T = scn . next ( ) ; if ( T . equals ( LAST_DATA ) ) { break ; } W = W . toLowerCase ( ) ; T = T . toLowerCase ( ) ; if ( T . equals ( W ) ) { jcpepph ++ ; } } System . out . println ( jcpepph ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Wbhsjhf { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int wbhsjhf = scanner . nextInt ( ) ; Map < String , Long > counts = new HashMap < > ( ) ; for ( int i = 0 ; i < wbhsjhf ; ++ i ) { String s = scanner . next ( ) ; char [ ] tmp = s . toCharArray ( ) ; Arrays . sort ( tmp ) ; s = new String ( tmp ) ; long count = counts . getOrDefault ( s , 0L ) ; counts . put ( s , count + 1L ) ; } long pairs = 0 ; for ( long count : counts . values ( ) ) { pairs += ( count * ( count - 1L ) / 2 ) ; } System . out . println ( pairs ) ; } } import java . util . * ; public class Wngkcdl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wngkcdl = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int [ ] point = new int [ wngkcdl ] ; Arrays . fill ( point , k - q ) ; for ( int i = 0 ; i < q ; i ++ ) { point [ Integer . parseInt ( sc . next ( ) ) - 1 ] ++ ; } for ( int i = 0 ; i < wngkcdl ; i ++ ) { if ( point [ i ] >= 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class Xpjzsrl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xpjzsrl = scan . nextInt ( ) ; System . out . println ( ( double ) ( xpjzsrl - xpjzsrl / 2 ) / ( double ) ( xpjzsrl ) ) ; } } import java . util . Scanner ; public class Rhllv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line1 = sc . nextLine ( ) ; int rhllv = Integer . parseInt ( line1 ) ; String line2 = sc . nextLine ( ) ; String [ ] kari = line2 . split ( " " ) ; int [ ] A = new int [ rhllv ] ; for ( int i = 0 ; i < rhllv ; i ++ ) { A [ i ] = Integer . parseInt ( kari [ i ] ) ; } System . out . println ( line2 ) ; int v = 0 ; int j = 0 ; for ( int i = 1 ; i < rhllv ; i ++ ) { v = A [ i ] ; j = i - 1 ; while ( j >= 0 && A [ j ] > v ) { A [ j + 1 ] = A [ j ] ; j -- ; } A [ j + 1 ] = v ; for ( int k = 0 ; k < rhllv - 1 ; k ++ ) { System . out . print ( A [ k ] ) ; System . out . print ( " " ) ; } System . out . println ( A [ rhllv - 1 ] ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Qggribb { public static void main ( String [ ] args ) throws java . lang . Exception { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; long qggribb = in . nextLong ( ) ; long b = in . nextLong ( ) ; long max = Math . max ( qggribb , b ) ; for ( long i = 0 ; i < max ; i ++ ) { if ( Math . abs ( qggribb - i ) == Math . abs ( b - i ) ) { out . println ( i ) ; out . close ( ) ; return ; } } out . println ( " IMPOSSIBLE " ) ; out . close ( ) ; } static class Qggribb { 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 ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . util . Scanner ; import java . util . Arrays ; import java . util . Deque ; import java . util . ArrayDeque ; class Wndgsp { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; Deque < Integer > stack = new ArrayDeque < > ( ) ; String [ ] line = scanner . nextLine ( ) . split ( " " ) ; int wndgsp , b ; for ( int i = 0 ; i < line . length ; i ++ ) { switch ( line [ i ] ) { case " + " : wndgsp = stack . pollLast ( ) ; b = stack . pollLast ( ) ; stack . offer ( b + wndgsp ) ; break ; case " - " : wndgsp = stack . pollLast ( ) ; b = stack . pollLast ( ) ; stack . offer ( b - wndgsp ) ; break ; case " * " : wndgsp = stack . pollLast ( ) ; b = stack . pollLast ( ) ; stack . offer ( b * wndgsp ) ; break ; default : stack . offer ( Integer . parseInt ( line [ i ] ) ) ; break ; } } System . out . println ( stack . poll ( ) ) ; } } import java . util . Scanner ; public class Bpdbtq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bpdbtq = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; while ( 0 < c && 0 < bpdbtq ) { c -= b ; if ( c <= 0 ) { break ; } bpdbtq -= d ; } if ( 0 < bpdbtq ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Xjhir { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xjhir = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int s = ( xjhir >= B ) ? xjhir : B ; int f = ( xjhir >= B ) ? B : xjhir ; long ans = s ; for ( int i = 1 ; i <= f ; i ++ ) { ans *= i ; if ( ans % f == 0 ) { System . out . println ( ans ) ; return ; } ans /= i ; } } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Xggapk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xggapk = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; while ( xggapk > 0 ) { String a = sc . next ( ) ; if ( map . containsKey ( a ) ) { map . put ( a , map . get ( a ) + 1 ) ; } else { map . put ( a , 1 ) ; } xggapk -- ; } System . out . println ( " AC x " + map . getOrDefault ( " AC " , 0 ) ) ; System . out . println ( " WA x " + map . getOrDefault ( " WA " , 0 ) ) ; System . out . println ( " TLE x " + map . getOrDefault ( " TLE " , 0 ) ) ; System . out . println ( " RE x " + map . getOrDefault ( " RE " , 0 ) ) ; } } import java . util . Scanner ; public class Xfhpxe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xfhpxe = scan . nextInt ( ) ; long total = 0 ; for ( int a = 1 ; a < xfhpxe + 1 ; a ++ ) { for ( int b = 1 ; b < xfhpxe + 1 ; b ++ ) { for ( int c = 1 ; c < xfhpxe + 1 ; c ++ ) { total += gcd ( gcd ( a , b ) , c ) ; } } } System . out . println ( total ) ; } static int gcd ( int p , int q ) { if ( p % q == 0 ) return q ; return gcd ( q , p % q ) ; } } import java . util . * ; public class Hshyxhi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] sArray = s . split ( " " ) ; List < String > acgt = Arrays . asList ( " A " , " C " , " G " , " T " ) ; int hshyxhi = 0 ; int maxCount = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( acgt . contains ( sArray [ i ] ) ) { hshyxhi ++ ; if ( hshyxhi > maxCount ) { maxCount = hshyxhi ; } } else { hshyxhi = 0 ; } } System . out . println ( maxCount ) ; } } import java . util . Scanner ; class Rqdzin { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; int rqdzin = Integer . parseInt ( s1 ) ; String s2 = sc . next ( ) ; int b = Integer . parseInt ( s2 ) ; double p = Math . pow ( 10 , 9 ) ; if ( 1 <= rqdzin && rqdzin <= p ) { if ( 1 <= b && b <= p ) { int d = rqdzin / b ; int r = rqdzin % b ; double f = ( double ) rqdzin / ( double ) b ; System . out . println ( d + " " + r + " " + String . format ( " %1$3f " , f ) ) ; } } } } import java . util . * ; class Jyxlw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jyxlw = sc . nextInt ( ) ; long [ ] A = new long [ jyxlw + 2 ] ; long [ ] B = new long [ jyxlw + 1 ] ; long cnt = 0 ; long wk = 0 ; long wk2 = 0 ; for ( int i = 0 ; i < jyxlw + 1 ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < jyxlw ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < jyxlw ; i ++ ) { wk = B [ i ] - A [ i ] ; if ( wk <= 0 ) { cnt = cnt + B [ i ] ; } else { cnt = cnt + A [ i ] ; wk2 = A [ i + 1 ] - wk ; if ( wk2 <= 0 ) { cnt = cnt + A [ i + 1 ] ; A [ i + 1 ] = 0 ; } else { A [ i + 1 ] = wk2 ; cnt = cnt + wk ; } } } System . out . print ( cnt ) ; } } import java . util . Scanner ; public class Sglqyr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int sglqyr = str . sglqyr ( ) ; for ( int i = 0 ; i < sglqyr ; i ++ ) { if ( str . charAt ( i ) == '1' ) System . out . print ( 9 ) ; else System . out . print ( 1 ) ; } } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; public class Onfndt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int onfndt = sc . nextInt ( ) ; HashSet < Integer > set = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < onfndt ; i ++ ) { int number = sc . nextInt ( ) ; set . add ( number ) ; } System . out . println ( set . size ( ) ) ; } } import java . util . Scanner ; class Hgaxcow { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String hgaxcow = sc . nextLine ( ) ; hgaxcow = hgaxcow . replaceAll ( " eraser " , " " ) ; hgaxcow = hgaxcow . replaceAll ( " erase " , " " ) ; hgaxcow = hgaxcow . replaceAll ( " dreamer " , " " ) ; hgaxcow = hgaxcow . replaceAll ( " dream " , " " ) ; if ( hgaxcow . equals ( " " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . io . IOException ; import java . util . Arrays ; import java . util . Scanner ; public class Wejsj { public static void main ( String [ ] args ) throws IOException { try ( Scanner s = new Scanner ( System . in ) ) { int wejsj = 3 ; int [ ] array = new int [ wejsj ] ; for ( int i = 0 ; i < wejsj ; i ++ ) { array [ i ] = s . nextInt ( ) ; } Arrays . sort ( array ) ; System . out . println ( ( array [ 0 ] == 5 && array [ 1 ] == 5 && array [ 2 ] == 7 ) ? " YES " : " NO " ) ; } } } import java . util . ArrayList ; import java . util . HashMap ; import java . util . Scanner ; public class Dinjb { public static void main ( String [ ] args ) { HashMap < Integer , Integer > h = new HashMap < > ( ) ; int dinjb = 0 ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { h . put ( i , 0 ) ; } for ( int i = 0 ; i < k ; i ++ ) { int d = sc . nextInt ( ) ; for ( int j = 0 ; j < d ; j ++ ) { int c = sc . nextInt ( ) ; h . put ( c , 1 ) ; } } for ( int i = 1 ; i <= n ; i ++ ) { if ( h . get ( i ) == 0 ) { dinjb ++ ; } } System . out . println ( dinjb ) ; } } import java . util . Scanner ; import java . util . InputMismatchException ; class Qaqnfd { public static void main ( String [ ] args ) { int qaqnfd = 0 , y = 0 ; int [ ] [ ] z ; Scanner scanner = new Scanner ( System . in ) ; qaqnfd = scanner . nextInt ( ) ; y = scanner . nextInt ( ) ; z = new int [ y ] [ 2 ] ; for ( int i = 0 ; i < y ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { z [ i ] [ j ] = scanner . nextInt ( ) ; } } scanner . close ( ) ; int sum = 0 ; int i , j ; int maxz = 0 ; int minz = 100001 ; for ( j = 0 ; j < y ; j ++ ) { if ( maxz < z [ j ] [ 0 ] ) { maxz = z [ j ] [ 0 ] ; } if ( minz > z [ j ] [ 1 ] ) { minz = z [ j ] [ 1 ] ; } } if ( minz - maxz > - 1 ) { System . out . println ( minz - maxz + 1 ) ; } else { System . out . println ( 0 ) ; } } } import java . util . * ; public class Hbrbxfa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hbrbxfa = sc . nextInt ( ) ; System . out . println ( hbrbxfa * 2 * 3.14 ) ; } } import java . util . * ; public class Qyzzwym { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qyzzwym = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] [ ] vectorA = new int [ qyzzwym ] [ m ] ; int [ ] vectorB = new int [ m ] ; int [ ] vectorC = new int [ qyzzwym ] ; for ( int i = 0 ; i < qyzzwym ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int elm = scan . nextInt ( ) ; vectorA [ i ] [ j ] = elm ; } } for ( int i = 0 ; i < m ; i ++ ) { int elm = scan . nextInt ( ) ; vectorB [ i ] = elm ; } for ( int i = 0 ; i < qyzzwym ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { vectorC [ i ] += vectorA [ i ] [ j ] * vectorB [ j ] ; } } for ( int i = 0 ; i < qyzzwym ; i ++ ) { System . out . println ( vectorC [ i ] ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . nio . charset . StandardCharsets ; public class Fmomp { public static void main ( String [ ] args ) throws IOException { InputStreamReader reader = new InputStreamReader ( System . in , StandardCharsets . UTF_8 ) ; BufferedReader in = new BufferedReader ( reader ) ; String s = in . readLine ( ) ; int fmomp = Integer . parseInt ( s ) ; s = in . readLine ( ) ; String [ ] as = s . split ( " " ) ; int [ ] a = new int [ fmomp ] ; for ( int i = 0 ; i < fmomp ; i ++ ) { a [ i ] = Integer . parseInt ( as [ i ] ) ; } output ( a ) ; insertionSort ( a , fmomp ) ; } private static void insertionSort ( int [ ] a , int fmomp ) { for ( int i = 1 ; i < fmomp ; i ++ ) { int v = a [ i ] ; int j = i - 1 ; while ( j >= 0 && a [ j ] > v ) { a [ j + 1 ] = a [ j ] ; j -- ; } a [ j + 1 ] = v ; output ( a ) ; } } private static void output ( int [ ] a ) { for ( int i = 0 ; i < a . length - 1 ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } System . out . println ( a [ a . length - 1 ] ) ; } } import java . util . * ; public class Rtzny { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rtzny , second ; rtzny = sc . nextInt ( ) ; second = sc . nextInt ( ) ; if ( rtzny > 0 && rtzny < 10 && second > 0 && second < 10 ) System . out . println ( rtzny * second ) ; else System . out . println ( " -1 " ) ; } } import java . util . * ; import java . io . * ; class Ipvqz { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; long ipvqz = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; long nA = Math . max ( 0 , ipvqz - K ) ; long nB = Math . max ( 0 , B - Math . max ( K - ipvqz , 0 ) ) ; System . out . println ( nA + " " + nB ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } } import java . util . * ; public class Ikykniv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ikykniv = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; String [ ] S = sc . next ( ) . split ( " - " ) ; if ( S . length == 2 ) { if ( S [ 0 ] . length ( ) == ikykniv && S [ 1 ] . length ( ) == B ) { System . out . println ( " Yes " ) ; sc . close ( ) ; System . exit ( 0 ) ; } } System . out . println ( " No " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Mknreo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mknreo ; while ( ( mknreo = scan . nextInt ( ) ) != 0 ) { int [ ] s = new int [ mknreo ] ; double m = 0 ; for ( int i = 0 ; i < mknreo ; i ++ ) { s [ i ] = scan . nextInt ( ) ; m += s [ i ] ; } m /= mknreo ; double sum = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { sum += ( s [ i ] - m ) * ( s [ i ] - m ) ; } System . out . println ( Math . sqrt ( sum / mknreo ) ) ; } } } import java . util . Scanner ; public class Bssiu { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int bssiu = in . nextInt ( ) ; int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int sum2 = 0 ; for ( int i = 1 ; i <= bssiu ; i ++ ) { int sum = sum ( i ) ; if ( sum >= A && sum <= B ) { sum2 += i ; } } System . out . println ( sum2 ) ; } } private static int sum ( int n ) { int sum = 0 ; for ( ; n > 0 ; ) { sum += n % 10 ; n /= 10 ; } return sum ; } } import java . util . * ; public class Jofyshj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < > ( ) ; list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; list . add ( sc . nextInt ( ) ) ; Collections . sort ( list ) ; System . out . println ( list . get ( 2 ) - list . get ( 0 ) ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; class Hdwktf { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int hdwktf = 0 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String w = " " ; String line = " " ; while ( ( line = br . readLine ( ) ) != null ) { if ( w . isEmpty ( ) ) { w = line . toLowerCase ( ) ; continue ; } if ( " END_OF_TEXT " . equals ( line ) ) { break ; } String [ ] words = line . split ( " " ) ; for ( int i = 0 ; i < words . length ; i ++ ) { if ( w . equals ( words [ i ] . toLowerCase ( ) ) ) { hdwktf ++ ; } } } System . out . println ( hdwktf ) ; } } import java . util . Scanner ; public class Vbfdm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vbfdm = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] ACs = new int [ vbfdm + 1 ] ; int [ ] WAs = new int [ vbfdm + 1 ] ; for ( int i = 0 ; i < vbfdm + 1 ; i ++ ) { ACs [ i ] = 0 ; WAs [ i ] = 0 ; } for ( int i = 1 ; i <= m ; i ++ ) { int p = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( s . equals ( " AC " ) && ACs [ p ] == 0 ) { ACs [ p ] ++ ; } else if ( s . equals ( " WA " ) && ACs [ p ] == 0 ) { WAs [ p ] ++ ; } } int sumAC = 0 ; int sumWA = 0 ; for ( int i = 1 ; i <= vbfdm ; i ++ ) { sumAC += ACs [ i ] ; if ( ACs [ i ] == 1 ) { sumWA += WAs [ i ] ; } } System . out . println ( sumAC ) ; System . out . println ( sumWA ) ; } } import java . util . * ; import java . io . * ; class Thnlk { public static void main ( String [ ] args ) { int thnlk , l , m , n , q , i , j , count = 0 ; int [ ] s = new int [ 1000000 ] ; int [ ] t = new int [ 1000000 ] ; Scanner scan = new Scanner ( System . in ) ; n = scan . nextInt ( ) ; for ( i = 0 ; i < n ; i ++ ) { s [ i ] = scan . nextInt ( ) ; } q = scan . nextInt ( ) ; for ( j = 0 ; j < q ; j ++ ) { t [ j ] = scan . nextInt ( ) ; } for ( j = 0 ; j < q ; j ++ ) { thnlk = n ; l = 0 ; m = n / 2 ; while ( true ) { if ( s [ m ] == t [ j ] ) { count ++ ; break ; } if ( m == l ) { break ; } if ( s [ m ] > t [ j ] ) { thnlk = m ; m = ( thnlk + l ) / 2 ; } if ( s [ m ] < t [ j ] ) { l = m + 1 ; m = ( thnlk + l ) / 2 ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Shnrvdk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long shnrvdk = Long . parseLong ( sc . next ( ) ) ; long b = Long . parseLong ( sc . next ( ) ) ; long k = Long . parseLong ( sc . next ( ) ) ; long resultA = shnrvdk - k ; long resultB = b ; if ( resultA < 0 ) { resultB = Math . max ( b + resultA , 0 ) ; resultA = 0 ; } System . out . println ( resultA + " " + resultB ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; public class Jtjzyb { private static int [ ] heights ; private static int jtjzyb , ans = Integer . MAX_VALUE , k ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; jtjzyb = sc . nextInt ( ) ; k = sc . nextInt ( ) ; heights = new int [ jtjzyb + 3 ] ; dp = new int [ jtjzyb + 3 ] ; for ( int i = 1 ; i <= jtjzyb ; i ++ ) { heights [ i ] = sc . nextInt ( ) ; } Arrays . fill ( dp , - 1 ) ; System . out . println ( findJumpCost ( 1 ) ) ; sc . close ( ) ; } private static int [ ] dp ; private static int findJumpCost ( int ind ) { if ( ind == jtjzyb ) return 0 ; if ( dp [ ind ] != - 1 ) { return dp [ ind ] ; } int min = Integer . MAX_VALUE ; for ( int i = ind + 1 ; i <= Math . min ( jtjzyb , ind + k ) ; i ++ ) { min = Math . min ( min , Math . abs ( heights [ i ] - heights [ ind ] ) + findJumpCost ( i ) ) ; } return dp [ ind ] = min ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Garywst { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String garywst = " No " ; String inStr = br . readLine ( ) ; String target = br . readLine ( ) ; String ring = inStr + inStr ; if ( inStr . length ( ) >= target . length ( ) ) { if ( ring . indexOf ( target ) != - 1 ) garywst = " Yes " ; } System . out . println ( garywst ) ; } } } import java . io . * ; class Icroc { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int icroc = Integer . parseInt ( buf . readLine ( ) ) ; String [ ] str ; int tarou = 0 ; int hanako = 0 ; for ( int i = 0 ; i < icroc ; i ++ ) { str = buf . readLine ( ) . split ( " " ) ; if ( str [ 0 ] . compareTo ( str [ 1 ] ) > 0 ) tarou += 3 ; else if ( str [ 0 ] . compareTo ( str [ 1 ] ) < 0 ) hanako += 3 ; else { tarou ++ ; hanako ++ ; } } System . out . println ( tarou + " " + hanako ) ; } } import java . util . * ; public class Efwrea { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] T = new int [ 5 ] ; int [ ] D = new int [ 5 ] ; for ( int efwrea = 0 ; efwrea < 5 ; efwrea ++ ) { T [ efwrea ] = sc . nextInt ( ) ; } int sum = 0 ; for ( int efwrea = 0 ; efwrea < 5 ; efwrea ++ ) { if ( T [ efwrea ] % 10 == 0 ) { D [ efwrea ] = T [ efwrea ] ; } else { D [ efwrea ] = ( T [ efwrea ] / 10 ) * 10 + 10 ; } } int max = 0 ; for ( int efwrea = 0 ; efwrea < 5 ; efwrea ++ ) { if ( ( D [ efwrea ] - T [ efwrea ] ) > max ) { max = D [ efwrea ] - T [ efwrea ] ; } sum = sum + D [ efwrea ] ; } System . out . println ( sum - max ) ; } } import java . util . Scanner ; public class Txsnxic { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int txsnxic = s . nextInt ( ) ; int [ ] a = new int [ txsnxic ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = 0 ; } for ( int i = 0 ; i < txsnxic - 1 ; i ++ ) { a [ s . nextInt ( ) - 1 ] ++ ; } for ( int i : a ) { System . out . println ( i ) ; } } } import java . util . * ; public class Bgjfm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int bgjfm = 1000000000 ; int sum = 0 ; for ( int i = 0 ; i < s . length ( ) - ( t . length ( ) - 1 ) ; i ++ ) { sum = 0 ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( i + j ) != t . charAt ( j ) ) sum ++ ; } bgjfm = Math . bgjfm ( bgjfm , sum ) ; } System . out . println ( bgjfm ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; class Gzznxu { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int gzznxu = scanner . nextInt ( ) ; List < Integer > numList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < gzznxu ; i ++ ) { numList . add ( scanner . nextInt ( ) ) ; } scanner . close ( ) ; int flag = 1 ; int c = 0 ; while ( flag == 1 ) { flag = 0 ; for ( int j = gzznxu - 1 ; j >= 1 ; j -- ) { if ( numList . get ( j ) < numList . get ( j - 1 ) ) { numList . add ( j - 1 , numList . get ( j ) ) ; numList . remove ( j + 1 ) ; c ++ ; flag = 1 ; } } } for ( int i = 0 ; i < gzznxu ; i ++ ) { System . out . print ( numList . get ( i ) ) ; if ( i < gzznxu - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; System . out . println ( c ) ; } } import java . util . Scanner ; public class Wxtxq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wxtxq = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ wxtxq ] ; int [ ] b = new int [ wxtxq ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ sc . nextInt ( ) - 1 ] ++ ; b [ sc . nextInt ( ) - 1 ] ++ ; } sc . close ( ) ; for ( int i = 0 ; i < wxtxq ; i ++ ) { System . out . println ( a [ i ] + b [ i ] ) ; } } } import java . util . Scanner ; public class Fwylkjt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String s1 = s + s ; char [ ] s1str = s1 . toCharArray ( ) ; String p = sc . nextLine ( ) ; char [ ] pstr = p . toCharArray ( ) ; boolean fwylkjt = false ; String msg = " No " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { for ( int l = 0 ; l < p . length ( ) ; l ++ ) { if ( s1str [ i + l ] != pstr [ l ] ) { fwylkjt = false ; break ; } fwylkjt = true ; } if ( fwylkjt == true ) { msg = " Yes " ; break ; } } System . out . println ( msg ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class Yxiiaqh { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; long yxiiaqh = stdIn . nextLong ( ) ; double b = stdIn . nextDouble ( ) ; BigDecimal bd1 = BigDecimal . valueOf ( yxiiaqh ) ; BigDecimal bd2 = BigDecimal . valueOf ( b ) ; BigDecimal ans = bd1 . multiply ( bd2 ) . setScale ( 0 , BigDecimal . ROUND_DOWN ) ; System . out . println ( ans ) ; } } import java . util . * ; class Mmytv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mmytv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . printf ( " %d " , c ) ; System . out . printf ( " %d " , mmytv ) ; System . out . print ( b ) ; } } import java . util . LinkedList ; import java . util . Scanner ; public class Cuxgo { public static void main ( String [ ] args ) { solve ( ) ; } private static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; sc . close ( ) ; String [ ] items = line . split ( " " ) ; Stack stack = new Stack ( ) ; int cuxgo ; int op2 ; for ( String item : items ) { switch ( item ) { case " + " : op2 = stack . pop ( ) ; cuxgo = stack . pop ( ) ; stack . push ( cuxgo + op2 ) ; break ; case " - " : op2 = stack . pop ( ) ; cuxgo = stack . pop ( ) ; stack . push ( cuxgo - op2 ) ; break ; case " * " : op2 = stack . pop ( ) ; cuxgo = stack . pop ( ) ; stack . push ( cuxgo * op2 ) ; break ; default : stack . push ( Integer . parseInt ( item ) ) ; } } System . out . println ( stack . pop ( ) ) ; } } class Cuxgo { private LinkedList < Integer > stack ; public Stack ( ) { stack = new LinkedList < Integer > ( ) ; } public void push ( int item ) { stack . addLast ( item ) ; } public int pop ( ) { int ret = stack . getLast ( ) ; stack . removeLast ( ) ; return ret ; } } import java . util . * ; public class Rjtufe { public static void main ( String [ ] args ) { boolean rjtufe = false ; Scanner sc = new Scanner ( System . in ) ; Integer x = sc . nextInt ( ) ; String y = sc . next ( ) ; if ( x % 2 == 0 ) { String firstHalf = y . substring ( 0 , y . length ( ) / 2 ) ; String secondHalf = y . substring ( y . length ( ) / 2 , y . length ( ) ) ; if ( firstHalf . equals ( secondHalf ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . io . IOException ; import java . util . Scanner ; public class Zrcdaw { static class Zrcdaw { public void find ( int perimeter , int [ ] arr ) { arr [ arr . length - 1 ] = perimeter ; int zrcdaw = Integer . MAX_VALUE ; int antiClock = ( arr [ 0 ] + perimeter ) % perimeter ; zrcdaw = Math . min ( zrcdaw , perimeter - ( perimeter - arr [ arr . length - 2 ] ) - antiClock ) ; zrcdaw = Math . min ( zrcdaw , perimeter - ( arr [ 1 ] - arr [ 0 ] ) ) ; for ( int i = 1 ; i < arr . length - 1 ; i ++ ) { zrcdaw = Math . min ( zrcdaw , perimeter - ( arr [ i + 1 ] - arr [ i ] ) ) ; zrcdaw = Math . min ( zrcdaw , perimeter - ( arr [ i ] - arr [ i - 1 ] ) ) ; } System . out . println ( zrcdaw ) ; } } public static void main ( String [ ] args ) throws IOException { Solution sol = new Solution ( ) ; Scanner sc = new Scanner ( System . in ) ; int perimeter = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } sol . find ( perimeter , arr ) ; } } import java . util . * ; import java . util . Collections ; public class Lnozihw { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int lnozihw = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; String [ ] A = new String [ lnozihw ] ; for ( int i = 0 ; i < lnozihw ; i ++ ) { A [ i ] = sc . next ( ) ; } Arrays . sort ( A ) ; StringBuilder B = new StringBuilder ( ) ; for ( int i = 0 ; i < A . length ; i ++ ) { B . append ( A [ i ] ) ; } System . out . println ( B ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Jsgzcpy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] [ ] rooms = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int jsgzcpy = 0 ; jsgzcpy < 4 ; jsgzcpy ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { rooms [ jsgzcpy ] [ j ] [ k ] = 0 ; } } } int n = sc . nextInt ( ) ; for ( int jsgzcpy = 0 ; jsgzcpy < n ; jsgzcpy ++ ) { int b = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int v = sc . nextInt ( ) ; rooms [ b - 1 ] [ f - 1 ] [ r - 1 ] += v ; } for ( int jsgzcpy = 0 ; jsgzcpy < 4 ; jsgzcpy ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { System . out . print ( " " + rooms [ jsgzcpy ] [ j ] [ k ] ) ; } System . out . println ( " " ) ; } if ( jsgzcpy < 3 ) { System . out . println ( " #################### " ) ; } } sc . close ( ) ; } } import java . util . Scanner ; class Oddnjl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int oddnjl = Integer . parseInt ( scan . next ( ) ) ; int a = Integer . parseInt ( scan . next ( ) ) ; int b = Integer . parseInt ( scan . next ( ) ) ; int sum = 0 ; for ( int i = 1 ; i < oddnjl + 1 ; i ++ ) { int c = 0 ; int j = i ; while ( true ) { if ( j / 10 != 0 ) { c += j % 10 ; j = j / 10 ; } else { c += j % 10 ; if ( c >= a && c <= b ) { sum += i ; } break ; } } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Fwqiq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fwqiq = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int num = fwqiq / a ; int amari = fwqiq % a ; System . out . println ( amari == 0 ? num : num + 1 ) ; } } import java . util . Scanner ; public class Mgxytyp { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { String mgxytyp = scanner . nextLine ( ) ; System . out . println ( " 2018/01/ " + mgxytyp . split ( " / " ) [ 2 ] ) ; } } } import java . util . * ; public class Ymtekzk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ymtekzk = sc . nextInt ( ) ; int ans = 0 ; int count = 0 ; if ( ymtekzk < 105 ) { System . out . println ( 0 ) ; return ; } for ( int i = 105 ; i <= ymtekzk ; i ++ ) { if ( i % 2 == 0 ) { continue ; } count = 0 ; for ( int j = 1 ; j <= i ; j ++ ) { if ( i % j == 0 ) { count ++ ; } } if ( count == 8 ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Apznozx { public static void main ( String ... args ) { Scanner in = new Scanner ( System . in ) ; int apznozx = in . nextInt ( ) ; int k = in . nextInt ( ) ; int q = in . nextInt ( ) ; int [ ] poinst = new int [ apznozx ] ; for ( int i = 0 ; i < poinst . length ; i ++ ) { poinst [ i ] = k - q ; } for ( int i = 0 ; i < q ; i ++ ) { int a = in . nextInt ( ) ; poinst [ a - 1 ] = poinst [ a - 1 ] + 1 ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < poinst . length ; i ++ ) { if ( poinst [ i ] > 0 ) { sb . append ( " Yes " + System . lineSeparator ( ) ) ; } else { sb . append ( " No " + System . lineSeparator ( ) ) ; } } System . out . print ( sb . toString ( ) ) ; } } import java . util . Scanner ; public class Ujxmsfj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ujxmsfj = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) ujxmsfj += sc . nextInt ( ) ; System . out . println ( ujxmsfj < 22 ? " win " : " bust " ) ; } } import java . util . * ; public class Kkhzz { public static void main ( String [ ] args ) { solve_148_A ( ) ; return ; } private static void solve_148_A ( ) { Scanner sc = new Scanner ( System . in ) ; int kkhzz = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C ; C = ( 6 - kkhzz - B ) ; System . out . println ( C ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class Cfjzb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cfjzb = sc . nextInt ( ) ; HashSet < Long > hs = new HashSet < > ( ) ; for ( int i = 0 ; i < cfjzb ; i ++ ) { hs . add ( sc . nextLong ( ) ) ; } String ans = hs . size ( ) == cfjzb ? " YES " : " NO " ; out ( ans ) ; } static long gcd ( long a , long b ) { return ( b == 0 ) ? a : gcd ( b , a % b ) ; } static int gcd ( int a , int b ) { return ( b == 0 ) ? a : gcd ( b , a % b ) ; } static void out ( String info ) { System . out . println ( info ) ; } static void out ( int info ) { System . out . println ( info ) ; } static void out ( double info ) { System . out . println ( info ) ; } static void out ( long info ) { System . out . println ( info ) ; } } import java . util . Scanner ; public class Aiwckqp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aiwckqp = Integer . parseInt ( sc . next ( ) ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int sumA = A * aiwckqp ; System . out . println ( ( sumA >= B ? B : sumA ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Retff { static boolean binary_search ( int x , int [ ] data ) { int retff = 0 , right = data . length ; while ( true ) { int mid = ( retff + right ) / 2 ; if ( retff > right ) return false ; if ( data [ mid ] == x ) { return true ; } else if ( data [ mid ] < x ) { retff = mid + 1 ; } else { right = mid - 1 ; } } } public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] s = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { s [ i ] = scanner . nextInt ( ) ; } int q = scanner . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < q ; ++ i ) { int t = scanner . nextInt ( ) ; if ( binary_search ( t , s ) ) ++ cnt ; } System . out . println ( cnt ) ; } } import java . util . * ; import java . io . * ; public class Bgmgw { public static void main ( String [ ] args ) throws Exception { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int bgmgw = in . nextInt ( ) ; int W = in . nextInt ( ) ; System . out . println ( W >= bgmgw ? " unsafe " : " safe " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Dmjowd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dmjowd = sc . nextInt ( ) ; ArrayList < Integer > Array = new ArrayList < Integer > ( ) ; for ( int i = 1 ; i < 10 ; i ++ ) { for ( int j = 1 ; j < 10 ; j ++ ) { Array . add ( i * j ) ; } } if ( Array . contains ( dmjowd ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . io . * ; class Olgxp { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String olgxp = br . readLine ( ) ; String p = br . readLine ( ) ; olgxp = olgxp + olgxp ; if ( olgxp . equals ( " " ) || p . equals ( " " ) ) System . exit ( 0 ) ; if ( olgxp . indexOf ( p ) != - 1 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } catch ( Exception e ) { System . err . println ( e ) ; } } } import java . util . * ; class Tdkytjs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tdkytjs = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; for ( int i = 0 ; i <= tdkytjs ; i ++ ) { int x = i * 10000 ; if ( x > Y ) break ; for ( int j = 0 ; j <= tdkytjs - i ; j ++ ) { int y = j * 5000 ; if ( ( x + y ) > Y ) break ; if ( ( Y - x - y ) / 1000 == ( tdkytjs - i - j ) ) { System . out . println ( i + " " + j + " " + ( Y - x - y ) / 1000 ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . util . Scanner ; public class Qslxl { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; int qslxl = Integer . parseInt ( std . next ( ) ) ; int [ ] line = new int [ qslxl ] ; int temp = 0 ; int exchange = 0 ; for ( int i = 0 ; i < qslxl ; i ++ ) { line [ i ] = Integer . parseInt ( std . next ( ) ) ; } boolean flag = true ; while ( flag ) { flag = false ; for ( int j = ( qslxl - 1 ) ; j > 0 ; j -- ) { if ( line [ j ] < line [ j - 1 ] ) { temp = line [ j ] ; line [ j ] = line [ j - 1 ] ; line [ j - 1 ] = temp ; exchange ++ ; flag = true ; } } } String outsd = Integer . toString ( line [ 0 ] ) ; for ( int i = 1 ; i < qslxl ; i ++ ) { outsd += " " + line [ i ] ; } System . out . println ( outsd ) ; System . out . println ( exchange ) ; } } import java . util . Scanner ; public class Ycgfus { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ycgfus = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; String S = sc . next ( ) ; String substring = S . substring ( K - 1 , K ) ; String lower = substring . toLowerCase ( ) ; String front = S . substring ( 0 , K - 1 ) ; String back = S . substring ( K , ycgfus ) ; System . out . println ( front + lower + back ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Shevv { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str ; long [ ] ans = new long [ 2 ] ; while ( ( str = br . readLine ( ) ) != null ) { String [ ] aa = str . split ( " " ) ; long [ ] a = new long [ aa . length ] ; for ( int shevv = 0 ; shevv < aa . length ; shevv ++ ) { a [ shevv ] = Long . parseLong ( aa [ shevv ] ) ; } ans [ 0 ] = gcd ( a [ 0 ] , a [ 1 ] ) ; ans [ 1 ] = ( a [ 0 ] / ans [ 0 ] ) * a [ 1 ] ; System . out . printf ( " %d %d \n " , ans [ 0 ] , ans [ 1 ] ) ; } } static long gcd ( long a , long b ) { if ( b > 0 ) { return gcd ( b , a % b ) ; } else { return a ; } } } import java . util . Scanner ; public class Kkvbck { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kkvbck = Integer . parseInt ( scan . next ( ) ) ; int T = Integer . parseInt ( scan . next ( ) ) ; int A = Integer . parseInt ( scan . next ( ) ) ; int H ; int temp ; int res = 0 ; int cc = 1000000000 ; int i = 0 ; for ( i = 1 ; i <= kkvbck ; i ++ ) { H = Integer . parseInt ( scan . next ( ) ) ; temp = T * 1000 - H * 6 - A * 1000 ; if ( temp < 0 ) temp = - temp ; if ( temp < cc ) { cc = temp ; res = i ; } } System . out . println ( res ) ; } } import java . util . Scanner ; public class Kidoi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int kidoi = sc . nextInt ( ) ; if ( kidoi == 0 ) { break ; } double [ ] s = new double [ kidoi ] ; double sum = 0 ; for ( int i = 0 ; i < kidoi ; i ++ ) { s [ i ] = sc . nextDouble ( ) ; sum += s [ i ] ; } double average = sum / kidoi ; double res = 0 ; for ( int i = 0 ; i < kidoi ; i ++ ) { res += Math . pow ( s [ i ] - average , 2 ) / kidoi ; } System . out . println ( Math . sqrt ( res ) ) ; } } } import java . util . Scanner ; public class Kaxos { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int kaxos = 0 ; for ( int i = 0 ; i < str . length ( ) ; ) { int cnt = 0 ; for ( int j = i ; j < str . length ( ) ; j ++ ) { i = j + 1 ; if ( ( str . charAt ( j ) == 'A' ) || ( str . charAt ( j ) == 'C' ) || ( str . charAt ( j ) == 'G' ) || ( str . charAt ( j ) == 'T' ) ) { cnt ++ ; } else { break ; } } kaxos = Math . kaxos ( kaxos , cnt ) ; } System . out . println ( kaxos ) ; } } import java . util . * ; public class Vtnnnej { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int vtnnnej = stdIn . nextInt ( ) ; int [ ] s = new int [ vtnnnej ] ; s [ 2 ] = vtnnnej % 10 ; vtnnnej /= 10 ; s [ 1 ] = vtnnnej % 10 ; vtnnnej /= 10 ; s [ 0 ] = vtnnnej % 10 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s [ i ] == 1 ) { s [ i ] = 9 ; } else { s [ i ] = 1 ; } } int goal = 100 * s [ 0 ] + 10 * s [ 1 ] + s [ 2 ] ; System . out . println ( goal ) ; } } import java . util . * ; import java . lang . Math ; public class Rhafg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long rhafg = sc . nextLong ( ) ; long n = ( int ) ( Math . log ( rhafg ) / Math . log ( 2 ) ) + 1 ; long ans = ( long ) Math . pow ( 2 , n ) - 1 ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Swerjl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int swerjl = scan . nextInt ( ) ; int ans = swerjl + swerjl * swerjl + swerjl * swerjl * swerjl ; System . out . print ( ans ) ; } } import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . Arrays ; import java . util . Collections ; class Kzwgvl { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; Integer [ ] mountains = new Integer [ 10 ] ; for ( int kzwgvl = 0 ; kzwgvl < 10 ; kzwgvl ++ ) { mountains [ kzwgvl ] = sc . nextInt ( ) ; } Arrays . sort ( mountains , Collections . reverseOrder ( ) ) ; StringBuilder sb = new StringBuilder ( " " ) ; for ( int kzwgvl = 0 ; kzwgvl < 3 ; kzwgvl ++ ) { sb . append ( mountains [ kzwgvl ] ) ; sb . append ( '\n' ) ; } System . out . print ( sb ) ; } } import java . util . * ; public class Teyog { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int teyog = sc . nextInt ( ) ; int [ ] array = new int [ teyog ] ; int sum = 0 ; for ( int i = 0 ; i < teyog ; i ++ ) { array [ i ] = sc . nextInt ( ) ; sum += array [ i ] ; } int sum2 = 0 ; int dif = 0 ; int min = 10000 ; for ( int i = 0 ; i < teyog ; i ++ ) { sum -= array [ i ] ; sum2 += array [ i ] ; dif = Math . abs ( sum - sum2 ) ; if ( min > dif ) { min = dif ; } } System . out . println ( min ) ; } } import java . util . * ; import java . util . stream . Collectors ; class Qqbja { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qqbja = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int result = 0 ; int lower ; int upper ; lower = Math . max ( qqbja , c ) ; upper = Math . min ( b , d ) ; if ( upper >= lower ) { result = upper - lower ; } System . out . println ( result ) ; } } import java . util . Scanner ; public class Ighck { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ighck = sc . nextInt ( ) ; sc . close ( ) ; for ( int i = ighck ; i >= 1 ; i -- ) { for ( int j = 1 ; j < 32 ; j ++ ) { for ( int j2 = 2 ; j2 < 10 ; j2 ++ ) { int a = ( int ) Math . pow ( j , j2 ) ; if ( a == i ) { System . out . println ( i ) ; return ; } } } } } } import java . util . * ; public class Mhtuw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mhtuw = sc . nextLong ( ) ; long ans = 100 ; for ( long i = 1 ; i * i <= mhtuw ; i ++ ) { if ( mhtuw % i == 0 ) { ans = Math . min ( ans , getDigits ( mhtuw / i ) ) ; } } System . out . println ( ans ) ; sc . close ( ) ; } static int getDigits ( long x ) { int ans = 0 ; while ( x > 0 ) { x /= 10 ; ans ++ ; } return ans ; } } import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Boanzkp { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { final String s = reader . readLine ( ) ; int boanzkp = Integer . parseInt ( s ) ; boolean flg = false ; for ( int i = 0 ; i <= boanzkp ; i ++ ) { for ( int j = 0 ; j <= boanzkp ; j ++ ) { if ( boanzkp == 4 * i + 7 * j ) { flg = true ; break ; } } } System . out . println ( flg ? " Yes " : " No " ) ; } } } import java . util . Scanner ; import java . util . Scanner ; public class Hcaioef { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; boolean hcaioef = false ; for ( int i = 0 ; i < s . length ( ) ; i = i + 2 ) { if ( ! ( s . charAt ( i ) == 'R' || s . charAt ( i ) == 'U' || s . charAt ( i ) == 'D' ) ) { hcaioef = true ; break ; } } for ( int i = 1 ; i < s . length ( ) ; i = i + 2 ) { if ( ! ( s . charAt ( i ) == 'L' || s . charAt ( i ) == 'U' || s . charAt ( i ) == 'D' ) ) { hcaioef = true ; break ; } } if ( hcaioef ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class Hgravt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hgravt = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = hgravt * b ; int d = hgravt + b ; int e = hgravt - b ; if ( c >= d && c >= e ) { System . out . println ( c ) ; } else if ( d >= c && d >= e ) { System . out . println ( d ) ; } else { System . out . println ( e ) ; } } } import java . util . * ; public class Oaurqip { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oaurqip = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = oaurqip - b ; if ( x <= c ) { System . out . println ( c - x ) ; } if ( x > c ) { System . out . println ( 0 ) ; } } } import java . util . * ; import java . io . * ; import static java . lang . Character . isUpperCase ; public class Cnmhi { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int cnmhi = in . nextInt ( ) ; System . out . println ( 2 * 3.14 * cnmhi ) ; } } import java . util . Scanner ; public class Aklbm { static Scanner scan ; public static boolean judgePN ( int a ) { if ( a == 1 ) return false ; int aklbm = a ; for ( int i = 2 ; i < a ; i ++ ) { aklbm = a / i ; if ( a % i == 0 ) return false ; if ( i > aklbm ) break ; } return true ; } public static void main ( String [ ] args ) { scan = new Scanner ( System . in ) ; final int n = scan . nextInt ( ) ; int [ ] list = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { list [ i ] = scan . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( judgePN ( list [ i ] ) ) count ++ ; } System . out . println ( count ) ; } } import java . math . BigDecimal ; import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Objects ; import java . util . Scanner ; import java . util . stream . Stream ; public class Nxcwjqj { public static void main ( final String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; boolean nxcwjqj = true ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { char tap = S . charAt ( i ) ; if ( i % 2 == 1 ) { if ( tap == 'R' ) nxcwjqj = false ; } else { if ( tap == 'L' ) nxcwjqj = false ; } } System . out . println ( nxcwjqj ? " Yes " : " No " ) ; } } import java . util . * ; import static java . util . Map . Entry . comparingByValue ; import static java . util . stream . Collectors . toMap ; public class Nomao { public static void main ( String [ ] args ) { Scanner Input = new Scanner ( System . in ) ; int nomao = Input . nextInt ( ) ; HashMap < String , Integer > HM = new HashMap ( ) ; for ( int I = 0 ; I < nomao ; I ++ ) { String S = Input . next ( ) ; if ( ! HM . containsKey ( S ) ) { HM . put ( S , 0 ) ; } } System . out . println ( HM . size ( ) ) ; } } import java . util . Scanner ; public class Yyuwaut { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int yyuwaut = s . nextInt ( ) ; int b = s . nextInt ( ) ; int from = b - ( yyuwaut - 1 ) ; int to = b + ( yyuwaut - 1 ) ; for ( int i = from ; i <= to ; i ++ ) { System . out . print ( i + " " ) ; } } } import java . util . * ; public class Jcmok { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; int jcmok = ob . nextInt ( ) ; int k = ob . nextInt ( ) ; int [ ] a = new int [ jcmok ] ; for ( int i = 0 ; i < jcmok ; i ++ ) { a [ i ] = ob . nextInt ( ) ; } int min = 0 ; int [ ] arr = new int [ jcmok ] ; arr [ 0 ] = 0 ; arr [ 1 ] = Math . abs ( a [ 1 ] - a [ 0 ] ) ; for ( int i = 2 ; i < a . length ; i ++ ) { min = Integer . MAX_VALUE ; for ( int j = 1 ; j <= k ; j ++ ) { if ( i - j >= 0 ) { min = Math . min ( arr [ i - j ] + Math . abs ( a [ i ] - a [ i - j ] ) , min ) ; } } arr [ i ] = min ; } System . out . println ( arr [ jcmok - 1 ] ) ; ob . close ( ) ; } } import java . util . * ; public class Pqfvbr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pqfvbr = Integer . parseInt ( sc . nextLine ( ) ) ; int max = 1 ; for ( int i = 2 ; i <= Math . sqrt ( pqfvbr ) ; i ++ ) { int n = i ; for ( int j = 2 ; n * i <= pqfvbr ; j ++ ) { n *= i ; } max = max < n ? n : max ; } System . out . println ( max ) ; } } import java . util . Scanner ; public class Vxveo { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int vxveo = sc . nextInt ( ) ; final int B = sc . nextInt ( ) ; final int C = sc . nextInt ( ) ; final int X = sc . nextInt ( ) ; final int Y = sc . nextInt ( ) ; final int price = Math . min ( C * 2 , vxveo + B ) * Math . min ( X , Y ) ; final int nokori = Math . max ( X , Y ) - Math . min ( X , Y ) ; if ( X > Y ) { System . out . println ( price + Math . min ( nokori * vxveo , nokori * C * 2 ) ) ; } else { System . out . println ( price + Math . min ( nokori * B , nokori * C * 2 ) ) ; } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Ipgxz { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; abc139_a solver = new abc139_a ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Ipgxz { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String [ ] S = in . next ( ) . split ( " " ) ; String [ ] T = in . next ( ) . split ( " " ) ; int ipgxz = 0 ; for ( int i = 0 ; i < S . length ; i ++ ) { if ( S [ i ] . compareTo ( T [ i ] ) == 0 ) { ipgxz ++ ; } } out . println ( ipgxz ) ; } } } import java . util . * ; public class Hvjnxy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hvjnxy = sc . nextInt ( ) ; String ans = " Yes " ; int nowT = 0 ; int nowX = 0 ; int nowY = 0 ; for ( int i = 0 ; i < hvjnxy ; i ++ ) { int t = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int vGap = Math . abs ( x - nowX ) + Math . abs ( y - nowY ) ; int tGap = t - nowT ; if ( vGap > t - nowT ) { ans = " No " ; break ; } else if ( vGap % 2 != tGap % 2 ) { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Stpyk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int stpyk = scan . nextInt ( ) ; int N = scan . nextInt ( ) ; int [ ] box = new int [ N ] ; int con = 0 ; int min = stpyk + 100 ; int judge = 0 ; int nbox ; for ( int i = 0 ; i < N ; i ++ ) { box [ i ] = scan . nextInt ( ) ; if ( stpyk == box [ i ] ) { con = 1 ; } } if ( con == 0 ) { System . out . print ( stpyk ) ; } else { for ( int i = 1 ; i <= 200 - stpyk ; i ++ ) { int a = stpyk - i ; int b = stpyk + i ; int acount = 0 ; int bcount = 0 ; if ( a <= min || b <= min ) { acount = 0 ; bcount = 0 ; for ( int j = 0 ; j < N ; j ++ ) { if ( box [ j ] != a ) { acount += 1 ; } if ( box [ j ] != b ) { bcount += 1 ; } } if ( acount == N ) { min = a ; break ; } else if ( bcount == N ) { min = b ; break ; } } } System . out . print ( min ) ; } } } import java . util . Scanner ; public class Gqbbg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gqbbg = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; String s = sc . next ( ) ; int [ ] pos = new int [ gqbbg ] ; for ( int i = 0 ; i < gqbbg - 1 ; i ++ ) { if ( s . charAt ( i ) == 'A' && s . charAt ( i + 1 ) == 'C' ) { pos [ i ] = 1 ; } } int [ ] num = new int [ gqbbg ] ; num [ 0 ] = pos [ 0 ] ; for ( int i = 1 ; i < gqbbg - 1 ; i ++ ) { num [ i ] = num [ i - 1 ] + pos [ i ] ; } for ( int i = 0 ; i < q ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int max ; if ( r - 1 - 1 < 0 ) { max = 0 ; } else { max = num [ r - 1 - 1 ] ; } int min ; if ( l - 1 - 1 < 0 ) { min = 0 ; } else { min = num [ l - 1 - 1 ] ; } int ans = max - min ; System . out . println ( ans ) ; } sc . close ( ) ; } } import java . util . * ; public class Eldet { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; String w = sc . next ( ) ; for ( int eldet = 0 ; eldet < w . length ( ) ; eldet ++ ) { int sum = 0 ; for ( int j = 0 ; j < w . length ( ) ; j ++ ) { if ( w . charAt ( eldet ) == w . charAt ( j ) ) sum = sum + 1 ; } if ( sum % 2 != 0 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Collections ; import java . util . LinkedList ; import java . util . Scanner ; public class Fejga { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fejga = sc . nextInt ( ) ; LinkedList < Integer > inputs = new LinkedList < > ( ) ; for ( int i = 0 ; i < fejga ; i ++ ) { inputs . add ( sc . nextInt ( ) ) ; } Collections . sort ( inputs ) ; double beforeParam = inputs . pop ( ) ; for ( int i = 0 ; i < fejga - 1 ; i ++ ) { beforeParam = ( beforeParam + inputs . pop ( ) ) / 2 ; } System . out . println ( beforeParam ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Aogaix { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int aogaix = scan . nextInt ( ) ; String str = scan . next ( ) ; if ( aogaix >= str . length ( ) ) { System . out . println ( str ) ; } else { System . out . println ( str . substring ( 0 , aogaix ) + " ... " ) ; } } } import java . util . * ; public class Vzpyda { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vzpyda = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; if ( S . length ( ) > vzpyda ) S = S . substring ( 0 , vzpyda ) + " ... " ; System . out . println ( S ) ; } } import java . util . * ; public class Spsia { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int spsia = sc . nextInt ( ) ; int [ ] h = new int [ spsia ] ; int landCt = 0 ; int answer = 0 ; for ( int i = 0 ; i < spsia ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int start = h [ 0 ] ; for ( int i = 0 ; i < 101 ; i ++ ) { landCt = 0 ; for ( int j = 0 ; j < spsia - 1 ; j ++ ) { if ( ( h [ j ] == 0 && h [ j + 1 ] > 0 ) || ( j == 0 && h [ 0 ] > 0 ) ) { landCt = landCt + 1 ; } } answer = answer + landCt ; oneMinus ( h ) ; } if ( spsia != 1 ) { System . out . println ( answer ) ; } else { System . out . println ( start ) ; } } public static void oneMinus ( int [ ] h ) { for ( int i = 0 ; i < h . length ; i ++ ) { if ( h [ i ] != 0 ) { h [ i ] = h [ i ] - 1 ; } } } } import java . util . Scanner ; public class Qxhqnaz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String in = sc . nextLine ( ) ; int qxhqnaz = in . codePointAt ( 0 ) - '0' ; int b = in . codePointAt ( 1 ) - '0' ; int c = in . codePointAt ( 2 ) - '0' ; int d = in . codePointAt ( 3 ) - '0' ; for ( int i = 0 ; i < 8 ; i ++ ) { int result = qxhqnaz ; result += ( ( i & 0x01 ) != 0 ) ? b : - b ; result += ( ( i & 0x02 ) != 0 ) ? c : - c ; result += ( ( i & 0x04 ) != 0 ) ? d : - d ; if ( result == 7 ) { System . out . println ( String . format ( " %d%c%d%c%d%c%d=7 " , qxhqnaz , ( ( i & 0x01 ) != 0 ) ? '+' : '-' , b , ( ( i & 0x02 ) != 0 ) ? '+' : '-' , c , ( ( i & 0x04 ) != 0 ) ? '+' : '-' , d ) ) ; System . exit ( 0 ) ; } } } } import java . util . Arrays ; import java . util . Scanner ; public class Zpfyjlk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int zpfyjlk = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int d = scanner . nextInt ( ) ; int ans = 0 ; boolean [ ] exits = new boolean [ 100 ] ; Arrays . fill ( exits , false ) ; for ( int i = zpfyjlk ; i < b ; i ++ ) { exits [ i ] = true ; } for ( int i = c ; i < d ; i ++ ) { if ( exits [ i ] ) { ans ++ ; } } System . out . println ( ans ) ; scanner . close ( ) ; } } import java . util . Scanner ; class Pqrja { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String search = scanner . nextLine ( ) ; boolean pqrja = true ; int count = 0 ; String end = " END_OF_TEXT " ; while ( pqrja ) { String word = scanner . next ( ) ; int result = word . lastIndexOf ( end ) ; if ( result != - 1 ) { pqrja = false ; } else { word = word . toLowerCase ( ) ; } if ( word . equals ( search ) ) { count ++ ; } } System . out . println ( count ) ; scanner . close ( ) ; } } import java . util . Scanner ; public class Zdkifmg { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; String T = scan . next ( ) ; for ( int zdkifmg = 0 ; zdkifmg < S . length ( ) ; zdkifmg ++ ) { if ( S . charAt ( zdkifmg ) != T . charAt ( zdkifmg ) ) { System . out . println ( " No " ) ; break ; } else if ( ( zdkifmg == S . length ( ) - 1 ) && ( S . length ( ) == T . length ( ) - 1 ) ) { System . out . println ( " Yes " ) ; } else if ( S . length ( ) == T . length ( ) ) { System . out . println ( " No " ) ; } } } } import java . util . * ; public class Xioky { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; while ( true ) { int xioky = cin . nextInt ( ) , x = cin . nextInt ( ) ; int res = 0 ; if ( xioky == 0 && x == 0 ) break ; for ( int i = 1 ; i <= xioky - 2 ; i ++ ) { for ( int j = i + 1 ; j <= xioky - 1 ; j ++ ) { for ( int k = j + 1 ; k <= xioky ; k ++ ) { if ( i + j + k == x ) res ++ ; } } } System . out . println ( res ) ; } } } import java . util . Scanner ; public class Mmdlv { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int mmdlv = s . nextInt ( ) ; long res = mmdlv ; res += mmdlv * mmdlv + mmdlv * mmdlv * mmdlv ; System . out . println ( res ) ; } } import java . util . Scanner ; public class Kdhtyqf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kdhtyqf = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int target = 0 ; int kekka = 10000 ; while ( target < 10000 ) { if ( ( int ) Math . floor ( ( double ) target * 0.08 ) == kdhtyqf && ( int ) Math . floor ( ( double ) target * 0.1 ) == B ) { System . out . println ( target ) ; break ; } else { target = target + 1 ; } } if ( target == 10000 ) { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; class Wignkr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String num = scan . nextLine ( ) ; int wignkr = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { char c = num . charAt ( i ) ; if ( c == '1' ) { wignkr ++ ; } } System . out . println ( wignkr ) ; } } import java . util . Scanner ; public class Kcnatwp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kcnatwp = scan . nextInt ( ) ; String s = scan . next ( ) ; String t = scan . next ( ) ; String ans = " " ; for ( int i = 0 ; i < kcnatwp ; i ++ ) { ans = ans . concat ( s . substring ( i , i + 1 ) ) . concat ( t . substring ( i , i + 1 ) ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Foers { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int foers = Integer . parseInt ( sc . next ( ) ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int result = n ; if ( foers == 0 && n == 100 ) { result ++ ; } else if ( 0 < foers ) { for ( int i = 0 ; i < foers ; i ++ ) { result *= 100 ; } if ( n == 100 ) { int add = 1 ; for ( int i = 0 ; i < foers ; i ++ ) { add *= 100 ; } result += add ; } } System . out . println ( result ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Eiigd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String day = sc . next ( ) ; int eiigd = 0 ; switch ( day ) { case " SUN " : eiigd = 7 ; break ; case " MON " : eiigd = 6 ; break ; case " TUE " : eiigd = 5 ; break ; case " WED " : eiigd = 4 ; break ; case " THU " : eiigd = 3 ; break ; case " FRI " : eiigd = 2 ; break ; case " SAT " : eiigd = 1 ; break ; } System . out . println ( eiigd ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Lwymavc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lwymavc = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; int ans = lwymavc ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } for ( int dif = 0 ; dif <= n ; dif ++ ) { if ( ! list . contains ( lwymavc - dif ) ) { ans = lwymavc - dif ; break ; } if ( ! list . contains ( lwymavc + dif ) ) { ans = lwymavc + dif ; break ; } } if ( n > 100 ) { System . out . println ( " error " ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class Dnupu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] antennaArr = new int [ 5 ] ; for ( int dnupu = 0 ; dnupu < antennaArr . length ; dnupu ++ ) { antennaArr [ dnupu ] = sc . nextInt ( ) ; } int border = sc . nextInt ( ) ; boolean canConnect = true ; for ( int dnupu = 0 ; dnupu < antennaArr . length ; dnupu ++ ) { for ( int j = 0 ; j < antennaArr . length ; j ++ ) { if ( dnupu >= j ) { continue ; } if ( antennaArr [ j ] - antennaArr [ dnupu ] > border ) { canConnect = false ; } } } if ( canConnect ) { System . out . println ( " Yay! " ) ; } else { System . out . println ( " :( " ) ; } } } import java . io . * ; import java . util . Scanner ; public class Pnthjy { public static boolean range ( int pnthjy , int b , int c ) { if ( pnthjy >= b ) return false ; if ( b >= c ) return false ; return true ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pnthjy = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( range ( pnthjy , b , c ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . io . * ; class Hhdbjey { static PrintStream out = System . out ; static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int hhdbjey = in . nextInt ( ) ; int a = in . nextInt ( ) ; long min = a , max = a , sum = a ; for ( int i = 1 ; i < hhdbjey ; i ++ ) { a = in . nextInt ( ) ; min = Math . min ( a , min ) ; max = Math . max ( a , max ) ; sum += a ; } out . println ( String . format ( " %d %d %d " , min , max , sum ) ) ; } } import java . io . * ; public class Umzefz { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int umzefz = Integer . parseInt ( br . readLine ( ) ) ; String [ ] S = br . readLine ( ) . split ( " " ) ; int q = Integer . parseInt ( br . readLine ( ) ) ; String [ ] T = br . readLine ( ) . split ( " " ) ; int count = 0 ; for ( int i = 0 ; i < q ; i ++ ) { if ( binarysarch ( S , T [ i ] ) != - 1 ) count ++ ; } System . out . println ( count ) ; } public static int binarysarch ( String [ ] S , String x ) { int lx = 0 , rx = S . length - 1 ; while ( lx <= rx ) { int c = ( lx + rx ) / 2 ; if ( Integer . parseInt ( S [ c ] ) == Integer . parseInt ( x ) ) { return c ; } else if ( Integer . parseInt ( S [ c ] ) < Integer . parseInt ( x ) ) { lx = c + 1 ; } else { rx = c - 1 ; } } return - 1 ; } } import java . util . Scanner ; public class Fjqekt { public static void main ( String [ ] args ) { int fjqekt = 1 ; int p = 2 ; double max = 0 ; double result ; Scanner scanner = new Scanner ( System . in ) ; int x = scanner . nextInt ( ) ; while ( fjqekt < 1000 ) { while ( p < 1000 ) { result = Math . pow ( fjqekt , p ) ; if ( result > x ) break ; if ( result >= max ) max = result ; p ++ ; } p = 2 ; fjqekt ++ ; } System . out . println ( ( int ) max ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Kdcyq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kdcyq = scan . nextInt ( ) ; int n = scan . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; int abs = 99 ; int ans = 100 ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( scan . nextInt ( ) ) ; } for ( int i = 0 ; i <= 200 ; i ++ ) { if ( ! ( list . contains ( i ) ) ) { if ( Math . abs ( kdcyq - i ) < abs ) { abs = Math . abs ( kdcyq - i ) ; ans = i ; } } } if ( n == 0 || ! ( list . contains ( kdcyq ) ) ) { System . out . println ( kdcyq ) ; } else { System . out . println ( ans ) ; } } } import java . util . Scanner ; public class Runchr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( " 123 " . replace ( sc . next ( ) , " " ) . replace ( sc . next ( ) , " " ) ) ; } } import java . util . Scanner ; public class Kmhptdz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; String A = " " ; String B = " " ; for ( int kmhptdz = 0 ; kmhptdz < Integer . parseInt ( b ) ; kmhptdz ++ ) { A += a ; } for ( int kmhptdz = 0 ; kmhptdz < Integer . parseInt ( a ) ; kmhptdz ++ ) { B += b ; } System . out . print ( ( A . compareTo ( B ) ) < 0 ? A : B ) ; } } import java . util . Scanner ; public class Jzooj { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long jzooj = in . nextLong ( ) ; long tk = 0 ; long pchso = jzooj / 500 ; tk = pchso * 1000 ; int baki = ( int ) ( jzooj % 500 ) ; long pach = baki / 5 ; tk = tk + ( pach * 5 ) ; System . out . println ( tk ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Lveje { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lveje = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; List < Integer > k = new ArrayList < > ( ) ; List < List < Integer > > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < lveje ; i ++ ) { k . add ( sc . nextInt ( ) ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int j = 0 ; j < k . get ( i ) ; j ++ ) { list . add ( sc . nextInt ( ) ) ; } a . add ( list ) ; } List < Integer > correct = new ArrayList < > ( a . get ( 0 ) ) ; for ( int i = 1 ; i < lveje ; i ++ ) { correct . retainAll ( a . get ( i ) ) ; } System . out . println ( correct . size ( ) ) ; } } import java . util . Scanner ; public class Dgcfphz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int dgcfphz = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int H = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; double degree = calculateAngle ( H , M ) ; double side = Math . sqrt ( dgcfphz * dgcfphz + B * B - 2 * dgcfphz * B * Math . cos ( Math . toRadians ( degree ) ) ) ; System . out . println ( side ) ; } static double calculateAngle ( double h , double m ) { double hour_angle = ( 0.5 * ( h * 60 + m ) ) ; double minute_angle = ( 6 * m ) ; double angle = Math . abs ( hour_angle - minute_angle ) ; angle = Math . min ( 360 - angle , angle ) ; return angle ; } } import java . util . Scanner ; public class Anqptqz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int anqptqz = scan . nextInt ( ) ; double debt = 100000 ; for ( int i = 0 ; i < anqptqz ; i ++ ) { debt = debt * 1.05 / 1000 ; debt = Math . ceil ( debt ) ; debt = debt * 1000 ; } int ans = ( int ) debt ; System . out . println ( ans ) ; } } import java . io . IOException ; import java . util . Scanner ; public class Qalzs { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; String input = scan . next ( ) ; char [ ] inputArray = input . toCharArray ( ) ; int qalzs = 0 ; for ( int i = 0 ; i < inputArray . length ; i ++ ) { if ( inputArray [ i ] == '1' ) { qalzs ++ ; } } System . out . println ( qalzs ) ; } public static String myReverse ( String pStr ) { if ( pStr . length ( ) < 1 ) { return " " ; } StringBuffer sb = new StringBuffer ( pStr ) ; return sb . reverse ( ) . toString ( ) ; } public static long myMod ( long a , long b ) { long ret = 0 ; ret = a % b ; if ( ret < 0 ) { ret += b ; } return ret ; } public static long myPowWithMod ( long kisu , long josu , long primeNumMod_0 ) { long qalzs = 1 ; if ( josu == 0 ) return 1 ; if ( primeNumMod_0 == 0 ) { while ( josu > 0 ) { if ( josu % 2 == 0 ) { kisu *= kisu ; josu = josu / 2 ; } else { qalzs *= kisu ; josu -- ; } } return qalzs ; } else { kisu = myMod ( kisu , primeNumMod_0 ) ; while ( josu > 0 ) { if ( josu % 2 == 0 ) { kisu *= myMod ( kisu , primeNumMod_0 ) ; josu = josu / 2 ; } else { qalzs *= myMod ( kisu , primeNumMod_0 ) ; josu -- ; } } return myMod ( qalzs , primeNumMod_0 ) ; } } } import java . util . Scanner ; public class Muelv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int muelv = sc . nextInt ( ) , b = sc . nextInt ( ) ; int c = sc . nextInt ( ) , x = sc . nextInt ( ) ; sc . close ( ) ; int tmpa = muelv , tmpb = b , tmpc = c , tmpx = x / 50 ; int r = tmpx % 2 ; int ans = 0 ; for ( int i = r ; i <= x ; i += 2 ) { if ( i > tmpc ) break ; int tmp = ( tmpx - i ) / 2 ; int tr = tmp % 5 ; for ( int j = tr ; j <= tmp ; j += 5 ) { if ( j > tmpb ) break ; int tmp2 = ( tmp - j ) / 5 ; if ( tmp2 <= muelv && tmp >= 0 ) ++ ans ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Xzgvunn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xzgvunn = sc . nextInt ( ) ; int last = sc . nextInt ( ) ; int res = last ; for ( int i = 0 ; i < xzgvunn - 2 ; i ++ ) { int t = sc . nextInt ( ) ; res += Math . min ( t , last ) ; last = t ; } System . out . println ( res + last ) ; } } import java . util . * ; import java . io . * ; public class Oiswd { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; String [ ] input1 = br . readLine ( ) . split ( " " ) ; int oiswd = Integer . parseInt ( input1 [ 0 ] ) ; int k = Integer . parseInt ( input1 [ 1 ] ) ; String [ ] input2 = br . readLine ( ) . split ( " " ) ; int [ ] numbers = new int [ oiswd ] ; int ans = 0 ; for ( int i = 0 ; i < oiswd ; i ++ ) { numbers [ i ] = Integer . parseInt ( input2 [ i ] ) ; if ( numbers [ i ] >= k ) { ans ++ ; } } out . println ( ans ) ; out . close ( ) ; } } import java . util . Scanner ; public class Ntnrv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ntnrv = scan . nextInt ( ) ; int [ ] h = new int [ ntnrv ] ; int i ; for ( i = 0 ; i < ntnrv ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } for ( i = ntnrv - 1 ; i >= 1 ; i -- ) { if ( h [ i ] >= h [ i - 1 ] ) { } else if ( h [ i - 1 ] - h [ i ] == 1 ) { h [ i - 1 ] -- ; } else { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class Xunrw { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int xunrw = sc . nextInt ( ) ; int [ ] A = new int [ xunrw ] ; int i ; int count = 0 ; for ( i = 0 ; i < xunrw ; i ++ ) { A [ i ] = sc . nextInt ( ) ; if ( isprime ( A [ i ] ) == true ) { count ++ ; } } System . out . println ( count ) ; } public static boolean isprime ( int x ) { int i = 0 ; if ( x == 2 ) { return true ; } else if ( ( x % 2 ) == 0 ) { return false ; } else { i = 3 ; while ( i <= Math . sqrt ( x ) ) { if ( ( x % i ) == 0 ) { return false ; } i = i + 2 ; } } return true ; } } import java . util . Scanner ; class Dzrhvvo { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int dzrhvvo = stdIn . nextShort ( ) ; int n1 = 1 ; int n2 ; do { n2 = 100 * n1 + 10 * n1 + n1 ; if ( dzrhvvo <= n2 ) { System . out . println ( n2 ) ; return ; } n1 = n1 + 1 ; } while ( n1 <= 9 ) ; } } import java . util . Scanner ; public class Xmnaqex { public static void main ( String [ ] args ) { int xmnaqex , a , b , digitsSum = 0 , totalSum = 0 ; Scanner sc = new Scanner ( System . in ) ; xmnaqex = sc . nextInt ( ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; for ( int i = 1 ; i <= xmnaqex ; i ++ ) { int tmp = i ; for ( int j = 0 ; j < 5 ; j ++ ) { digitsSum += tmp % 10 ; tmp /= 10 ; } if ( a <= digitsSum && digitsSum <= b ) totalSum += i ; digitsSum = 0 ; } System . out . println ( totalSum ) ; } } import java . util . * ; class Hrdya { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int hrdya = sc . nextInt ( ) ; final int W = sc . nextInt ( ) ; sc . close ( ) ; if ( hrdya > W ) { System . out . println ( " safe " ) ; } else { System . out . println ( " unsafe " ) ; } } } import java . util . * ; import java . io . * ; class Xvqjaxj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int xvqjaxj = Integer . parseInt ( br . readLine ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; int count = 0 ; int a = 1 , b ; if ( xvqjaxj >= 3 && xvqjaxj <= 10000 ) { for ( ; count < xvqjaxj ; count ++ ) { b = a / 10 ; if ( a % 3 == 0 ) { sb . append ( " " ) ; sb . append ( a ) ; } else { b = a ; while ( b != 0 ) { if ( b % 10 == 3 ) { sb . append ( " " ) ; sb . append ( a ) ; break ; } b /= 10 ; } } a ++ ; } } System . out . println ( sb ) ; } } import java . util . Scanner ; public class Jcjsxyp { public static void main ( String [ ] args ) { Main mainObj = new Main ( ) ; mainObj . solve ( ) ; } public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int jcjsxyp = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] heightStrArr = sc . nextLine ( ) . split ( " " ) ; sc . close ( ) ; int [ ] heightArr = new int [ jcjsxyp ] ; for ( int i = 0 ; i < jcjsxyp ; i ++ ) { heightArr [ i ] = Integer . parseInt ( heightStrArr [ i ] ) ; } if ( heightArr [ 0 ] > 0 ) { heightArr [ 0 ] = heightArr [ 0 ] - 1 ; } for ( int i = 1 ; i < jcjsxyp ; i ++ ) { if ( heightArr [ i ] > heightArr [ i - 1 ] ) { heightArr [ i ] = heightArr [ i ] - 1 ; } if ( heightArr [ i ] < heightArr [ i - 1 ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Uvyfvr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uvyfvr = Integer . parseInt ( sc . next ( ) ) ; int m = Integer . parseInt ( sc . next ( ) ) ; int [ ] love = new int [ m ] ; int k , a ; for ( int i = 0 ; i < uvyfvr ; i ++ ) { k = Integer . parseInt ( sc . next ( ) ) ; for ( int j = 0 ; j < k ; j ++ ) { a = Integer . parseInt ( sc . next ( ) ) ; love [ a - 1 ] ++ ; } } int count = 0 ; for ( int i = 0 ; i < m ; i ++ ) { if ( love [ i ] == uvyfvr ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; class Jkege { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jkege = sc . nextInt ( ) ; int [ ] cnt = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { cnt [ i ] = 0 ; } String [ ] s = new String [ jkege ] ; for ( int i = 0 ; i < jkege ; i ++ ) { s [ i ] = sc . next ( ) ; switch ( s [ i ] ) { case " AC " : cnt [ 0 ] ++ ; break ; case " WA " : cnt [ 1 ] ++ ; break ; case " TLE " : cnt [ 2 ] ++ ; break ; case " RE " : cnt [ 3 ] ++ ; break ; } } sc . close ( ) ; System . out . println ( " AC x " + cnt [ 0 ] ) ; System . out . println ( " WA x " + cnt [ 1 ] ) ; System . out . println ( " TLE x " + cnt [ 2 ] ) ; System . out . println ( " RE x " + cnt [ 3 ] ) ; } } import java . util . Scanner ; public class Jhklvtb { void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int jhklvtb = sc . nextInt ( ) ; int [ ] p = new int [ jhklvtb ] ; for ( int i = 0 ; i < jhklvtb ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } if ( isOK ( p ) ) { System . out . println ( " YES " ) ; return ; } for ( int i = 0 ; i <= jhklvtb - 2 ; i ++ ) { for ( int j = i + 1 ; j <= jhklvtb - 1 ; j ++ ) { int [ ] pClone = p . clone ( ) ; int tmp = pClone [ i ] ; pClone [ i ] = pClone [ j ] ; pClone [ j ] = tmp ; if ( isOK ( ( pClone ) ) ) { System . out . println ( " YES " ) ; return ; } } } System . out . println ( " NO " ) ; } boolean isOK ( int [ ] array ) { for ( int i = 0 ; i <= array . length - 2 ; i ++ ) { if ( array [ i ] > array [ i + 1 ] ) { return false ; } } return true ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; class Bbmmgi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] dance = sc . next ( ) . toCharArray ( ) ; boolean bbmmgi = true ; for ( int i = 0 ; i < dance . length ; i ++ ) { if ( i % 2 == 0 ) { if ( dance [ i ] == 'L' ) { bbmmgi = false ; break ; } } else { if ( dance [ i ] == 'R' ) { bbmmgi = false ; break ; } } } if ( bbmmgi ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Sbkgprz { public Main ( ) { } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sbkgprz ; int h ; int index ; int index2 ; int result = 1 ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; sbkgprz = sc . nextInt ( ) ; for ( index = 0 ; index < sbkgprz ; index ++ ) { h = sc . nextInt ( ) ; map . put ( index , h ) ; } sc . close ( ) ; loop1 : for ( index = 1 ; index < sbkgprz ; index ++ ) { loop2 : for ( index2 = 0 ; index2 < index ; index2 ++ ) { if ( map . get ( index2 ) > map . get ( index ) ) { result -- ; break loop2 ; } } result ++ ; } System . out . println ( result ) ; } } import java . util . Scanner ; class Gdnum { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String x = sc . next ( ) ; double gdnum = Double . valueOf ( x ) ; int ans = 0 ; double tot = 100 ; while ( tot < gdnum ) { tot = Math . floor ( tot * 1.01 ) ; ans ++ ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Lnwrgve { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String lnwrgve = sc . nextLine ( ) ; sc . close ( ) ; System . out . println ( lnwrgve . lastIndexOf ( " Z " ) - lnwrgve . indexOf ( " A " ) + 1 ) ; } } import java . util . Scanner ; public class Uallabt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uallabt = Integer . parseInt ( sc . next ( ) ) ; int [ ] H = new int [ uallabt ] ; for ( int i = 0 ; i < uallabt ; i ++ ) { H [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int prev = ( H [ 0 ] > 1 ) ? H [ 0 ] - 1 : H [ 0 ] ; for ( int i = 1 ; i < uallabt - 1 ; i ++ ) { int target = H [ i ] ; int next = H [ i + 1 ] ; if ( ( target - next ) > 1 ) { System . out . println ( " No " ) ; return ; } else if ( ( target - next ) == 1 ) { target -= 1 ; if ( prev > target ) { System . out . println ( " No " ) ; return ; } } else { if ( prev < target ) { target -= 1 ; } } prev = target ; } System . out . println ( " Yes " ) ; } } import java . io . * ; import java . util . * ; public class Rlmhru { public static String repeat ( String str , int n ) { return String . join ( " " , Collections . nCopies ( n , str ) ) ; } public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = reader . readLine ( ) . split ( " " ) ; int rlmhru = Integer . parseInt ( arr [ 0 ] ) ; int b = Integer . parseInt ( arr [ 1 ] ) ; System . out . println ( rlmhru < b ? repeat ( arr [ 0 ] , b ) : repeat ( arr [ 1 ] , rlmhru ) ) ; } } import java . util . * ; public class Xqifcwa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xqifcwa = sc . nextInt ( ) ; char [ ] nChar = String . valueOf ( xqifcwa ) . toCharArray ( ) ; int sn = 0 ; for ( int i = 0 ; i < nChar . length ; i ++ ) { sn += Integer . parseInt ( String . valueOf ( nChar [ i ] ) ) ; } if ( xqifcwa % sn == 0 ) { System . out . println ( " Yes " ) ; return ; } System . out . println ( " No " ) ; } } import java . util . * ; class Oapof { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oapof = sc . nextInt ( ) ; final int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; final int D = sc . nextInt ( ) ; sc . close ( ) ; while ( true ) { C -= B ; if ( C <= 0 ) break ; oapof -= D ; if ( oapof <= 0 ) break ; } if ( C <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Kvkfy { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; String kvkfy = s . next ( ) ; switch ( kvkfy ) { case " MON " : System . out . println ( " 6 " ) ; break ; case " TUE " : System . out . println ( " 5 " ) ; break ; case " WED " : System . out . println ( " 4 " ) ; break ; case " THU " : System . out . println ( " 3 " ) ; break ; case " FRI " : System . out . println ( " 2 " ) ; break ; case " SAT " : System . out . println ( " 1 " ) ; break ; default : System . out . println ( " 7 " ) ; } } } import java . util . * ; class Ceupynw { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; long ceupynw = scn . nextInt ( ) ; long num2 = scn . nextInt ( ) ; System . out . println ( CommonMultipleNum . cmn ( ceupynw , num2 ) ) ; } } class Ceupynw { static long cmn ( long ceupynw , long num2 ) { long tmp ; long num3 = ceupynw ; num3 *= num2 ; while ( ( tmp = ceupynw % num2 ) != 0 ) { ceupynw = num2 ; num2 = tmp ; } return ( long ) ( num3 / num2 ) ; } } import java . util . * ; class Qlsucb { public static void main ( String [ ] args ) { Scanner inp = new Scanner ( System . in ) ; do_ ( inp ) ; inp . close ( ) ; } public static void do_ ( Scanner inp ) { int qlsucb = inp . nextInt ( ) ; int b = inp . nextInt ( ) ; int c = inp . nextInt ( ) ; System . out . println ( c + " " + qlsucb + " " + b ) ; } } import java . util . * ; public class Mdigy { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String [ ] x = s . nextLine ( ) . split ( " " ) ; int mdigy = Integer . parseInt ( x [ 0 ] ) ; int b = Integer . parseInt ( x [ 1 ] ) ; int c = Integer . parseInt ( x [ 2 ] ) ; int d = Integer . parseInt ( x [ 3 ] ) ; int diff1 = ( int ) mdigy / d ; if ( mdigy % d != 0 ) { diff1 = diff1 + 1 ; } int diff2 = ( int ) c / b ; if ( c % b != 0 ) { diff2 = diff2 + 1 ; } boolean g = diff1 >= diff2 ; if ( g ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Bgfcg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bgfcg = sc . nextInt ( ) ; if ( bgfcg % 10 == 3 || bgfcg % 100 == 3 ) { System . out . println ( " bon " ) ; } else if ( bgfcg % 10 == 0 || bgfcg % 10 == 1 | bgfcg % 10 == 6 || bgfcg % 10 == 8 ) { System . out . println ( " pon " ) ; } else System . out . println ( " hon " ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Hyyxb { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int hyyxb = in . nextInt ( ) ; int n = in . nextInt ( ) ; if ( n == 100 ) n = 101 ; for ( int i = 0 ; i < hyyxb ; i ++ ) n *= 100 ; System . out . println ( n ) ; in . close ( ) ; } } import java . util . Scanner ; public class Ijwec { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ijwec = scanner . nextInt ( ) ; int result = ijwec + ( int ) Math . pow ( ijwec , 2 ) + ( int ) Math . pow ( ijwec , 3 ) ; System . out . println ( result ) ; } } import java . util . * ; public class Mblnkw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mblnkw = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; sum += A [ i ] ; } if ( ( mblnkw - sum ) <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Gbqwpy { static int [ ] stack = new int [ 1000 ] ; static int gbqwpy = 0 ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] input = ( scanner . nextLine ( ) ) . split ( " " ) ; for ( int i = 0 ; i < input . length ; i ++ ) { if ( input [ i ] . equals ( " * " ) ) { push ( pop ( ) * pop ( ) ) ; } else if ( input [ i ] . equals ( " + " ) ) { push ( pop ( ) + pop ( ) ) ; } else if ( input [ i ] . equals ( " - " ) ) { push ( - pop ( ) + pop ( ) ) ; } else { push ( Integer . parseInt ( input [ i ] ) ) ; } } System . out . println ( pop ( ) ) ; } public static int pop ( ) { gbqwpy -- ; return stack [ gbqwpy + 1 ] ; } public static void push ( int i ) { gbqwpy ++ ; stack [ gbqwpy ] = i ; } } import java . util . Scanner ; public class Ffdwif { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . next ( ) ; String t = scanner . next ( ) ; int ffdwif = t . length ( ) ; String T = t . substring ( 0 , ffdwif - 1 ) ; if ( s . equals ( T ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scanner . close ( ) ; } } import java . util . * ; public class Qvvoh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qvvoh = sc . nextInt ( ) ; int [ ] a = new int [ qvvoh + 1 ] ; for ( int i = 0 ; i < qvvoh + 1 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } long sum = 0 ; for ( int i = 0 ; i < qvvoh ; i ++ ) { int b = sc . nextInt ( ) ; int buster = Math . min ( a [ i ] , b ) ; int secondBuster = Math . min ( a [ i + 1 ] , b - buster ) ; a [ i + 1 ] -= secondBuster ; sum += buster + secondBuster ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class Eqrno { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] x = new int [ 5 ] ; int eqrno = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { x [ i ] = sc . nextInt ( ) ; if ( x [ i ] != i + 1 ) eqrno = i + 1 ; } System . out . println ( eqrno ) ; } } import java . util . * ; public class Hrrhbn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hrrhbn = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; int d = Integer . parseInt ( sc . next ( ) ) ; double x = ( double ) hrrhbn / d ; double y = ( double ) c / b ; x = Math . ceil ( x ) ; y = Math . ceil ( y ) ; if ( x >= y ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Lorxb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int lorxb = s . length ( ) ; for ( int i = 0 ; i < lorxb ; i ++ ) { System . out . print ( " x " ) ; } System . out . println ( " " ) ; } } import java . util . * ; public class Hbgio { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hbgio = sc . nextInt ( ) ; int n = hbgio ; int m , s = 0 ; for ( int i = 10 ; i > 0 ; i -- ) { m = n / ( int ) ( Math . pow ( 10 , i ) ) ; s = s + m ; if ( m != 0 ) { n = n - ( int ) ( Math . pow ( 10 , i ) ) * m ; } } s = s + n % 10 ; if ( hbgio % s == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Wbksxr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long wbksxr = sc . nextLong ( ) ; wbksxr -- ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long total = b - wbksxr ; long divD = b / d - wbksxr / d ; long divC = b / c - wbksxr / c ; long lcm = getLcm ( c , d ) ; long divL = b / lcm - wbksxr / lcm ; System . out . println ( total - ( divD + divC - divL ) ) ; } private static long getLcm ( long n , long m ) { long bn = n ; long bm = m ; while ( n != m ) { if ( n < m ) { n += bn ; } else { m += bm ; } } return n ; } } import java . util . Scanner ; import java . util . Map ; import java . util . TreeMap ; import java . util . Iterator ; public class Myfkxa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int myfkxa = Integer . parseInt ( sc . next ( ) ) ; TreeMap < String , Integer > S = new TreeMap < String , Integer > ( ) ; String tmp ; int max = 1 ; int count ; for ( int i = 0 ; i < myfkxa ; i ++ ) { tmp = sc . next ( ) ; if ( S . containsKey ( tmp ) ) { count = S . get ( tmp ) + 1 ; if ( max < count ) { max = count ; } S . put ( tmp , count ) ; } else { S . put ( tmp , 1 ) ; } } for ( Iterator < String > it = S . keySet ( ) . iterator ( ) ; it . hasNext ( ) ; ) { String result = it . next ( ) ; if ( S . get ( result ) == max ) { System . out . println ( result ) ; } } } } import java . util . Scanner ; public class Yrolfg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yrolfg = sc . nextInt ( ) ; long Y = sc . nextLong ( ) ; sc . close ( ) ; int A = 0 ; int B = 0 ; int C = 0 ; for ( int i = 0 ; i <= yrolfg ; i ++ ) { A = i * 10000 ; for ( int j = 0 ; j <= yrolfg ; j ++ ) { B = j * 5000 ; C = ( yrolfg - i - j ) * 1000 ; if ( A + B + C == Y && C >= 0 ) { System . out . println ( i + " " + j + " " + ( yrolfg - i - j ) ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . util . Scanner ; public class Lycgk { public static char abc_ans ( String str_a , String str_b , String str_c ) { char [ ] a = str_a . toCharArray ( ) ; char [ ] b = str_b . toCharArray ( ) ; char [ ] c = str_c . toCharArray ( ) ; int lycgk = a . length ; int b_count = b . length ; int c_count = c . length ; int a_number = 0 ; int b_number = 0 ; int c_number = 0 ; char x = a [ a_number ] ; while ( true ) { switch ( x ) { case 'a' : if ( a_number >= a . length ) { return ( 'A' ) ; } x = a [ a_number ] ; a_number ++ ; break ; case 'b' : if ( b_number >= b . length ) { return ( 'B' ) ; } x = b [ b_number ] ; b_number ++ ; break ; case 'c' : if ( c_number >= c . length ) { return ( 'C' ) ; } x = c [ c_number ] ; c_number ++ ; break ; } } } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str_a = scan . next ( ) ; String str_b = scan . next ( ) ; String str_c = scan . next ( ) ; System . out . println ( abc_ans ( str_a , str_b , str_c ) ) ; } } import java . util . * ; public class Zdmhj { public static void main ( String [ ] args ) { Scanner yomi = new Scanner ( System . in ) ; String zdmhj = yomi . next ( ) ; if ( zdmhj . equals ( " SUN " ) ) { System . out . println ( 7 ) ; } else if ( zdmhj . equalsIgnoreCase ( " MON " ) ) { System . out . println ( 6 ) ; } else if ( zdmhj . equalsIgnoreCase ( " TUE " ) ) { System . out . println ( 5 ) ; } else if ( zdmhj . equalsIgnoreCase ( " WED " ) ) { System . out . println ( 4 ) ; } else if ( zdmhj . equalsIgnoreCase ( " THU " ) ) { System . out . println ( 3 ) ; } else if ( zdmhj . equalsIgnoreCase ( " FRI " ) ) { System . out . println ( 2 ) ; } else if ( zdmhj . equalsIgnoreCase ( " SAT " ) ) { System . out . println ( 1 ) ; } } } import java . util . * ; public class Vkosr { public static void main ( String [ ] args ) throws NumberFormatException { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) . trim ( ) ; String [ ] segments = S . split ( " " ) ; int vkosr = Integer . parseInt ( segments [ 0 ] ) ; int K = Integer . parseInt ( segments [ 1 ] ) ; double result = 0 ; double np = ( double ) 1.0 / vkosr ; for ( int i = 1 ; i <= vkosr ; i ++ ) { result += np * calcP ( i , K ) ; } System . out . println ( result ) ; } private static double calcP ( int n , int k ) { int score = n ; int cnt = 0 ; while ( score < k ) { cnt ++ ; score *= 2 ; } if ( cnt > 0 ) { return Math . pow ( ( double ) 0.5 , cnt ) ; } else { return 1 ; } } } import java . util . Scanner ; public class Iuwezv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iuwezv = sc . nextInt ( ) ; String S = sc . next ( ) ; String S1 = S . substring ( iuwezv / 2 ) ; String S2 = S . substring ( 0 , iuwezv / 2 ) ; String S3 = S1 + S2 ; sc . close ( ) ; if ( iuwezv % 2 == 1 ) { System . out . println ( " No " ) ; } else { if ( S . equals ( S3 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; class Mkviwps { Scanner sc = new Scanner ( System . in ) ; void main ( ) { int mkviwps = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] [ ] x = new int [ mkviwps + 1 ] [ c + 1 ] ; for ( int i = 0 ; i < mkviwps ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { x [ i ] [ j ] = sc . nextInt ( ) ; x [ i ] [ c ] += x [ i ] [ j ] ; } } for ( int i = 0 ; i < mkviwps ; i ++ ) for ( int j = 0 ; j < c + 1 ; j ++ ) x [ mkviwps ] [ j ] += x [ i ] [ j ] ; for ( int i = 0 ; i < mkviwps + 1 ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) System . out . print ( x [ i ] [ j ] + " " ) ; System . out . println ( x [ i ] [ c ] ) ; } } public static void main ( String [ ] ag ) { new Main ( ) . main ( ) ; } } import java . util . Scanner ; public class Hnowyb { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int hnowyb = in . nextInt ( ) ; int b = in . nextInt ( ) ; int min = b ; int max = b ; long sum = b ; for ( int i = 0 ; i < hnowyb - 1 ; i ++ ) { int c = in . nextInt ( ) ; if ( min > c ) { min = c ; } if ( max < c ) { max = c ; } sum += c ; } System . out . println ( min + " " + max + " " + sum ) ; } } import java . util . Scanner ; public class Kqixcj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long kqixcj = sc . nextLong ( ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long C = kqixcj / ( A + B ) ; long D = kqixcj % ( A + B ) ; if ( A == 0 ) { System . out . println ( 0 ) ; } else if ( D <= A ) { System . out . println ( C * A + D ) ; } else if ( D > A ) { System . out . println ( C * A + A ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Fqxevs { public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = in . readLine ( ) ; String [ ] Ws = W . split ( " " ) ; long fqxevs = Long . parseLong ( Ws [ 0 ] ) ; long B = Long . parseLong ( Ws [ 1 ] ) ; long K = fqxevs + B ; if ( K % 2 == 1 ) { System . out . println ( " IMPOSSIBLE " ) ; } else { System . out . println ( K / 2 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Wxcdvse { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] Aandb = ( input . readLine ( ) ) . split ( " \\ s " ) ; int wxcdvse = Integer . parseInt ( Aandb [ 0 ] ) ; int m = Integer . parseInt ( Aandb [ 1 ] ) ; int [ ] [ ] A = new int [ wxcdvse ] [ m ] ; String [ ] z = null ; for ( int i = 0 ; i < wxcdvse ; i ++ ) { z = ( input . readLine ( ) ) . split ( " \\ s " ) ; for ( int j = 0 ; j < m ; j ++ ) { A [ i ] [ j ] = Integer . parseInt ( z [ j ] ) ; } } int [ ] b = new int [ m ] ; for ( int k = 0 ; k < m ; k ++ ) { b [ k ] = Integer . parseInt ( input . readLine ( ) ) ; } for ( int l = 0 ; l < wxcdvse ; l ++ ) { int C = 0 ; for ( int s = 0 ; s < m ; s ++ ) { C += ( A [ l ] [ s ] * b [ s ] ) ; } System . out . println ( C ) ; } } } import java . util . * ; public class Fyptjg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int fyptjg = scan . nextInt ( ) ; for ( int i = fyptjg ; i <= Math . pow ( 10 , 9 ) ; i ++ ) { if ( isPrime ( i ) ) { System . out . println ( i ) ; return ; } } scan . close ( ) ; } public static boolean isPrime ( int n ) { for ( int i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } } import java . io . * ; public class Dhquc { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int dhquc = 0 ; String [ ] line ; line = new String [ 10000 ] ; try { while ( dhquc < 10000 ) { line [ dhquc ] = reader . readLine ( ) ; if ( line [ dhquc ] . equals ( " 0 " ) ) break ; dhquc ++ ; } dhquc = 0 ; while ( dhquc < 10000 ) { if ( line [ dhquc ] . equals ( " 0 " ) ) break ; System . out . println ( " Case " + ( dhquc + 1 ) + " : " + line [ dhquc ] ) ; dhquc ++ ; } } catch ( IOException e ) { System . out . println ( e ) ; } catch ( NumberFormatException e ) { System . out . println ( e ) ; } } } import java . util . * ; public class Ntvaoi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ntvaoi = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] S = sc . nextLine ( ) . split ( " " ) ; int count = 0 ; int now = 0 ; for ( int i = 0 ; i < ntvaoi ; i ++ ) { int n = Integer . parseInt ( S [ i ] ) ; if ( n > now ) { count += n - now ; now = n ; } else { now = n ; } } System . out . println ( count ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class Bsweqd { public static void main ( String [ ] args ) throws Exception { solve ( System . in , System . out ) ; } static void solve ( InputStream is , PrintStream os ) { Scanner scan = new Scanner ( is ) ; long bsweqd = scan . nextLong ( ) ; int N = scan . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) A [ i ] = scan . nextInt ( ) ; Arrays . sort ( A ) ; for ( int i = N - 1 ; i >= 0 ; i -- ) { bsweqd -= A [ i ] ; if ( bsweqd <= 0 ) break ; } if ( bsweqd <= 0 ) os . println ( " Yes " ) ; else os . println ( " No " ) ; } } import java . util . * ; class Rmnpfnp { public static void main ( String [ ] str ) { Scanner s = new Scanner ( System . in ) ; String s1 = s . next ( ) ; String s2 = s . next ( ) ; int rmnpfnp = s2 . length ( ) ; int i = 0 ; String res = s2 . substring ( i , rmnpfnp - 1 ) ; if ( res . equals ( s1 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . * ; import java . math . * ; import java . security . * ; import java . text . * ; import java . util . * ; import java . util . concurrent . * ; import java . util . regex . * ; public class Moucot { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int moucot = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int t = scan . nextInt ( ) ; int time = 0 ; while ( moucot > 0 ) { moucot -= x ; time += t ; } System . out . println ( time ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Anlst { public static void main ( String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; int anlst = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] problems = new int [ anlst ] ; int [ ] was = new int [ anlst ] ; for ( int i = 0 ; i < M ; i ++ ) { final int p = sc . nextInt ( ) - 1 ; boolean isAC = sc . next ( ) . equals ( " AC " ) ; if ( isAC ) { problems [ p ] = 1 ; } else { if ( problems [ p ] != 1 ) { was [ p ] ++ ; } } } int wa = 0 ; for ( int i = 0 ; i < anlst ; i ++ ) { if ( problems [ i ] == 1 ) { wa += was [ i ] ; } } System . out . println ( Arrays . stream ( problems ) . sum ( ) + " " + wa ) ; } } import java . util . Scanner ; class Yqiue { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int yqiue = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int a1 = yqiue * b ; int a2 = 2 * ( yqiue + b ) ; System . out . printf ( " %d %d \n " , a1 , a2 ) ; } } import java . util . Scanner ; public class Rgjhnng { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rgjhnng = sc . nextInt ( ) ; long res = 0 ; for ( int i = 1 ; i <= rgjhnng ; i ++ ) if ( String . valueOf ( i ) . length ( ) % 2 == 1 ) res ++ ; System . out . println ( res ) ; } } import java . util . * ; public class Bgtdtr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bgtdtr = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; int count = 1 ; int ans = 0 ; for ( int i = 0 ; i < bgtdtr ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp == count ) { ans ++ ; count ++ ; } list . add ( tmp ) ; } if ( ans == 0 ) { System . out . println ( " -1 " ) ; } else { System . out . println ( bgtdtr - ans ) ; } } } import java . util . * ; public class Cmlzc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] arr = sc . next ( ) . toCharArray ( ) ; if ( arr [ 1 ] == 'R' ) { arr [ 1 ] = 'B' ; } else { arr [ 1 ] = 'R' ; } System . out . println ( arr ) ; } } import java . util . Scanner ; public class Dziboy { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int dziboy = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int c = stdIn . nextInt ( ) ; int x = stdIn . nextInt ( ) ; int y = stdIn . nextInt ( ) ; if ( c - 0.5 * dziboy - 0.5 * b > 0 ) { System . out . println ( dziboy * x + b * y ) ; } else { if ( x < y ) { if ( b * ( y - x ) + 2 * c * x <= 2 * c * y ) { System . out . println ( b * ( y - x ) + 2 * c * x ) ; } else { System . out . println ( 2 * c * y ) ; } } else { if ( dziboy * ( x - y ) + 2 * c * y <= 2 * c * x ) { System . out . println ( dziboy * ( x - y ) + 2 * c * y ) ; } else { System . out . println ( 2 * c * x ) ; } } } } } import java . util . * ; class Klokg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int klokg = scan . nextInt ( ) ; String [ ] S = new String [ klokg + 1 ] ; int [ ] C = { 0 , 0 , 0 , 0 } ; for ( int i = 0 ; i < klokg + 1 ; i ++ ) { S [ i ] = scan . nextLine ( ) ; } for ( int i = 0 ; i < klokg + 1 ; i ++ ) { switch ( S [ i ] ) { case " AC " : C [ 0 ] += 1 ; break ; case " WA " : C [ 1 ] += 1 ; break ; case " TLE " : C [ 2 ] += 1 ; break ; case " RE " : C [ 3 ] += 1 ; break ; default : } } System . out . println ( " AC x " + C [ 0 ] + " \n " + " WA x " + C [ 1 ] + " \n " + " TLE x " + C [ 2 ] + " \n " + " RE x " + C [ 3 ] ) ; scan . close ( ) ; } } import java . util . Scanner ; public class Uzfrwil { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uzfrwil = sc . nextInt ( ) ; int [ ] h = new int [ uzfrwil ] ; for ( int i = 0 ; i < uzfrwil ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int ans = 0 ; while ( true ) { boolean flg = true ; int count = 0 ; for ( int i = 0 ; i < uzfrwil ; i ++ ) { if ( h [ i ] != 0 && flg ) { ans ++ ; flg = false ; } else if ( h [ i ] == 0 ) { flg = true ; count ++ ; } if ( h [ i ] > 0 ) { h [ i ] -- ; } if ( count == uzfrwil ) { System . out . println ( ans ) ; return ; } } } } } import java . util . Scanner ; public class Ulpksrj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; boolean ulpksrj = true ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z ; while ( true ) { z = x % y ; x = y ; y = z ; if ( y == 0 ) { break ; } } System . out . printf ( " %d%n " , x ) ; } } import java . util . Scanner ; public class Lxbohf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lxbohf = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; String ans = " No " ; if ( lxbohf == B && B != C ) ans = " Yes " ; if ( lxbohf == C && lxbohf != B ) ans = " Yes " ; if ( B == C && lxbohf != B ) ans = " Yes " ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Cycqp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cycqp = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] array = new int [ cycqp ] ; int swap1 , swap2 ; byte garbage ; for ( int i = 0 ; i < cycqp ; i ++ ) array [ i ] = i + 1 ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] swaps = sc . next ( ) . split ( " , " , 0 ) ; swap1 = Integer . parseInt ( swaps [ 0 ] ) - 1 ; swap2 = Integer . parseInt ( swaps [ 1 ] ) - 1 ; int temp = array [ swap1 ] ; array [ swap1 ] = array [ swap2 ] ; array [ swap2 ] = temp ; } for ( int i = 0 ; i < cycqp ; i ++ ) { System . out . println ( array [ i ] ) ; } } } import java . util . Scanner ; public class Rlitc { public static void rlitc ( String str ) { boolean rlitc = false ; if ( rlitc == false ) { return ; } System . out . println ( str ) ; } public static void main ( String [ ] args ) { int N ; int A ; int B ; try ( Scanner sc = new Scanner ( System . in ) ) { N = sc . nextInt ( ) ; A = sc . nextInt ( ) ; B = sc . nextInt ( ) ; } int res = N * A < B ? N * A : B ; System . out . println ( res ) ; } } import java . util . Scanner ; public class Mehkd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int mehkd = 0 ; int b = 0 ; int c = 0 ; int n = scanner . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { mehkd = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; c = scanner . nextInt ( ) ; if ( c * c == mehkd * mehkd + b * b || b * b == mehkd * mehkd + c * c || mehkd * mehkd == b * b + c * c ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Oigew { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int oigew = in . nextInt ( ) ; int [ ] value = new int [ oigew ] ; for ( int i = 0 ; i < oigew ; i ++ ) { value [ i ] = in . nextInt ( ) ; } int [ ] cost = new int [ oigew ] ; for ( int j = 0 ; j < oigew ; j ++ ) { cost [ j ] = in . nextInt ( ) ; } int result = solve ( oigew , value , cost ) ; System . out . println ( result ) ; in . close ( ) ; } public static int solve ( int oigew , int [ ] value , int [ ] cost ) { int result = 0 ; for ( int i = 0 ; i < oigew ; i ++ ) { if ( ( value [ i ] - cost [ i ] ) > 0 ) { result += value [ i ] - cost [ i ] ; } } return result ; } } import java . util . * ; import java . util . stream . * ; public class Frjkq { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int frjkq = in . nextInt ( ) ; int L = in . nextInt ( ) ; int min = Integer . MAX_VALUE ; int sum = 0 ; for ( int i = 0 ; i < frjkq ; i ++ ) { sum += L + i ; if ( Math . abs ( L + i ) < Math . abs ( min ) ) { min = L + i ; } } System . out . println ( sum - min ) ; } } import java . util . * ; public class Rzxongl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rzxongl = sc . nextInt ( ) ; int cnt = 0 ; Set < Integer > set = new TreeSet < > ( ) ; for ( int i = 1 ; i <= rzxongl ; i += 2 ) { int tmp = i ; for ( int j = 1 ; j <= Math . sqrt ( tmp ) ; j ++ ) { if ( tmp % j == 0 ) { set . add ( tmp ) ; set . add ( j ) ; set . add ( tmp / j ) ; } } if ( set . size ( ) == 8 ) { cnt ++ ; } set . clear ( ) ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Qxstifm { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { while ( sc . hasNext ( ) ) { String alf = sc . next ( ) ; if ( alf . equals ( " - " ) ) break ; int qxstifm = sc . nextInt ( ) ; for ( int i = 0 ; i < qxstifm ; i ++ ) { int subNum = sc . nextInt ( ) ; String tmpSub = alf . substring ( 0 , subNum ) ; String tmp = alf . substring ( subNum ) ; alf = tmp + tmpSub ; } System . out . println ( alf ) ; } } } import java . util . * ; public class Yjdukgz { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int yjdukgz = sc . nextInt ( ) ; int [ ] num = new int [ 1000000 ] ; int ans = 0 ; num [ 0 ] = yjdukgz ; for ( int i = 1 ; i < 1000000 ; i ++ ) { if ( yjdukgz % 2 == 0 ) { num [ i ] = yjdukgz / 2 ; yjdukgz = yjdukgz / 2 ; } else if ( yjdukgz % 2 == 1 ) { num [ i ] = 3 * yjdukgz + 1 ; yjdukgz = 3 * yjdukgz + 1 ; } for ( int j = 0 ; j < i ; j ++ ) { if ( num [ j ] == num [ i ] ) { ans = i + 1 ; } } if ( ans != 0 ) { break ; } } System . out . println ( ans ) ; } } import java . io . * ; public class Uqeonx { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = reader . readLine ( ) . split ( " " ) ; int uqeonx , Y ; uqeonx = Integer . parseInt ( arr [ 0 ] ) ; Y = Integer . parseInt ( arr [ 1 ] ) ; int C , T ; C = 2 * uqeonx - Y / 2 ; T = - uqeonx + Y / 2 ; System . out . println ( 0 <= C && 0 <= T && 2 * C + 4 * T == Y && C + T == uqeonx ? " Yes " : " No " ) ; return ; } } import java . util . * ; public class Thlbw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int thlbw = sc . nextInt ( ) ; int [ ] P = new int [ thlbw ] ; P [ 0 ] = sc . nextInt ( ) ; int error = 0 ; boolean asc = true ; boolean once = true ; for ( int i = 1 ; i < thlbw ; i ++ ) { P [ i ] = sc . nextInt ( ) ; if ( once && ! asc && error - 1 == P [ i - 1 ] ) { asc = true ; once = false ; } else if ( P [ i ] < P [ i - 1 ] ) { error = P [ i - 1 ] ; asc = false ; } } System . out . println ( asc ? " YES " : " NO " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Tzaazo { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = input . readLine ( ) ; String WORD = word . toUpperCase ( ) ; int tzaazo = 0 ; while ( true ) { String [ ] str = input . readLine ( ) . split ( " " ) ; if ( str [ 0 ] . equals ( " END_OF_TEXT " ) ) break ; String [ ] STR = new String [ str . length ] ; for ( int num = 0 ; num < str . length ; num ++ ) STR [ num ] = str [ num ] . toUpperCase ( ) ; for ( int num = 0 ; num < STR . length ; num ++ ) { if ( STR [ num ] . equals ( WORD ) ) { tzaazo ++ ; } } } System . out . println ( tzaazo ) ; } } import java . util . Scanner ; public class Haoqn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] m = new int [ 200 ] ; int haoqn = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; int sum = 0 ; for ( int i = 0 ; i < haoqn ; i ++ ) m [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < haoqn ; i ++ ) X -= m [ i ] ; for ( int i = 0 ; i < haoqn ; i ++ ) if ( m [ i ] < min ) min = m [ i ] ; sum = haoqn + ( X / min ) ; System . out . println ( sum ) ; } } import java . util . Scanner ; import java . lang . Math ; public class Levvxr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int levvxr = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( solve ( levvxr ) ) ; } public static int solve ( int levvxr ) { int ans = 0 ; for ( int i = 1 ; i <= levvxr ; i ++ ) { int digit = ( int ) Math . log10 ( i ) + 1 ; if ( digit % 2 == 1 ) { ans ++ ; } } return ans ; } } import java . io . IOException ; import java . util . Scanner ; public class Xhjda { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int xhjda = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d ; d = 0 ; while ( xhjda <= b ) { if ( c % xhjda == 0 ) { d = d + 1 ; } xhjda = xhjda + 1 ; } System . out . println ( d ) ; } } import java . util . Scanner ; import java . util . Stack ; class Glpeq { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; int glpeq = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] nanbon = new int [ glpeq ] ; for ( int i = 0 ; i < M ; i ++ ) { nanbon [ sc . nextInt ( ) - 1 ] ++ ; nanbon [ sc . nextInt ( ) - 1 ] ++ ; } for ( int i = 0 ; i < glpeq ; i ++ ) { System . out . println ( nanbon [ i ] ) ; } } } import java . util . LinkedList ; import java . util . Queue ; import java . util . Scanner ; public class Oygtz { public static void main ( String [ ] args ) { int oygtz ; int quantum ; int clock = 0 ; String line ; Queue < String > taskQueue = new LinkedList < String > ( ) ; Queue < Integer > timeQueue = new LinkedList < Integer > ( ) ; Scanner keyboard = new Scanner ( System . in ) ; Scanner input ; line = keyboard . nextLine ( ) ; input = new Scanner ( line ) ; oygtz = Integer . parseInt ( input . next ( ) ) ; quantum = Integer . parseInt ( input . next ( ) ) ; for ( int i = 0 ; i < oygtz ; i ++ ) { line = keyboard . nextLine ( ) ; input = new Scanner ( line ) ; taskQueue . add ( input . next ( ) ) ; timeQueue . add ( Integer . parseInt ( input . next ( ) ) ) ; } while ( ! taskQueue . isEmpty ( ) ) { String currentTask = taskQueue . remove ( ) ; int currentTime = timeQueue . remove ( ) ; if ( currentTime > quantum ) { currentTime = currentTime - quantum ; taskQueue . add ( currentTask ) ; timeQueue . add ( currentTime ) ; clock = clock + quantum ; } else { clock = clock + currentTime ; System . out . print ( currentTask + " " ) ; System . out . println ( clock ) ; } } } } import java . util . * ; public class Orlxlrh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int orlxlrh = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; String s = sc . next ( ) ; System . out . println ( sln ( k , s ) ) ; } public static String sln ( int k , String s ) { String res = s . substring ( 0 , k - 1 ) + ( s . charAt ( k - 1 ) + " " ) . toLowerCase ( ) + s . substring ( k ) ; return res ; } } import java . util . Scanner ; public class Xucih { public static void main ( String [ ] args ) { solve ( ) ; } private static void solve ( ) { Scanner input = new Scanner ( System . in ) ; int xucih = input . nextInt ( ) ; int [ ] nums = new int [ xucih ] ; int first = 0 ; int second = 0 ; for ( int i = 0 ; i < xucih ; i ++ ) { nums [ i ] = input . nextInt ( ) ; if ( nums [ i ] >= first ) { second = first ; first = nums [ i ] ; } else if ( nums [ i ] >= second ) { second = nums [ i ] ; } } for ( int i = 0 ; i < xucih ; i ++ ) { if ( nums [ i ] == first ) { System . out . println ( second ) ; } else { System . out . println ( first ) ; } } } } import java . util . * ; public class Mtbdc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mtbdc = sc . nextInt ( ) ; int [ ] a = new int [ mtbdc ] ; int sumA = 0 ; int sumB = 0 ; for ( int i = 0 ; i < mtbdc ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int i = mtbdc - 1 ; i >= 0 ; i -= 2 ) { sumA += a [ i ] ; } for ( int i = mtbdc - 2 ; i >= 0 ; i -= 2 ) { sumB += a [ i ] ; } System . out . println ( sumA - sumB ) ; } } import java . util . * ; public class Sznnju { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sznnju = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] ps = new int [ n ] ; int ans ; int istack ; for ( int i = 0 ; i < n ; i ++ ) { istack = sc . nextInt ( ) ; if ( istack < sznnju ) ps [ i ] = Math . abs ( sznnju - istack ) * 2 ; else ps [ i ] = Math . abs ( sznnju - istack ) * 2 + 1 ; } Arrays . sort ( ps ) ; ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ps [ i ] == ans ) ans ++ ; else break ; } if ( ans % 2 == 0 ) sznnju -= ans / 2 ; else sznnju += ans / 2 ; System . out . println ( sznnju ) ; } } import java . util . Scanner ; public class Vznrym { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int vznrym = scan . nextInt ( ) ; int [ ] ar = new int [ vznrym ] ; int ans = 0 ; int pre = 0 ; int cur ; for ( int i = 0 ; i < vznrym ; i ++ ) { int curr = scan . nextInt ( ) ; if ( pre > curr ) { ans += pre - curr ; } pre = curr ; } ans += pre ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Fdzni { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fdzni = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int [ ] result = getMax ( fdzni , b , c ) ; fdzni = result [ 0 ] ; b = result [ 1 ] ; c = result [ 2 ] ; } System . out . println ( fdzni + b + c ) ; } private static int [ ] getMax ( int fdzni , int b , int c ) { int [ ] newInput = new int [ ] { fdzni , b , c } ; if ( fdzni <= b && c <= b ) { newInput [ 1 ] = 2 * b ; } else if ( b <= fdzni && c <= fdzni ) { newInput [ 0 ] = 2 * fdzni ; } else if ( fdzni <= c && b <= c ) { newInput [ 2 ] = 2 * c ; } return newInput ; } } import java . util . Scanner ; class Igtspkp { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int igtspkp = scan . nextInt ( ) ; int H = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; double area = ( double ) igtspkp * H / 2 ; int flag = 0 ; if ( x * 2 == igtspkp && y * 2 == H ) { flag = 1 ; } System . out . println ( area + " " + flag ) ; } } import java . util . Scanner ; public class Hlzpob { static int [ ] subTreeSize ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long hlzpob = sc . nextLong ( ) ; hlzpob -- ; int idx = 0 ; for ( ; idx < s . length ( ) && s . charAt ( idx ) == '1' ; idx ++ ) ; char ans = hlzpob < idx ? '1' : s . charAt ( idx ) ; System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Okmtylm { public static void main ( String [ ] args ) throws Exception { try { long okmtylm = 0 ; int min = 1000000 ; int max = - 1000000 ; BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String input1 = buf . readLine ( ) ; int count = Integer . parseInt ( input1 ) ; String input2 = buf . readLine ( ) ; String [ ] strAry = input2 . split ( " " ) ; for ( int i = 0 ; i < count ; i ++ ) { int x = Integer . parseInt ( strAry [ i ] ) ; okmtylm = okmtylm + x ; if ( x < min ) { min = x ; } if ( x > max ) { max = x ; } } System . out . println ( min + " " + max + " " + okmtylm ) ; } catch ( Exception e ) { System . out . println ( " ???????????? " ) ; } } } import java . util . Scanner ; public class Zmjcr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int zmjcr = scan . nextInt ( ) * scan . nextInt ( ) ; scan . close ( ) ; System . out . println ( zmjcr ) ; } } import java . util . Scanner ; public class Izcemu { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int izcemu = stdIn . nextInt ( ) ; int n = stdIn . nextInt ( ) ; int [ ] [ ] a = new int [ izcemu ] [ n ] ; int [ ] b = new int [ n ] ; int ans ; for ( int i = 0 ; i < izcemu ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { a [ i ] [ j ] = stdIn . nextInt ( ) ; } } for ( int k = 0 ; k < n ; k ++ ) { b [ k ] = stdIn . nextInt ( ) ; } stdIn . close ( ) ; for ( int x = 0 ; x < izcemu ; x ++ ) { ans = 0 ; for ( int y = 0 ; y < n ; y ++ ) { ans += a [ x ] [ y ] * b [ y ] ; } System . out . println ( ans ) ; } } } import java . util . Scanner ; class Kbigzeu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kbigzeu = scan . nextInt ( ) ; int A = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < B - A + 1 ; i ++ ) { if ( ( A + i ) % kbigzeu == 0 ) { count += 1 ; } else { } } if ( count > 0 ) { System . out . println ( " OK " ) ; } if ( count == 0 ) { System . out . println ( " NG " ) ; } } } import java . util . Scanner ; public class Koqkzoi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int koqkzoi = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; double d = koqkzoi / 0.08 ; int x = ( int ) ( koqkzoi / 0.08 ) ; if ( d != x ) x ++ ; System . err . println ( x ) ; int min = koqkzoi ; int max = koqkzoi ; int xmin = x ; int xmax = x ; int i = 0 ; while ( min == koqkzoi ) { xmin -- ; min = ( int ) ( xmin * 0.08 ) ; } while ( max == koqkzoi ) { xmax ++ ; max = ( int ) ( xmax * 0.08 ) ; } System . err . println ( " min: " + xmin + " max: " + xmax ) ; for ( int j = xmin + 1 ; j < xmax ; j ++ ) { if ( b == ( int ) ( j * 0.1 ) ) { System . out . println ( j ) ; return ; } } System . out . println ( - 1 ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . List ; public class Wthkw { public static void main ( String [ ] args ) throws Exception { InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader reader = new BufferedReader ( is ) ; List < String > mylist = new ArrayList < > ( ) ; String strinput = reader . readLine ( ) ; while ( strinput != null ) { mylist . add ( strinput ) ; strinput = reader . readLine ( ) ; } String [ ] arr01 = mylist . get ( 0 ) . split ( " " ) ; String [ ] arr02 = mylist . get ( 1 ) . split ( " " ) ; int wthkw = Integer . valueOf ( arr01 [ 0 ] ) ; Boolean chkflg = true ; for ( int i = 0 ; i < wthkw - 2 ; i ++ ) { int temp1 = Integer . valueOf ( arr02 [ i ] ) ; int temp2 = Integer . valueOf ( arr02 [ i + 1 ] ) ; int temp3 = Integer . valueOf ( arr02 [ i + 2 ] ) ; if ( temp1 < temp2 ) { temp2 -= 1 ; arr02 [ i + 1 ] = String . valueOf ( temp2 ) ; if ( temp2 > temp3 ) { chkflg = false ; break ; } } else if ( temp1 == temp2 ) { if ( temp2 > temp3 ) { chkflg = false ; break ; } } else { chkflg = false ; break ; } } System . out . println ( chkflg ? " Yes " : " No " ) ; } } import java . util . * ; import java . util . Arrays ; public class Rntruv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rntruv = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; long [ ] arr = new long [ rntruv ] ; for ( int i = 0 ; i < rntruv ; i ++ ) { arr [ i ] = sc . nextLong ( ) ; } Arrays . sort ( arr ) ; long total = 0 ; for ( int j = 0 ; j < rntruv - K ; j ++ ) { total += arr [ j ] ; } System . out . println ( total ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Awuguk { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; String t = in . next ( ) ; int awuguk = 0 ; int min = 9999 ; for ( int i = 0 ; i <= s . length ( ) - t . length ( ) ; i ++ ) { awuguk = 0 ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( i + j ) == t . charAt ( j ) ) { } else { awuguk ++ ; } } if ( min > awuguk ) { min = awuguk ; } } if ( s . contains ( t ) ) { System . out . println ( 0 ) ; } else System . out . println ( min ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Xvopsq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strArray = br . readLine ( ) . split ( " " ) ; int xvopsq = Integer . parseInt ( strArray [ 0 ] ) ; int b = Integer . parseInt ( strArray [ 1 ] ) ; System . out . println ( getGCD ( xvopsq , b ) ) ; } public static int getGCD ( int xvopsq , int b ) { if ( xvopsq == b ) return xvopsq ; else if ( xvopsq < b ) { return getGCD ( xvopsq , b - xvopsq ) ; } else return getGCD ( xvopsq - b , xvopsq ) ; } } import java . util . Scanner ; public class Tcybd { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s_a = in . nextLine ( ) ; String s_b = in . nextLine ( ) ; String s_c = in . nextLine ( ) ; int tcybd = 0 ; int b = 0 ; int c = 0 ; char currentChar = 'a' ; while ( true ) { if ( currentChar == 'a' ) { if ( tcybd == s_a . length ( ) ) { System . out . println ( 'A' ) ; break ; } currentChar = s_a . charAt ( tcybd ) ; tcybd ++ ; } else if ( currentChar == 'b' ) { if ( b == s_b . length ( ) ) { System . out . println ( 'B' ) ; break ; } currentChar = s_b . charAt ( b ) ; b ++ ; } else if ( currentChar == 'c' ) { if ( c == s_c . length ( ) ) { System . out . println ( 'C' ) ; break ; } currentChar = s_c . charAt ( c ) ; c ++ ; } } } } import java . util . Scanner ; public class Mnswb { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int mnswb = scanner . nextInt ( ) , w = scanner . nextInt ( ) ; System . out . println ( ( mnswb > w ) ? " safe " : " unsafe " ) ; } } } import java . io . * ; import java . util . * ; public class Grvsgjy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int grvsgjy , B ; grvsgjy = scan . nextInt ( ) ; B = scan . nextInt ( ) ; double tax8 = 0.08 ; double tax10 = 0.10 ; int price = - 1 ; for ( int i = 1 ; i <= 1000 ; i ++ ) { if ( ( int ) ( i * tax8 + i ) - i == grvsgjy && ( int ) ( i * tax10 + i ) - i == B ) { price = i ; break ; } } System . out . println ( price ) ; } } import java . util . * ; class Nehyf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nehyf = sc . nextInt ( ) ; int [ ] t = new int [ nehyf + 1 ] , x = new int [ nehyf + 1 ] , y = new int [ nehyf + 1 ] ; boolean flag = true ; t [ 0 ] = 0 ; x [ 0 ] = 0 ; y [ 0 ] = 0 ; for ( int i = 1 ; i < nehyf + 1 ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < nehyf + 1 ; i ++ ) { if ( t [ i ] - t [ i - 1 ] < Math . abs ( x [ i ] - x [ i - 1 ] ) + Math . abs ( y [ i ] - y [ i - 1 ] ) || ( t [ i ] - t [ i - 1 ] ) % 2 != Math . abs ( x [ i ] + y [ i ] - x [ i - 1 ] - y [ i - 1 ] ) % 2 ) flag = false ; } String ans = flag ? " Yes " : " No " ; System . out . println ( ans ) ; } } import java . util . * ; public class Vlkrw { static int vlkrw = 1000000007 ; static int INF = Integer . MAX_VALUE ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; sc . close ( ) ; long res = lcm ( a , b ) ; System . out . println ( res ) ; } public static int gcd ( int m , int n ) { if ( m < n ) return gcd ( n , m ) ; if ( n == 0 ) return m ; return gcd ( n , m % n ) ; } public static long lcm ( int a , int b ) { int d = gcd ( a , b ) ; return ( long ) a / d * b ; } } import java . util . * ; public class Sumkgx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sumkgx = sc . nextInt ( ) ; int a = 1000 ; int i = 2 ; while ( a < sumkgx ) { a = 1000 * i ; i ++ ; } System . out . println ( a - sumkgx ) ; } } import java . util . * ; public class Emoymo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int emoymo = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int q = scan . nextInt ( ) ; int [ ] g = new int [ emoymo ] ; for ( int i = 0 ; i < q ; i ++ ) { int t = scan . nextInt ( ) ; g [ t - 1 ] += 1 ; } for ( int j = 0 ; j < emoymo ; j ++ ) { if ( k - q + g [ j ] > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . ArrayList ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; public class Vgepia { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vgepia = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < vgepia ; i ++ ) { String s = sc . next ( ) ; list . add ( s ) ; } List < String > listb = new ArrayList < String > ( new HashSet < > ( list ) ) ; sc . close ( ) ; System . out . println ( listb . size ( ) ) ; } } import java . util . * ; public class Bcgjpk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bcgjpk = sc . nextInt ( ) ; int [ ] st = new int [ bcgjpk ] ; for ( int i = 0 ; i < bcgjpk ; i ++ ) { st [ i ] = sc . nextInt ( ) ; } Arrays . sort ( st ) ; int a = st [ 0 ] ; int b = st [ bcgjpk - 1 ] ; System . out . println ( Math . abs ( a - b ) ) ; } } import java . util . * ; import java . lang . Math ; class Sshui { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double sshui = sc . nextInt ( ) ; double tmp = Math . ceil ( sshui / 2 ) ; double ans = tmp / sshui ; System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Oyuyitq { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int oyuyitq = Integer . parseInt ( scn . nextLine ( ) ) ; String name = scn . nextLine ( ) ; char [ ] original = name . toCharArray ( ) ; ArrayList < Character > result = new ArrayList < > ( ) ; result . add ( original [ 0 ] ) ; for ( int i = 1 ; i < oyuyitq ; i ++ ) { if ( result . get ( result . size ( ) - 1 ) == original [ i ] ) { continue ; } else result . add ( original [ i ] ) ; } System . out . println ( result . size ( ) ) ; } } import java . io . PrintWriter ; import java . util . Scanner ; public class Wpiixph { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wpiixph = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 1 ; i <= wpiixph ; i ++ ) { if ( String . valueOf ( i ) . length ( ) == 1 ) { count ++ ; } else if ( String . valueOf ( i ) . length ( ) % 2 != 0 ) { count ++ ; } } PrintWriter out = new PrintWriter ( System . out ) ; out . println ( count ) ; out . flush ( ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Mmeuh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; Integer N = Integer . parseInt ( sc . next ( ) ) ; Integer Y = Integer . parseInt ( sc . next ( ) ) ; for ( int mmeuh = 0 ; mmeuh <= N ; mmeuh ++ ) { for ( int m = 0 ; m <= N - mmeuh ; m ++ ) { int n = N - mmeuh - m ; if ( mmeuh * 10000 + m * 5000 + n * 1000 == Y ) { System . out . println ( mmeuh + " " + m + " " + n ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . io . * ; class Brqcoz { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int brqcoz = Integer . parseInt ( br . readLine ( ) ) ; int count = 0 ; for ( int i = 0 ; i < brqcoz ; i ++ ) { long x = Long . parseLong ( br . readLine ( ) ) ; if ( isprime ( x ) ) count ++ ; } System . out . println ( count ) ; } catch ( Exception e ) { System . out . println ( e ) ; } } public static boolean isprime ( long x ) { if ( x == 2 ) return true ; if ( x < 2 || x % 2 == 0 ) return false ; int i = 3 ; while ( i <= Math . sqrt ( x ) ) { if ( x % i == 0 ) return false ; i = i + 2 ; } return true ; } } import java . util . * ; public class Wlvos { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wlvos = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int attack = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; attack += a [ i ] ; } if ( wlvos <= attack ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Ggroyt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ggroyt = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int len = ( ggroyt < B ) ? ggroyt : B ; List r = new ArrayList < Integer > ( ) ; for ( int i = 1 ; i <= len ; i ++ ) { if ( ggroyt % i == 0 && B % i == 0 ) r . add ( i ) ; } System . out . println ( r . get ( r . size ( ) - K ) ) ; } } import java . util . Scanner ; public class Qbocj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qbocj = sc . nextInt ( ) ; long [ ] townmonster = new long [ qbocj + 1 ] ; for ( int i = 0 ; i < qbocj + 1 ; i ++ ) { townmonster [ i ] = sc . nextLong ( ) ; } long [ ] yusha = new long [ qbocj + 1 ] ; for ( int i = 0 ; i < qbocj ; i ++ ) { yusha [ i ] = sc . nextLong ( ) ; } yusha [ qbocj ] = 0 ; long count = 0 ; long yojou = 0 ; for ( int i = 0 ; i < qbocj + 1 ; i ++ ) { long target = townmonster [ i ] ; long yusha_yoryoku = yusha [ i ] ; if ( target >= yusha_yoryoku + yojou ) { count += yusha_yoryoku + yojou ; yojou = 0 ; } else { count += target ; long nokori = target - yojou ; if ( nokori > 0 ) { yojou = yusha_yoryoku - nokori ; } else { yojou = yusha_yoryoku ; } } } System . out . println ( count ) ; } } import java . util . * ; public class Ffjjlxc { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; String str1 = scan . nextLine ( ) ; String [ ] str2 = new String [ str1 . length ( ) ] ; boolean ffjjlxc = true ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { str2 [ i ] = str1 . substring ( i , i + 1 ) ; if ( i % 2 == 0 && ! str1 . substring ( i , i + 1 ) . equals ( " R " ) && ! str1 . substring ( i , i + 1 ) . equals ( " U " ) && ! str1 . substring ( i , i + 1 ) . equals ( " D " ) ) { ffjjlxc = false ; } else if ( i % 2 == 1 && ! str1 . substring ( i , i + 1 ) . equals ( " L " ) && ! str1 . substring ( i , i + 1 ) . equals ( " U " ) && ! str1 . substring ( i , i + 1 ) . equals ( " D " ) ) { ffjjlxc = false ; } } if ( ffjjlxc ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . List ; public class Mmvhh { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; List < String > list = new ArrayList < > ( ) ; String data ; while ( ( data = br . readLine ( ) ) != null ) { list . add ( data ) ; } int mmvhh = Integer . parseInt ( list . get ( 0 ) ) ; String s = list . get ( 1 ) ; br . close ( ) ; int count = 0 ; int size = mmvhh ; for ( int i = 0 ; i < size ; i ++ ) { if ( size - i >= 3 ) { String tmp = s . substring ( i , i + 3 ) ; if ( " ABC " . equals ( tmp ) ) { count ++ ; } } else { break ; } } System . out . println ( count ) ; } } import java . util . * ; public class Jggcbcu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jggcbcu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int max = Math . max ( jggcbcu , b ) ; max = Math . max ( max , c ) ; int sum = 0 ; if ( max == jggcbcu ) { for ( int i = 0 ; i < n ; i ++ ) { jggcbcu *= 2 ; } } else if ( max == b ) { for ( int i = 0 ; i < n ; i ++ ) { b *= 2 ; } } else { for ( int i = 0 ; i < n ; i ++ ) { c *= 2 ; } } sum = jggcbcu + b + c ; System . out . println ( sum ) ; } public static void printArray ( int [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( i == array . length ) { System . out . println ( array [ i ] ) ; } else { System . out . print ( String . format ( " %d " , array [ i ] ) ) ; } } } public static int gcd ( int jggcbcu , int b ) { if ( b == 0 ) return jggcbcu ; return gcd ( b , jggcbcu % b ) ; } public static int lcm ( int jggcbcu , int b ) { return jggcbcu * b / gcd ( jggcbcu , b ) ; } } import java . util . Scanner ; public class Pfihmc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pfihmc = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] food = new int [ M + 1 ] ; for ( int i = 0 ; i < food . length ; i ++ ) { food [ i ] = 0 ; } for ( int i = 0 ; i < pfihmc ; i ++ ) { int K = sc . nextInt ( ) ; for ( int j = 0 ; j < K ; j ++ ) { food [ sc . nextInt ( ) ] += 1 ; } } int sum = 0 ; for ( int i = 0 ; i < food . length ; i ++ ) { if ( food [ i ] == pfihmc ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Oimqm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final long oimqm = sc . nextLong ( ) ; final long H = sc . nextLong ( ) ; final long x = sc . nextLong ( ) ; final long y = sc . nextLong ( ) ; final long r = sc . nextLong ( ) ; if ( x - r < 0 || x + r > oimqm || y - r < 0 || y + r > H ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class Cgyxgbw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cgyxgbw = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] lot = new int [ cgyxgbw ] ; String bar ; String [ ] s ; int a ; int b ; int save ; for ( int i = 0 ; i < cgyxgbw ; i ++ ) { lot [ i ] = i + 1 ; } for ( int i = 0 ; i < n ; i ++ ) { bar = sc . next ( ) ; s = bar . split ( " , " ) ; a = Integer . parseInt ( s [ 0 ] ) ; b = Integer . parseInt ( s [ 1 ] ) ; save = lot [ b - 1 ] ; lot [ b - 1 ] = lot [ a - 1 ] ; lot [ a - 1 ] = save ; } for ( int i = 0 ; i < cgyxgbw ; i ++ ) { System . out . println ( " " + lot [ i ] ) ; } } } import java . util . Scanner ; class Iortsjs { public static void main ( String [ ] args ) { int iortsjs ; int M ; int X ; int i ; int a = 0 ; int b = 0 ; int [ ] A = new int [ 99 ] ; Scanner sc = new Scanner ( System . in ) ; iortsjs = sc . nextInt ( ) ; M = sc . nextInt ( ) ; X = sc . nextInt ( ) ; i = M ; for ( i = 1 ; i <= M ; i ++ ) { A [ i ] = sc . nextInt ( ) ; if ( A [ i ] > X ) { a ++ ; } else { b ++ ; } } if ( a <= b ) { System . out . println ( a ) ; } else { System . out . println ( b ) ; } } } import java . util . * ; public class Iuvfo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iuvfo = sc . nextInt ( ) ; int wk = 0 ; int ans = 0 ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 2 ; i <= iuvfo ; i ++ ) { wk = sc . nextInt ( ) ; if ( map . containsKey ( wk ) ) { map . put ( wk , map . get ( wk ) + 1 ) ; } else { map . put ( wk , 1 ) ; } } Object [ ] mapkey = map . keySet ( ) . toArray ( ) ; Arrays . sort ( mapkey ) ; for ( int i = 1 ; i <= iuvfo ; i ++ ) { if ( map . containsKey ( i ) ) { System . out . println ( map . get ( i ) ) ; } else { System . out . println ( ans ) ; } } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Yrtwo { public static void main ( String [ ] args ) throws Exception { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int yrtwo = Integer . parseInt ( stdReader . readLine ( ) ) ; String [ ] A = stdReader . readLine ( ) . split ( " " , 0 ) ; int j = 0 ; System . out . println ( String . join ( " " , A ) ) ; for ( int i = 1 ; i < yrtwo ; i ++ ) { String v = A [ i ] ; j = i - 1 ; while ( j >= 0 && Integer . parseInt ( A [ j ] ) > Integer . parseInt ( v ) ) { A [ j + 1 ] = A [ j ] ; j -- ; } A [ j + 1 ] = v ; System . out . println ( String . join ( " " , A ) ) ; } } } import java . util . Scanner ; public class Zxtjlv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int zxtjlv = 0 ; int min2 = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( i % 2 == Character . getNumericValue ( str . charAt ( i ) ) ) { zxtjlv += 1 ; } else { min2 += 1 ; } } System . out . println ( Math . min ( zxtjlv , min2 ) ) ; } } import java . util . Scanner ; class Nazgxlw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nazgxlw = sc . nextInt ( ) ; int numCol1Row2 = sc . nextInt ( ) ; int numCol2 = sc . nextInt ( ) ; int [ ] [ ] mat1 = new int [ nazgxlw ] [ numCol1Row2 ] ; int [ ] [ ] mat2 = new int [ numCol1Row2 ] [ numCol2 ] ; long [ ] [ ] matOut = new long [ nazgxlw ] [ numCol2 ] ; int i , j , k ; for ( i = 0 ; i < nazgxlw ; i ++ ) { for ( j = 0 ; j < numCol1Row2 ; j ++ ) { mat1 [ i ] [ j ] = sc . nextInt ( ) ; } } for ( i = 0 ; i < numCol1Row2 ; i ++ ) { for ( j = 0 ; j < numCol2 ; j ++ ) { mat2 [ i ] [ j ] = sc . nextInt ( ) ; } } for ( i = 0 ; i < nazgxlw ; i ++ ) { for ( j = 0 ; j < numCol2 ; j ++ ) { for ( k = 0 ; k < numCol1Row2 ; k ++ ) { matOut [ i ] [ j ] += mat1 [ i ] [ k ] * mat2 [ k ] [ j ] ; } if ( j != 0 ) System . out . print ( " " ) ; System . out . print ( matOut [ i ] [ j ] ) ; } System . out . println ( ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Lwefm { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String tmp = br . readLine ( ) ; if ( tmp == null ) { break ; } String [ ] tmpArray = tmp . split ( " " ) ; int lwefm = Integer . parseInt ( tmpArray [ 0 ] ) ; int b = Integer . parseInt ( tmpArray [ 1 ] ) ; System . out . println ( GCD ( lwefm , b ) + " " + LCM ( lwefm , b ) ) ; } } static long GCD ( long lwefm , long b ) { long candidate = lwefm ; while ( b % lwefm != 0 ) { candidate = b % lwefm ; b = lwefm ; lwefm = candidate ; } return candidate ; } static long LCM ( long lwefm , long b ) { long GCD = GCD ( lwefm , b ) ; return GCD * ( lwefm / GCD ) * ( b / GCD ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Ujibzz { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] ar = br . readLine ( ) . split ( " " ) ; int ujibzz = Integer . parseInt ( ar [ 0 ] ) ; int col = Integer . parseInt ( ar [ 1 ] ) ; int [ ] [ ] a = new int [ ujibzz ] [ col ] ; int [ ] b = new int [ col ] ; for ( int i = 0 ; i < a . length ; i ++ ) { ar = br . readLine ( ) . split ( " " ) ; for ( int n = 0 ; n < a [ i ] . length ; n ++ ) { a [ i ] [ n ] = Integer . parseInt ( ar [ n ] ) ; } } for ( int i = 0 ; i < b . length ; i ++ ) { b [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } for ( int i = 0 ; i < a . length ; i ++ ) { int ans = 0 ; for ( int n = 0 ; n < a [ i ] . length ; n ++ ) { ans += a [ i ] [ n ] * b [ n ] ; } System . out . println ( ans ) ; } } } import java . util . Scanner ; public class Hoeyld { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hoeyld = sc . nextInt ( ) ; int th = hoeyld / 500 ; int g = ( hoeyld - ( th * 500 ) ) / 5 ; int ans = ( th * 1000 ) + ( g * 5 ) ; System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class Cdpzj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cdpzj = sc . nextInt ( ) ; double D = sc . nextDouble ( ) ; int cnt = 0 ; double [ ] X = new double [ cdpzj ] ; double [ ] Y = new double [ cdpzj ] ; for ( int i = 0 ; i < cdpzj ; i ++ ) { X [ i ] = sc . nextDouble ( ) ; Y [ i ] = sc . nextDouble ( ) ; double d = Math . sqrt ( X [ i ] * X [ i ] + Y [ i ] * Y [ i ] ) ; if ( d <= D ) { cnt ++ ; } else if ( cdpzj == 0 || d > D ) { continue ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class Vmsmt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vmsmt = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ vmsmt ] ; for ( int i = 0 ; i < vmsmt ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Insertion_Sort ( a ) ; } private static void Insertion_Sort ( int [ ] a ) { for ( int i = 0 ; i < a . length ; i ++ ) { int p = a [ i ] ; int j = i - 1 ; while ( j >= 0 && a [ j ] > p ) { a [ j + 1 ] = a [ j ] ; j -- ; } a [ j + 1 ] = p ; for ( int j2 = 0 ; j2 < a . length ; j2 ++ ) { System . out . print ( a [ j2 ] ) ; if ( j2 != a . length - 1 ) { System . out . print ( " " ) ; } } System . out . println ( " " ) ; } } } import java . util . Scanner ; public class Yrqebw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String yrqebw = sc . nextLine ( ) ; if ( yrqebw . equals ( " 5 5 7 " ) || yrqebw . equals ( " 5 7 5 " ) || yrqebw . equals ( " 7 5 5 " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Fmynykc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; if ( s . charAt ( 0 ) != 'A' ) { System . out . println ( " WA " ) ; return ; } int fmynykc = 0 ; for ( int i = 2 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == 'C' ) { fmynykc ++ ; } } if ( fmynykc != 1 ) { System . out . println ( " WA " ) ; return ; } for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( Character . isUpperCase ( s . charAt ( i ) ) && s . charAt ( i ) != 'C' ) { System . out . println ( " WA " ) ; return ; } } System . out . println ( " AC " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Zxrnft { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int zxrnft = scan . nextInt ( ) ; int [ ] A = new int [ zxrnft ] ; for ( int i = 0 ; i < zxrnft ; i ++ ) { A [ i ] = scan . nextInt ( ) ; } insertionSort ( A , zxrnft ) ; } public static void insertionSort ( int [ ] A , int zxrnft ) { String output = Arrays . toString ( A ) . replaceAll ( " , " , " " ) ; System . out . println ( output . substring ( 1 , output . length ( ) - 1 ) ) ; for ( int i = 1 ; i < zxrnft ; i ++ ) { int v = A [ i ] ; int j = i - 1 ; while ( j >= 0 && A [ j ] > v ) { A [ j + 1 ] = A [ j ] ; j -- ; A [ j + 1 ] = v ; } output = Arrays . toString ( A ) . replaceAll ( " , " , " " ) ; System . out . println ( output . substring ( 1 , output . length ( ) - 1 ) ) ; } } } import java . util . * ; public class Xtxdms { public static void main ( String [ ] args ) { taskScheduling ( ) ; } public static void taskScheduling ( ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; a [ 0 ] = sc . nextInt ( ) ; a [ 1 ] = sc . nextInt ( ) ; a [ 2 ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; int xtxdms = 0 ; for ( int i = 1 ; i < a . length ; i ++ ) { xtxdms += a [ i ] - a [ i - 1 ] ; } System . out . println ( xtxdms ) ; } } import java . util . Scanner ; public class Epvurwh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int epvurwh = Integer . parseInt ( sc . next ( ) ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int sum = 0 ; for ( int i = 1 ; i < epvurwh + 1 ; i ++ ) { int tmp = addPerDegit ( i ) ; if ( A <= tmp && tmp <= B ) { sum += i ; } } System . out . println ( sum ) ; } private static int addPerDegit ( int i ) { int sum = 0 ; while ( i > 0 ) { sum += i % 10 ; i /= 10 ; } return sum ; } } import java . util . Scanner ; public class Jjvisss { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double jjvisss = scan . nextDouble ( ) ; double tmp = jjvisss / 3 ; System . out . println ( tmp * tmp * tmp ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Ljhsaf { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ABC121_2 solver = new ABC121_2 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Ljhsaf { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int ljhsaf = in . nextInt ( ) ; int M = in . nextInt ( ) ; int C = in . nextInt ( ) ; int accnt = 0 ; int [ ] B = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { B [ i ] = in . nextInt ( ) ; } for ( int i = 0 ; i < ljhsaf ; i ++ ) { int ttl = 0 ; for ( int b : B ) { int A = in . nextInt ( ) * b ; ttl += A ; } if ( ( ttl + C ) > 0 ) { accnt ++ ; } } out . println ( accnt ) ; } } } import java . util . * ; import java . io . * ; public class Dxrja { public static void main ( String [ ] args ) throws Exception { int dxrja = 998244353 ; BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( bf . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; int count = 0 ; while ( n > 0 ) { n /= k ; count ++ ; } out . println ( count ) ; out . close ( ) ; } } import java . util . Scanner ; import java . util . List ; import java . util . ArrayList ; public class Xhccu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xhccu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( xhccu > b ) { System . out . println ( 2 * xhccu - 1 ) ; } else if ( xhccu == b ) { System . out . println ( 2 * xhccu ) ; } else { System . out . println ( 2 * b - 1 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; class Hdsuj { static Scanner sc = new Scanner ( ) ; public static void main ( final String [ ] args ) throws IOException { int hdsuj = sc . nextInt ( ) ; int [ ] a = new int [ hdsuj ] ; for ( int i = 0 ; i < hdsuj ; i ++ ) { a [ sc . nextInt ( ) - 1 ] = i + 1 ; } for ( int i = 0 ; i < hdsuj ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } } static class Hdsuj { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) , 1 << 15 ) ; StringTokenizer tokenizer ; String next ( ) throws IOException { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } } } import java . util . * ; public class Nasfeey { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int nasfeey = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < nasfeey ; i ++ ) { int a = Integer . parseInt ( sc . next ( ) ) ; while ( 0 < a && a % 2 == 0 ) { a /= 2 ; count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Ktmbcjk { void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int ktmbcjk = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; long min = Long . MAX_VALUE ; for ( int i = ktmbcjk ; i <= R ; i ++ ) { for ( int j = i + 1 ; j <= R ; j ++ ) { long ij = ( ( long ) i * j ) % 2019 ; if ( ij == 0 ) { min = 0 ; break ; } min = Math . min ( min , ij ) ; } if ( min == 0 ) { break ; } } System . out . print ( min ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Eepcgup { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int eepcgup = Integer . parseInt ( br . readLine ( ) ) ; String [ ] kachi = br . readLine ( ) . split ( " " ) ; String [ ] cost = br . readLine ( ) . split ( " " ) ; int k = 0 ; int c = 0 ; int sum = 0 ; for ( int i = 0 ; i < eepcgup ; i ++ ) { k = Integer . parseInt ( kachi [ i ] ) ; c = Integer . parseInt ( cost [ i ] ) ; if ( k - c > 0 ) { sum += k - c ; } } System . out . println ( sum ) ; } } import java . util . * ; public class Wwxsl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] data = sc . nextLine ( ) . split ( " " ) ; int wwxsl = Integer . parseInt ( data [ 0 ] ) ; int b = Integer . parseInt ( data [ 1 ] ) ; int c = Integer . parseInt ( data [ 2 ] ) ; if ( wwxsl + b + c >= 22 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } } } import java . util . * ; public class Gtnwr { public static int digit ( int x ) { int gtnwr = 0 , tmp = x ; if ( x == 0 ) return 1 ; while ( tmp != 0 ) { tmp /= 10 ; ++ gtnwr ; } return gtnwr ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; sc . close ( ) ; String [ ] gtnwr = { " Yes " , " No " } ; int an = 1 , tmpa = a , tmpb = b ; int d = digit ( tmpb ) ; tmpa *= ( int ) Math . pow ( 10 , d ) ; tmpa += tmpb ; tmpb = ( int ) Math . sqrt ( tmpa ) ; if ( tmpa == tmpb * tmpb ) an = 0 ; System . out . println ( gtnwr [ an ] ) ; } } import java . util . Scanner ; class Lpfbox { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lpfbox = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int C = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( C - ( lpfbox - B ) > 0 ? C - ( lpfbox - B ) : 0 ) ; } } import java . util . Scanner ; public class Svlcul { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long svlcul = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long c = scan . nextLong ( ) ; long d = scan . nextLong ( ) ; scan . close ( ) ; long numC = b / c - ( svlcul - 1 ) / c ; long numD = b / d - ( svlcul - 1 ) / d ; long lcmCD = lcm ( c , d ) ; long numCD = b / lcmCD - ( svlcul - 1 ) / lcmCD ; System . out . println ( b - svlcul + 1 - numC - numD + numCD ) ; } public static long lcm ( long svlcul , long b ) { return svlcul * b / gcd ( svlcul , b ) ; } public static long gcd ( long svlcul , long b ) { if ( svlcul < b ) { return gcd ( b , svlcul ) ; } if ( b == 0 ) { return svlcul ; } return gcd ( b , svlcul % b ) ; } } import java . util . Scanner ; public class Jykxry { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int jykxry = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( jykxry == 0 && y == 0 ) { break ; } else if ( jykxry < y ) { System . out . print ( jykxry + " " ) ; System . out . println ( y ) ; } else { System . out . print ( y + " " ) ; System . out . println ( jykxry ) ; } } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Xogmiio { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int xogmiio = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; Integer [ ] [ ] array = new Integer [ xogmiio ] [ m ] ; for ( int i = 0 ; m > i ; i ++ ) { int a = sc . nextInt ( ) ; list . add ( a ) ; } for ( int i = 0 ; xogmiio > i ; i ++ ) { for ( int j = 0 ; m > j ; j ++ ) { int a = sc . nextInt ( ) ; array [ i ] [ j ] = a ; } } int count = 0 ; for ( int i = 0 ; xogmiio > i ; i ++ ) { int keisan = 0 ; for ( int j = 0 ; m > j ; j ++ ) { keisan = keisan + list . get ( j ) * array [ i ] [ j ] ; } if ( keisan + c > 0 ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; class Fwqqx { public static int abs ( int a ) { return ( a > 0 ) ? a : ( - a ) ; } public static int max2 ( int a , int b ) { return ( a > b ) ? a : b ; } public static int max3 ( int a , int b , int c ) { return ( max2 ( a , b ) > c ) ? max2 ( a , b ) : c ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fwqqx = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int ab = abs ( fwqqx - B ) ; int bc = abs ( B - C ) ; int ca = abs ( C - fwqqx ) ; int minus = max3 ( ab , bc , ca ) ; System . out . println ( ab + bc + ca - minus ) ; } } import java . util . * ; public class Xonvzv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char xonvzv = s . charAt ( 0 ) ; String ans = " Good " ; for ( int i = 1 ; i < 4 ; i ++ ) { if ( xonvzv == s . charAt ( i ) ) ans = " Bad " ; xonvzv = s . charAt ( i ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Rbaephm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int rbaephm = sc . nextInt ( ) ; if ( rbaephm == 0 ) { break ; } int [ ] scores = new int [ rbaephm ] ; for ( int i = 0 ; i < scores . length ; i ++ ) { scores [ i ] = sc . nextInt ( ) ; } double average = 0 , variance = 0 ; for ( int i = 0 ; i < scores . length ; i ++ ) { average += ( double ) scores [ i ] / rbaephm ; } for ( int i = 0 ; i < scores . length ; i ++ ) { variance += ( double ) ( scores [ i ] - average ) * ( scores [ i ] - average ) / rbaephm ; } System . out . println ( Math . sqrt ( variance ) ) ; } } } import java . util . * ; public class Cbwdawv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String numM = scan . next ( ) ; int cbwdawv = Integer . parseInt ( numM ) ; int startNum = 0 ; for ( int i = 0 ; i < numM . length ( ) ; i ++ ) { startNum = startNum + Integer . parseInt ( String . valueOf ( numM . charAt ( i ) ) ) ; } if ( cbwdawv % startNum == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Yadup { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long [ ] inputs = new long [ 3 ] ; for ( int yadup = 0 ; yadup < 3 ; yadup ++ ) { inputs [ yadup ] = sc . nextLong ( ) ; } Arrays . sort ( inputs ) ; for ( int yadup = 0 ; yadup < 3 ; yadup ++ ) { System . out . print ( inputs [ yadup ] + ( ( yadup != 2 ) ? " " : " " ) ) ; } System . out . println ( ) ; } } import java . util . * ; public class Wldmn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wldmn = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < wldmn ; i ++ ) { sum += l + i ; } if ( wldmn + l <= 0 ) { System . out . println ( sum - ( wldmn + l - 1 ) ) ; } else if ( l < 0 ) { System . out . println ( sum ) ; } else { System . out . println ( sum - l ) ; } } } import java . util . Scanner ; public class Wiidno { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] s = S . toCharArray ( ) ; boolean wiidno = false ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s [ i ] == s [ i + 1 ] ) { wiidno = true ; break ; } } if ( wiidno ) { System . out . println ( " Bad " ) ; } else { System . out . println ( " Good " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ngmjx { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int ngmjx = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; int [ ] [ ] matrix = new int [ ngmjx ] [ m ] ; int [ ] vector = new int [ m ] ; for ( int i = 0 ; i < ngmjx ; i ++ ) { str = br . readLine ( ) . split ( " " ) ; for ( int j = 0 ; j < m ; j ++ ) { matrix [ i ] [ j ] = Integer . parseInt ( str [ j ] ) ; } } for ( int k = 0 ; k < m ; k ++ ) { String str1 = br . readLine ( ) ; vector [ k ] = Integer . parseInt ( str1 ) ; } for ( int i = 0 ; i < ngmjx ; i ++ ) { int kakezan = 0 ; for ( int j = 0 ; j < m ; j ++ ) { kakezan += matrix [ i ] [ j ] * vector [ j ] ; } System . out . println ( kakezan ) ; } } } import java . util . * ; class Pngmrtd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] T = sc . next ( ) . toCharArray ( ) ; int pngmrtd = 0 ; int now = 0 ; char [ ] atcg = { 'A' , 'T' , 'C' , 'G' } ; for ( int i = 0 ; i < T . length ; i ++ ) { boolean isATCG = false ; for ( int j = 0 ; j < atcg . length ; j ++ ) { if ( T [ i ] == atcg [ j ] ) { isATCG = true ; } } if ( ! isATCG ) { now = 0 ; } else { now ++ ; pngmrtd = Math . max ( pngmrtd , now ) ; } } System . out . println ( pngmrtd ) ; } } import java . util . * ; import java . lang . * ; public class Csanja { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int csanja ; csanja = sc . nextInt ( ) ; if ( csanja % 10 == 3 ) { System . out . println ( " bon " ) ; } else if ( ( csanja % 10 == 0 ) || ( csanja % 10 == 1 ) || ( csanja % 10 == 6 ) || ( csanja % 10 == 8 ) ) { System . out . println ( " pon " ) ; } else { System . out . println ( " hon " ) ; } } } import java . util . * ; public class Urqmej { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String urqmej = sc . next ( ) ; String T = sc . next ( ) ; String end = T . substring ( urqmej . length ( ) , urqmej . length ( ) + 1 ) ; if ( T . equals ( urqmej + end ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Yqjoo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yqjoo = sc . nextInt ( ) ; int [ ] a = new int [ yqjoo + 1 ] ; for ( int i = 0 ; i < yqjoo ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int max ; for ( int i = 0 ; i < yqjoo ; i ++ ) { for ( int j = i ; j < yqjoo ; j ++ ) { if ( a [ i ] < a [ j ] ) { max = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = max ; } } } int A = 0 ; int B = 0 ; for ( int i = 0 ; i < yqjoo ; i ++ ) { if ( i % 2 == 0 ) { A = A + a [ i ] ; } if ( i % 2 != 0 ) { B = B + a [ i ] ; } } int point = Math . abs ( A - B ) ; System . out . println ( point ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Wsfqxko { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner scanner = new Scanner ( System . in ) ; int wsfqxko = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = wsfqxko + b ; switch ( c ) { case 3 : System . out . println ( 3 ) ; break ; case 4 : System . out . println ( 2 ) ; break ; case 5 : System . out . println ( 1 ) ; break ; } } } import java . util . * ; public class Zjbcze { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] str = new String [ 3 ] ; int [ ] count = new int [ 3 ] ; for ( int zjbcze = 0 ; zjbcze < 3 ; ++ zjbcze ) { str [ zjbcze ] = sc . next ( ) ; count [ zjbcze ] = str [ zjbcze ] . length ( ) ; } int zjbcze = 0 ; while ( true ) { if ( count [ zjbcze ] == 0 && zjbcze == 0 ) { System . out . println ( " A " ) ; return ; } else if ( count [ zjbcze ] == 0 && zjbcze == 1 ) { System . out . println ( " B " ) ; return ; } else if ( count [ zjbcze ] == 0 && zjbcze == 2 ) { System . out . println ( " C " ) ; return ; } if ( str [ zjbcze ] . charAt ( str [ zjbcze ] . length ( ) - count [ zjbcze ] ) == 'a' ) { count [ zjbcze ] -- ; zjbcze = 0 ; } else if ( str [ zjbcze ] . charAt ( str [ zjbcze ] . length ( ) - count [ zjbcze ] ) == 'b' ) { count [ zjbcze ] -- ; zjbcze = 1 ; } else if ( str [ zjbcze ] . charAt ( str [ zjbcze ] . length ( ) - count [ zjbcze ] ) == 'c' ) { count [ zjbcze ] -- ; zjbcze = 2 ; } } } } import java . io . * ; import java . util . * ; class Ptbeo { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int ptbeo = Integer . parseInt ( st . nextToken ( ) ) ; int f = Integer . parseInt ( st . nextToken ( ) ) ; int r = Integer . parseInt ( st . nextToken ( ) ) ; if ( ptbeo == - 1 && f == - 1 && r == - 1 ) { break ; } if ( ptbeo == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } else if ( ( ptbeo + f ) >= 80 ) { System . out . println ( " A " ) ; } else if ( ( ptbeo + f ) >= 65 ) { System . out . println ( " B " ) ; } else if ( ( ( ptbeo + f ) >= 50 ) || ( ( ptbeo + f ) >= 30 && r >= 50 ) ) { System . out . println ( " C " ) ; } else if ( ( ptbeo + f ) >= 30 ) { System . out . println ( " D " ) ; } else { System . out . println ( " F " ) ; } } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Aazpdhi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aazpdhi = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int max = 0 ; for ( int i = 0 ; aazpdhi > i ; i ++ ) { int a = sc . nextInt ( ) ; list . add ( a ) ; } for ( int i = 0 ; aazpdhi - 1 > i ; i ++ ) { for ( int j = i + 1 ; aazpdhi > j ; j ++ ) { int b = Math . abs ( list . get ( i ) - list . get ( j ) ) ; if ( b > max ) max = b ; } } System . out . println ( max ) ; } } import java . util . * ; public class Tzfhr { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int tzfhr = sc . nextInt ( ) ; int [ ] a = new int [ tzfhr ] ; int [ ] b = new int [ tzfhr ] ; for ( int i = 0 ; i < tzfhr ; i ++ ) a [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < tzfhr ; i ++ ) b [ i ] = sc . nextInt ( ) ; int c = 0 , s = 0 ; for ( int i = 0 ; i < tzfhr ; i ++ ) { if ( a [ i ] > b [ i ] ) { c = c + a [ i ] ; s = s + b [ i ] ; } } System . out . println ( c - s ) ; } } import java . util . Scanner ; public class Vespppi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vespppi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; boolean bool = true ; loop : for ( int i = 1 ; i <= 1010 ; i ++ ) { int k1 = ( int ) ( i * 0.08 ) ; int k2 = ( int ) ( i * 0.1 ) ; if ( k1 == vespppi && k2 == b ) { bool = false ; System . out . println ( i ) ; break loop ; } } if ( bool ) { System . out . println ( " -1 " ) ; } sc . close ( ) ; } } import java . util . * ; public class Ahnkkdz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ahnkkdz = sc . nextInt ( ) ; if ( ahnkkdz == 1 ) { ahnkkdz = 0 ; } else { ahnkkdz = 1 ; } System . out . println ( ahnkkdz ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Bwhvw { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { final int bwhvw = sc . nextInt ( ) ; while ( sc . hasNext ( ) ) { int [ ] x = new int [ 3 ] ; x [ 0 ] = sc . nextInt ( ) ; x [ 1 ] = sc . nextInt ( ) ; x [ 2 ] = sc . nextInt ( ) ; Arrays . sort ( x ) ; boolean isTriangle = ( x [ 0 ] * x [ 0 ] ) + ( x [ 1 ] * x [ 1 ] ) == ( x [ 2 ] * x [ 2 ] ) ; System . out . println ( isTriangle ? " YES " : " NO " ) ; } } } } import java . util . * ; public class Ouzwpqj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ouzwpqj = sc . nextInt ( ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; String ans = " " ; for ( int i = 0 ; i < ouzwpqj ; i ++ ) { String s1 = String . valueOf ( s . charAt ( i ) ) ; String s2 = String . valueOf ( t . charAt ( i ) ) ; ans += s1 ; ans += s2 ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Mqhzgwa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int mqhzgwa = 0 ; int ans = 0 ; for ( char ss : s ) { if ( ss == 'R' ) { mqhzgwa ++ ; } else { mqhzgwa = 0 ; } ans = Math . max ( mqhzgwa , ans ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Ahkpi { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ahkpi = in . nextInt ( ) ; int b = in . nextInt ( ) ; int ans = ahkpi * b ; System . out . print ( ans ) ; } } import java . util . Scanner ; public class Ducpsnz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ducpsnz = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] p = new int [ N ] ; int a = ducpsnz ; int ans1 = ducpsnz ; int ans2 = ducpsnz ; int s = 0 ; for ( int i = 0 ; i < N ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < N + 1 ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( p [ j ] != ducpsnz ) { s ++ ; } } if ( s == N ) { ans1 = ducpsnz ; break ; } s = 0 ; ducpsnz = ducpsnz - 1 ; } ducpsnz = a ; s = 0 ; for ( int i = 0 ; i < N + 1 ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( p [ j ] != ducpsnz ) { s ++ ; } } if ( s == N ) { ans2 = ducpsnz ; break ; } s = 0 ; ducpsnz = ducpsnz + 1 ; } ducpsnz = a - ans1 ; N = ans2 - a ; if ( ducpsnz <= N ) { System . out . println ( ans1 ) ; } else { System . out . println ( ans2 ) ; } } } import java . util . * ; class Hokbwjj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hokbwjj = sc . nextInt ( ) ; Set < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < hokbwjj ; i ++ ) { set . add ( sc . next ( ) ) ; } if ( set . size ( ) < hokbwjj ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } } import java . util . Scanner ; class Pxcvojo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String pxcvojo = scan . next ( ) ; pxcvojo = pxcvojo . replaceAll ( " 0 " , " " ) ; System . out . print ( pxcvojo . length ( ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Yzyguxe { public static void main ( String [ ] args ) { try { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; while ( true ) { String buf = br . readLine ( ) ; StringTokenizer st = new StringTokenizer ( buf , " " ) ; int yzyguxe = Integer . parseInt ( st . nextToken ( ) ) ; int W = Integer . parseInt ( st . nextToken ( ) ) ; if ( W == 0 && yzyguxe == 0 ) break ; if ( yzyguxe >= 300 && W >= 300 ) break ; ; for ( int i = 1 ; i <= yzyguxe ; i ++ ) { for ( int j = 1 ; j <= W ; j ++ ) { if ( i % 2 == 0 ) { if ( j % 2 == 0 ) System . out . print ( " # " ) ; else System . out . print ( " . " ) ; } else { if ( j % 2 == 0 ) System . out . print ( " . " ) ; else System . out . print ( " # " ) ; } } System . out . println ( ) ; } System . out . println ( ) ; } } catch ( IOException e ) { System . err . println ( e ) ; } } } import java . util . * ; class Gopkdb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gopkdb = sc . nextInt ( ) ; int [ ] param = new int [ gopkdb ] ; for ( int i = 0 ; i < gopkdb ; i ++ ) { param [ i ] = sc . nextInt ( ) ; } Arrays . sort ( param ) ; int alice = 0 ; int bob = 0 ; if ( gopkdb % 2 == 0 ) { for ( int i = 0 ; i < gopkdb ; i ++ ) { if ( i % 2 == 0 ) { bob += param [ i ] ; } else { alice += param [ i ] ; } } } else { for ( int i = 0 ; i < gopkdb ; i ++ ) { if ( i % 2 == 0 ) { alice += param [ i ] ; } else { bob += param [ i ] ; } } } int total = alice - bob ; System . out . println ( total ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Huaotgn { public static void main ( String [ ] args ) throws IOException { int huaotgn = 0 ; int b = 0 ; int c = 0 ; int answer = 0 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; String [ ] result = str . split ( " " ) ; huaotgn = Integer . parseInt ( result [ 0 ] ) ; b = Integer . parseInt ( result [ 1 ] ) ; c = Integer . parseInt ( result [ 2 ] ) ; for ( int i = huaotgn ; i <= b ; i += 1 ) { if ( c % i == 0 ) { answer ++ ; } } System . out . println ( answer ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; public class Gnncvbs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter ou = new PrintWriter ( System . out ) ; int [ ] a = new int [ 5 ] ; for ( int gnncvbs = 0 ; gnncvbs < 5 ; gnncvbs ++ ) a [ gnncvbs ] = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; Arrays . sort ( a ) ; if ( k >= a [ 4 ] - a [ 0 ] ) ou . println ( " Yay! " ) ; else ou . println ( " :( " ) ; ou . flush ( ) ; } } import java . util . Scanner ; public class Ltjorr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . next ( ) ; String p = scanner . next ( ) ; String out = " No " ; for ( int ltjorr = 0 ; ltjorr < s . length ( ) ; ltjorr ++ ) { String str = " " ; for ( int j = 0 ; j < p . length ( ) ; j ++ ) { int k = ltjorr + j ; if ( k >= s . length ( ) ) { k -= s . length ( ) ; } str += s . substring ( k , k + 1 ) ; } if ( p . equals ( str ) ) { out = " Yes " ; break ; } } System . out . println ( out ) ; } } import java . util . Scanner ; import java . util . HashMap ; import java . util . List ; import java . util . Arrays ; import java . util . ArrayList ; import java . lang . Math ; public class Lxwwvz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lxwwvz = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] ab = { lxwwvz + b , lxwwvz - b , lxwwvz * b } ; System . out . println ( maxInt ( ab ) ) ; } private static int maxInt ( int [ ] array ) { int max = array [ 0 ] ; for ( int i = 1 ; i < array . length ; i ++ ) { if ( max < array [ i ] ) max = array [ i ] ; } return max ; } private static long maxLong ( long [ ] array ) { long max = array [ 0 ] ; for ( int i = 1 ; i < array . length ; i ++ ) { if ( max < array [ i ] ) max = array [ i ] ; } return max ; } private static int minInt ( int [ ] array ) { int min = array [ 0 ] ; for ( int i = 1 ; i < array . length ; i ++ ) { if ( min > array [ i ] ) min = array [ i ] ; } return min ; } private static long minLong ( long [ ] array ) { long min = array [ 0 ] ; for ( int i = 1 ; i < array . length ; i ++ ) { if ( min > array [ i ] ) min = array [ i ] ; } return min ; } } import java . util . * ; public class Isdsrt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int isdsrt = sc . nextInt ( ) ; Map < Integer , Boolean > map = new HashMap < > ( ) ; String ans = " YES " ; for ( int i = 0 ; i < isdsrt ; i ++ ) { int num = sc . nextInt ( ) ; if ( map . get ( num ) == null ) { map . put ( num , true ) ; } else { ans = " NO " ; break ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Raadhw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int raadhw = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; int q = sc . nextInt ( ) ; int [ ] a = new int [ q ] ; int [ ] win = new int [ raadhw ] ; for ( int i = 0 ; i < q ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < q ; i ++ ) { win [ a [ i ] - 1 ] ++ ; } for ( int i = 0 ; i < raadhw ; i ++ ) { if ( k - ( q - win [ i ] ) > 0 ) { System . out . println ( " Yes " ) ; continue ; } System . out . println ( " No " ) ; } } } import java . util . * ; public class Abygoy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int abygoy , f , r ; while ( true ) { abygoy = scan . nextInt ( ) ; f = scan . nextInt ( ) ; r = scan . nextInt ( ) ; if ( abygoy + f + r == - 3 ) break ; int s = abygoy + f ; if ( abygoy == - 1 || f == - 1 ) { System . out . println ( " F " ) ; continue ; } if ( s >= 80 ) System . out . println ( " A " ) ; if ( s >= 65 && s < 80 ) System . out . println ( " B " ) ; if ( s >= 50 && s < 65 ) System . out . println ( " C " ) ; if ( s >= 30 && s < 50 ) { if ( r >= 50 ) System . out . println ( " C " ) ; else System . out . println ( " D " ) ; } if ( s < 30 ) System . out . println ( " F " ) ; } } } import java . util . * ; public class Jpdkgix { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jpdkgix = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int c = 0 ; int x , y , z , w ; for ( int i = jpdkgix ; i <= B ; i ++ ) { x = i / 10000 ; y = i % 10 ; z = i / 1000 - x * 10 ; w = ( i % 100 - y ) / 10 ; if ( x == y && z == w ) { c ++ ; } } System . out . println ( c ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . lang . Exception ; import java . lang . Integer ; import java . lang . System ; public class Trdky { public static void main ( String [ ] a ) throws Exception { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s ; int trdky ; double total ; while ( ( s = r . readLine ( ) ) != null ) { trdky = Integer . parseInt ( s ) ; total = 100000 ; for ( int i = 0 ; i < trdky ; i ++ ) { total *= 1.05 ; total /= 1000 ; total = Math . ceil ( total ) * 1000 ; } System . out . printf ( " %.0f \n " , total ) ; } } } import java . util . * ; class Hfkkky { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int hfkkky = - 1 ; String [ ] ss = { " SUN " , " MON " , " TUE " , " WED " , " THU " , " FRI " , " SAT " } ; for ( int i = 0 ; i < ss . length ; i ++ ) { if ( ss [ i ] . equals ( s ) ) { hfkkky = i ; } } System . out . println ( 7 - hfkkky ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Bywppq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bywppq = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; long count = 0 ; long count1 = 0 ; int [ ] array = new int [ 3 ] ; Arrays . sort ( array ) ; if ( bywppq <= 9 && m <= 9 ) { System . out . println ( bywppq * m ) ; } else { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; public class Ogpds { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long ogpds = Long . parseLong ( scanner . nextLine ( ) ) ; char [ ] ans = scanner . nextLine ( ) . toCharArray ( ) ; int a = 0 ; for ( int i = 0 ; i < ogpds ; i ++ ) { if ( i < ogpds - 2 && ans [ i ] == 'A' ) { if ( ans [ i + 1 ] == 'B' ) { if ( ans [ i + 2 ] == 'C' ) { a ++ ; i += 2 ; } } } } System . out . println ( a ) ; } } import java . util . * ; public class Zlqpx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zlqpx = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = 0 ; for ( int i = 0 ; i < zlqpx - 2 ; i ++ ) { if ( s . charAt ( i ) == 'A' && s . charAt ( i + 1 ) == 'B' && s . charAt ( i + 2 ) == 'C' ) { count ++ ; } } System . out . println ( count ) ; } } import java . io . IOException ; import java . util . Arrays ; import java . util . OptionalLong ; import java . util . Scanner ; import java . util . stream . LongStream ; class Idyhl { public static void main ( String [ ] args ) throws IOException { Scanner scane = new Scanner ( System . in ) ; int idyhl = scane . nextInt ( ) ; long [ ] nums = new long [ idyhl ] ; for ( int i = 0 ; i < idyhl ; i ++ ) { nums [ i ] = scane . nextInt ( ) ; } LongStream stream = Arrays . stream ( nums ) ; LongStream stream2 = Arrays . stream ( nums ) ; LongStream stream3 = Arrays . stream ( nums ) ; OptionalLong min = stream . min ( ) ; OptionalLong max = stream2 . max ( ) ; long total = stream3 . sum ( ) ; System . out . println ( min . getAsLong ( ) + " " + max . getAsLong ( ) + " " + total ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Sdrprb { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Multiplication3 solver = new Multiplication3 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Sdrprb { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String [ ] inputs = in . nextLine ( ) . split ( " " ) ; long sdrprb = Long . parseLong ( inputs [ 0 ] ) ; long b = Long . parseLong ( inputs [ 1 ] . replaceAll ( " \\ . " , " " ) ) ; out . append ( String . valueOf ( sdrprb * b / 100 ) ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Ophfqdy { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int ophfqdy = 1 ; while ( true ) { String str = br . readLine ( ) ; String [ ] s = str . split ( " " ) ; int [ ] n = new int [ s . length ] ; for ( int i = 0 ; i < s . length ; i ++ ) { n [ i ] = Integer . parseInt ( s [ i ] ) ; } if ( n [ 0 ] == 0 && n [ 1 ] == 0 ) { break ; } System . out . println ( Math . min ( n [ 0 ] , n [ 1 ] ) + " " + Math . max ( n [ 0 ] , n [ 1 ] ) ) ; ophfqdy ++ ; } } } import java . util . * ; public class Aehbnh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int aehbnh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = Math . min ( aehbnh * b , c ) ; System . out . println ( d ) ; } } import java . util . Scanner ; public class Nqmuebk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nqmuebk = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; sc . close ( ) ; int s = - 1 ; for ( int i = 1 ; i <= 1009 ; i ++ ) { if ( ( int ) ( i * 0.08 ) == nqmuebk && ( int ) ( i * 0.1 ) == B ) { s = i ; break ; } } System . out . println ( s ) ; } } import java . util . Scanner ; public class Ojrnb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ojrnb = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; if ( ojrnb > m ) { System . out . println ( " a > b " ) ; } if ( ojrnb < m ) { System . out . println ( " a < b " ) ; } if ( ojrnb == m ) { System . out . println ( " a == b " ) ; } } } import java . util . * ; public class Xdclrvt { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; float xdclrvt = in . nextFloat ( ) , t = in . nextFloat ( ) , s = in . nextFloat ( ) ; if ( ( xdclrvt / s ) <= t ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Mxguqx { public static void main ( String [ ] args ) { Scanner o = new Scanner ( System . in ) ; int mxguqx = o . nextInt ( ) ; int b = o . nextInt ( ) ; int c = o . nextInt ( ) ; int k = o . nextInt ( ) ; int ans = 0 ; ans += Math . min ( k , mxguqx ) ; k -= ans ; mxguqx -= ans ; int x = Math . min ( k , b ) ; k -= x ; b -= x ; int y = Math . min ( k , c ) ; ans -= y ; System . out . println ( ans ) ; } } import java . util . * ; class Mycokb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; list . add ( sc . nextInt ( ) ) ; for ( int mycokb = 1 ; mycokb < 10001 ; mycokb ++ ) { if ( list . get ( mycokb - 1 ) == 0 ) { break ; } System . out . println ( " Case " + mycokb + " : " + list . get ( mycokb - 1 ) ) ; list . add ( sc . nextInt ( ) ) ; } } } import java . util . Scanner ; public class Ufuzvux { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String sline = sc . next ( ) ; int ufuzvux = sline . length ( ) ; sc . close ( ) ; StringBuffer sb = new StringBuffer ( sline ) ; String reversed = sb . reverse ( ) . toString ( ) ; boolean ans = true ; String [ ] words = { " maerd " , " remaerd " , " esare " , " resare " } ; for ( int i = 0 ; i < ufuzvux ; ) { boolean can = false ; for ( String w : words ) { int end = w . length ( ) ; if ( i + end > ufuzvux ) continue ; if ( reversed . substring ( i , i + end ) . equals ( w ) ) { i += end ; can = true ; } } if ( can == false ) { ans = false ; break ; } } if ( ans ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class Nkuwdgd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nkuwdgd = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int s = 0 ; if ( nkuwdgd < b ) { for ( ; nkuwdgd < b ; nkuwdgd ++ ) { if ( c % nkuwdgd == 0 ) s ++ ; } } else if ( nkuwdgd > b ) ; { for ( ; b < nkuwdgd ; b ++ ) { if ( c % b == 0 ) s ++ ; } } if ( nkuwdgd == b ) if ( c % nkuwdgd == 0 ) s ++ ; System . out . println ( s ) ; } } import java . util . Scanner ; import java . util . Arrays ; import java . util . ArrayList ; public class Ugnpa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > A = new ArrayList < > ( ) ; int ugnpa = sc . nextInt ( ) ; for ( int a = 0 ; a < ugnpa ; ++ a ) { A . add ( sc . nextInt ( ) ) ; } int [ ] p_num = new int [ 8 ] ; Arrays . fill ( p_num , 0 ) ; int sp = 0 ; int redExist = 0 ; for ( int a : A ) { if ( a < 3200 ) { p_num [ a / 400 ] += 1 ; } else { sp += 1 ; redExist = 1 ; } } int ans = 0 ; for ( int p : p_num ) { if ( p > 0 ) { ans += 1 ; } } int ans_min = Math . max ( ans , 1 ) ; int ans_max = ans + sp ; System . out . println ( ans_min + " " + ans_max ) ; } } import java . util . Scanner ; public class Ivmfo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ivmfo = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; System . out . println ( helper ( ivmfo , b ) ) ; sc . close ( ) ; } static long helper ( long ivmfo , long b ) { long v = ivmfo , u = b , y ; while ( b > 0 ) { y = ivmfo % b ; ivmfo = b ; b = y ; } return v * u / ivmfo ; } } import java . util . Scanner ; public class Sunpdsa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String sunpdsa = sc . next ( ) ; String t = sc . next ( ) ; if ( ( sunpdsa . length ( ) == t . length ( ) ) && ( sunpdsa + sunpdsa ) . contains ( t ) ) { System . out . println ( " Yes " ) ; return ; } System . out . println ( " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Bxyhdvo { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; byte arrayLength = Byte . parseByte ( in . readLine ( ) ) ; byte [ ] array = new byte [ arrayLength ] ; short count = 0 ; String [ ] strData = in . readLine ( ) . split ( " " ) ; for ( byte i = 0 ; i < arrayLength ; i ++ ) { array [ i ] = Byte . parseByte ( strData [ i ] ) ; } for ( int bxyhdvo = 0 ; bxyhdvo < arrayLength ; bxyhdvo ++ ) { for ( byte y = ( byte ) ( arrayLength - 1 ) ; y > bxyhdvo ; y -- ) { if ( array [ y ] < array [ y - 1 ] ) { byte temp = array [ y ] ; array [ y ] = array [ y - 1 ] ; array [ y - 1 ] = temp ; count ++ ; } } } for ( int z = 0 ; z < arrayLength ; z ++ ) { if ( z == arrayLength - 1 ) { System . out . println ( array [ z ] ) ; } else { System . out . print ( array [ z ] + " " ) ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Knevswx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int knevswx = sc . nextInt ( ) ; String slimes = sc . next ( ) ; StringBuilder ans = new StringBuilder ( ) ; String [ ] slimesarr = new String [ knevswx + 1 ] ; for ( int i = 0 ; i < knevswx ; i ++ ) { slimesarr [ i ] = String . valueOf ( slimes . charAt ( i ) ) ; } for ( int i = 0 ; i < knevswx ; i ++ ) { if ( slimesarr [ i ] . equals ( slimesarr [ i + 1 ] ) ) { } else { ans . append ( slimesarr [ i ] ) ; } } System . out . println ( ans . toString ( ) . length ( ) ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . LinkedHashSet ; import java . util . List ; import java . util . Scanner ; public class Zkhwuv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < String > box = new ArrayList < > ( ) ; int zkhwuv = sc . nextInt ( ) ; String each = null ; for ( int i = 0 ; i < zkhwuv ; i ++ ) { box . add ( sc . next ( ) ) ; } List < String > list = new ArrayList < String > ( new LinkedHashSet < > ( box ) ) ; System . out . println ( list . size ( ) ) ; } } import java . util . * ; public class Immxu { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int immxu = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int min = sc . nextInt ( ) ; int max = sc . nextInt ( ) ; m -- ; while ( m -- > 0 ) { min = Math . max ( min , sc . nextInt ( ) ) ; max = Math . min ( max , sc . nextInt ( ) ) ; } if ( min > max ) { System . out . println ( 0 ) ; return ; } System . out . println ( max - min + 1 ) ; } } import java . util . Scanner ; public class Punvnta { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int punvnta = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] L = new int [ m ] ; int [ ] R = new int [ m ] ; int maxL = 0 ; int minR = Integer . MAX_VALUE ; for ( int i = 0 ; i < m ; i ++ ) { L [ i ] = sc . nextInt ( ) ; R [ i ] = sc . nextInt ( ) ; maxL = Math . max ( maxL , L [ i ] ) ; minR = Math . min ( minR , R [ i ] ) ; } System . out . println ( Math . max ( minR - maxL + 1 , 0 ) ) ; } } import java . io . * ; import java . util . * ; public class Segga { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str ; while ( ( str = br . readLine ( ) ) != null ) { if ( str . equals ( " - " ) ) { break ; } StringBuilder aabc = new StringBuilder ( str ) ; int segga = aabc . length ( ) ; str = br . readLine ( ) ; int m = Integer . parseInt ( str ) ; for ( int i = 0 ; i < m ; i ++ ) { str = br . readLine ( ) ; int h = Integer . parseInt ( str ) ; String temp = aabc . substring ( 0 , h ) ; aabc . append ( temp ) ; aabc . delete ( 0 , h ) ; } System . out . println ( aabc . toString ( ) ) ; } } } import java . util . * ; public class Voylbl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int voylbl = sc . nextInt ( ) ; int [ ] t = new int [ voylbl + 1 ] ; int [ ] x = new int [ voylbl + 1 ] ; int [ ] y = new int [ voylbl + 1 ] ; for ( int i = 1 ; i <= voylbl ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } int dist = 0 ; int flag = 1 ; int time = 0 ; for ( int i = 1 ; i <= voylbl ; i ++ ) { time = t [ i ] - t [ i - 1 ] ; dist = Math . abs ( Math . abs ( ( x [ i ] - x [ i - 1 ] ) ) + Math . abs ( ( y [ i ] - y [ i - 1 ] ) ) ) ; if ( time < dist ) { flag = 0 ; break ; } else if ( ( time - dist ) % 2 != 0 ) { flag = 0 ; break ; } } if ( flag == 1 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . Scanner ; class Yfgtiqx { static final long yfgtiqx = 1000000007 ; static int H , W , K ; static long [ ] [ ] dp = new long [ 110 ] [ 10 ] ; static int ans = 0 ; static long n = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; for ( int i = x ; i <= 999 ; i ++ ) { if ( i == 111 || i == 222 || i == 333 || i == 444 || i == 555 || i == 666 || i == 777 || i == 888 || i == 999 ) { System . out . println ( i ) ; return ; } } } } class Yfgtiqx implements Comparable { int from ; int end ; int num ; int bango ; @ Override public int compareTo ( Object other ) { Pair otherpair = ( Pair ) other ; return end - otherpair . end ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class Xvkij { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int xvkij = sc . nextInt ( ) ; while ( IsPrime ( xvkij ) == false ) { xvkij ++ ; } System . out . println ( xvkij ) ; } private static boolean IsPrime ( int num ) { if ( num < 2 ) return false ; else if ( num == 2 ) return true ; else if ( num % 2 == 0 ) return false ; for ( int i = 3 ; i < num ; i += 2 ) { if ( num % i == 0 ) { return false ; } } return true ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Xacsjm { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int xacsjm = Integer . parseInt ( tokenizer . nextToken ( ) ) ; String [ ] a = new String [ xacsjm ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = input . readLine ( ) ; } Arrays . sort ( a ) ; StringBuilder out = new StringBuilder ( ) ; for ( int i = 0 ; i < xacsjm ; i ++ ) { out . append ( a [ i ] ) ; } System . out . println ( out ) ; } } import java . util . Scanner ; public class Xcpue { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xcpue = scan . nextInt ( ) ; int [ ] h = new int [ xcpue ] ; for ( int i = 0 ; i < xcpue ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; int check = 1 ; if ( xcpue != 1 ) { for ( int i = xcpue - 2 ; i >= 0 ; i -- ) { if ( h [ i ] > h [ i + 1 ] ) h [ i ] -- ; if ( h [ i ] > h [ i + 1 ] ) { check = 0 ; break ; } } } System . out . println ( ( check == 1 ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Iamilmk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int iamilmk = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; System . out . println ( Integer . toString ( iamilmk , K ) . length ( ) ) ; } } import java . util . Scanner ; class Pgrxn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pgrxn = sc . nextInt ( ) ; String nn = String . valueOf ( pgrxn ) ; int [ ] nnn = new int [ 3 ] ; for ( int i = 0 ; i <= 2 ; i ++ ) { if ( nn . charAt ( i ) == '1' ) { nnn [ i ] = 9 ; } else { nnn [ i ] = 1 ; } } for ( int i = 0 ; i <= 2 ; i ++ ) { System . out . print ( nnn [ i ] ) ; } } } import java . util . Scanner ; public class Ukincy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ukincy = sc . next ( ) ; if ( ukincy . length ( ) < 6 ) { System . out . print ( " No " ) ; } else { if ( ukincy . charAt ( 2 ) == ukincy . charAt ( 3 ) && ukincy . charAt ( 4 ) == ukincy . charAt ( 5 ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } } import java . util . * ; public class Hvuvjt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hvuvjt = sc . nextInt ( ) ; int [ ] w = new int [ hvuvjt + 1 ] ; int sum = 0 ; for ( int i = 1 ; i <= hvuvjt ; i ++ ) { w [ i ] = sc . nextInt ( ) ; sum += w [ i ] ; } int s1 = 0 ; int s2 = 0 ; int ans = sum ; for ( int i = 1 ; i <= hvuvjt ; i ++ ) { s1 += w [ i ] ; s2 = sum - s1 ; ans = Math . min ( ans , Math . abs ( s2 - s1 ) ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Nvyto { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; StringBuilder ans = new StringBuilder ( ) ; for ( char nvyto : c ) { if ( nvyto == '0' ) ans . append ( " 0 " ) ; if ( nvyto == '1' ) ans . append ( " 1 " ) ; if ( nvyto == 'B' ) { if ( ans . length ( ) == 1 ) ans = new StringBuilder ( ) ; if ( ! ans . toString ( ) . isEmpty ( ) ) ans . setLength ( ans . length ( ) - 1 ) ; } } System . out . println ( ans . toString ( ) ) ; } } import java . util . Scanner ; public class Ffvbw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int ffvbw = 0 ; int changedCntFrm0 = 0 ; int changedCntFrm1 = 0 ; int [ ] tile = new int [ s . length ( ) ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { tile [ i ] = s . charAt ( i ) ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { ffvbw = 48 ; } else { ffvbw = 49 ; } if ( tile [ i ] != ffvbw ) { changedCntFrm0 ++ ; } } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { ffvbw = 49 ; } else { ffvbw = 48 ; } if ( tile [ i ] != ffvbw ) { changedCntFrm1 ++ ; } } if ( changedCntFrm0 >= changedCntFrm1 ) { System . out . println ( changedCntFrm1 ) ; } else { System . out . println ( changedCntFrm0 ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class Tpuxkd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] tmp = scanner . nextLine ( ) . split ( " " ) ; int tpuxkd = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { if ( Integer . parseInt ( tmp [ i ] ) == 0 ) { tpuxkd = i + 1 ; break ; } } System . out . println ( tpuxkd ) ; } } import java . util . * ; public class Wfbnukt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wfbnukt = sc . nextInt ( ) ; int [ ] num = new int [ wfbnukt + 1 ] ; for ( int i = 1 ; i <= wfbnukt ; i ++ ) { num [ i ] = sc . nextInt ( ) ; } int number = 1 ; int count = 0 ; boolean key = false ; for ( int i = 1 ; i <= wfbnukt ; i ++ ) { int tmp = num [ number ] ; if ( tmp == - 1 ) { System . out . println ( - 1 ) ; System . exit ( 0 ) ; } num [ number ] = - 1 ; number = tmp ; count ++ ; if ( number == 2 ) { key = true ; break ; } } System . out . println ( true ? count : - 1 ) ; } } import java . util . Scanner ; public class Pyilb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pyilb = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int x = y / 1000 - pyilb ; int coefficient1 = 9 ; int coefficient2 = 4 ; int [ ] result = { - 1 , - 1 , - 1 } ; for ( int i = 0 ; i <= pyilb ; i ++ ) { int tmp = x - ( 9 * i ) ; int [ ] tmp2 = new int [ 3 ] ; if ( tmp % 4 == 0 && tmp >= 0 && tmp <= 4 * pyilb ) { tmp2 [ 0 ] = i ; tmp2 [ 1 ] = tmp / 4 ; tmp2 [ 2 ] = pyilb - tmp2 [ 0 ] - tmp2 [ 1 ] ; if ( tmp2 [ 2 ] >= 0 && tmp2 [ 2 ] <= pyilb ) { result = tmp2 ; break ; } } } System . out . println ( result [ 0 ] + " " + result [ 1 ] + " " + result [ 2 ] ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Jsofwi { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BMaximumDifference solver = new BMaximumDifference ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Jsofwi { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int jsofwi = in . nextInt ( ) ; int min = Integer . MAX_VALUE , max = 0 ; for ( int i = 0 ; i < jsofwi ; i ++ ) { int a = in . nextInt ( ) ; min = Math . min ( min , a ) ; max = Math . max ( max , a ) ; } out . println ( max - min ) ; } } } import java . util . * ; public class Tigyk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; int tigyk = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String U = sc . next ( ) ; if ( U . equals ( S ) ) { System . out . printf ( " %d %d " , tigyk - 1 , B ) ; } else { System . out . printf ( " %d %d " , tigyk , B - 1 ) ; } } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class Rdtha { public static void main ( String [ ] args ) throws Exception { solve ( System . in , System . out ) ; } static void solve ( InputStream is , PrintStream os ) { Scanner scan = new Scanner ( is ) ; long rdtha = scan . nextLong ( ) ; long depo = 100 ; int ans = 0 ; while ( rdtha > depo ) { depo *= 1.01 ; ans ++ ; } os . println ( ans ) ; } } import java . util . * ; class Zojdlid { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zojdlid = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= zojdlid ; i ++ ) { int test = i ; int num = 0 ; while ( test > 0 ) { test /= 10 ; num ++ ; } if ( num % 2 != 0 ) { count ++ ; } } System . out . println ( count ) ; } } import java . io . * ; import java . util . * ; import java . util . stream . * ; public class Ozgncyn { private static BufferedReader br = null ; public static void main ( String [ ] args ) { String n = read ( 1 ) [ 0 ] ; for ( int ozgncyn = 0 ; ozgncyn < n . length ( ) ; ozgncyn ++ ) { System . out . print ( n . charAt ( ozgncyn ) == '1' ? '9' : '1' ) ; } System . out . println ( ) ; } private static String [ ] read ( int len ) { List < String > strList = new ArrayList < > ( ) ; try { if ( br == null ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } for ( int ozgncyn = 0 ; ozgncyn < len ; ozgncyn ++ ) { strList . add ( br . readLine ( ) ) ; } } catch ( IOException e ) { } return strList . toArray ( new String [ 0 ] ) ; } private static void close ( ) { try { if ( br != null ) { br . close ( ) ; } } catch ( IOException e ) { } } } import java . io . IOException ; import java . util . ArrayList ; import java . util . Scanner ; public class Xhauqpe { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; long xhauqpe = scanner . nextLong ( ) ; long n = scanner . nextLong ( ) ; long max = 0 ; long sum = 0 ; long first = 0 ; long previous = 0 ; for ( long i = 0 ; i < n ; i ++ ) { long a = scanner . nextLong ( ) ; if ( i == 0 ) { max = a ; sum = a ; first = a ; previous = a ; } else { long aida = a - previous ; previous = a ; sum = sum + aida ; if ( aida > max ) { max = aida ; } } } long saigo = xhauqpe - sum + first ; if ( saigo > max ) { max = saigo ; } System . out . println ( xhauqpe - max ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Eoevzv { static class Eoevzv { boolean eoevzv ; int waCount ; Result ( boolean eoevzv , int waCount ) { this . eoevzv = eoevzv ; this . waCount = waCount ; } int getPenaltyCount ( ) { return eoevzv ? waCount : 0 ; } } public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = Integer . parseInt ( scanner . next ( ) ) ; int M = Integer . parseInt ( scanner . next ( ) ) ; Map < Integer , Result > map = new HashMap < > ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int number = Integer . parseInt ( scanner . next ( ) ) ; String acOrWa = scanner . next ( ) ; boolean isAc = acOrWa . equals ( " AC " ) ; Result result ; if ( map . containsKey ( number ) ) { result = map . get ( number ) ; if ( isAc ) { result . eoevzv = true ; } else { if ( ! result . eoevzv ) { result . waCount ++ ; } } } else { result = new Result ( isAc , isAc ? 0 : 1 ) ; map . put ( number , result ) ; } } scanner . close ( ) ; int acCount = 0 ; int penaltyCount = 0 ; for ( Map . Entry < Integer , Result > entry : map . entrySet ( ) ) { acCount += entry . getValue ( ) . eoevzv ? 1 : 0 ; penaltyCount += entry . getValue ( ) . getPenaltyCount ( ) ; } System . out . println ( acCount + " " + penaltyCount ) ; } } import java . util . * ; public class Zkjfslg { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int zkjfslg = scn . nextInt ( ) ; int [ ] Nmonster = new int [ zkjfslg + 1 ] ; for ( int i = 0 ; i < zkjfslg + 1 ; i ++ ) { Nmonster [ i ] = scn . nextInt ( ) ; } long Nbeaten = 0 ; for ( int i = 0 ; i < zkjfslg ; i ++ ) { int Nbeatble = scn . nextInt ( ) ; if ( Nbeatble < Nmonster [ i ] ) { Nbeaten += Nbeatble ; } else { Nbeaten += Nmonster [ i ] ; Nbeatble -= Nmonster [ i ] ; int diff = Nbeatble - Nmonster [ i + 1 ] ; if ( diff >= 0 ) { Nbeaten += Nmonster [ i + 1 ] ; Nmonster [ i + 1 ] = 0 ; } else { Nbeaten += Nbeatble ; Nmonster [ i + 1 ] -= Nbeatble ; } } } System . out . println ( Nbeaten ) ; } } import java . util . * ; import java . text . * ; public class Uvpswra { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String uvpswra = sc . nextLine ( ) ; if ( uvpswra . compareTo ( " 2019/04/30 " ) > 0 ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } try { Date date1 = DateFormat . getDateInstance ( ) . parse ( uvpswra ) ; } catch ( ParseException e ) { } } } import java . io . InputStream ; import java . io . IOException ; import java . util . HashSet ; class Zhrly { InputStream stream ; public MyScanner ( ) { stream = System . in ; } public int nextInt ( ) { int zhrly = 0 ; try { while ( true ) { char readed = ( char ) stream . read ( ) ; if ( readed < '0' || readed > '9' ) { break ; } zhrly = zhrly * 10 + ( readed - '0' ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { return zhrly ; } } } class Zhrly { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; HashSet < Integer > set = new HashSet < Integer > ( ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; boolean [ ] selected = new boolean [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { set . add ( i ) ; } for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) { selected [ j ] = true ; } int c = sc . nextInt ( ) ; for ( int j = 0 ; j < c ; ++ j ) { selected [ sc . nextInt ( ) - 1 ] = false ; } for ( int j = 0 ; j < m ; ++ j ) { if ( selected [ j ] ) { set . remove ( j ) ; } } } System . out . println ( set . size ( ) ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; import static java . lang . Math . min ; public class Pxvusqu { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; Map < String , Integer > count = new HashMap < > ( ) ; int pxvusqu = in . nextInt ( ) ; for ( int i = 0 ; i < pxvusqu ; i ++ ) { String s = sort ( in . next ( ) ) ; if ( count . containsKey ( s ) ) { count . replace ( s , count . get ( s ) + 1 ) ; } else { count . put ( s , 1 ) ; } } long res = 0 ; for ( Map . Entry < String , Integer > kv : count . entrySet ( ) ) { res += ( long ) kv . getValue ( ) * ( long ) ( kv . getValue ( ) - 1 ) / 2 ; } System . out . println ( res ) ; } private static String sort ( String text ) { char [ ] chars = text . toCharArray ( ) ; Arrays . sort ( chars ) ; return new String ( chars ) ; } } import java . util . * ; public final class Wtiakj { private static int solution ( int [ ] array ) { int wtiakj = 1 ; int score = 1 ; int minimum = array [ 0 ] ; while ( wtiakj < array . length ) { if ( array [ wtiakj ] < minimum ) { minimum = array [ wtiakj ] ; score ++ ; } wtiakj ++ ; } return score ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] array = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } System . out . println ( solution ( array ) ) ; } } import java . util . Scanner ; public class Xdufv { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xdufv = sc . nextInt ( ) ; int val = 0 ; if ( xdufv != 0 ) { val = ( xdufv / 500 ) * 1000 ; val += ( xdufv % 500 ) / 5 * 5 ; } System . out . println ( val ) ; } } import java . util . Scanner ; public class Pmomg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String pmomg = sc . next ( ) ; if ( pmomg . matches ( " ^((dreamer)|(eraser)|(dream)|(erase))+$ " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Curzcyf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int curzcyf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int te = - 1 ; for ( int i = 0 ; i < 10000 ; i ++ ) { if ( ( int ) ( i * 0.08 ) == curzcyf && ( int ) ( i * 0.1 ) == b ) { te = i ; break ; } } System . out . print ( te ) ; } } import java . util . * ; class Bjltslp { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int bjltslp = stdIn . nextInt ( ) ; int ans = - 1000000000 ; int min = stdIn . nextInt ( ) ; for ( int i = 1 ; i < bjltslp ; i ++ ) { int r = stdIn . nextInt ( ) ; ans = Math . max ( ans , r - min ) ; min = Math . min ( min , r ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Zzmcotv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long zzmcotv = Long . parseLong ( scan . next ( ) ) ; scan . close ( ) ; StringBuilder sb = new StringBuilder ( ) ; while ( zzmcotv > 0 ) { long l = zzmcotv % 26 ; if ( l == 0 ) { sb . append ( 'z' ) ; zzmcotv -= 1 ; } else { char c = 'a' ; c += l - 1 ; sb . append ( c ) ; } zzmcotv /= 26 ; } System . out . println ( sb . reverse ( ) . toString ( ) ) ; } } import java . util . * ; public class Ekwphs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ekwphs = sc . nextInt ( ) ; sc . close ( ) ; int count = 0 ; for ( int i = 1 ; i <= ekwphs ; i ++ ) { int cnt = 0 ; int tmp = i ; while ( tmp != 0 ) { tmp /= 10 ; cnt ++ ; } if ( cnt % 2 == 1 ) count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class Gstqabi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long gstqabi = sc . nextLong ( ) ; if ( gstqabi == 1 ) { System . out . println ( 1 ) ; return ; } long x = gstqabi ; int cnt = 0 ; while ( true ) { x /= 2 ; cnt ++ ; if ( x == 1 ) break ; } long ans = 2 ; for ( int i = 0 ; i < cnt ; i ++ ) { ans *= 2 ; } if ( cnt > 0 ) ans -- ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Oglckko { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oglckko = sc . nextInt ( ) ; String S = sc . next ( ) ; String T = " " ; if ( S . length ( ) <= oglckko ) { T = S ; } else { for ( int i = 0 ; i < oglckko ; i ++ ) { T += S . charAt ( i ) ; } T += " ... " ; } sc . close ( ) ; System . out . println ( T ) ; } } import java . util . * ; public class Tcpwmm { final static int tcpwmm = 1000000007 ; final static int INF = 1000000000 ; public static void main ( String [ ] args ) { Deque < Integer > S = new ArrayDeque < Integer > ( ) ; Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] str = line . split ( " " ) ; for ( String s : str ) { if ( s . equals ( " " ) ) break ; if ( s . equals ( " + " ) ) { int b = S . pop ( ) ; int a = S . pop ( ) ; S . push ( a + b ) ; } else if ( s . equals ( " - " ) ) { int b = S . pop ( ) ; int a = S . pop ( ) ; S . push ( a - b ) ; } else if ( s . equals ( " * " ) ) { int b = S . pop ( ) ; int a = S . pop ( ) ; S . push ( a * b ) ; } else { S . push ( Integer . parseInt ( s ) ) ; } } sc . close ( ) ; System . out . println ( S . getFirst ( ) . intValue ( ) ) ; } } import java . util . * ; public class Pzivm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] weathers = new String [ 3 ] ; weathers [ 0 ] = " Sunny " ; weathers [ 1 ] = " Cloudy " ; weathers [ 2 ] = " Rainy " ; String today = sc . next ( ) ; int pzivm = 0 ; for ( String weather : weathers ) { if ( weather . equals ( today ) ) { System . out . println ( weathers [ ( pzivm + 1 ) % 3 ] ) ; return ; } pzivm ++ ; } } } import java . math . BigInteger ; import java . util . Scanner ; import java . util . Arrays ; public class Tziaapp { public static void main ( String [ ] args ) { int tziaapp , i , j , m , k , p , q , o , l , s , tt = 1 ; Double x , y , z ; int [ ] ar , br ; char ch ; BigInteger an , su , u , v ; String a , b = " " , c = " " , d ; Scanner sc = new Scanner ( System . in ) ; Scanner scc = new Scanner ( System . in ) ; ar = new int [ 200001 ] ; br = new int [ 200001 ] ; tziaapp = sc . nextInt ( ) ; k = 50000000 ; for ( i = 0 ; i < tziaapp ; i ++ ) { o = sc . nextInt ( ) ; if ( k > o ) { k = o ; } ar [ i ] = o ; br [ i ] = k ; } k = 0 ; for ( i = 1 ; i < tziaapp ; i ++ ) { if ( ar [ i ] <= br [ i ] ) { k ++ ; } } System . out . println ( k + 1 ) ; } } import java . util . * ; public class Czmhp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int czmhp = sc . nextInt ( ) ; int x = 100000 ; for ( int i = 0 ; i < czmhp ; i ++ ) { x = ( int ) ( 1.05 * x ) ; if ( x % 1000 != 0 ) { x = ( ( x / 1000 ) + 1 ) * 1000 ; } } System . out . println ( x ) ; } } import java . util . * ; public class Ryhxn { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String [ ] s = sc . next ( ) . split ( " " ) ; String t = sc . next ( ) ; String concat = " " ; for ( int ryhxn = 0 ; ryhxn < s . length ; ryhxn ++ ) { concat = s [ s . length - 1 ] ; for ( int j = 0 ; j < s . length - 1 ; j ++ ) { concat += s [ j ] ; } if ( concat . equals ( t ) ) { System . out . println ( " Yes " ) ; return ; } s = concat . split ( " " ) ; } System . out . println ( " No " ) ; } } import java . util . * ; public class Ccuqc { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int ccuqc = sc . nextInt ( ) ; final int b = sc . nextInt ( ) ; final int c = sc . nextInt ( ) ; final int k = sc . nextInt ( ) ; sc . close ( ) ; int result = 0 ; if ( ccuqc >= k ) { result = k ; } else if ( b >= k - ccuqc ) { result = ccuqc ; } else if ( c >= k - b - ccuqc ) { result = 2 * ccuqc + b - k ; } System . out . println ( result ) ; } } import java . util . * ; public class Xayosr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xayosr = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( xayosr % 2 == 1 ) { System . out . println ( " No " ) ; return ; } String ss = s . substring ( xayosr / 2 , xayosr ) ; s = s . substring ( 0 , xayosr / 2 ) ; if ( s . equals ( ss ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class Jydqj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jydqj = sc . nextInt ( ) , b = sc . nextInt ( ) ; while ( jydqj != 0 && b != 0 ) { int c = b ; b = jydqj % b ; jydqj = c ; } System . out . println ( jydqj + b ) ; } } import java . util . Scanner ; public class Qlpyx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qlpyx = 0 ; String str = sc . next ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( str . charAt ( i ) == '+' ) qlpyx ++ ; else qlpyx -- ; } System . out . println ( qlpyx ) ; } } import java . util . Scanner ; public class Mugqx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mugqx = sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; String s = ( e - mugqx <= k ) ? " Yay! " : " :( " ; System . out . println ( s ) ; } } import java . io . * ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; class Eyyic { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; int eyyic = in . nextInt ( ) ; int H = in . nextInt ( ) ; int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; int r = in . nextInt ( ) ; if ( 0 <= x - r && x + r <= eyyic && 0 <= y - r && y + r <= H ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Ptmejw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int ptmejw = S . length ( ) ; String a = " AC " ; int b = 0 ; int sum = 0 ; int [ ] x = new int [ ptmejw + 1 ] ; if ( S . charAt ( 0 ) != a . charAt ( 0 ) ) { System . out . println ( " WA " ) ; } else { for ( int i = 2 ; i <= ptmejw - 2 ; i ++ ) { if ( S . charAt ( i ) == a . charAt ( 1 ) ) { break ; } if ( i == ptmejw - 2 ) { System . out . println ( " WA " ) ; b = ptmejw - 2 ; } } if ( b != ptmejw - 2 ) { String US = S . toUpperCase ( ) ; for ( int i = 0 ; i < ptmejw ; i ++ ) { if ( S . charAt ( i ) == US . charAt ( i ) ) { sum += 1 ; x [ sum ] = i ; } } if ( sum == 2 && S . charAt ( x [ 1 ] ) == a . charAt ( 0 ) && S . charAt ( x [ 2 ] ) == a . charAt ( 1 ) ) { System . out . println ( " AC " ) ; } else if ( sum > 2 ) { System . out . println ( " WA " ) ; } } } } } import java . util . Scanner ; public class Zrcmy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zrcmy = 0 ; int [ ] num = new int [ 9 ] ; for ( int i = 0 ; i < 9 ; i ++ ) { num [ i ] = sc . nextInt ( ) ; zrcmy += num [ i ] ; } int nextTotal1 = num [ 0 ] + num [ 1 ] + num [ 3 ] + num [ 4 ] ; int nextTotal2 = num [ 4 ] + num [ 5 ] + num [ 7 ] + num [ 8 ] ; int nextTotal3 = num [ 1 ] + num [ 2 ] + num [ 4 ] + num [ 5 ] ; int nextTotal4 = num [ 3 ] + num [ 4 ] + num [ 6 ] + num [ 7 ] ; int nextTotal5 = num [ 0 ] + num [ 2 ] + num [ 6 ] + num [ 8 ] ; if ( zrcmy % 3 == 0 && nextTotal1 % 2 == 0 && nextTotal1 % 2 == 0 && nextTotal3 % 2 == 0 && nextTotal4 % 2 == 0 && nextTotal5 % 2 == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Wlfafc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wlfafc = sc . nextInt ( ) ; String ans = " No " ; int c = 0 ; int d = 0 ; while ( 4 * c + 7 * d <= wlfafc ) { while ( 4 * c + 7 * d <= wlfafc ) { if ( 4 * c + 7 * d == wlfafc ) { ans = " Yes " ; break ; } else d ++ ; } c ++ ; d = 0 ; } System . out . println ( ans ) ; } } public class Kwlxu { public void run ( java . io . InputStream in , java . io . PrintStream out ) { java . util . Scanner sc = new java . util . Scanner ( in ) ; int kwlxu , h , x , y , r ; kwlxu = sc . nextInt ( ) ; h = sc . nextInt ( ) ; x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; r = sc . nextInt ( ) ; if ( x >= r && y >= r && kwlxu >= ( x + r ) && h >= ( y + r ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } public static void main ( String [ ] args ) { ( new Main ( ) ) . run ( System . in , System . out ) ; } } import java . util . * ; public class Geiid { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; char [ ] chars = str . toCharArray ( ) ; for ( int geiid = 0 ; geiid < str . length ( ) ; geiid ++ ) { if ( 'a' <= chars [ geiid ] && chars [ geiid ] <= 'z' ) chars [ geiid ] = Character . toUpperCase ( chars [ geiid ] ) ; else if ( 'A' <= chars [ geiid ] && chars [ geiid ] <= 'Z' ) chars [ geiid ] = Character . toLowerCase ( chars [ geiid ] ) ; } String str2 = String . valueOf ( chars ) ; System . out . println ( str2 ) ; } } import java . math . BigDecimal ; import java . math . MathContext ; import java . math . RoundingMode ; import java . util . Scanner ; public class Nrigjuf { static Scanner sc = new Scanner ( System . in ) ; static int nrigjuf = sc . nextInt ( ) ; static int B = sc . nextInt ( ) ; static int H = sc . nextInt ( ) ; static int M = sc . nextInt ( ) ; public static void main ( String [ ] args ) { double kHour = H * 30 + M * 0.5 ; double kMin = M * 6 ; double kakudo = kHour - kMin ; if ( kakudo > 180 ) { kakudo = 360 - kakudo ; } else if ( kakudo < 0 ) { kakudo *= - 1 ; } double dC = nrigjuf * nrigjuf + B * B - 2 * nrigjuf * B * Math . cos ( Math . toRadians ( kakudo ) ) ; double result = Math . sqrt ( dC ) ; System . out . print ( result ) ; } } import java . util . Scanner ; import java . util . Arrays ; class Ghcrzz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ghcrzz = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( Math . max ( Math . max ( ghcrzz , b ) , c ) - Math . min ( Math . min ( ghcrzz , b ) , c ) ) ; } } import java . util . Scanner ; public class Eyzaaq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int eyzaaq = solve ( S ) ; System . out . println ( eyzaaq ) ; } private static int solve ( String s ) { int eyzaaq = 0 ; char [ ] sn = s . toCharArray ( ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( sn [ i - 1 ] == sn [ i ] ) { eyzaaq ++ ; sn [ i ] = sn [ i ] == '0' ? '1' : '0' ; } } return eyzaaq ; } } import java . util . * ; public class Hunvn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hunvn = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; int z = Integer . parseInt ( sc . next ( ) ) ; int work ; work = hunvn ; hunvn = y ; y = work ; work = hunvn ; hunvn = z ; z = work ; System . out . print ( hunvn ) ; System . out . print ( " " ) ; System . out . print ( y ) ; System . out . print ( " " ) ; System . out . print ( z ) ; } } import java . util . Scanner ; public class Vlyckcs { private static String text ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String line = scanner . nextLine ( ) ; String [ ] lines = line . split ( " " ) ; int vlyckcs = Integer . parseInt ( lines [ 0 ] ) ; int B = Integer . parseInt ( lines [ 1 ] ) ; int plus = vlyckcs + B ; int minus = vlyckcs - B ; int multi = vlyckcs * B ; int display ; if ( plus > minus && plus > multi ) display = plus ; else if ( minus > plus && minus > multi ) display = minus ; else if ( plus == minus && plus > multi ) display = plus ; else display = multi ; System . out . println ( display ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; class Nkuwebo { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int nkuwebo = Integer . parseInt ( scan . next ( ) ) ; int q = Integer . parseInt ( scan . next ( ) ) ; int sumTime = 0 ; Queue < Process > queue = new ArrayDeque < Process > ( ) ; for ( int i = 0 ; i < nkuwebo ; i ++ ) { String namae = scan . next ( ) ; int Time = Integer . parseInt ( scan . next ( ) ) ; queue . add ( new Process ( namae , Time ) ) ; } Queue < Process > ans = new ArrayDeque < > ( ) ; while ( ! queue . isEmpty ( ) ) { Process buf = queue . remove ( ) ; if ( buf . pTime - q <= 0 ) { int buf2 = buf . pTime ; buf . pTime += sumTime ; sumTime += buf2 ; ans . add ( buf ) ; } else { buf . pTime -= q ; queue . add ( buf ) ; sumTime += q ; } } for ( Process p : ans ) { System . out . println ( p . name + " " + p . pTime ) ; } } } class Nkuwebo { String name ; int pTime ; public Process ( String name , int pTime ) { this . name = name ; this . pTime = pTime ; } } import java . util . * ; public class Ontumqf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ontumqf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; sc . close ( ) ; int tk = ( c + b - 1 ) / b ; int ao = ( d + ontumqf - 1 ) / d ; if ( tk <= ao ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class Jgdbap { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int jgdbap = 0 ; jgdbap < 5 ; jgdbap ++ ) { list . add ( Integer . parseInt ( sc . next ( ) ) ) ; } sc . close ( ) ; for ( int jgdbap = 0 ; jgdbap < 5 ; jgdbap ++ ) { if ( list . get ( jgdbap ) == 0 ) { int ans = jgdbap + 1 ; System . out . println ( ans ) ; return ; } } } } import java . util . Scanner ; public class Xjsrr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int xjsrr = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] ave = new int [ xjsrr ] ; for ( int i = 0 ; i < M ; i ++ ) { ave [ sc . nextInt ( ) - 1 ] ++ ; ave [ sc . nextInt ( ) - 1 ] ++ ; } for ( int i = 0 ; i < ave . length ; i ++ ) { System . out . println ( ave [ i ] ) ; } sc . close ( ) ; } } import java . util . Scanner ; class Twlaaef { public static void main ( String [ ] args ) { int twlaaef , n2 , n3 ; String str1 , str2 , str3 ; Scanner in = new Scanner ( System . in ) ; str1 = in . next ( ) ; str2 = in . next ( ) ; str3 = in . next ( ) ; twlaaef = Integer . parseInt ( str1 ) ; n2 = Integer . parseInt ( str2 ) ; n3 = Integer . parseInt ( str3 ) ; if ( twlaaef < n2 && n2 < n3 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; in . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Ojiirg { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int ojiirg = in . nextInt ( ) ; int x = in . nextInt ( ) ; int t = in . nextInt ( ) ; int ans = ojiirg / x ; if ( ojiirg % x != 0 ) ans ++ ; ans *= t ; System . out . println ( ans ) ; } } import java . util . Scanner ; class Ekggaic { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ekggaic , m , i , j ; int [ ] [ ] a = new int [ 100 ] [ 100 ] ; int [ ] b = new int [ 100 ] ; int [ ] c = new int [ 100 ] ; ekggaic = scan . nextInt ( ) ; m = scan . nextInt ( ) ; for ( i = 0 ; i < ekggaic ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { a [ i ] [ j ] = scan . nextInt ( ) ; } } for ( j = 0 ; j < m ; j ++ ) { b [ j ] = scan . nextInt ( ) ; } for ( i = 0 ; i < ekggaic ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { c [ i ] += a [ i ] [ j ] * b [ j ] ; } System . out . println ( c [ i ] ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Dppaj { public static void main ( String [ ] args ) throws Exception { String dppaj = readLine ( ) ; String WA = " WA " ; String AC = " AC " ; if ( dppaj . startsWith ( " A " ) ) { if ( dppaj . substring ( 0 , 2 ) . indexOf ( " C " ) != - 1 || dppaj . endsWith ( " C " ) ) { System . out . println ( WA ) ; return ; } if ( dppaj . replace ( " C " , " " ) . length ( ) != dppaj . length ( ) - 1 ) { System . out . println ( WA ) ; return ; } String str1 = dppaj . replace ( " A " , " " ) ; String str2 = str1 . replace ( " C " , " " ) ; if ( str2 . equals ( str2 . toLowerCase ( ) ) ) { System . out . println ( AC ) ; } else { System . out . println ( WA ) ; } } else { System . out . println ( WA ) ; } } private static String readLine ( ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; return br . readLine ( ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Aaknprt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aaknprt = sc . nextInt ( ) ; ArrayList < Integer > array = new ArrayList < Integer > ( ) ; long ans = 0 ; for ( int i = 1 ; i <= aaknprt ; i ++ ) { if ( ! ( i % 3 == 0 || i % 5 == 0 ) ) { array . add ( i ) ; } } for ( int i = 0 ; i < array . size ( ) ; i ++ ) { ans += array . get ( i ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Xrbboe { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int xrbboe = reader . nextInt ( ) ; int B = reader . nextInt ( ) ; int ans = Math . max ( xrbboe + xrbboe - 1 , B + B - 1 ) ; ans = Math . max ( ans , xrbboe + B ) ; System . out . print ( ans ) ; reader . close ( ) ; } } import java . util . Scanner ; public class Idogkw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int idogkw = 0 ; int b = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { char c = s [ i ] ; if ( i % 2 == 0 ) { if ( c == '0' ) idogkw ++ ; else b ++ ; } else { if ( c == '1' ) idogkw ++ ; else b ++ ; } } System . out . println ( Math . min ( idogkw , b ) ) ; } } import java . util . * ; public class Jjeount { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jjeount = sc . nextInt ( ) ; int [ ] X = new int [ jjeount ] ; for ( int i = 0 ; i < jjeount ; i ++ ) { X [ i ] = sc . nextInt ( ) ; } boolean flag = true ; for ( int i = jjeount - 2 ; i >= 0 ; i -- ) { if ( X [ i ] > X [ i + 1 ] ) { if ( X [ i ] - X [ i + 1 ] == 1 ) X [ i ] -- ; else { flag = false ; break ; } } } System . out . println ( ( flag ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Elrhbfp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int elrhbfp = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ elrhbfp ] ; int first = 0 ; int second = 0 ; int loc = 0 ; for ( int i = 0 ; i < elrhbfp ; i ++ ) { int k = Integer . parseInt ( sc . next ( ) ) ; if ( second <= k ) { if ( first <= k ) { second = first ; first = k ; loc = i ; } else { second = k ; } } } for ( int j = 0 ; j < elrhbfp ; j ++ ) { if ( j == loc ) { System . out . println ( second ) ; } else { System . out . println ( first ) ; } } } } import java . util . * ; public class Capvnin { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; sc . close ( ) ; char [ ] array = s . toCharArray ( ) ; String ans = " No " ; for ( int capvnin = 0 ; capvnin < array . length ; capvnin ++ ) { if ( capvnin % 2 == 0 && ( array [ capvnin ] == 'R' || array [ capvnin ] == 'U' || array [ capvnin ] == 'D' ) ) { ans = " Yes " ; } else if ( capvnin % 2 == 1 && ( array [ capvnin ] == 'L' || array [ capvnin ] == 'U' || array [ capvnin ] == 'D' ) ) { ans = " Yes " ; } else { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; class Tqqavrw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char tqqavrw = sc . next ( ) . charAt ( 0 ) ; int d = tqqavrw + 1 ; char ans = ( char ) d ; System . out . println ( ans ) ; } } import java . util . * ; public class Iqzkhka { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int iqzkhka = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int count = 0 ; if ( b != 1 ) { count = 1 ; } int sum = iqzkhka ; while ( b > sum ) { sum += iqzkhka - 1 ; count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class Yspvfh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; boolean yspvfh = true ; int n = sc . nextInt ( ) ; long l = 1000000000 ; l *= l ; long po = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( po == 0 ) { break ; } else { long a = sc . nextLong ( ) ; if ( ( l / po >= a ) ) { po *= a ; } else { yspvfh = false ; } } } System . out . println ( yspvfh ? po : ( po == 0 ) ? 0 : - 1 ) ; } } import java . util . * ; public class Hkdwen { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hkdwen = sc . nextInt ( ) ; String a1 ; String a2 ; a1 = sc . next ( ) ; a2 = sc . next ( ) ; String ans = " " ; for ( int i = 0 ; i < hkdwen ; i ++ ) { char aa = a1 . charAt ( i ) ; char bb = a2 . charAt ( i ) ; ans += String . valueOf ( aa ) + String . valueOf ( bb ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class Tydzcbr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tydzcbr = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; char [ ] arr = sc . next ( ) . toCharArray ( ) ; int [ ] dp = new int [ arr . length ] ; for ( int i = 1 ; i < dp . length ; i ++ ) { if ( arr [ i ] == 'C' && arr [ i - 1 ] == 'A' ) { dp [ i ] = 1 ; } } for ( int i = 1 ; i < dp . length ; i ++ ) { dp [ i ] += dp [ i - 1 ] ; } while ( Q -- > 0 ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; l -- ; r -- ; int val = dp [ r ] - dp [ l ] ; System . out . println ( val ) ; } } } import java . util . Scanner ; public class Bxryqz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bxryqz = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; for ( int i = 0 ; i <= bxryqz ; i ++ ) { if ( i * 2 + ( bxryqz - i ) * 4 == y ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; sc . close ( ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Cvpkkd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cvpkkd = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; if ( n == 0 ) { System . out . println ( cvpkkd ) ; return ; } Set < Integer > p = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { p . add ( sc . nextInt ( ) ) ; } sc . close ( ) ; Integer underPos = null ; Integer upwardPos = null ; int startPos = cvpkkd ; while ( underPos == null ) { if ( p . contains ( startPos ) != true ) { underPos = startPos ; } startPos -- ; } startPos = cvpkkd ; while ( upwardPos == null ) { if ( p . contains ( startPos ) != true ) { upwardPos = startPos ; } startPos ++ ; } int underDist = Math . abs ( cvpkkd - underPos ) ; int upwardDist = Math . abs ( cvpkkd - upwardPos ) ; if ( underDist == upwardDist ) { System . out . println ( underPos ) ; return ; } if ( underDist < upwardDist ) { System . out . println ( underPos ) ; } else { System . out . println ( upwardPos ) ; } } } import java . util . * ; public class Mhavm { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; String patt = ob . next ( ) ; int mhavm = 0 ; for ( int i = 0 ; i < patt . length ( ) ; i ++ ) { int temp = 0 ; for ( int j = i ; j < patt . length ( ) ; j ++ ) { if ( patt . charAt ( j ) == 'R' ) { temp ++ ; } else { break ; } } mhavm = Math . max ( mhavm , temp ) ; } System . out . println ( mhavm ) ; ob . close ( ) ; } } import java . util . Scanner ; class Ctezwf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; StringBuilder str = new StringBuilder ( ) ; while ( true ) { int ctezwf = scan . nextInt ( ) ; int w = scan . nextInt ( ) ; if ( ctezwf == 0 && w == 0 ) break ; for ( int i = 0 ; i < ctezwf ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { str . append ( " # " ) ; } str . append ( " \n " ) ; } str . append ( " \n " ) ; } System . out . print ( str ) ; } } import java . util . Scanner ; public class Kvaxt { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; int kvaxt = Integer . parseInt ( stdin . nextLine ( ) ) ; boolean boo = true ; int [ ] seq = new int [ kvaxt ] ; if ( kvaxt <= 100 ) { for ( int i = 0 ; i < kvaxt ; i ++ ) { seq [ i ] = stdin . nextInt ( ) ; if ( seq [ i ] >= 0 && seq [ i ] <= 1000 ) { continue ; } else { boo = false ; break ; } } } if ( boo == true ) { for ( int j = kvaxt ; j > 0 ; j -- ) { if ( j != 1 ) { System . out . print ( seq [ j - 1 ] + " " ) ; } else { System . out . println ( seq [ j - 1 ] ) ; } } } stdin . close ( ) ; } } import java . util . * ; import java . lang . * ; import java . math . * ; public class Tvvcz { Scanner sc = new Scanner ( System . in ) ; void run ( ) { long tvvcz , y , z ; long first , second ; long tmp ; while ( sc . hasNext ( ) ) { first = sc . nextLong ( ) ; second = sc . nextLong ( ) ; tvvcz = first ; y = second ; if ( tvvcz < y ) { tmp = tvvcz ; tvvcz = y ; y = tmp ; } do { z = tvvcz % y ; tvvcz = y ; y = z ; } while ( z != 0 ) ; System . out . println ( tvvcz + " " + first * second / tvvcz ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; class Dtnsv { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String S = sc . nextLine ( ) ; for ( int dtnsv = 0 ; dtnsv < S . length ( ) ; dtnsv ++ ) { if ( Character . isUpperCase ( S . charAt ( dtnsv ) ) ) { System . out . print ( Character . toLowerCase ( S . charAt ( dtnsv ) ) ) ; } else { System . out . print ( Character . toUpperCase ( S . charAt ( dtnsv ) ) ) ; } } System . out . println ( " " ) ; } } } import java . util . Scanner ; public class Wqvdc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wqvdc = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int result2 = wqvdc ; int result = 0 ; do { result2 = result2 / K ; result ++ ; } while ( result2 != 0 ) ; System . out . println ( result ) ; } } public class Biznhg { public static void main ( String [ ] args ) { java . util . Scanner sc = new java . util . Scanner ( System . in ) ; int biznhg = sc . nextInt ( ) ; int [ ] x = new int [ biznhg ] ; double sum = 0 ; int total = 0 ; for ( int i = 0 ; i < biznhg ; i ++ ) { x [ i ] = sc . nextInt ( ) ; sum += x [ i ] ; } double val = sum / biznhg ; val = Math . round ( val ) ; int avg = ( int ) val ; for ( int i = 0 ; i < biznhg ; i ++ ) { int num = avg - x [ i ] ; num = num * num ; total += num ; } System . out . println ( total ) ; } } import java . util . * ; public class Cfvwd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cfvwd = sc . nextInt ( ) ; int count = 0 ; int valLen = String . valueOf ( cfvwd ) . length ( ) ; for ( int i = valLen ; i > 0 ; i -- ) { if ( i % 2 == 1 ) { if ( i == valLen ) { count += cfvwd % Math . pow ( 10 , i - 1 ) + 1 ; count += ( ( cfvwd / ( int ) Math . pow ( 10 , i - 1 ) ) - 1 ) * ( int ) Math . pow ( 10 , i - 1 ) ; } else if ( i == 1 ) { count += 9 ; } else { count += 9 * ( int ) Math . pow ( 10 , i - 1 ) ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Jeyfjf { static int jeyfjf = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int [ ] [ ] X = new int [ N ] [ D ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < D ; j ++ ) { X [ i ] [ j ] = sc . nextInt ( ) ; } } sc . close ( ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { solve ( D , X , i , j ) ; } } System . out . println ( jeyfjf ) ; } static void solve ( int D , int [ ] [ ] X , int idx1 , int idx2 ) { int sum = 0 ; for ( int i = 0 ; i < D ; i ++ ) { int yx = Math . abs ( X [ idx1 ] [ i ] - X [ idx2 ] [ i ] ) ; sum += yx * yx ; } double sqrt1 = Math . sqrt ( sum ) ; int sqrt2 = ( int ) sqrt1 ; if ( sqrt1 == ( double ) sqrt2 ) jeyfjf ++ ; } } import java . util . Scanner ; public class Jcgiylz { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int jcgiylz = stdIn . nextInt ( ) ; int A = stdIn . nextInt ( ) ; int B = stdIn . nextInt ( ) ; int z = 1 , y = 0 , x = 0 , ans = 0 ; while ( z <= jcgiylz ) { y = z ; while ( true ) { x += y % 10 ; y /= 10 ; if ( y == 0 ) break ; } if ( A <= x && B >= x ) ans += z ; x = 0 ; z ++ ; } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class Fzfut { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] nyu = sc . nextLine ( ) . split ( " " ) ; int fzfut = Integer . parseInt ( nyu [ 0 ] ) ; int B = Integer . parseInt ( nyu [ 1 ] ) ; int C = Integer . parseInt ( nyu [ 2 ] ) ; int [ ] num = { fzfut , B , C } ; Arrays . sort ( num ) ; if ( num [ 0 ] == 5 && num [ 1 ] == 5 && num [ 2 ] == 7 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Ufpmmr { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int [ ] [ ] C = new int [ 3 ] [ 3 ] ; for ( int ufpmmr = 0 ; ufpmmr < 3 ; ufpmmr ++ ) { for ( int c = 0 ; c < 3 ; c ++ ) { C [ ufpmmr ] [ c ] = in . nextInt ( ) ; } } int [ ] a = new int [ 3 ] ; int [ ] b = new int [ 3 ] ; int [ ] [ ] a2 = new int [ 3 ] [ 3 ] ; a [ 0 ] = 0 ; for ( int c = 0 ; c < 3 ; c ++ ) { b [ c ] = C [ 0 ] [ c ] - a [ 0 ] ; } for ( int ufpmmr = 0 ; ufpmmr < 3 ; ufpmmr ++ ) { for ( int c = 0 ; c < 3 ; c ++ ) { a2 [ ufpmmr ] [ c ] = C [ ufpmmr ] [ c ] - b [ c ] ; } } for ( int ufpmmr = 0 ; ufpmmr < 3 ; ufpmmr ++ ) { for ( int c = 1 ; c < 3 ; c ++ ) { if ( a2 [ ufpmmr ] [ c - 1 ] != a2 [ ufpmmr ] [ c ] ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Ocxurc { public static void main ( String [ ] args ) { Scanner sc1 = new Scanner ( System . in ) ; int [ ] num = new int [ 3 ] ; num [ 0 ] = sc1 . nextInt ( ) ; num [ 1 ] = sc1 . nextInt ( ) ; num [ 2 ] = sc1 . nextInt ( ) ; int ocxurc = sc1 . nextInt ( ) ; Arrays . sort ( num ) ; for ( int i = 0 ; i < ocxurc ; i ++ ) { num [ 2 ] *= 2 ; } System . out . println ( num [ 0 ] + num [ 1 ] + num [ 2 ] ) ; sc1 . close ( ) ; } } import java . io . * ; public class Fwmjj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line ; while ( ( line = br . readLine ( ) ) != null ) { String [ ] numbers = line . split ( " " ) ; for ( int fwmjj = numbers . length - 1 ; fwmjj >= 0 ; fwmjj -- ) { System . out . print ( numbers [ fwmjj ] ) ; } System . out . println ( ) ; } } } import java . util . Scanner ; public class Dxhjbcl { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long dxhjbcl = Long . parseLong ( s . next ( ) ) ; System . out . println ( atack ( dxhjbcl ) ) ; } static long atack ( long h ) { if ( h == 1 ) { return 1 ; } return atack ( h / 2 ) * 2 + 1 ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Aovgxyg { public static void main ( String [ ] args ) { FastReader f = new FastReader ( ) ; String line = f . nextLine ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( char aovgxyg : line . toCharArray ( ) ) { if ( ! Character . isAlphabetic ( aovgxyg ) ) { sb . append ( aovgxyg ) ; } else if ( aovgxyg < 97 ) { sb . append ( Character . toChars ( aovgxyg + 32 ) ) ; } else { sb . append ( Character . toChars ( aovgxyg - 32 ) ) ; } } System . out . println ( sb ) ; } static class Aovgxyg { 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 . io . * ; import java . util . * ; import java . math . * ; public class Sryfo { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int sryfo = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; if ( sryfo > w ) System . out . println ( " safe " ) ; else System . out . println ( " unsafe " ) ; } static class Sryfo { StringTokenizer st ; BufferedReader br ; public Scanner ( InputStream sryfo ) { br = new BufferedReader ( new InputStreamReader ( sryfo ) ) ; } public Scanner ( String file ) throws FileNotFoundException { br = new BufferedReader ( new FileReader ( file ) ) ; } public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } public String nextLine ( ) throws IOException { return br . readLine ( ) ; } public double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } public boolean ready ( ) throws IOException { return br . ready ( ) ; } public int [ ] nextArr ( int n ) throws IOException { int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = nextInt ( ) ; return arr ; } } } import java . util . Scanner ; public class Orhyl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int orhyl = sc . nextInt ( ) ; String s = sc . next ( ) ; sc . close ( ) ; if ( ( orhyl + 2 ) % 2 != 0 ) { System . out . println ( " No " ) ; return ; } if ( orhyl == 2 ) { System . out . println ( s . charAt ( 0 ) == s . charAt ( 1 ) ? " Yes " : " No " ) ; return ; } System . out . println ( s . substring ( 0 , orhyl / 2 - 1 ) . equals ( s . substring ( orhyl / 2 , orhyl - 1 ) ) ? " Yes " : " No " ) ; } } import java . util . * ; public class Bwsucz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bwsucz = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int count1 = 0 ; int count2 = 0 ; if ( bwsucz >= 2 ) { count1 = ( bwsucz * ( bwsucz - 1 ) ) / 2 ; } if ( m >= 2 ) { count2 = ( m * ( m - 1 ) ) / 2 ; } System . out . println ( count1 + count2 ) ; } } import java . util . Scanner ; public class Fwxnore { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fwxnore = sc . nextInt ( ) ; double T = sc . nextDouble ( ) , A = sc . nextInt ( ) , temp = 60001 ; int ans = 0 ; for ( int i = 1 ; i <= fwxnore ; i ++ ) { double h = A - ( T - ( 0.006 * sc . nextDouble ( ) ) ) ; if ( Math . abs ( h ) < Math . abs ( temp ) ) { temp = Math . abs ( h ) ; ans = i ; } } System . out . println ( ans ) ; } } import java . math . BigInteger ; import java . util . * ; public class Qpuiyx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; BigInteger N = scanner . nextBigInteger ( ) ; BigInteger K = scanner . nextBigInteger ( ) ; scanner . close ( ) ; BigInteger a = N . remainder ( K ) ; if ( a . compareTo ( K . subtract ( a ) ) > 0 ) { System . out . println ( K . subtract ( a ) ) ; } else { System . out . println ( a ) ; } } } import java . util . Scanner ; class Otdmdd { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String S = sc . next ( ) ; boolean otdmdd = true ; for ( int i = 0 ; i < S . length ( ) / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( S . length ( ) - i - 1 ) ) { otdmdd = false ; break ; } } for ( int i = 0 ; i < S . length ( ) / 4 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( S . length ( ) / 2 - i - 1 ) ) { otdmdd = false ; break ; } } System . out . println ( otdmdd ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Qcaiczg { public static void main ( String [ ] args ) { Scanner inputs = new Scanner ( System . in ) ; int qcaiczg = inputs . nextInt ( ) ; int x = inputs . nextInt ( ) ; int t = inputs . nextInt ( ) ; int takoyakiMade = 0 ; int timeTook = 0 ; do { timeTook += t ; takoyakiMade += x ; } while ( takoyakiMade < qcaiczg ) ; System . out . println ( timeTook ) ; } } import java . util . Scanner ; public class Afutcct { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int afutcct = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; String s = sc . next ( ) ; char c1 = s . charAt ( k - 1 ) ; String c2 = ( String . valueOf ( c1 ) ) . toLowerCase ( ) ; String before = s . substring ( 0 , k - 1 ) ; String after = s . substring ( k , s . length ( ) ) ; System . out . println ( before + c2 + after ) ; } } import java . util . Scanner ; public class Opjhsc { public static void main ( String [ ] args ) { int opjhsc ; Scanner in = new Scanner ( System . in ) ; opjhsc = Integer . parseInt ( in . next ( ) ) ; int cnt ; int ans = 0 ; for ( int i = 1 ; i <= opjhsc ; i += 2 ) { cnt = 0 ; for ( int j = 1 ; j * j <= i ; j ++ ) { if ( i % j == 0 ) { if ( j * j == i ) { cnt ++ ; } else { cnt += 2 ; } } } if ( cnt == 8 ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; public class Mungx { public static void main ( String [ ] args ) throws Exception { int mungx ; ArrayList < Integer > prime = new ArrayList < > ( ) ; ArrayList < Integer > exist = new ArrayList < > ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; int n = Integer . parseInt ( line ) ; for ( int i = 0 ; i < n ; i ++ ) { line = br . readLine ( ) ; mungx = Integer . parseInt ( line ) ; if ( isPrime ( mungx ) ) { prime . add ( mungx ) ; } } System . out . println ( prime . size ( ) ) ; } static boolean isPrime ( int n ) { if ( n == 2 ) { return true ; } if ( n < 2 || n % 2 == 0 ) { return false ; } int i = 3 ; while ( i <= Math . sqrt ( ( double ) n ) ) { if ( n % i == 0 ) { return false ; } i = i + 2 ; } return true ; } } import java . lang . reflect . Array ; import java . util . * ; public class Htqzquq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int htqzquq = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int tmp = htqzquq ; htqzquq = b ; b = tmp ; tmp = htqzquq ; htqzquq = c ; c = tmp ; System . out . println ( htqzquq + " " + b + " " + c ) ; } } import java . util . * ; public class Osude { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int osude = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] num = new int [ Q ] ; int [ ] count = new int [ osude ] ; int t = 0 ; for ( int i = 0 ; i < Q ; i ++ ) { num [ i ] = sc . nextInt ( ) ; count [ num [ i ] - 1 ] ++ ; } for ( int j = 0 ; j < osude ; j ++ ) { if ( ( count [ j ] + K - Q ) > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class Dmrbrr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long dmrbrr = sc . nextLong ( ) ; long t = ( long ) Math . sqrt ( dmrbrr ) ; long a = 1 ; for ( long i = t ; 1 <= i ; i -- ) { if ( dmrbrr % i == 0 ) { a = dmrbrr / i ; break ; } } System . out . print ( ( dmrbrr / a ) + a - 2 ) ; } } import java . util . Scanner ; public class Vpivr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vpivr = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( vpivr * y ) ; sc . close ( ) ; } } import java . util . * ; public class Ynmeoqd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) , b = sc . next ( ) , c = sc . next ( ) ; char ynmeoqd = 'a' ; int ac = 0 , bc = 0 , cc = 0 ; while ( true ) { if ( ynmeoqd == 'a' ) { if ( ac == a . length ( ) ) { System . out . println ( " A " ) ; break ; } ynmeoqd = a . charAt ( ac ) ; ac ++ ; } else if ( ynmeoqd == 'b' ) { if ( bc == b . length ( ) ) { System . out . println ( " B " ) ; break ; } ynmeoqd = b . charAt ( bc ) ; bc ++ ; } else if ( ynmeoqd == 'c' ) { if ( cc == c . length ( ) ) { System . out . println ( " C " ) ; break ; } ynmeoqd = c . charAt ( cc ) ; cc ++ ; } } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Cgzrua { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Set < Integer > set = new HashSet < > ( ) ; for ( int cgzrua = 0 ; cgzrua < 3 ; cgzrua ++ ) set . add ( sc . nextInt ( ) ) ; System . out . println ( set . size ( ) == 2 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Irhezz { public static void main ( final String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int irhezz = scanner . nextInt ( ) ; Point currentPoint = new Point ( 0 , 0 ) ; for ( int i = 0 ; i < irhezz ; i ++ ) { final int time = scanner . nextInt ( ) ; final int x = scanner . nextInt ( ) ; final int y = scanner . nextInt ( ) ; final int distance = Math . abs ( x - currentPoint . x ) + Math . abs ( y - currentPoint . y ) ; if ( distance > time || ( time - distance ) % 2 == 1 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } static class Irhezz { int x ; int y ; Point ( final int x , final int y ) { this . x = x ; this . y = y ; } } } import java . util . * ; public class Pygjg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int pygjg = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = pygjg + B ; ans = ans < pygjg - B ? pygjg - B : ans ; ans = ans < pygjg * B ? pygjg * B : ans ; System . out . print ( ans ) ; } } import java . io . * ; import java . util . * ; public class Ykjpp { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int ykjpp = Integer . parseInt ( st . nextToken ( ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; int [ ] y = new int [ ykjpp ] ; int p = 0 ; while ( st . hasMoreTokens ( ) ) { y [ p ] = Integer . parseInt ( st . nextToken ( ) ) ; p ++ ; } Arrays . sort ( y ) ; System . out . println ( y [ ykjpp - 1 ] - y [ 0 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Zwuzruf { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Solver solver = new Solver ( ) ; solver . init ( ) ; solver . readHead ( in . readLine ( ) ) ; } } class Zwuzruf { int zwuzruf ; int cnt ; public void init ( ) { zwuzruf = 0 ; cnt = 0 ; } public void readHead ( String str ) { String [ ] strArr = str . split ( " \\ s+ " ) ; int x = Integer . parseInt ( str ) ; int [ ] prime = new int [ 200000 ] ; for ( int n = 2 ; ; n ++ ) { if ( prime [ n ] != 0 ) continue ; if ( n >= x ) { System . out . println ( n ) ; break ; } for ( int np = n + n ; np < 200000 ; np += n ) prime [ np ] = 1 ; } } public boolean hasNext ( ) { return cnt < zwuzruf ; } public void readBody ( String str ) { cnt ++ ; } public void solve ( ) { } } import java . util . * ; public class Jqnapgk { public static void main ( String [ ] args ) { ALDS1_1_A ( ) ; } public static void ALDS1_1_A ( ) { Scanner sc = new Scanner ( System . in ) ; int jqnapgk = sc . nextInt ( ) ; int [ ] a = new int [ jqnapgk ] ; for ( int i = 0 ; i < jqnapgk ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < jqnapgk ; i ++ ) { for ( int j = 0 ; j < jqnapgk ; j ++ ) { if ( j == jqnapgk - 1 ) { System . out . print ( a [ j ] ) ; } else { System . out . print ( a [ j ] + " " ) ; } } System . out . println ( ) ; int temp = a [ i ] ; int j = i - 1 ; while ( j >= 0 && temp < a [ j ] ) { a [ j + 1 ] = a [ j ] ; j -- ; } a [ j + 1 ] = temp ; } for ( int j = 0 ; j < jqnapgk ; j ++ ) { if ( j == jqnapgk - 1 ) { System . out . print ( a [ j ] ) ; } else { System . out . print ( a [ j ] + " " ) ; } } System . out . println ( ) ; } } import java . util . Scanner ; import java . util . TreeSet ; public class Dxxvvt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; TreeSet < Integer > A = new TreeSet < > ( ) ; TreeSet < Integer > Z = new TreeSet < > ( ) ; for ( int dxxvvt = 0 ; dxxvvt < s . length ( ) ; dxxvvt ++ ) { if ( s . charAt ( dxxvvt ) == 'A' ) { A . add ( dxxvvt ) ; } else if ( s . charAt ( dxxvvt ) == 'Z' ) { Z . add ( dxxvvt ) ; } } System . out . println ( Z . last ( ) - A . first ( ) + 1 ) ; } } import java . util . Scanner ; class Hpphtgg { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int hpphtgg ; double t , a ; hpphtgg = scan . nextInt ( ) ; t = scan . nextDouble ( ) ; a = scan . nextDouble ( ) ; double [ ] h = new double [ hpphtgg ] ; for ( int i = 0 ; i < hpphtgg ; i ++ ) { h [ i ] = scan . nextDouble ( ) ; } double min = 99999999.0 ; double x ; int ans = 0 ; for ( int i = 0 ; i < hpphtgg ; i ++ ) { x = t - h [ i ] * 0.006 ; if ( Math . abs ( x - a ) < min ) { min = Math . abs ( x - a ) ; ans = i + 1 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; class Bhcsctl { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; if ( scanner . hasNextLine ( ) ) { String [ ] array = scanner . nextLine ( ) . split ( " " ) ; long bhcsctl = Integer . parseInt ( array [ 0 ] ) ; long b = Integer . parseInt ( array [ 1 ] ) ; long c = Integer . parseInt ( array [ 2 ] ) ; int k = Integer . parseInt ( scanner . nextLine ( ) ) ; if ( bhcsctl > b && bhcsctl > c ) { for ( int i = 0 ; i < k ; ++ i ) { bhcsctl *= 2 ; } } else if ( b > c ) { for ( int i = 0 ; i < k ; ++ i ) { b *= 2 ; } } else { for ( int i = 0 ; i < k ; ++ i ) { c *= 2 ; } } System . out . println ( bhcsctl + b + c ) ; } } } import java . util . Scanner ; public class Veoyg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String veoyg = scan . next ( ) ; String anser = " No " ; if ( veoyg . contains ( " A " ) && veoyg . contains ( " B " ) ) { anser = " Yes " ; } System . out . println ( anser ) ; } } import java . util . Scanner ; public class Tqcfdwd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tqcfdwd = Integer . parseInt ( sc . next ( ) ) ; tqcfdwd += Integer . parseInt ( sc . next ( ) ) ; tqcfdwd += Integer . parseInt ( sc . next ( ) ) ; if ( tqcfdwd > 21 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } sc . close ( ) ; } } import java . util . * ; public class Imhtsad { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int imhtsad = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int a = - 1 ; int b = - 1 ; int c = - 1 ; for ( int i = 0 ; i <= imhtsad ; i ++ ) { for ( int j = 0 ; j <= imhtsad ; j ++ ) { if ( y / 1000 - 10 * i - 5 * j == imhtsad - j - i && imhtsad - j - i >= 0 ) { a = i ; b = j ; c = imhtsad - i - j ; break ; } } } System . out . println ( a + " " + b + " " + c ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Ocnbnyj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int ocnbnyj = scan . nextInt ( ) ; if ( ocnbnyj == 1 ) { System . out . println ( 1 ) ; return ; } int answer = 0 ; while ( ocnbnyj != 1 ) { answer += 1 ; ocnbnyj /= 2 ; } System . out . println ( ( int ) Math . pow ( 2 , answer ) ) ; } } import java . util . * ; import static java . lang . Math . * ; import java . math . BigInteger ; public class Kapexfg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; for ( int kapexfg = 0 ; kapexfg < n . length ( ) ; kapexfg ++ ) { if ( n . charAt ( kapexfg ) == '1' ) System . out . print ( 9 ) ; if ( n . charAt ( kapexfg ) == '9' ) System . out . print ( 1 ) ; } } } import java . io . * ; class Tvwxdsc { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] cmd = br . readLine ( ) . split ( " " , 0 ) ; int [ ] S = new int [ 100 ] ; for ( int tvwxdsc = 0 , p = 0 ; tvwxdsc < cmd . length ; tvwxdsc ++ ) { if ( cmd [ tvwxdsc ] . equals ( " + " ) ) { p -- ; S [ p - 1 ] += S [ p ] ; } else if ( cmd [ tvwxdsc ] . equals ( " - " ) ) { p -- ; S [ p - 1 ] -= S [ p ] ; } else if ( cmd [ tvwxdsc ] . equals ( " * " ) ) { p -- ; S [ p - 1 ] *= S [ p ] ; } else { S [ p ] = Integer . parseInt ( " " + cmd [ tvwxdsc ] ) ; p ++ ; } } System . out . println ( S [ 0 ] ) ; } catch ( IOException e ) { System . out . println ( " Exception : " + e ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Rmrnsy { PrintWriter out = new PrintWriter ( System . out ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tok = new StringTokenizer ( " " ) ; String next ( ) throws IOException { if ( ! tok . hasMoreTokens ( ) ) { tok = new StringTokenizer ( in . readLine ( ) ) ; } return tok . nextToken ( ) ; } int ni ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } long nl ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } void solve ( ) throws IOException { String s = next ( ) ; String t = next ( ) ; int rmrnsy = Integer . MAX_VALUE ; for ( int i = 0 ; i <= s . length ( ) - t . length ( ) ; i ++ ) { int na = 0 ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( i + j ) != t . charAt ( j ) ) na ++ ; } rmrnsy = Math . min ( rmrnsy , na ) ; } System . out . println ( rmrnsy ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class Lpmgviv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lpmgviv = sc . nextInt ( ) ; double T = sc . nextDouble ( ) ; int A = sc . nextInt ( ) ; double [ ] H = new double [ lpmgviv ] ; for ( int i = 0 ; i < lpmgviv ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } double tmp = 2000000000 ; double ans = 2000000000 ; int res = 0 ; for ( int i = 0 ; i < lpmgviv ; i ++ ) { tmp = T - H [ i ] * 0.006 ; if ( Math . abs ( tmp - A ) < ans ) { ans = Math . abs ( tmp - A ) ; res = i ; } } System . out . println ( res + 1 ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Lldkan { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int lldkan = in . nextInt ( ) ; int [ ] d = new int [ lldkan ] ; for ( int i = 0 ; i < d . length ; ++ i ) { d [ i ] = in . nextInt ( ) ; } Arrays . sort ( d ) ; int mid1 = d [ lldkan / 2 - 1 ] ; int mid2 = d [ lldkan / 2 ] ; System . out . println ( mid2 - mid1 ) ; } } } import java . util . Scanner ; public class Irlbjl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String input = scan . nextLine ( ) ; int irlbjl = Integer . parseInt ( input . split ( " " ) [ 0 ] ) ; double d = Integer . parseInt ( input . split ( " " ) [ 1 ] ) ; int c = 0 ; int [ ] [ ] x = new int [ irlbjl ] [ 2 ] ; for ( int i = 0 ; i < irlbjl ; i ++ ) { input = scan . nextLine ( ) ; x [ i ] [ 0 ] = Integer . parseInt ( input . split ( " " ) [ 0 ] ) ; x [ i ] [ 1 ] = Integer . parseInt ( input . split ( " " ) [ 1 ] ) ; if ( d >= Math . sqrt ( Math . pow ( x [ i ] [ 0 ] , 2 ) + Math . pow ( x [ i ] [ 1 ] , 2 ) ) ) { c += 1 ; } } System . out . println ( c ) ; } } import java . util . * ; public class Vupcqox { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vupcqox = sc . nextInt ( ) ; int int100 = sc . nextInt ( ) ; int int50 = sc . nextInt ( ) ; int total = sc . nextInt ( ) ; int count = 0 ; for ( int a = 0 ; a <= vupcqox ; a ++ ) { for ( int b = 0 ; b <= int100 ; b ++ ) { for ( int c = 0 ; c <= int50 ; c ++ ) { int sum = a * 500 + b * 100 + c * 50 ; if ( sum == total ) count ++ ; } } } System . out . println ( count ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class Mljxskv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigDecimal a = sc . nextBigDecimal ( ) ; BigDecimal b = sc . nextBigDecimal ( ) ; BigDecimal c = a . multiply ( b ) ; System . out . println ( c . setScale ( 0 , BigDecimal . ROUND_DOWN ) ) ; } } import java . util . * ; public class Wmmyy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wmmyy = sc . nextInt ( ) ; int as = sc . nextInt ( ) ; int [ ] ar = new int [ 10000 ] ; int s = 0 ; for ( int i = 0 ; i < as ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < ar . length ; i ++ ) { s = s + ar [ i ] ; } int f = wmmyy - s ; if ( f >= 0 ) { System . out . println ( f ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Kuldbm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kuldbm = scan . nextInt ( ) , l = scan . nextInt ( ) ; ArrayList < String > dict = new ArrayList < String > ( ) ; for ( int i = 0 ; i < kuldbm ; i ++ ) { dict . add ( scan . next ( ) ) ; } Collections . sort ( dict ) ; String result = " " ; for ( int i = 0 ; i < kuldbm ; i ++ ) { result += dict . get ( i ) ; } System . out . println ( result ) ; } } import java . util . Scanner ; public class Qcaouw { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; int qcaouw = std . nextInt ( ) ; int b = std . nextInt ( ) ; if ( qcaouw >= 13 ) { System . out . println ( b ) ; } else if ( qcaouw <= 5 ) { System . out . println ( " 0 " ) ; } else { System . out . println ( b / 2 ) ; } } } import java . util . Scanner ; public class Ufsrulz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ufsrulz = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; if ( a * ufsrulz < b ) ans = a * ufsrulz ; else ans = b ; System . out . println ( ans ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Qhxyq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int qhxyq = scanner . nextInt ( ) ; int [ ] nums = new int [ qhxyq ] ; for ( int i = 0 ; i < qhxyq ; i ++ ) nums [ i ] = scanner . nextInt ( ) ; bubbleSort ( qhxyq , nums ) ; } private static void bubbleSort ( int qhxyq , int [ ] a ) { boolean flg = true ; int i = 0 ; int sw = 0 ; while ( flg ) { flg = false ; for ( int j = qhxyq - 1 ; j > i ; j -- ) { if ( a [ j ] < a [ j - 1 ] ) { int w = a [ j ] ; a [ j ] = a [ j - 1 ] ; a [ j - 1 ] = w ; sw ++ ; flg = true ; } } i ++ ; } trace ( a ) ; System . out . println ( sw ) ; } private static void trace ( int [ ] nums ) { System . out . println ( Arrays . toString ( nums ) . replaceAll ( " [ \\ [ \\ ],] " , " " ) ) ; } } import java . io . * ; public class Stpnb { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; double stpnb = Double . parseDouble ( br . readLine ( ) ) ; System . out . printf ( " %.6f %.6f " , stpnb * stpnb * Math . PI , 2 * stpnb * Math . PI ) ; } } import java . util . * ; public class Plvtcgy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] time = new int [ 5 ] , wait = new int [ 5 ] ; int plvtcgy = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { time [ i ] = sc . nextInt ( ) ; wait [ i ] = ( 10 - time [ i ] % 10 ) % 10 ; plvtcgy += time [ i ] + wait [ i ] ; } int idx = maxIdx ( wait ) ; plvtcgy -= wait [ idx ] ; System . out . println ( plvtcgy ) ; } public static int maxIdx ( int [ ] wait ) { int idx = 0 , data = wait [ 0 ] ; for ( int i = 1 ; i < 5 ; i ++ ) { if ( data < wait [ i ] ) { data = wait [ i ] ; idx = i ; } } return idx ; } } import java . util . Scanner ; public class Rkbhzvy { public static String check ( int x , int y ) { return " " ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int rkbhzvy = in . nextInt ( ) ; int count = 0 ; int vit = 0 ; while ( rkbhzvy -- != 0 ) { int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; if ( x == y ) { count ++ ; } else { count = 0 ; } if ( count == 3 ) { vit = 1 ; } } if ( vit == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . math . BigDecimal ; public class Qyjzsmo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigDecimal k = BigDecimal . valueOf ( sc . nextLong ( ) ) ; BigDecimal money = BigDecimal . valueOf ( 100.0 ) ; BigDecimal a = BigDecimal . valueOf ( 1.01 ) ; int qyjzsmo = 0 ; while ( money . compareTo ( k ) == - 1 ) { qyjzsmo += 1 ; money = money . multiply ( a ) ; BigDecimal bd1 = money . setScale ( 0 , BigDecimal . ROUND_DOWN ) ; money = bd1 ; } System . out . println ( qyjzsmo ) ; } } import java . util . * ; import java . io . * ; public class Lcyyaf { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; String s = sc . next ( ) ; int lcyyaf = 0 ; int run = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == 'R' ) { run ++ ; } else { lcyyaf = Math . max ( lcyyaf , run ) ; run = 0 ; } } lcyyaf = Math . max ( lcyyaf , run ) ; out . println ( lcyyaf ) ; out . close ( ) ; } public static class Lcyyaf { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } } import java . util . * ; public class Bcume { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bcume = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] L = new int [ bcume + 1 ] ; L [ 0 ] = 0 ; for ( int i = 1 ; i < bcume + 1 ; i ++ ) { L [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; System . out . println ( Bounding ( bcume + 1 , X , L , 0 , 0 ) ) ; } public static int Bounding ( int bcume , int X , int [ ] L , int index , int sum ) { if ( bcume <= index ) { return 0 ; } if ( sum + L [ index ] <= X ) { return 1 + Bounding ( bcume , X , L , index + 1 , sum + L [ index ] ) ; } return 0 ; } } import java . util . HashSet ; import java . util . Scanner ; public class Ynjwfc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ynjwfc = sc . nextInt ( ) ; HashSet < Integer > set = new HashSet < > ( ) ; for ( int i = 0 ; i < ynjwfc ; i ++ ) { set . add ( sc . nextInt ( ) ) ; } System . out . println ( set . size ( ) ) ; } } import java . util . * ; public class Acvzlb { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int acvzlb = Integer . parseInt ( sc . next ( ) ) ; if ( acvzlb < 105 ) { System . out . println ( 0 ) ; } else if ( acvzlb < 135 ) { System . out . println ( 1 ) ; } else if ( acvzlb < 165 ) { System . out . println ( 2 ) ; } else if ( acvzlb < 189 ) { System . out . println ( 3 ) ; } else if ( acvzlb < 195 ) { System . out . println ( 4 ) ; } else { System . out . println ( 5 ) ; } } } import java . util . Scanner ; public class Ffbfwq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String color1 = sc . next ( ) ; sc . next ( ) ; int ffbfwq = sc . nextInt ( ) ; int color2Cnt = sc . nextInt ( ) ; String disposed = sc . next ( ) ; if ( disposed . equals ( color1 ) ) { System . out . printf ( " %d %d " , ffbfwq - 1 , color2Cnt ) ; return ; } System . out . printf ( " %d %d " , ffbfwq , color2Cnt - 1 ) ; } } import java . io . * ; class Uvphi { public static void main ( String [ ] args ) throws IOException { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String str = br . readLine ( ) ; char [ ] ch = str . toCharArray ( ) ; for ( int uvphi = 0 ; uvphi < ch . length ; uvphi ++ ) { if ( Character . isUpperCase ( ch [ uvphi ] ) ) { ch [ uvphi ] = Character . toLowerCase ( ch [ uvphi ] ) ; } else ch [ uvphi ] = Character . toUpperCase ( ch [ uvphi ] ) ; } for ( int uvphi = 0 ; uvphi < ch . length ; uvphi ++ ) { System . out . print ( ch [ uvphi ] ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class Cojqfcs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cojqfcs = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int s = 0 ; for ( int i = 1 ; i <= cojqfcs ; i ++ ) { s = s + l + i - 1 ; } int a = 0 ; for ( int i = 1 ; i <= cojqfcs ; i ++ ) { if ( l - 1 + i == 0 ) { a = i ; } } if ( a == 0 ) { if ( l * l > ( l + cojqfcs - 1 ) * ( l + cojqfcs - 1 ) ) { a = cojqfcs ; } else { a = 1 ; } } System . out . println ( s - l + 1 - a ) ; sc . close ( ) ; } } import java . util . * ; class Ruccu { final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int ruccu = sc . nextInt ( ) ; Set < Long > set = new HashSet < > ( ) ; for ( int i = 0 ; i < ruccu ; i ++ ) { long a = sc . nextInt ( ) ; if ( set . contains ( a ) ) { System . out . println ( " NO " ) ; return ; } set . add ( a ) ; } System . out . println ( " YES " ) ; } } import java . io . * ; public class Rbwjokq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String input = br . readLine ( ) ; for ( int rbwjokq = 0 ; rbwjokq < input . length ( ) ; rbwjokq ++ ) { char a = input . charAt ( rbwjokq ) ; if ( Character . isUpperCase ( a ) ) { System . out . print ( Character . toLowerCase ( a ) ) ; } else { System . out . print ( Character . toUpperCase ( a ) ) ; } } System . out . print ( " \n " ) ; } } import java . util . * ; public class Efhdpw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long efhdpw = sc . nextLong ( ) ; for ( long j = efhdpw ; j < 1000000 ; j ++ ) { int count = 0 ; for ( long i = 2 ; i < efhdpw ; i ++ ) { if ( efhdpw % i == 0 ) { count ++ ; } } if ( count == 0 ) { System . out . println ( efhdpw ) ; System . exit ( 0 ) ; } efhdpw ++ ; } } } import java . util . Scanner ; public class Mzzzqdc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int mzzzqdc = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != t . charAt ( i ) ) { mzzzqdc ++ ; } } System . out . println ( mzzzqdc ) ; } } import java . util . Scanner ; public class Qdgcb { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] str ; str = new String [ 3 ] ; int qdgcb , num2 , Ans ; Ans = 0 ; for ( int i = 1 ; ; i ++ ) { str [ 0 ] = in . next ( ) ; str [ 1 ] = in . next ( ) ; str [ 2 ] = in . next ( ) ; qdgcb = Integer . parseInt ( str [ 0 ] ) ; num2 = Integer . parseInt ( str [ 2 ] ) ; if ( str [ 1 ] . equals ( " ? " ) ) { break ; } else { if ( str [ 1 ] . equals ( " + " ) ) { Ans = qdgcb + num2 ; } if ( str [ 1 ] . equals ( " - " ) ) { Ans = qdgcb - num2 ; } if ( str [ 1 ] . equals ( " * " ) ) { Ans = qdgcb * num2 ; } if ( str [ 1 ] . equals ( " / " ) ) { Ans = qdgcb / num2 ; } System . out . println ( Ans ) ; } } } } import java . util . Scanner ; public class Agaoh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int agaoh = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= 9 ; i ++ ) { for ( int j = 1 ; j <= 9 ; j ++ ) { if ( i * j == agaoh ) { count = 200 ; } else { count ++ ; } } } if ( count >= 200 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; class Yuzsz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double yuzsz = sc . nextDouble ( ) ; double t = sc . nextDouble ( ) ; double s = sc . nextDouble ( ) ; double sum = yuzsz / s ; if ( sum <= t ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . * ; import java . io . * ; public class Ysevil { public static void main ( String [ ] args ) { Scanner s = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; String turn = s . next ( ) ; Integer tarou = 0 ; Integer hanako = 0 ; for ( int ysevil = 0 ; ysevil < Integer . parseInt ( turn ) ; ysevil ++ ) { String tarou_card = s . next ( ) ; String hanako_card = s . next ( ) ; Integer result = tarou_card . compareTo ( hanako_card ) ; if ( result == 0 ) { if ( tarou_card . equals ( hanako_card ) ) { tarou += 1 ; hanako += 1 ; } } else if ( result > 0 ) { tarou += 3 ; } else { hanako += 3 ; } } s . close ( ) ; System . out . println ( tarou + " " + hanako ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Aqfgowc { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st ; PrintWriter pw = new PrintWriter ( System . out ) ; char [ ] c = br . readLine ( ) . toCharArray ( ) ; for ( int aqfgowc = 0 ; aqfgowc < c . length ; aqfgowc ++ ) c [ aqfgowc ] = 'x' ; pw . println ( c ) ; pw . flush ( ) ; pw . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Jkxka { public static void main ( String [ ] args ) { try { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String jkxka = stdReader . readLine ( ) ; String [ ] inputStr = jkxka . split ( " " ) ; String tateStr = inputStr [ 0 ] ; String yokoStr = inputStr [ 1 ] ; Integer tate = Integer . valueOf ( tateStr ) ; Integer yoko = Integer . valueOf ( yokoStr ) ; System . out . println ( tate * yoko + " " + 2 * ( tate + yoko ) ) ; System . exit ( 0 ) ; stdReader . close ( ) ; } catch ( Exception e ) { System . exit ( - 1 ) ; } } } import java . io . * ; import java . util . * ; class Dwwyyyv { public static void main ( String [ ] args ) { BufferedReader kb = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String [ ] str = kb . readLine ( ) . split ( " " ) ; int dwwyyyv = Integer . parseInt ( str [ 0 ] ) ; int q = Integer . parseInt ( str [ 1 ] ) ; LinkedList < String > ps = new LinkedList < String > ( ) ; LinkedList < Integer > times = new LinkedList < Integer > ( ) ; for ( int i = 0 ; i < dwwyyyv ; i ++ ) { str = kb . readLine ( ) . split ( " " ) ; ps . offer ( str [ 0 ] ) ; times . offer ( Integer . parseInt ( str [ 1 ] ) ) ; } StringBuilder output = new StringBuilder ( ) ; String job ; int time , t ; t = 0 ; while ( null != ( job = ps . peek ( ) ) ) { time = times . peek ( ) ; if ( times . peek ( ) <= q ) { output . append ( job ) ; output . append ( " " ) ; output . append ( t + time ) ; output . append ( " \n " ) ; t += time ; } else { ps . offer ( job ) ; times . offer ( time - q ) ; t += q ; } ps . poll ( ) ; times . poll ( ) ; } System . out . print ( output ) ; } catch ( IOException e ) { System . err . println ( e ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class Rqrsl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rqrsl = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int ans = 0 ; int minAbs = 100 ; ArrayList < String > numList = new ArrayList < > ( ) ; for ( int i = - 100 ; i <= 101 ; i ++ ) { numList . add ( String . valueOf ( i ) ) ; } for ( int i = 1 ; i <= n ; i ++ ) { String p = sc . next ( ) ; if ( numList . contains ( p ) ) { numList . remove ( p ) ; } } for ( int i = 0 ; i < numList . size ( ) ; i ++ ) { int abs = Math . abs ( rqrsl - Integer . parseInt ( numList . get ( i ) ) ) ; if ( abs < minAbs ) { minAbs = abs ; ans = Integer . parseInt ( numList . get ( i ) ) ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Zkwgvqu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zkwgvqu = sc . nextInt ( ) ; String C = sc . next ( ) ; int count = 1 ; for ( int i = 1 ; i < C . length ( ) ; i ++ ) { if ( ! C . substring ( i - 1 , i ) . equals ( C . substring ( i , i + 1 ) ) ) count ++ ; } System . out . println ( count ) ; } } import java . io . * ; import java . util . * ; public class Ukmztfz { PrintWriter out = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tok ; public void go ( ) throws IOException { ntok ( ) ; String s = spar ( ) ; out . println ( s . indexOf ( '7' ) != - 1 ? " Yes " : " No " ) ; out . flush ( ) ; in . close ( ) ; } public void ntok ( ) throws IOException { tok = new StringTokenizer ( in . readLine ( ) ) ; } public int ipar ( ) { return Integer . parseInt ( tok . nextToken ( ) ) ; } public int [ ] iapar ( int n ) { int [ ] arr = new int [ n ] ; for ( int ukmztfz = 0 ; ukmztfz < n ; ukmztfz ++ ) { arr [ ukmztfz ] = ipar ( ) ; } return arr ; } public long lpar ( ) { return Long . parseLong ( tok . nextToken ( ) ) ; } public long [ ] lapar ( int n ) { long [ ] arr = new long [ n ] ; for ( int ukmztfz = 0 ; ukmztfz < n ; ukmztfz ++ ) { arr [ ukmztfz ] = lpar ( ) ; } return arr ; } public double dpar ( ) { return Double . parseDouble ( tok . nextToken ( ) ) ; } public String spar ( ) { return tok . nextToken ( ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) . go ( ) ; } } import java . util . Scanner ; class Hnjfrd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double hnjfrd = scanner . nextDouble ( ) ; System . out . println ( String . format ( " %.5f " , Math . pow ( hnjfrd , ( double ) 2 ) * Math . PI ) + " " + String . format ( " %.5f " , hnjfrd * ( double ) 2 * Math . PI ) ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; public class Iuejknm { static class Iuejknm { 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 ; } } public static void main ( String [ ] args ) { FastReader ob = new FastReader ( ) ; int iuejknm = ob . nextInt ( ) ; HashMap < String , Integer > map = new HashMap < > ( ) ; int count = 0 ; for ( int i = 0 ; i < iuejknm ; i ++ ) { String s1 = ob . next ( ) ; if ( ! map . containsKey ( s1 ) ) { map . put ( s1 , 0 ) ; count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Qrzimhv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double qrzimhv = sc . nextDouble ( ) ; double odd = 0 ; double notOdd = 0 ; for ( int i = 1 ; i <= qrzimhv ; i ++ ) { if ( i % 2 == 0 ) { notOdd ++ ; } else { odd ++ ; } } System . out . println ( odd / qrzimhv ) ; } } import java . util . Scanner ; public class Hsntsa { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int hsntsa = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int total = 0 ; for ( int i = hsntsa ; i <= B ; i ++ ) { String s = String . valueOf ( i ) ; StringBuffer sb = new StringBuffer ( s ) ; String r = new String ( sb . reverse ( ) ) ; if ( s . equals ( r ) ) { total ++ ; } } System . out . println ( total ) ; } } import java . util . * ; public class Qfnido { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int qfnido = scanner . nextInt ( ) ; int X = scanner . nextInt ( ) ; int s = X - ( qfnido - 1 ) ; int e = X + ( qfnido - 1 ) ; for ( int i = s ; i <= e ; i ++ ) { System . out . println ( i ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Hithvst { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] lines = br . readLine ( ) . split ( " " ) ; int hithvst = Integer . parseInt ( lines [ 0 ] ) ; int m = Integer . parseInt ( lines [ 1 ] ) ; int [ ] rowSum = new int [ m ] ; for ( int i = 0 ; i < hithvst ; i ++ ) { lines = br . readLine ( ) . split ( " " ) ; int columnSum = 0 ; for ( int j = 0 ; j < m ; j ++ ) { int e = Integer . parseInt ( lines [ j ] ) ; columnSum += e ; rowSum [ j ] += e ; System . out . print ( e + " " ) ; } System . out . println ( columnSum ) ; } int totalSum = 0 ; for ( int i = 0 ; i < m ; i ++ ) { totalSum += rowSum [ i ] ; System . out . print ( rowSum [ i ] + " " ) ; } System . out . println ( totalSum ) ; } } import java . util . * ; public class Wwuxip { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long wwuxip = sc . nextLong ( ) ; long H = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; double ans = ( wwuxip * H ) / 2.0 ; int can = 0 ; if ( x * 2 == wwuxip && y * 2 == H ) { can = 1 ; } System . out . println ( ans + " " + can ) ; } } import java . util . Scanner ; public class Wgpnvc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long wgpnvc = scan . nextInt ( ) ; long B = scan . nextInt ( ) ; long gcd = GCD ( wgpnvc , B ) ; long lcm = LCM ( wgpnvc , B , gcd ) ; System . out . println ( lcm ) ; } public static long GCD ( long a , long b ) { for ( long i = a ; i > 0 ; i -- ) { if ( a % i == 0 && b % i == 0 ) { return i ; } } return 1 ; } public static long LCM ( long a , long b , long gcd ) { return a * b / gcd ; } } import java . io . * ; public class Gsurvyx { final static long gsurvyx = 1000000007 ; public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = in . readLine ( ) ; int N = Integer . parseInt ( W ) ; W = in . readLine ( ) ; String [ ] Ws = W . split ( " " ) ; long [ ] A = new long [ Ws . length ] ; for ( int i = 0 ; i < Ws . length ; i ++ ) { A [ i ] = Long . parseLong ( Ws [ i ] ) ; } String ans = " APPROVED " ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] % 2 == 0 && ! ( A [ i ] % 3 == 0 || A [ i ] % 5 == 0 ) ) { ans = " DENIED " ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Zewnipt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zewnipt = sc . nextInt ( ) ; Integer [ ] ans = new Integer [ zewnipt ] ; for ( int n = 0 ; n < zewnipt ; n ++ ) { ans [ n ] = sc . nextInt ( ) ; } sc . close ( ) ; int sunuke = 0 ; for ( int an = 0 ; an < ans . length ; an ++ ) { if ( ans [ an ] == sunuke + 1 ) { sunuke ++ ; } } if ( sunuke == 0 ) { System . out . println ( " -1 " ) ; } else { System . out . println ( zewnipt - sunuke ) ; } } } import java . util . Scanner ; public class Ntlden { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ntlden = Integer . parseInt ( sc . next ( ) ) ; int [ ] ans = new int [ ntlden ] ; for ( int i = 0 ; i < ntlden ; i ++ ) { int tmp = Integer . parseInt ( sc . next ( ) ) ; ans [ tmp - 1 ] = i + 1 ; } for ( int i : ans ) { System . out . println ( i ) ; } } } import java . util . Scanner ; class Lnoiy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; sc . close ( ) ; String [ ] S = s . split ( " " ) ; int lnoiy = Integer . parseInt ( S [ 0 ] ) ; int b = Integer . parseInt ( S [ 1 ] ) ; int count = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( lnoiy > b ) { count += lnoiy ; lnoiy -- ; } else { count += b ; b -- ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Cibpqim { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cibpqim = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] [ ] matrix = new int [ cibpqim ] [ c ] ; for ( int i = 0 ; i < cibpqim ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { matrix [ i ] [ j ] = sc . nextInt ( ) ; } } int rc_sum = 0 ; for ( int i = 0 ; i < cibpqim ; i ++ ) { int c_sum = 0 ; for ( int j = 0 ; j < c ; j ++ ) { System . out . print ( matrix [ i ] [ j ] + " " ) ; c_sum += matrix [ i ] [ j ] ; if ( i != 0 ) matrix [ i ] [ j ] += matrix [ i - 1 ] [ j ] ; } System . out . println ( c_sum ) ; rc_sum += c_sum ; } for ( int j = 0 ; j < c ; j ++ ) { System . out . print ( matrix [ cibpqim - 1 ] [ j ] + " " ) ; } System . out . println ( rc_sum ) ; } } import java . util . Scanner ; import java . util . regex . * ; class Ckofasc { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) . useDelimiter ( " [ \t , \n ] " ) ; int ckofasc = stdin . nextInt ( ) ; int line = stdin . nextInt ( ) ; int [ ] nums = new int [ ckofasc + 1 ] ; for ( int i = 1 ; i <= ckofasc ; i ++ ) { nums [ i ] = i ; } stdin . nextLine ( ) ; for ( int i = 0 ; i < line ; i ++ ) { int sw1 = stdin . nextInt ( ) ; int sw2 = stdin . nextInt ( ) ; int temp = nums [ sw1 ] ; nums [ sw1 ] = nums [ sw2 ] ; nums [ sw2 ] = temp ; } for ( int i = 1 ; i <= ckofasc ; i ++ ) { System . out . println ( nums [ i ] ) ; } } } import java . util . Scanner ; public class Nvckkw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] [ ] BigHouse = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int nvckkw = 0 ; nvckkw < 4 ; nvckkw ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { BigHouse [ nvckkw ] [ j ] [ k ] = 0 ; } } } int order = sc . nextInt ( ) ; for ( int nvckkw = 0 ; nvckkw < order ; nvckkw ++ ) { int b = sc . nextInt ( ) - 1 ; int f = sc . nextInt ( ) - 1 ; int r = sc . nextInt ( ) - 1 ; int v = sc . nextInt ( ) ; BigHouse [ b ] [ f ] [ r ] += v ; if ( BigHouse [ b ] [ f ] [ r ] < 0 ) { BigHouse [ b ] [ f ] [ r ] = 0 ; } } for ( int nvckkw = 0 ; nvckkw < 4 ; nvckkw ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { System . out . print ( " " + BigHouse [ nvckkw ] [ j ] [ k ] ) ; } System . out . println ( ) ; } if ( nvckkw != 3 ) { System . out . println ( " #################### " ) ; } } } } import java . util . * ; public class Hpjoln { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long hpjoln = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = a + b ; long p = hpjoln / c ; long q = hpjoln % c ; if ( q > a ) { q = a ; } long ans = a * p + q ; System . out . println ( ans ) ; } } import java . util . Scanner ; class Fyaarc { public void cubic ( ) { Scanner sc = new Scanner ( System . in ) ; int fyaarc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; String out = " No " ; if ( fyaarc < b ) { if ( b < c ) { out = " Yes " ; } } System . out . println ( out ) ; } public static void main ( String [ ] args ) { new Main ( ) . cubic ( ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Jkelfs { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String input = scanner . nextLine ( ) ; Iroha solver = new Iroha ( ) ; System . out . println ( solver . anotherSolve ( input ) ) ; } static class Jkelfs { public String anotherSolve ( String input ) { List < Integer > inputList = new ArrayList < Integer > ( ) ; int jkelfs = 0 ; int seven = 0 ; for ( String s : input . split ( " " ) ) { if ( Integer . parseInt ( s ) == 5 ) { jkelfs ++ ; } else if ( Integer . parseInt ( s ) == 7 ) { seven ++ ; } } if ( jkelfs == 2 && seven == 1 ) { return " YES " ; } else { return " NO " ; } } } } import java . util . Scanner ; public class Fnejite { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; char [ ] ca = str . toCharArray ( ) ; for ( int fnejite = 0 ; fnejite < ca . length ; fnejite ++ ) { System . out . print ( ca [ ca . length - 1 - fnejite ] ) ; } System . out . println ( ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class Zzrcii { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int zzrcii = sc . nextInt ( ) ; int [ ] d = nextIntArray ( sc , zzrcii ) ; sc . close ( ) ; int ans = 0 ; for ( int i = 0 ; i < zzrcii - 1 ; i ++ ) { for ( int j = i + 1 ; j < zzrcii ; j ++ ) { ans += d [ i ] * d [ j ] ; } } out . println ( ans ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } @ SuppressWarnings ( " unused " ) private int [ ] nextIntArray ( Scanner sc , int n ) { int [ ] result = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { result [ i ] = sc . nextInt ( ) ; } return result ; } } import java . util . Scanner ; public class Bxsqz { public static void main ( String [ ] args ) { Scanner In = new Scanner ( System . in ) ; int bxsqz ; do { bxsqz = In . nextInt ( ) ; } while ( bxsqz <= 2 && bxsqz >= 200000 ) ; int [ ] a = new int [ bxsqz ] ; for ( int i = 0 ; i < bxsqz ; i ++ ) { do { a [ i ] = In . nextInt ( ) ; } while ( 1 >= a [ i ] && a [ i ] >= Math . pow ( 10 , 9 ) ) ; } int minv = a [ 0 ] ; int maxv = a [ 1 ] - a [ 0 ] ; for ( int j = 1 ; j <= bxsqz - 1 ; j ++ ) { maxv = maxv > ( a [ j ] - minv ) ? maxv : ( a [ j ] - minv ) ; minv = minv < a [ j ] ? minv : a [ j ] ; } System . out . println ( maxv ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Xenmky { public static void main ( String [ ] args ) { int xenmky = 0 ; Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; scanner . close ( ) ; String [ ] str = s . split ( " " , 0 ) ; int [ ] input = new int [ str . length ] ; for ( int i = 0 ; i < str . length ; i ++ ) { input [ i ] = Integer . parseInt ( str [ i ] ) ; } Arrays . sort ( input ) ; for ( int i = 0 ; i < input . length - 1 ; i ++ ) { xenmky += input [ i + 1 ] - input [ i ] ; } System . out . println ( xenmky ) ; } } import java . util . * ; public class Kesmhcv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kesmhcv = sc . nextInt ( ) ; int [ ] array = new int [ kesmhcv ] ; long count = 0 ; for ( int i = 0 ; i < kesmhcv ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < ( kesmhcv - 1 ) ; i ++ ) { int temp = array [ i ] ; int next = array [ i + 1 ] ; if ( next < temp ) { count += ( temp - next ) ; array [ i + 1 ] = temp ; } } System . out . println ( count ) ; } } import java . util . * ; import java . util . stream . Collectors ; class Njehxyv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int njehxyv = sc . nextInt ( ) ; int otoshidama = sc . nextInt ( ) ; int x = - 1 ; int y = - 1 ; int z = - 1 ; boolean isFinish = false ; for ( int i = 0 ; i <= njehxyv ; i ++ ) { for ( int j = 0 ; j <= njehxyv ; j ++ ) { if ( njehxyv - i - j >= 0 && i + j + ( njehxyv - i - j ) == njehxyv ) { if ( i * 10000 + j * 5000 + ( njehxyv - i - j ) * 1000 == otoshidama ) { x = i ; y = j ; z = njehxyv - i - j ; isFinish = true ; break ; } else if ( njehxyv - i - j < 0 ) { break ; } } } if ( isFinish ) { break ; } } System . out . println ( x + " " + y + " " + z ) ; } } import java . util . Scanner ; public class Dydygl { private static final String dydygl = " Sunny " ; private static final String CLOUDY = " Cloudy " ; private static final String RAINY = " Rainy " ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String r = null ; switch ( s ) { case dydygl : r = CLOUDY ; break ; case CLOUDY : r = RAINY ; break ; case RAINY : r = dydygl ; break ; default : break ; } System . out . println ( r ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Fynegks { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fynegks = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; if ( fynegks != 1 && Y != 1 ) System . out . println ( 1 ) ; else if ( fynegks != 2 && Y != 2 ) System . out . println ( 2 ) ; else System . out . println ( 3 ) ; } } import java . util . Scanner ; public class Sgefy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String sgefy = sc . next ( ) ; char [ ] c = sgefy . toCharArray ( ) ; System . out . println ( ( char ) ( c [ 0 ] + 0x01 ) ) ; sc . close ( ) ; } } import java . math . BigInteger ; import java . util . Scanner ; public class Zxgwbel { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String zxgwbel = scan . nextLine ( ) ; scan . close ( ) ; String [ ] substr = zxgwbel . split ( " " , 0 ) ; BigInteger n = new BigInteger ( substr [ 0 ] ) ; BigInteger a = new BigInteger ( substr [ 1 ] ) ; BigInteger b = new BigInteger ( substr [ 2 ] ) ; BigInteger c = a . add ( b ) ; BigInteger m = n . mod ( c ) ; BigInteger s = n . divide ( c ) ; BigInteger buf = BigInteger . ZERO ; if ( a != BigInteger . ZERO ) { if ( m . compareTo ( a ) >= 0 ) buf = a ; if ( m . compareTo ( a ) < 0 ) buf = m ; } System . out . println ( a . multiply ( s ) . add ( buf ) ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Zizwie { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zizwie = sc . nextInt ( ) ; int [ ] p = new int [ zizwie ] ; for ( int i = 0 ; i < zizwie ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int min = zizwie + 1 ; int ans = 0 ; for ( int i = 0 ; i < zizwie ; i ++ ) { if ( p [ i ] < min ) { min = p [ i ] ; ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Vxzqmua { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vxzqmua = sc . nextInt ( ) ; double Ad = ( double ) vxzqmua ; int B = sc . nextInt ( ) ; double Bd = ( double ) B ; int H = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; sc . close ( ) ; double arg , C ; arg = ( double ) H * 30.0 + ( double ) M * 0.5 - ( double ) M * 6.0 ; C = Math . sqrt ( Ad * Ad + Bd * Bd - 2.0 * Ad * Bd * Math . cos ( Math . toRadians ( arg ) ) ) ; System . out . println ( C ) ; } } import java . util . * ; public class Qwviu { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int qwviu = Integer . parseInt ( sc . next ( ) ) ; final int K = Integer . parseInt ( sc . next ( ) ) ; int result = 0 ; int [ ] pricelist = new int [ qwviu ] ; for ( int i = 0 ; i < qwviu ; i ++ ) { pricelist [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; Arrays . sort ( pricelist ) ; for ( int i = 0 ; i < K ; i ++ ) { result = result + pricelist [ i ] ; } System . out . println ( result ) ; } } import java . util . * ; public class Rdsryjh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; int rdsryjh = 0 ; for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = j + 1 ; k < S . length ( ) ; k ++ ) { if ( S . charAt ( j ) == S . charAt ( k ) ) { rdsryjh ++ ; } } } if ( rdsryjh == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Nnahtme { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int nnahtme = in . nextInt ( ) ; int M = in . nextInt ( ) ; long sum = 0 ; sum = 1 ; sum *= nnahtme ; sum *= ( nnahtme - 1 ) ; sum /= 2 ; int sumM = 1 ; sumM *= ( M - 1 ) ; sumM *= M ; sumM /= 2 ; System . out . println ( sum + sumM ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Cyptmnh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cyptmnh = scan . nextInt ( ) ; int price = scan . nextInt ( ) ; if ( cyptmnh >= 13 ) { System . out . println ( price ) ; } else if ( cyptmnh >= 6 ) { System . out . println ( price / 2 ) ; } else { System . out . println ( 0 ) ; } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Xlddz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xlddz = scan . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < xlddz ; i ++ ) { int x = scan . nextInt ( ) ; if ( x % 2 == 0 ) { cnt ++ ; if ( x % 3 == 0 || x % 5 == 0 ) { cnt -- ; } } } if ( cnt == 0 ) { System . out . println ( " APPROVED " ) ; } else { System . out . println ( " DENIED " ) ; } } } import java . util . * ; public class Dbtcu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dbtcu = sc . nextInt ( ) ; sc . close ( ) ; boolean can = false ; for ( int i = 0 ; i < 25 ; ++ i ) { for ( int j = 0 ; j < 25 ; ++ j ) { if ( dbtcu == 4 * i + 7 * j ) { can = true ; } } } if ( can == true ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . Scanner ; class Juhuzms { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int [ ] anntena = new int [ 5 ] ; anntena [ 0 ] = scn . nextInt ( ) ; anntena [ 1 ] = scn . nextInt ( ) ; anntena [ 2 ] = scn . nextInt ( ) ; anntena [ 3 ] = scn . nextInt ( ) ; anntena [ 4 ] = scn . nextInt ( ) ; int juhuzms = scn . nextInt ( ) ; if ( anntena [ 4 ] - anntena [ 0 ] > juhuzms ) { System . out . println ( " :( " ) ; } else { System . out . println ( " Yay! " ) ; } } } import java . util . Scanner ; public class Cjqbr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str , str2 ; while ( true ) { str = sc . next ( ) ; if ( str . equals ( " - " ) ) break ; str2 = " " ; int cjqbr = sc . nextInt ( ) ; for ( int i = 0 ; i < cjqbr ; i ++ ) { int n = sc . nextInt ( ) ; for ( int j = n ; j < str . length ( ) ; j ++ ) { str2 += str . charAt ( j ) ; } for ( int j = 0 ; j < n ; j ++ ) { str2 += str . charAt ( j ) ; } str = str2 ; str2 = " " ; } System . out . println ( str ) ; } } } import java . util . * ; class Xmuzdb { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; double xmuzdb = reader . nextDouble ( ) ; System . out . println ( 2 * xmuzdb * 3.14159265 ) ; } } import java . util . Scanner ; import java . lang . Math ; public class Rohxs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rohxs ; double [ ] ans = new double [ 1000 ] ; int k = 0 ; while ( true ) { rohxs = scan . nextInt ( ) ; if ( rohxs == 0 ) break ; int [ ] a = new int [ rohxs ] ; int sum = 0 ; for ( int i = 0 ; i < rohxs ; i ++ ) { a [ i ] = scan . nextInt ( ) ; sum += a [ i ] ; } double ave = ( double ) sum / rohxs ; double var = 0 ; for ( int i = 0 ; i < rohxs ; i ++ ) { var = var + ( ( a [ i ] - ave ) * ( a [ i ] - ave ) / rohxs ) ; } ans [ k ] = Math . sqrt ( var ) ; k ++ ; } for ( int i = 0 ; i < k ; i ++ ) { System . out . printf ( " %.5f \n " , ans [ i ] ) ; } } } import java . util . Scanner ; public class Xyjpuy { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int xyjpuy = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; String s = sc . next ( ) ; String tmp = null ; switch ( s . substring ( k - 1 , k ) ) { case " A " : tmp = " a " ; break ; case " B " : tmp = " b " ; break ; case " C " : tmp = " c " ; break ; } System . out . println ( s . substring ( 0 , k - 1 ) + tmp + s . substring ( k ) ) ; } } } import java . util . Scanner ; public class Inmdkq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int inmdkq , h , x , y , r ; inmdkq = sc . nextInt ( ) ; h = sc . nextInt ( ) ; x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; r = sc . nextInt ( ) ; if ( x + r > inmdkq || y + r > h || x - r < 0 || y - r < 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; class Batxudq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String batxudq = sc . nextLine ( ) ; batxudq = batxudq . replace ( " 2017/ " , " 2018/ " ) ; System . out . println ( batxudq ) ; } } import java . util . Scanner ; public class Globv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int globv = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sc . close ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= globv ; i ++ ) { int cnt = 0 ; double p = i ; while ( p < K ) { cnt ++ ; p *= 2.0 ; } ans += 1.0 / globv * Math . pow ( 0.5 , cnt ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class Scgejz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int scgejz = sc . nextInt ( ) , x = 0 ; Map < String , Integer > map = new LinkedHashMap < > ( ) ; String [ ] items = { " AC " , " WA " , " TLE " , " RE " } ; for ( String s : items ) map . put ( s , 0 ) ; for ( int i = 0 ; i < scgejz ; i ++ ) { String ans = sc . next ( ) ; map . put ( ans , map . get ( ans ) + 1 ) ; } for ( int n : map . values ( ) ) System . out . println ( items [ x ++ ] + " x " + n ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . PriorityQueue ; import java . util . Scanner ; public class Tvzwb { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int tvzwb = in . nextInt ( ) ; int r = solve ( tvzwb ) ; System . out . println ( r ) ; } private static int solve ( int tvzwb ) { if ( tvzwb == 2 ) return 2 ; int [ ] s = new int [ 10000 ] ; int sm = 1 ; s [ 0 ] = 2 ; for ( int i = 3 ; ; i ++ ) { int j = 0 ; while ( j < sm ) { if ( i % s [ j ] == 0 ) break ; j ++ ; } if ( j == sm ) { s [ sm ] = i ; sm ++ ; if ( i >= tvzwb ) return i ; } } } } import java . util . Scanner ; public class Xsjvpgr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; long xsjvpgr = sc . nextLong ( ) ; if ( S . length ( ) == 1 ) { System . out . println ( S ) ; return ; } int i = 0 ; while ( i < S . length ( ) && S . charAt ( i ) == '1' ) { i ++ ; } if ( xsjvpgr <= i ) { System . out . println ( 1 ) ; return ; } System . out . print ( S . charAt ( i ) ) ; } } import java . util . * ; public class Fldchn { static void swap ( int [ ] A , int i , int j ) { int fldchn = A [ i ] ; A [ i ] = A [ j ] ; A [ j ] = fldchn ; } static int selectionSort ( int [ ] A , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int minj = i ; for ( int j = i ; j < N ; j ++ ) { if ( A [ j ] < A [ minj ] ) minj = j ; } if ( i != minj ) { swap ( A , i , minj ) ; count ++ ; } } return count ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; int c = selectionSort ( a , n ) ; System . out . print ( a [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) System . out . print ( " " + a [ i ] ) ; System . out . println ( ) ; System . out . println ( c ) ; } } import java . util . * ; public class Ygdgkq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] str = sc . nextLine ( ) . split ( " " ) ; String p = sc . nextLine ( ) ; for ( int ygdgkq = 0 ; ygdgkq < str . length ; ygdgkq ++ ) { sb . setLength ( 0 ) ; for ( int j = ygdgkq ; j < ygdgkq + str . length ; j ++ ) { int a = j ; if ( a >= str . length ) { a -= str . length ; } sb . append ( str [ a ] ) ; } String s = sb . toString ( ) ; if ( s . contains ( p ) ) { System . out . println ( " Yes " ) ; break ; } else if ( ygdgkq == str . length - 1 ) { System . out . println ( " No " ) ; } } } } import java . util . * ; public class Lqmoet { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; String r = " " ; for ( char lqmoet : n . toCharArray ( ) ) { r += solve ( lqmoet ) ; } System . out . print ( r ) ; } static char solve ( char lqmoet ) { switch ( lqmoet ) { case '1' : return '9' ; case '9' : return '1' ; default : return lqmoet ; } } } import java . util . Scanner ; public class Tdtdr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tdtdr = sc . nextInt ( ) ; boolean flg = false ; int cnt = 0 ; for ( int i = 0 ; i < tdtdr ; i ++ ) { sc . nextLine ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a == b ) { cnt ++ ; if ( cnt == 3 ) { flg = true ; } } else { cnt = 0 ; } } String ans = flg ? " Yes " : " No " ; System . out . println ( ans ) ; } } import java . util . * ; class Muezi { Scanner sc ; void calc ( ) { sc = new Scanner ( System . in ) ; String muezi = sc . next ( ) ; if ( muezi . charAt ( 2 ) == muezi . charAt ( 3 ) && muezi . charAt ( 4 ) == muezi . charAt ( 5 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . * ; public class Otsaofv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int otsaofv = Integer . parseInt ( sc . next ( ) ) ; int l = Integer . parseInt ( sc . next ( ) ) ; int [ ] x = new int [ otsaofv + 1 ] ; x [ 0 ] = 0 ; for ( int i = 1 ; i < otsaofv + 1 ; i ++ ) { x [ i ] = x [ i - 1 ] + Integer . parseInt ( sc . next ( ) ) ; } int ans = 0 ; for ( int i = 0 ; i < otsaofv + 1 ; i ++ ) { if ( x [ i ] > l ) { ans = i ; break ; } if ( i == otsaofv ) { ans = i + 1 ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Xsjyrqb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; if ( sc . nextInt ( ) <= sc . nextInt ( ) * sc . nextInt ( ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . lang . Math . * ; import java . util . * ; import java . math . * ; import java . text . * ; public class Choadjv { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; NumberFormat nf = NumberFormat . getInstance ( ) ; nf . setMaximumFractionDigits ( 8 ) ; nf . setGroupingUsed ( false ) ; while ( true ) { int choadjv = Integer . parseInt ( br . readLine ( ) ) ; if ( choadjv == 0 ) break ; String [ ] line = br . readLine ( ) . split ( " " ) ; double [ ] points = new double [ choadjv ] ; for ( int i = 0 ; i < choadjv ; i ++ ) points [ i ] = Double . parseDouble ( line [ i ] ) ; double sample = 0 ; double ave_d = ave ( points ) ; double ans = 0 ; for ( int i = 0 ; i < points . length ; i ++ ) sample += ( Math . pow ( ( points [ i ] - ave_d ) , 2 ) ) ; ans = Math . sqrt ( sample / points . length ) ; System . out . println ( nf . format ( ans ) ) ; } } static double sum ( double [ ] tag ) { double sum = 0 ; for ( int i = 0 ; i < tag . length ; i ++ ) sum += tag [ i ] ; return sum ; } static double ave ( double [ ] tag ) { return sum ( tag ) / tag . length ; } } import java . util . Scanner ; public class Yucdea { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] str = sc . next ( ) . toCharArray ( ) ; int yucdea = 0 ; int tmpCount = 0 ; for ( int i = 0 ; i < str . length ; i ++ ) { if ( ( i % 2 == 0 && str [ i ] == '0' ) || ( i % 2 == 1 && str [ i ] == '1' ) ) { yucdea ++ ; } } for ( int i = 0 ; i < str . length ; i ++ ) { if ( ( i % 2 == 1 && str [ i ] == '0' ) || ( i % 2 == 0 && str [ i ] == '1' ) ) { tmpCount ++ ; } } System . out . println ( Math . min ( yucdea , tmpCount ) ) ; } } import java . util . * ; public class Wdedxtx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wdedxtx = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int [ ] B = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } List < int [ ] > Ai = new ArrayList < > ( ) ; for ( int i = 0 ; i < wdedxtx ; i ++ ) { int [ ] A = new int [ M ] ; for ( int j = 0 ; j < M ; j ++ ) { A [ j ] = sc . nextInt ( ) ; } Ai . add ( A ) ; } int count = 0 ; for ( int i = 0 ; i < Ai . size ( ) ; i ++ ) { int [ ] A = Ai . get ( i ) ; int clear = C ; for ( int j = 0 ; j < M ; j ++ ) { clear += A [ j ] * B [ j ] ; } if ( 0 < clear ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class Mhohytm { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int mhohytm = sc . nextInt ( ) ; System . out . println ( solve ( mhohytm ) ) ; } public static int solve ( int mhohytm ) { int max = ( int ) Math . pow ( mhohytm , 0.5 ) + 1 ; int ret = 1 ; for ( int i = 2 ; i < max ; i ++ ) { int pow = 2 ; while ( Math . pow ( i , pow ) <= mhohytm ) { ret = Math . max ( ret , ( int ) Math . pow ( i , pow ) ) ; pow ++ ; } } return ret ; } } import java . util . * ; class Feiwv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long feiwv = sc . nextLong ( ) + sc . nextLong ( ) ; if ( feiwv % 2 == 1 ) System . out . println ( " IMPOSSIBLE " ) ; else System . out . println ( feiwv / 2 ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Wzpslo { static class Wzpslo { 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 wzpslo = " " ; try { wzpslo = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return wzpslo ; } } public static void main ( String [ ] args ) { FastReader obj = new FastReader ( ) ; String wzpslo = obj . next ( ) ; System . out . println ( ( wzpslo . compareTo ( " ABC " ) == 0 ) ? " ARC " : " ABC " ) ; } } import java . util . Scanner ; public class Ogdjin { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int ogdjin = sc . nextInt ( ) ; int taro = 0 , hanako = 0 ; for ( int i = 0 ; i < ogdjin ; i ++ ) { String a = sc . next ( ) ; String b = sc . next ( ) ; if ( a . compareTo ( b ) > 0 ) { taro += 3 ; } else if ( a . compareTo ( b ) < 0 ) { hanako += 3 ; } else { taro += 1 ; hanako += 1 ; } } System . out . println ( taro + " " + hanako ) ; } } } import java . util . * ; public class Ybybwvo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ybybwvo = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; String S = sc . next ( ) ; int [ ] count = new int [ ybybwvo ] ; Arrays . fill ( count , 0 ) ; for ( int i = 1 ; i < ybybwvo ; i ++ ) { if ( S . charAt ( i - 1 ) == 'A' && S . charAt ( i ) == 'C' ) { count [ i ] = count [ i - 1 ] + 1 ; } else { count [ i ] = count [ i - 1 ] ; } } for ( int i = 0 ; i < Q ; i ++ ) { int l = sc . nextInt ( ) - 1 ; int r = sc . nextInt ( ) - 1 ; System . out . println ( count [ r ] - count [ l ] ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Hhqhfit { public static void main ( String [ ] age ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int hhqhfit = 1 ; int j = 0 ; while ( true ) { String [ ] input = br . readLine ( ) . split ( " " ) ; int H = Integer . parseInt ( input [ 0 ] ) ; int W = Integer . parseInt ( input [ 1 ] ) ; if ( H == 0 && W == 0 ) break ; for ( hhqhfit = 1 ; hhqhfit <= H ; hhqhfit ++ ) { for ( j = 1 ; j <= W ; j ++ ) { if ( hhqhfit % 2 == 1 ) { if ( j % 2 == 1 ) { System . out . print ( " # " ) ; } else { System . out . print ( " . " ) ; } } else { if ( j % 2 == 1 ) { System . out . print ( " . " ) ; } else { System . out . print ( " # " ) ; } } } System . out . print ( " \n " ) ; } System . out . print ( " \n " ) ; } } } import java . util . Scanner ; public class Qptqdf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qptqdf = sc . nextInt ( ) ; int [ ] a = new int [ qptqdf ] ; for ( int i = 0 ; i < qptqdf ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int x = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { while ( a [ i ] % 2 == 0 ) { if ( a [ i ] % 2 == 0 ) { a [ i ] /= 2 ; x ++ ; } } } System . out . println ( x ) ; } } import java . util . Scanner ; public class Vrclu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vrclu = 0 , h = 0 ; int x = sc . nextInt ( ) ; for ( int i = 0 ; i < x ; i ++ ) { String str1 = sc . next ( ) ; String str2 = sc . next ( ) ; if ( str1 . compareTo ( str2 ) < 0 ) { h += 3 ; } else if ( str1 . compareTo ( str2 ) == 0 ) { vrclu ++ ; h ++ ; } else { vrclu += 3 ; } } System . out . println ( vrclu + " " + h ) ; } } import java . util . * ; class Tlljx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long tlljx = sc . nextLong ( ) ; long money = 100 ; int year = 0 ; while ( money < tlljx ) { money *= 1.01 ; year ++ ; } System . out . println ( year ) ; } } import java . util . * ; public class Hxhdd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hxhdd = sc . nextInt ( ) ; int [ ] values = new int [ hxhdd ] ; for ( int i = 0 ; i < hxhdd ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } int count = 0 ; hoge : while ( true ) { for ( int i = 0 ; i < hxhdd ; i ++ ) { if ( values [ i ] % 2 != 0 ) { break hoge ; } values [ i ] = values [ i ] / 2 ; } count ++ ; } System . out . println ( count ) ; } } import java . io . * ; class Ocvpztv { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int ocvpztv = Integer . parseInt ( br . readLine ( ) ) ; int i = 1 ; int x ; while ( true ) { x = i ; if ( x % 3 == 0 ) { System . out . print ( " " + i ) ; } else { while ( x != 0 ) { if ( x % 10 == 3 ) { System . out . print ( " " + i ) ; break ; } x /= 10 ; } } if ( ++ i > ocvpztv ) break ; } System . out . print ( " \n " ) ; } } import java . util . Scanner ; public class Cimpzpo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cimpzpo = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; double d = 0.0 ; int coin = 0 ; int calc = 0 ; for ( int i = 1 ; i <= cimpzpo ; i ++ ) { calc = i ; coin = 0 ; for ( ; calc < K ; coin ++ ) calc *= 2 ; d += ( 1.0 / cimpzpo ) * Math . pow ( ( 1.0 / 2 ) , coin ) ; } System . out . println ( d ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Qdwegcf { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int qdwegcf = 0 ; int sum = 0 ; String str = br . readLine ( ) ; StringTokenizer st = new StringTokenizer ( str , " " ) ; int a = Integer . parseInt ( st . nextToken ( ) ) ; int b = Integer . parseInt ( st . nextToken ( ) ) ; int c = Integer . parseInt ( st . nextToken ( ) ) ; for ( qdwegcf = a ; qdwegcf <= b ; qdwegcf ++ ) { if ( c % qdwegcf == 0 ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; class Bzzpyfa { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int bzzpyfa , b , c ; bzzpyfa = cin . nextInt ( ) ; b = cin . nextInt ( ) ; c = cin . nextInt ( ) ; int res = serch_divisor_number ( bzzpyfa , b , c ) ; System . out . println ( res ) ; } private static int serch_divisor_number ( int bzzpyfa , int b , int c ) { int m = 0 ; for ( int i = bzzpyfa ; i <= b ; i ++ ) { if ( c % i == 0 ) m ++ ; } return ( m ) ; } } import java . util . Scanner ; public class Isgtlv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; for ( int isgtlv = 0 ; isgtlv < s . length ( ) ; isgtlv ++ ) { if ( s . equals ( t ) ) { System . out . println ( " Yes " ) ; return ; } s = s . charAt ( s . length ( ) - 1 ) + s . substring ( 0 , s . length ( ) - 1 ) ; } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Pmkibt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pmkibt = sc . nextInt ( ) ; int num2 = sc . nextInt ( ) ; int tap = 0 ; int outlet = 1 ; while ( num2 > outlet ) { outlet += pmkibt - 1 ; tap ++ ; } System . out . println ( tap ) ; } } import java . util . * ; import java . lang . * ; public class Vgqcsh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vgqcsh = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= 3 ; i ++ ) { int b = ( int ) Math . pow ( vgqcsh , i ) ; sum = sum + b ; } System . out . println ( sum ) ; } } import java . util . * ; public class Cwukk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cwukk = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ cwukk + 1 ] ; for ( int i = 1 ; i <= cwukk ; i ++ ) h [ i ] = sc . nextInt ( ) ; int [ ] dp = new int [ cwukk + 1 ] ; dp [ 1 ] = 0 ; for ( int i = 2 ; i <= cwukk ; i ++ ) { dp [ i ] = 1000000000 ; for ( int j = i - 1 ; j >= 1 && ( i - j ) <= k ; j -- ) { dp [ i ] = Math . min ( dp [ i ] , dp [ j ] + Math . abs ( h [ i ] - h [ j ] ) ) ; } } System . out . println ( dp [ cwukk ] ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Tgsyalz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int tgsyalz = 0 ; int N = scanner . nextInt ( ) ; int X = scanner . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int m = scanner . nextInt ( ) ; list . add ( m ) ; X -= m ; } Collections . sort ( list ) ; int min = list . get ( 0 ) ; for ( int x = 0 ; x <= X / min ; x ++ ) { tgsyalz = x ; if ( min * x > X ) { break ; } } tgsyalz += N ; System . out . println ( tgsyalz ) ; } } import java . util . * ; public class Uvkwu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long uvkwu = sc . nextLong ( ) ; long checkx = 0 ; long x = 0 ; long checky = 0 ; long y = 0 ; for ( checkx = 1 ; checkx <= Math . sqrt ( uvkwu ) ; checkx ++ ) { if ( uvkwu % checkx == 0 ) { checky = uvkwu / checkx ; if ( x == 0 && y == 0 ) { x = checkx ; y = checky ; } if ( checkx + checky < x + y ) { x = checkx ; y = checky ; } } } System . out . println ( x + y - 2 ) ; } } import java . util . Scanner ; public class Hksqh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hksqh = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] an = sc . nextLine ( ) . split ( " " ) ; long molec = 0L ; for ( String elm : an ) { int i = Integer . parseInt ( elm ) ; if ( molec == 0L ) { molec = gcd ( i , i ) ; } else { molec = gcd ( i , molec ) ; } } long denom = 0L ; for ( String elm : an ) { int i = Integer . parseInt ( elm ) ; long times = molec / i ; denom += times ; } System . err . println ( molec + " / " + denom ) ; double ans = ( double ) molec / ( double ) denom ; System . out . println ( ans ) ; } private static long gcd ( long a , long b ) { long tmp ; long c = a ; c *= b ; while ( ( tmp = a % b ) != 0 ) { a = b ; b = tmp ; } return c / b ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Gyrwmj { public static void main ( String [ ] args ) throws IOException { BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Integer nInteger = Integer . parseInt ( bufferedReader . readLine ( ) ) ; String string = bufferedReader . readLine ( ) ; String [ ] str = string . split ( " " ) ; for ( int gyrwmj = str . length - 1 ; gyrwmj >= 0 ; gyrwmj -- ) { if ( gyrwmj != 0 ) { System . out . print ( str [ gyrwmj ] + " " ) ; } else { System . out . print ( str [ gyrwmj ] ) ; } } System . out . println ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ouame { public static void main ( String [ ] a ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; char [ ] data = str . toCharArray ( ) ; char ouame ; for ( int i = 0 ; i < data . length / 2 ; i ++ ) { ouame = data [ i ] ; data [ i ] = data [ data . length - 1 - i ] ; data [ data . length - 1 - i ] = ouame ; } System . out . println ( data ) ; } } import java . io . * ; public class Kifwy { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int kifwy = Integer . parseInt ( br . readLine ( ) ) ; if ( kifwy == 0 ) System . out . println ( " 1 " ) ; else System . out . println ( " 0 " ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; public class Pipec { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int pipec = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int T = scan . nextInt ( ) ; int i = 0 , count = 0 ; ; while ( i + pipec <= ( T + 0.5 ) ) { count ++ ; i += pipec ; } System . out . println ( B * count ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Orooupq { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int orooupq = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 1 ] ) ; int c = Integer . parseInt ( str [ 2 ] ) ; int d = Integer . parseInt ( str [ 3 ] ) ; int x = ( orooupq + d - 1 ) / d ; int y = ( c + b - 1 ) / b ; System . out . println ( x >= y ? " Yes " : " No " ) ; } } import java . util . * ; public class Rcwsa { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; double rcwsa = scn . nextDouble ( ) ; double h = scn . nextDouble ( ) ; double x = scn . nextDouble ( ) ; double y = scn . nextDouble ( ) ; double ans = rcwsa * h / 2 ; int check = 0 ; if ( x == rcwsa / 2 && y == h / 2 ) check = 1 ; System . out . println ( ans + " " + check ) ; } } import java . util . * ; public class Xghvkaq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xghvkaq = sc . nextInt ( ) ; boolean b = false ; for ( int i = 1 ; i < 10 ; i ++ ) { for ( int j = i ; j < 10 ; j ++ ) { if ( i * j == xghvkaq ) { b = true ; } } } if ( b ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Gdqndr { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int gdqndr = sc . nextInt ( ) ; int [ ] A = new int [ gdqndr ] ; for ( int i = 0 ; i < gdqndr - 1 ; i ++ ) { A [ sc . nextInt ( ) - 1 ] ++ ; } for ( int a : A ) { System . out . println ( a ) ; } sc . close ( ) ; } } import java . awt . Point ; import java . util . ArrayDeque ; import java . util . Scanner ; import java . util . * ; import java . util . Arrays ; import java . util . ArrayList ; import java . util . Set ; import java . util . HashSet ; import java . util . Collection ; public class Uvwsx { static final Scanner sc = new Scanner ( System . in ) ; static int uvwsx = sc . nextInt ( ) ; static long [ ] a = new long [ uvwsx ] ; public static void main ( String [ ] args ) { int sum = 0 ; for ( int i = 0 ; i < uvwsx ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long x = 0 ; for ( int i = 0 ; i < uvwsx ; i ++ ) { x = a [ i ] ; for ( ; ; ) { if ( x % 2 == 0 ) { sum ++ ; x = x / 2 ; } else { break ; } } } System . out . println ( sum ) ; } } import java . io . * ; import java . math . * ; import java . util . * ; public class Ergjtsq { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int ergjtsq = input . nextInt ( ) ; ergjtsq %= 10 ; String ans = " " ; if ( ergjtsq == 3 ) ans = " bon " ; else if ( ergjtsq == 0 || ergjtsq == 1 || ergjtsq == 6 || ergjtsq == 8 ) ans = " pon " ; else ans = " hon " ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class Kmbant { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; String answer = " " ; String input = scan . next ( ) ; int kmbant = input . length ( ) ; for ( int i = 0 ; i < kmbant ; i ++ ) { switch ( input . charAt ( 0 ) ) { case '0' : if ( input . length ( ) > 0 ) { input = input . substring ( 1 ) ; } answer = answer . concat ( " 0 " ) ; break ; case '1' : if ( input . length ( ) > 0 ) { input = input . substring ( 1 ) ; } answer = answer . concat ( " 1 " ) ; break ; case 'B' : input = input . substring ( 1 ) ; if ( answer . length ( ) > 0 ) { answer = answer . substring ( 0 , answer . length ( ) - 1 ) ; } break ; } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class Vmsbmb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vmsbmb = sc . nextInt ( ) ; int intB = sc . nextInt ( ) ; double dbF ; dbF = ( double ) vmsbmb / ( double ) intB ; String f2 = String . format ( " %.5f " , dbF ) ; System . out . println ( vmsbmb / intB + " " + vmsbmb % intB + " " + f2 ) ; } } import java . util . Scanner ; public class Bztkqs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bztkqs = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; sc . close ( ) ; if ( S . substring ( 0 , bztkqs / 2 ) . equals ( S . substring ( bztkqs / 2 , bztkqs ) ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Oybsn { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( true ) { int oybsn = in . nextInt ( ) ; int term_end = in . nextInt ( ) ; int retest = in . nextInt ( ) ; int sum = oybsn + term_end ; if ( oybsn == - 1 && term_end == - 1 && retest == - 1 ) { break ; } else if ( oybsn == - 1 || term_end == - 1 ) { System . out . println ( " F " ) ; } else if ( sum >= 80 ) { System . out . println ( " A " ) ; } else if ( sum < 80 && sum >= 65 ) { System . out . println ( " B " ) ; } else if ( sum < 65 && sum >= 50 ) { System . out . println ( " C " ) ; } else if ( sum < 50 && sum >= 30 ) { if ( retest >= 50 ) { System . out . println ( " C " ) ; } else { System . out . println ( " D " ) ; } } else if ( sum < 30 ) { System . out . println ( " F " ) ; } } } } import java . util . * ; public class Eukkwtd { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int eukkwtd = 0 ; int min = 0 ; int max = 0 ; min = scan . nextInt ( ) ; scan . nextInt ( ) ; scan . nextInt ( ) ; scan . nextInt ( ) ; max = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; if ( ( max - min ) > k ) { System . out . println ( " :( " ) ; } else { System . out . println ( " Yay! " ) ; } } } import java . util . Scanner ; public class Ysfgj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String a = " " ; String okikae = " " ; for ( int ysfgj = 0 ; ysfgj < s . length ( ) ; ysfgj ++ ) { okikae = s . substring ( ysfgj , ysfgj + 1 ) ; okikae = " x " ; a = a + okikae ; } System . out . println ( a ) ; scan . close ( ) ; } } import java . util . * ; public class Irnyq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int irnyq = sc . nextInt ( ) ; HashMap < String , Integer > map = new HashMap < String , Integer > ( ) ; long ans = 0 ; for ( int i = 0 ; i < irnyq ; i ++ ) { String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; Arrays . sort ( c ) ; String s2 = new String ( c ) ; if ( map . containsKey ( s2 ) ) { ans += ( long ) map . get ( s2 ) ; map . put ( s2 , map . get ( s2 ) + 1 ) ; } else { map . put ( s2 , 1 ) ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Yelpxoz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yelpxoz = sc . nextInt ( ) ; Set < Integer > set = new HashSet < > ( ) ; int past = yelpxoz ; set . add ( past ) ; for ( int i = 2 ; i <= 1000000 ; i ++ ) { int cur ; if ( past % 2 == 0 ) { cur = past / 2 ; } else { cur = 3 * past + 1 ; } if ( set . contains ( cur ) ) { System . out . println ( i ) ; return ; } set . add ( cur ) ; past = cur ; } } } import java . util . Scanner ; class Pzdkt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pzdkt = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int max = Math . max ( pzdkt - B , pzdkt + B ) ; max = Math . max ( max , pzdkt * B ) ; System . out . println ( max ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Guhsr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int guhsr = 0 ; guhsr < 3 ; guhsr ++ ) { a [ guhsr ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( a ) ; int cost = 0 ; for ( int guhsr = 0 ; guhsr < 3 ; guhsr ++ ) { if ( guhsr != 0 ) { cost += a [ guhsr ] - a [ guhsr - 1 ] ; } } System . out . println ( cost ) ; } } import java . util . * ; public class Swrtdvz { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solveB ( ) ; } private void solveA ( ) { Scanner sc = new Scanner ( System . in ) ; int swrtdvz = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String s ; if ( swrtdvz >= 9 || B >= 9 ) { s = " :( " ; } else { s = " Yay! " ; } System . out . println ( s ) ; } private void solveB ( ) { Scanner sc = new Scanner ( System . in ) ; int D = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int p = 1 ; for ( int i = 0 ; i < D ; i ++ ) { p *= 100 ; } if ( N == 100 ) N = 101 ; System . out . println ( p * N ) ; } } import java . util . * ; import java . io . * ; class Bffivgn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int bffivgn = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; int [ ] L = new int [ M ] ; int [ ] R = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { L [ i ] = Integer . parseInt ( sc . next ( ) ) ; R [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; int Lmax = 0 ; int Rmin = Integer . MAX_VALUE ; for ( int i = 0 ; i < M ; i ++ ) { if ( Lmax < L [ i ] ) { Lmax = L [ i ] ; } if ( R [ i ] < Rmin ) { Rmin = R [ i ] ; } } out . printf ( " %d \n " , Math . max ( 0 , Rmin - Lmax + 1 ) ) ; out . flush ( ) ; } } import java . util . Scanner ; class Ajqghe { public static void main ( String [ ] args ) { int ajqghe , t ; int minCost = 1001 ; Scanner sc = new Scanner ( System . in ) ; ajqghe = sc . nextInt ( ) ; t = sc . nextInt ( ) ; for ( int i = 0 ; i < ajqghe ; ++ i ) { int ci = sc . nextInt ( ) ; int ti = sc . nextInt ( ) ; if ( ti <= t ) { minCost = Math . min ( minCost , ci ) ; } } if ( minCost == 1001 ) { System . out . println ( " TLE " ) ; } else { System . out . println ( minCost ) ; } } } import java . util . * ; public class Ulyqppi { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int ulyqppi = Integer . parseInt ( sc . next ( ) ) ; long [ ] a = new long [ ulyqppi ] ; for ( int i = 0 ; i < ulyqppi ; i ++ ) { a [ i ] = Long . parseLong ( sc . next ( ) ) ; if ( a [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } long total = 1L ; long LIMIT = 1000000000000000000L ; for ( int i = 0 ; i < ulyqppi ; i ++ ) { if ( a [ i ] <= LIMIT / total ) { total *= a [ i ] ; } else { System . out . println ( - 1 ) ; return ; } } System . out . println ( total ) ; } } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class Vxzuh { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int vxzuh = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int [ ] ans = null ; for ( int m = 0 ; m <= vxzuh ; m ++ ) { for ( int g = 0 ; g <= vxzuh - m ; g ++ ) { int s = vxzuh - ( m + g ) ; if ( Y == m * 10000 + g * 5000 + s * 1000 ) { ans = new int [ ] { m , g , s } ; } } } if ( ans == null ) { out . println ( " -1 -1 -1 " ) ; } else { out . println ( ans [ 0 ] + " " + ans [ 1 ] + " " + ans [ 2 ] ) ; } sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } } import java . util . * ; public class Jbeol { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] list = { sc . next ( ) , sc . next ( ) , sc . next ( ) } ; int jbeol = 0 ; int seven_count = 0 ; for ( String l : list ) { if ( l . equals ( " 5 " ) ) jbeol ++ ; else if ( l . equals ( " 7 " ) ) seven_count ++ ; } if ( jbeol == 2 && seven_count == 1 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . * ; public class Psqefpb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int psqefpb = sc . nextInt ( ) ; int attackCount = sc . nextInt ( ) ; int [ ] list = new int [ attackCount ] ; int damage = 0 ; for ( int i = 0 ; i < attackCount ; ++ i ) { list [ i ] = sc . nextInt ( ) ; damage += list [ i ] ; } if ( psqefpb <= damage ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class Soqfin { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int soqfin , b , f , r , v ; int [ ] [ ] [ ] house = new int [ 4 ] [ 3 ] [ 10 ] ; String output ; String [ ] input = new String [ 4 ] ; soqfin = Integer . parseInt ( sc . nextLine ( ) ) ; for ( int i = 0 ; i < soqfin ; i ++ ) { input = sc . nextLine ( ) . split ( " [ \\ s]+ " ) ; b = Integer . parseInt ( input [ 0 ] ) ; f = Integer . parseInt ( input [ 1 ] ) ; r = Integer . parseInt ( input [ 2 ] ) ; v = Integer . parseInt ( input [ 3 ] ) ; house [ b - 1 ] [ f - 1 ] [ r - 1 ] += v ; } for ( b = 0 ; b < 4 ; b ++ ) { for ( f = 0 ; f < 3 ; f ++ ) { output = " " ; for ( r = 0 ; r < 10 ; r ++ ) { output += " " + house [ b ] [ f ] [ r ] ; } System . out . println ( output ) ; } if ( b < 3 ) { System . out . println ( " #################### " ) ; } } } } import java . util . * ; public class Wvahw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wvahw = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int p ; String S ; int [ ] AC = new int [ wvahw ] ; int [ ] WA = new int [ wvahw ] ; for ( int i = 0 ; i < wvahw ; i ++ ) { AC [ i ] = 0 ; WA [ i ] = 0 ; } int penalty = 0 ; for ( int i = 0 ; i < M ; i ++ ) { p = sc . nextInt ( ) - 1 ; S = sc . next ( ) ; if ( S . equals ( " WA " ) ) { WA [ p ] ++ ; } else if ( S . equals ( " AC " ) ) { if ( AC [ p ] == 0 ) { penalty = penalty + WA [ p ] ; } AC [ p ] = 1 ; } } int clear = 0 ; for ( int i = 0 ; i < wvahw ; i ++ ) { clear = clear + AC [ i ] ; } System . out . print ( clear + " " + penalty ) ; } } import java . util . * ; class Cohwki { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] nl = scanner . nextLine ( ) . split ( " " , 2 ) ; int cohwki = Integer . parseInt ( nl [ 0 ] ) ; int l = Integer . parseInt ( nl [ 1 ] ) ; String [ ] arr = new String [ cohwki ] ; for ( int i = 0 ; i < cohwki ; i ++ ) { arr [ i ] = scanner . nextLine ( ) ; } Arrays . sort ( arr ) ; for ( int i = 0 ; i < cohwki ; i ++ ) { System . out . print ( arr [ i ] ) ; } System . out . print ( " \n " ) ; } } import java . util . * ; public class Fzaqv { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String n = s . nextLine ( ) ; String s1 = String . valueOf ( n . charAt ( 0 ) ) ; int fzaqv = 0 ; int i2 = 0 ; String s2 = " " ; for ( int i = 0 ; i < n . length ( ) ; i ++ ) { if ( String . valueOf ( n . charAt ( i ) ) . equals ( s1 ) ) { fzaqv ++ ; } else { if ( s2 . equals ( " " ) || String . valueOf ( n . charAt ( i ) ) . equals ( s2 ) ) { s2 = String . valueOf ( n . charAt ( i ) ) ; i2 ++ ; } } } System . out . println ( fzaqv == 2 && i2 == 2 ? " Yes " : " No " ) ; } } import java . util . * ; class Waxegtr { static int waxegtr ; static int [ ] a ; static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { while ( read ( ) ) { insertionSort ( a ) ; } } static boolean read ( ) { if ( ! scanner . hasNext ( ) ) return false ; waxegtr = scanner . nextInt ( ) ; a = new int [ waxegtr ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } return true ; } static int [ ] insertionSort ( int [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { int v = array [ i ] ; int j = i - 1 ; while ( j >= 0 && array [ j ] > v ) { array [ j + 1 ] = array [ j ] ; j -- ; } array [ j + 1 ] = v ; traceArray ( array ) ; } return array ; } static void traceArray ( int [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( i == array . length - 1 ) { System . out . print ( array [ i ] ) ; continue ; } System . out . print ( array [ i ] + " " ) ; } System . out . println ( ) ; } } import java . util . * ; import java . text . * ; public class Timzfiz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int timzfiz = Integer . parseInt ( sc . nextLine ( ) ) ; double debt = 100000 ; while ( timzfiz > 0 ) { debt *= 1.05 ; debt = 1000.0 * Math . ceil ( debt / 1000.0 ) ; timzfiz -- ; } System . out . println ( String . format ( " %.0f " , debt ) ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Nursp { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; Arrays . parallelSort ( s ) ; if ( s [ 0 ] == s [ 1 ] && s [ 2 ] == s [ 3 ] && s [ 0 ] != s [ 2 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Uwlak { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uwlak = sc . nextInt ( ) ; ArrayList < Integer > vList = new ArrayList < > ( ) ; for ( int i = 0 ; i < uwlak ; i ++ ) { vList . add ( sc . nextInt ( ) ) ; } Collections . sort ( vList ) ; double ans = ( double ) vList . get ( 0 ) ; for ( int i = 1 ; i < uwlak ; i ++ ) { double sum = ans + ( double ) vList . get ( i ) ; ans = sum / 2 ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Yystfp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yystfp = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { yystfp -= sc . nextInt ( ) ; } if ( yystfp <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Gzydqu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gzydqu = sc . nextInt ( ) ; int [ ] array = new int [ gzydqu ] ; int [ ] DP = new int [ gzydqu + 1 ] ; Arrays . fill ( DP , Integer . MAX_VALUE ) ; DP [ 0 ] = 0 ; for ( int i = 0 ; i < gzydqu ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < gzydqu - 2 ; i ++ ) { DP [ i + 1 ] = Math . min ( DP [ i + 1 ] , DP [ i ] + Math . abs ( array [ i + 1 ] - array [ i ] ) ) ; DP [ i + 2 ] = Math . min ( DP [ i + 2 ] , DP [ i ] + Math . abs ( array [ i + 2 ] - array [ i ] ) ) ; } DP [ gzydqu - 1 ] = Math . min ( DP [ gzydqu - 1 ] , DP [ gzydqu - 2 ] + Math . abs ( array [ gzydqu - 1 ] - array [ gzydqu - 2 ] ) ) ; System . out . println ( DP [ gzydqu - 1 ] ) ; } } import java . util . * ; public class Opoepn { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int opoepn = in . nextInt ( ) ; int t = in . nextInt ( ) ; int s = in . nextInt ( ) ; double time = ( double ) opoepn / s ; if ( time - t > 0 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . * ; public class Mybsb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] data = new int [ 3 ] ; for ( int mybsb = 0 ; mybsb < 3 ; mybsb ++ ) { data [ mybsb ] = sc . nextInt ( ) ; } int K = sc . nextInt ( ) ; int maxIdx = 0 ; int max = data [ 0 ] ; for ( int mybsb = 1 ; mybsb < 3 ; mybsb ++ ) { if ( max < data [ mybsb ] ) { max = data [ mybsb ] ; maxIdx = mybsb ; } } for ( int mybsb = 0 ; mybsb < K ; mybsb ++ ) { data [ maxIdx ] *= 2 ; } System . out . println ( data [ 0 ] + data [ 1 ] + data [ 2 ] ) ; sc . close ( ) ; } } import java . util . * ; public class Fexvvxl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fexvvxl = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int m = 0 ; int flag = 0 ; if ( y <= fexvvxl * 2 || y <= fexvvxl * 4 ) { for ( int i = 1 ; i <= fexvvxl ; i ++ ) { int j = i * 2 ; m = i * 4 ; int h = y - j ; int h1 = y - m ; if ( ( h1 % 2 == 0 && h1 / 2 == fexvvxl - i ) || ( h % 4 == 0 && h / 4 == fexvvxl - i ) ) { flag = 1 ; break ; } } } if ( flag == 1 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import javax . print . DocFlavor ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Rxohfm { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int rxohfm = Integer . parseInt ( reader . readLine ( ) ) ; String [ ] l = reader . readLine ( ) . split ( " " ) ; int s = 0 ; int sumsq = 0 ; for ( String t : l ) { int y = Integer . parseInt ( t ) ; s = s + y ; sumsq += y * y ; } int p = ( s / rxohfm ) ; System . out . println ( Math . min ( ( rxohfm * p * p - 2 * p * s + sumsq ) , ( rxohfm * ( p + 1 ) * ( p + 1 ) - 2 * ( p + 1 ) * s + sumsq ) ) ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class Dptlnl { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; Main m = new Main ( sc ) ; m . show ( m . solve ( ) ) ; sc . close ( ) ; } Scanner sc ; int dptlnl ; Map < String , Integer > map = new TreeMap < String , Integer > ( ) ; Main ( Scanner sc ) { this . sc = sc ; this . dptlnl = sc . nextInt ( ) ; } private List < String > solve ( ) { int max = 0 ; List < String > answer = new ArrayList < String > ( ) ; for ( int i = 0 ; i < dptlnl ; i ++ ) { String S = sc . next ( ) ; if ( map . containsKey ( S ) ) { map . put ( S , map . get ( S ) + 1 ) ; } else { map . put ( S , 1 ) ; } } for ( String S : map . keySet ( ) ) { max = Math . max ( max , map . get ( S ) ) ; } for ( String S : map . keySet ( ) ) { if ( max == map . get ( S ) ) { answer . add ( S ) ; } } return answer ; } public void show ( List < String > answer ) { for ( int i = 0 ; i < answer . size ( ) ; i ++ ) { System . out . println ( answer . get ( i ) ) ; } } } import java . util . Scanner ; public class Amkgq { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String S = stdIn . next ( ) ; char [ ] s = new char [ S . length ( ) ] ; for ( int amkgq = 0 ; amkgq < S . length ( ) ; amkgq ++ ) { s [ amkgq ] = S . charAt ( amkgq ) ; } s [ 3 ] = '8' ; System . out . println ( s ) ; } } import java . util . * ; public class Fgnwlh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fgnwlh = sc . nextInt ( ) ; String s = sc . next ( ) ; boolean val = true ; if ( s . length ( ) % 2 != 0 ) val = false ; else { for ( int i = 0 ; i < fgnwlh / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i + fgnwlh / 2 ) ) { val = false ; break ; } } } System . out . println ( val ? " Yes " : " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Ivnmofz { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word ; int ivnmofz = 0 ; word = in . readLine ( ) ; while ( true ) { String [ ] text ; text = in . readLine ( ) . split ( " " ) ; if ( text [ 0 ] . equals ( " END_OF_TEXT " ) ) { break ; } for ( String str : text ) { str = str . toLowerCase ( ) ; if ( str . matches ( word ) ) { ivnmofz ++ ; } else { continue ; } } } System . out . println ( ivnmofz ) ; } } import java . util . * ; public class Dgpob { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dgpob = 1 ; while ( true ) { int a = sc . nextInt ( ) ; if ( a != 0 ) System . out . println ( " Case " + dgpob + " : " + a ) ; else break ; dgpob = dgpob + 1 ; } } } import java . util . * ; public class Zymup { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long zymup = sc . nextLong ( ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } Arrays . sort ( a ) ; long d = zymup + a [ 0 ] - a [ n - 1 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( d < a [ i ] - a [ i - 1 ] ) { d = a [ i ] - a [ i - 1 ] ; } } System . out . println ( zymup - d ) ; } } import java . util . Scanner ; public class Iznrlu { public static final String OK = " Yay! " ; public static final String NO = " :( " ; public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iznrlu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; sc . close ( ) ; if ( e - iznrlu > k ) System . out . println ( NO ) ; else System . out . println ( OK ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Fhina { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long fhina = 0 ; long [ ] array = new long [ 3 ] ; Arrays . sort ( array ) ; int buff = Integer . parseInt ( s . substring ( 0 , 4 ) ) ; int buff1 = Integer . parseInt ( s . substring ( 5 , 7 ) ) ; if ( buff > 2019 || buff1 > 4 ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } } } import java . io . FileNotFoundException ; import java . util . Arrays ; import java . util . Scanner ; public class Iwwwt { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int iwwwt = sc . nextInt ( ) ; int [ ] A = new int [ iwwwt ] ; for ( int i = 0 ; i < iwwwt ; i ++ ) { A [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; int [ ] B = A . clone ( ) ; Arrays . sort ( B ) ; int max = B [ iwwwt - 1 ] ; int nextmax = B [ iwwwt - 2 ] ; for ( int i = 0 ; i < iwwwt ; i ++ ) { if ( A [ i ] == max ) { System . out . println ( nextmax ) ; } else { System . out . println ( max ) ; } } } } import java . util . * ; class Dufuy { Scanner sc = new Scanner ( System . in ) ; public int ini ( ) { return sc . nextInt ( ) ; } public int [ ] vi ( int n ) { int [ ] a = new int [ n ] ; for ( int dufuy = 0 ; dufuy < n ; dufuy ++ ) a [ dufuy ] = sc . nextInt ( ) ; return a ; } } public class Dufuy extends Reader { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . show ( main . solve ( ) ) ; } int n ; int [ ] a ; public Main ( ) { n = ini ( ) ; a = vi ( n ) ; } int solve ( ) { int ans = 0 ; for ( int dufuy = 0 ; dufuy < n - 1 ; dufuy ++ ) { for ( int j = dufuy + 1 ; j < n ; j ++ ) { ans += a [ dufuy ] * a [ j ] ; } } return ans ; } void show ( int ans ) { System . out . println ( ans ) ; } } import java . util . Scanner ; public class Paglgdl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int paglgdl = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) ; int x = sc . nextInt ( ) , y = sc . nextInt ( ) ; int min = x * paglgdl + y * b ; min = Math . min ( min , 2 * y * c + Math . max ( 0 , x - y ) * paglgdl ) ; min = Math . min ( min , 2 * x * c + Math . max ( 0 , y - x ) * b ) ; min = Math . min ( min , 2 * Math . max ( x , y ) * c ) ; System . out . println ( min ) ; sc . close ( ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Qjyoohj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qjyoohj = scan . nextInt ( ) ; int N = scan . nextInt ( ) ; ArrayList < Integer > H = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { H . add ( scan . nextInt ( ) ) ; } scan . close ( ) ; int min = 100 ; int result = 0 ; for ( int i = - 100 ; i <= 101 ; i ++ ) { if ( ! H . contains ( i ) ) { int tmp2 = qjyoohj - i ; if ( tmp2 < 0 ) { tmp2 = i - qjyoohj ; } if ( tmp2 < min ) { min = tmp2 ; result = i ; } } } System . out . println ( result ) ; } } import java . util . * ; public class Tlalunv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tlalunv , b , sum ; tlalunv = sc . nextInt ( ) ; b = sc . nextInt ( ) ; sum = 0 ; if ( ( tlalunv == 1 || tlalunv == 2 ) && ( b == 1 || b == 2 ) ) { sum = 3 ; System . out . println ( sum ) ; } else if ( ( tlalunv == 1 || tlalunv == 3 ) && ( b == 1 || b == 3 ) ) { sum = 2 ; System . out . println ( sum ) ; } else { sum = 1 ; System . out . println ( sum ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Pfkpag { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; char [ ] strArray = str . toCharArray ( ) ; for ( int pfkpag = 0 ; pfkpag < strArray . length ; pfkpag ++ ) { if ( Character . isUpperCase ( strArray [ pfkpag ] ) ) { strArray [ pfkpag ] = Character . toLowerCase ( strArray [ pfkpag ] ) ; } else if ( Character . isLowerCase ( strArray [ pfkpag ] ) ) { strArray [ pfkpag ] = Character . toUpperCase ( strArray [ pfkpag ] ) ; } else { strArray [ pfkpag ] = strArray [ pfkpag ] ; } } for ( int pfkpag = 0 ; pfkpag < strArray . length - 1 ; pfkpag ++ ) { System . out . print ( strArray [ pfkpag ] ) ; } System . out . println ( strArray [ strArray . length - 1 ] ) ; } } import java . util . * ; public class Bmdep { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String S = s . next ( ) ; String T = s . next ( ) ; char [ ] sc = S . toCharArray ( ) ; char [ ] tc = T . toCharArray ( ) ; if ( ( tc . length - sc . length ) > 1 ) { System . out . println ( " No " ) ; } for ( int bmdep = 0 ; bmdep < tc . length ; bmdep ++ ) { if ( bmdep < sc . length && sc [ bmdep ] != tc [ bmdep ] ) { System . out . println ( " No " ) ; break ; } if ( bmdep == tc . length - 1 ) { System . out . println ( " Yes " ) ; } } } } import java . util . Scanner ; public class Plhec { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int plhec = stdIn . nextInt ( ) ; char [ ] s = stdIn . next ( ) . toCharArray ( ) ; int [ ] ans = new int [ s . length ] ; char [ ] words = { 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' } ; int count = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { for ( int j = 0 ; j < words . length ; j ++ ) { if ( s [ i ] == words [ j ] ) { ans [ count ++ ] = j ; } } } for ( int i = 0 ; i < plhec ; i ++ ) { for ( int j = 0 ; j < ans . length ; j ++ ) { if ( ans [ j ] == 25 ) { ans [ j ] = 0 ; } else { ans [ j ] ++ ; } } } for ( int i = 0 ; i < ans . length ; i ++ ) { System . out . print ( words [ ans [ i ] ] ) ; } } } import java . util . * ; import java . io . * ; public class Kmgopz { static StringTokenizer st ; static BufferedReader br ; static PrintWriter out ; public static void main ( String [ ] args ) throws IOException { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int kmgopz = nextInt ( ) ; int N = nextInt ( ) ; int [ ] input = new int [ N ] ; for ( int x = 0 ; x < N ; x ++ ) { input [ x ] = nextInt ( ) ; } Arrays . sort ( input ) ; int max = Integer . MIN_VALUE ; for ( int x = 1 ; x < N ; x ++ ) { int tmp = input [ x ] - input [ x - 1 ] ; max = Math . max ( tmp , max ) ; } max = Math . max ( kmgopz - input [ N - 1 ] + input [ 0 ] , max ) ; System . out . println ( kmgopz - max ) ; } public static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public static long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } public static double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } static String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) . trim ( ) ) ; return st . nextToken ( ) ; } } import java . util . * ; class Oeemqkz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oeemqkz = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] A = new int [ oeemqkz ] ; for ( int i = 0 ; i < K ; i ++ ) { int d = sc . nextInt ( ) ; for ( int j = 0 ; j < d ; j ++ ) { A [ sc . nextInt ( ) - 1 ] ++ ; } } int count = 0 ; for ( int r : A ) { if ( r == 0 ) { count ++ ; } } System . out . print ( count ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Jkcjyt { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; line = line . trim ( ) ; String [ ] readLineArray = line . split ( " [ \\ s+] " ) ; double jkcjyt = Double . parseDouble ( readLineArray [ 0 ] ) ; double S = Math . PI * jkcjyt * jkcjyt ; double L = 2 * Math . PI * jkcjyt ; System . out . printf ( " %.5f %.5f " , S , L ) ; } } import java . util . Scanner ; public class Ssuihwh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ssuihwh = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int min = 0 ; for ( int i = 1 ; i <= 1009 ; i ++ ) { if ( ( int ) ( i * 0.08 ) == ssuihwh && ( int ) ( i * 0.1 ) == b ) { min = i ; break ; } else { min = - 1 ; } } System . out . println ( min ) ; scan . close ( ) ; } } import java . util . * ; class Yaqlfte { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String [ ] S = scan . nextLine ( ) . split ( " " ) ; int yaqlfte = 0 ; for ( int i = 0 ; i < S . length / 2 ; i ++ ) { if ( ! ( S [ i ] . equals ( S [ S . length - 1 - i ] ) ) ) { yaqlfte ++ ; } } System . out . println ( yaqlfte ) ; } } import java . awt . * ; import java . awt . geom . * ; import java . io . * ; import java . util . * ; class Sfseu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int sfseu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( sfseu == 0 && b == 0 ) break ; System . out . println ( ( sfseu < b ) ? ( sfseu + " " + b ) : ( b + " " + sfseu ) ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Znnqkvw { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; char [ ] c = ob . next ( ) . toCharArray ( ) ; int znnqkvw = 0 ; for ( int i = 0 ; i < c . length ; i ++ ) { znnqkvw = znnqkvw + Character . getNumericValue ( c [ i ] ) ; } if ( znnqkvw % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . * ; import java . util . * ; public class Ysqdd extends PrintWriter { Main ( ) { super ( System . out , true ) ; } Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { Main o = new Main ( ) ; o . main ( ) ; o . flush ( ) ; } void main ( ) { int ysqdd = sc . nextInt ( ) ; if ( ysqdd > 50 ) { ysqdd = 50 ; } String S = sc . next ( ) ; int Y = 0 ; int U = 0 ; for ( int i = 0 ; i < ysqdd ; i ++ ) { if ( Y == 0 ) { if ( S . charAt ( i ) == 'A' ) { Y = 1 ; } } else if ( Y == 1 ) { if ( S . charAt ( i ) == 'B' ) { Y = 2 ; } else if ( S . charAt ( i ) == 'A' ) { Y = 1 ; } else { Y = 0 ; } } else if ( Y == 2 ) { if ( S . charAt ( i ) == 'C' ) { Y = 0 ; U ++ ; } else if ( S . charAt ( i ) == 'C' ) { Y = 1 ; } else { Y = 0 ; } } } print ( U ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; public class Fcwrk { public static void main ( String [ ] args ) throws java . lang . Exception { ArrayList < Integer > array = new ArrayList < Integer > ( ) ; ArrayList < Integer > array2 = new ArrayList < Integer > ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String data = " " ; br . readLine ( ) ; data = br . readLine ( ) ; String [ ] hairetsu = data . split ( " " , 0 ) ; for ( int fcwrk = 0 ; fcwrk < hairetsu . length ; fcwrk ++ ) { array . add ( Integer . parseInt ( hairetsu [ fcwrk ] ) ) ; } for ( int fcwrk = 0 ; fcwrk < array . size ( ) ; fcwrk ++ ) { array2 . add ( array . get ( array . size ( ) - 1 - fcwrk ) ) ; } for ( int fcwrk = 0 ; fcwrk < array2 . size ( ) ; fcwrk ++ ) { System . out . print ( array2 . get ( fcwrk ) ) ; if ( fcwrk < array2 . size ( ) - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } import java . util . * ; public class Mxtims { public static void main ( String [ ] args ) throws Exception { String [ ] lines = getStdin ( ) ; String str = lines [ 0 ] ; long mxtims = Long . parseLong ( str ) ; long sum = 100 ; int count = 0 ; while ( sum < mxtims ) { sum = sum + ( sum * 1 / 100 ) ; count ++ ; } System . out . println ( count ) ; } private static String [ ] getStdin ( ) { Scanner scanner = new Scanner ( System . in ) ; ArrayList < String > lines = new ArrayList < > ( ) ; while ( scanner . hasNext ( ) ) { lines . add ( scanner . nextLine ( ) ) ; } return lines . toArray ( new String [ lines . size ( ) ] ) ; } } import java . util . * ; class Babhnan { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long babhnan = sc . nextLong ( ) ; long min = Integer . MAX_VALUE ; for ( long a = 1 ; a <= Math . sqrt ( ( double ) babhnan ) ; a ++ ) { if ( babhnan % a == 0 ) { long b = babhnan / a ; int f = Math . max ( String . valueOf ( a ) . length ( ) , String . valueOf ( b ) . length ( ) ) ; if ( f < min ) min = f ; } } System . out . println ( min ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Mhqswzk { public static void main ( String [ ] Arguments ) throws IOException { BufferedReader BR = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer ST = new StringTokenizer ( BR . readLine ( ) ) ; int mhqswzk = Integer . parseInt ( ST . nextToken ( ) ) , M = Integer . parseInt ( ST . nextToken ( ) ) , homeworkDays = 0 ; ST = new StringTokenizer ( BR . readLine ( ) ) ; for ( ; M > 0 ; M -- ) homeworkDays += Integer . parseInt ( ST . nextToken ( ) ) ; System . out . println ( ( homeworkDays <= mhqswzk ) ? mhqswzk - homeworkDays : - 1 ) ; } } import java . util . Scanner ; public class Ielxy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String [ ] str = { " MON " , " TUE " , " WED " , " THU " , " FRI " , " SAT " , " SUN " } ; for ( int ielxy = 0 ; ielxy < str . length ; ielxy ++ ) { if ( str [ ielxy ] . equals ( S ) ) { if ( ielxy == 6 ) { System . out . println ( 7 ) ; } else { System . out . println ( 7 - ( ielxy + 1 ) ) ; } } } } } import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Kwbojh { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; String kwbojh = keyboard . nextLine ( ) ; String SB = keyboard . nextLine ( ) ; String SC = keyboard . nextLine ( ) ; String input = kwbojh . substring ( 0 , 1 ) ; keyboard . close ( ) ; System . out . print ( solve ( kwbojh , SB , SC , input ) ) ; } public static String solve ( String A , String B , String C , String input2 ) { String output ; if ( input2 . equals ( " a " ) ) { if ( A . length ( ) != 0 ) { output = A . substring ( 0 , 1 ) ; return solve ( A . substring ( 1 ) , B , C , output ) ; } else { return " A " ; } } else if ( input2 . equals ( " b " ) ) { if ( B . length ( ) != 0 ) { output = B . substring ( 0 , 1 ) ; return solve ( A , B . substring ( 1 ) , C , output ) ; } else { return " B " ; } } else { if ( C . length ( ) != 0 ) { output = C . substring ( 0 , 1 ) ; return solve ( A , B , C . substring ( 1 ) , output ) ; } else { return " C " ; } } } } import java . util . Scanner ; public class Vycis { public static int vycis = 0 ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int length = scanner . nextInt ( ) ; int [ ] array = new int [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { array [ i ] = scanner . nextInt ( ) ; } scanner . close ( ) ; bubbleSort ( array , length ) ; printArray ( array ) ; System . out . println ( vycis ) ; } public static void bubbleSort ( int [ ] array , int length ) { for ( int i = 0 ; i < length ; i ++ ) { for ( int j = length - 1 ; j > i ; j -- ) { if ( array [ j ] < array [ j - 1 ] ) { array [ j - 1 ] = array [ j - 1 ] + array [ j ] ; array [ j ] = array [ j - 1 ] - array [ j ] ; array [ j - 1 ] = array [ j - 1 ] - array [ j ] ; vycis ++ ; } } } } public static void printArray ( int [ ] array ) { for ( int i = 0 ; i < array . length ; i ++ ) { if ( i > 0 ) System . out . print ( " " ) ; System . out . print ( array [ i ] ) ; } System . out . print ( " \n " ) ; } } import java . util . * ; public class Epjyb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; if ( judge ( s , 0 ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } public static boolean judge ( String s , int i ) { if ( i == s . length ( ) ) { return true ; } boolean epjyb = false ; if ( s . length ( ) >= i + 7 && s . substring ( i , i + 7 ) . equals ( " dreamer " ) ) { epjyb |= judge ( s , i + 7 ) ; } if ( s . length ( ) >= i + 5 && s . substring ( i , i + 5 ) . equals ( " dream " ) ) { epjyb |= judge ( s , i + 5 ) ; } if ( s . length ( ) >= i + 6 && s . substring ( i , i + 6 ) . equals ( " eraser " ) ) { epjyb |= judge ( s , i + 6 ) ; } if ( s . length ( ) >= i + 5 && s . substring ( i , i + 5 ) . equals ( " erase " ) ) { epjyb |= judge ( s , i + 5 ) ; } return epjyb ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintStream ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Ckgos { public static final Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; public static final PrintStream out = System . out ; public static void main ( String [ ] args ) { int ckgos = in . nextInt ( ) ; int [ ] H = new int [ ckgos ] ; for ( int i = 0 ; i < ckgos ; i ++ ) { H [ i ] = in . nextInt ( ) ; } int step = 0 ; for ( int i : H ) { if ( i < step ) { out . println ( " No " ) ; return ; } else if ( i <= step + 1 ) { continue ; } else { step = i - 1 ; } } out . println ( " Yes " ) ; } } import java . util . * ; public class Hoveeq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int hoveeq = 0 ; int tmp = 0 ; char [ ] weather = new char [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { weather [ i ] = S . charAt ( i ) ; } for ( int j = 0 ; j < 3 ; j ++ ) { if ( weather [ j ] == 'R' ) { tmp ++ ; if ( hoveeq < tmp ) hoveeq = tmp ; } else { if ( hoveeq < tmp ) hoveeq = tmp ; tmp = 0 ; } } System . out . println ( hoveeq ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . text . Collator ; public class Sdykl { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { StringBuilder line = new StringBuilder ( ) ; StringBuilder wordA = new StringBuilder ( ) ; StringBuilder wordB = new StringBuilder ( ) ; Collator collator = Collator . getInstance ( ) ; int sdykl = Integer . parseInt ( br . readLine ( ) ) ; int pointA = 0 ; int pointB = 0 ; int result = 0 ; for ( int i = 0 ; i < sdykl ; i ++ ) { line . append ( br . readLine ( ) ) ; wordA . append ( line . substring ( 0 , line . indexOf ( " " ) ) ) ; wordB . append ( line . substring ( line . indexOf ( " " ) + 1 , line . length ( ) ) ) ; result = collator . compare ( wordA . toString ( ) , wordB . toString ( ) ) ; pointA += result == 0 ? 1 : result < 0 ? 0 : 3 ; pointB += result == 0 ? 1 : result < 0 ? 3 : 0 ; line . setLength ( 0 ) ; wordA . setLength ( 0 ) ; wordB . setLength ( 0 ) ; } System . out . println ( pointA + " " + pointB ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class Cxspx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cxspx = scan . nextInt ( ) ; int [ ] a = new int [ cxspx ] ; long sum = 0 ; for ( int i = 0 ; i < cxspx ; i ++ ) { a [ i ] = scan . nextInt ( ) ; sum += a [ i ] ; } Arrays . sort ( a ) ; System . out . println ( a [ 0 ] + " " + a [ a . length - 1 ] + " " + sum ) ; scan . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Wfcoii { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wfcoii = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; String [ ] s = new String [ wfcoii ] ; for ( int i = 0 ; i < wfcoii ; i ++ ) { s [ i ] = sc . next ( ) ; } Arrays . sort ( s ) ; String ans = " " ; for ( int i = 0 ; i < wfcoii ; i ++ ) { ans += s [ i ] ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Qcgix { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Long num = sc . nextLong ( ) ; List < Long > list = method ( num ) ; list . add ( num ) ; int qcgix = list . qcgix ( ) ; if ( qcgix % 2 == 0 ) { int pos = qcgix / 2 ; long a = list . get ( pos ) ; long b = list . get ( pos - 1 ) ; System . out . println ( a + b - 2 ) ; } else { int pos = qcgix / 2 ; long a = list . get ( pos ) ; System . out . println ( a + a - 2 ) ; } } public static List < Long > method ( Long num ) { List < Long > list = new ArrayList < > ( ) ; Long sNum = Double . valueOf ( Math . sqrt ( num . doubleValue ( ) ) ) . longValue ( ) ; if ( sNum % 2L != 0L ) { sNum ++ ; } for ( Long i = 1L ; i <= sNum ; i ++ ) { if ( num % i == 0L ) { list . add ( i ) ; } } Long temp = list . get ( list . qcgix ( ) - 1 ) ; int qcgix = list . qcgix ( ) ; if ( num / temp == temp ) { qcgix = qcgix - 1 ; } for ( int i = qcgix - 1 ; i > 0 ; i -- ) { Long n = list . get ( i ) ; list . add ( num / n ) ; } return list ; } } import java . io . * ; import java . util . Arrays ; public class Whfnl { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { int whfnl = 0 ; String line = br . readLine ( ) ; String [ ] spl = line . split ( " " ) ; int n = Integer . parseInt ( spl [ 0 ] ) ; int x = Integer . parseInt ( spl [ 1 ] ) ; if ( n == 0 && x == 0 ) { break ; } for ( int i = 1 ; i <= ( n - 2 ) ; i ++ ) { for ( int j = i + 1 ; j <= ( n - 1 ) ; j ++ ) { for ( int k = j + 1 ; k <= n ; k ++ ) { if ( i + j + k == x ) { whfnl ++ ; } } } } System . out . println ( whfnl ) ; } } } import java . util . Scanner ; class Ijisihc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ijisihc = 1 ; while ( true ) { int x = scanner . nextInt ( ) ; if ( x == 0 ) break ; System . out . println ( " Case " + ijisihc + " : " + x ) ; ijisihc += 1 ; } } } import java . util . * ; public class Etihr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int etihr = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int temp = y ; if ( y % 2 == 0 && y >= ( etihr * 2 ) && y <= etihr * 4 ) { System . out . print ( " Yes " ) ; } else System . out . print ( " No " ) ; } } import java . util . * ; import java . util . Scanner ; public class Zjvedh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int zjvedh = sc . nextInt ( ) ; int [ ] a = new int [ zjvedh ] ; int res = 0 ; for ( int i = 0 ; i < zjvedh ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; if ( a [ zjvedh / 2 - 1 ] != a [ zjvedh / 2 ] ) { res = a [ zjvedh / 2 ] - a [ zjvedh / 2 - 1 ] ; } System . out . println ( res ) ; } } import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Deque ; import java . util . List ; import java . util . Scanner ; public class Zeazvpy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zeazvpy = sc . nextInt ( ) ; int wk = 0 ; int ans = 0 ; ans = zeazvpy / 2 ; wk = zeazvpy % 2 ; if ( wk == 1 ) { ans = ans + 1 ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Lgmhr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lgmhr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int result = Integer . MAX_VALUE ; for ( int i = 0 ; i <= x ; i ++ ) { int sum = 0 ; sum += i * lgmhr ; int rx = x - i ; if ( rx > y ) { sum += c * 2 * rx ; } else { int diff = y - rx ; sum += Math . min ( c * 2 * rx + diff * b , c * 2 * y ) ; } result = Math . min ( sum , result ) ; } System . out . println ( result ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Dxazatv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dxazatv = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; String S = sc . next ( ) ; int [ ] cnt = new int [ dxazatv + 1 ] ; for ( int i = 0 ; i < dxazatv - 1 ; i ++ ) { cnt [ i + 1 ] = cnt [ i ] + ( S . substring ( i , i + 2 ) . equals ( " AC " ) ? 1 : 0 ) ; } for ( int i = 0 ; i < Q ; i ++ ) { int L = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; System . out . println ( cnt [ R - 1 ] - cnt [ L - 1 ] ) ; } sc . close ( ) ; } } import java . util . * ; public class Bmayy { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; int bmayy = keyboard . nextInt ( ) ; HashMap < String , Integer > count = new HashMap < String , Integer > ( ) ; for ( int s = 0 ; s < bmayy ; s ++ ) { String S = keyboard . next ( ) ; if ( count . containsKey ( S ) ) { int now = count . get ( S ) ; count . replace ( S , now + 1 ) ; } else { count . put ( S , 1 ) ; } } int Max = 0 ; for ( int val : count . values ( ) ) { if ( Max <= val ) { Max = val ; } } List < String > print = new ArrayList < String > ( ) ; for ( String s : count . keySet ( ) ) { int now = count . get ( s ) ; if ( now == Max ) { print . add ( s ) ; } } Collections . sort ( print ) ; for ( int i = 0 ; i < print . size ( ) ; i ++ ) { String ans = print . get ( i ) ; System . out . println ( ans ) ; } keyboard . close ( ) ; } } import java . util . Scanner ; public class Uqvnb { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; for ( ; ; ) { int uqvnb = scan . nextInt ( ) ; double sum = 0 ; double m = 0 ; if ( uqvnb == 0 ) break ; double [ ] s = new double [ uqvnb ] ; for ( int i = 0 ; i < uqvnb ; i ++ ) { s [ i ] = scan . nextDouble ( ) ; sum += s [ i ] ; } m = ( double ) sum / uqvnb ; double a = 0 ; for ( int i = 0 ; i < uqvnb ; i ++ ) { a += ( s [ i ] - m ) * ( s [ i ] - m ) ; } double ans = Math . sqrt ( a / uqvnb ) ; if ( ans >= 0 ) { System . out . println ( ans ) ; } } } } import java . util . Scanner ; class Kmpsq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kmpsq = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( kmpsq < 10 && b < 10 ) { System . out . println ( kmpsq * b ) ; } else { System . out . println ( - 1 ) ; } scan . close ( ) ; } } import java . util . * ; public class Pxupko { static int pxupko = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double sum_power = 0 , count = 0 ; if ( ( num >= 1 && num <= 100000 ) && ( k >= 1 && k <= 100000 ) ) { for ( int i = 1 ; i <= num ; i ++ ) { count = doublet ( i , k ) ; double p = Math . pow ( 2 , count ) * num ; sum_power = sum_power + 1 / p ; pxupko = 0 ; } System . out . println ( sum_power ) ; } } static int doublet ( int n , int f ) { if ( n < f ) { pxupko = pxupko + 1 ; return doublet ( 2 * n , f ) ; } else return pxupko ; } } import java . util . * ; public class Dndwn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double dndwn = sc . nextDouble ( ) ; double A = ( double ) dndwn * dndwn * Math . PI ; double L = ( double ) dndwn * 2 * Math . PI ; System . out . println ( String . format ( " %f " , A ) + " " + String . format ( " %f " , L ) ) ; } } import java . util . Scanner ; public class Sqfxvnl { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String sqfxvnl = " ABCDEFGHIJKLMNOPQRSTUVWXYZ " ; String lowercase = " abcdefghijklmnopqrstuvwxyz " ; String alpha = scanner . nextLine ( ) ; if ( sqfxvnl . contains ( alpha ) ) System . out . println ( " A " ) ; else System . out . println ( " a " ) ; } } import java . math . BigInteger ; import java . util . * ; import java . io . * ; public class Oafnxzc { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int oafnxzc = sc . nextInt ( ) ; pw . println ( 1 - oafnxzc ) ; pw . flush ( ) ; } static class Oafnxzc { BufferedReader br ; StringTokenizer st ; public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; } public Scanner ( FileReader f ) { br = new BufferedReader ( f ) ; } public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } public int [ ] nextIntArr ( int oafnxzc ) throws IOException { int [ ] arr = new int [ oafnxzc ] ; for ( int i = 0 ; i < oafnxzc ; i ++ ) { arr [ i ] = Integer . parseInt ( next ( ) ) ; } return arr ; } } } import java . util . * ; public class Nqoda { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; if ( s . contains ( t ) ) { System . out . println ( 0 ) ; return ; } char nqoda ; char sj ; int startcount = 0 ; int matchcount = 0 ; int min = 0 ; for ( int i = 0 ; i < s . length ( ) - t . length ( ) + 1 ; i ++ ) { matchcount = 0 ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { nqoda = t . charAt ( j ) ; sj = s . charAt ( j + startcount ) ; if ( nqoda == sj ) { matchcount ++ ; } } if ( min == 0 || min > t . length ( ) - matchcount ) { min = t . length ( ) - matchcount ; } startcount ++ ; } System . out . println ( min ) ; sc . close ( ) ; } } import java . io . * ; public class Afkcxlh { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s ; try { while ( ( s = br . readLine ( ) ) != null ) { String [ ] str = s . split ( " " ) ; int afkcxlh = Integer . parseInt ( str [ 0 ] ) + Integer . parseInt ( str [ 1 ] ) ; System . out . println ( Integer . toString ( afkcxlh ) . length ( ) ) ; } br . close ( ) ; } catch ( Exception e ) { } } } import java . util . ArrayList ; import java . util . Scanner ; public class Ogkuc { public static void main ( String [ ] args ) { int ogkuc = 0 ; Scanner sc = new Scanner ( System . in ) ; int i = sc . nextInt ( ) ; ArrayList < Integer > al = new ArrayList < Integer > ( i ) ; for ( int j = 0 ; j < i ; j ++ ) { al . add ( sc . nextInt ( ) ) ; } me : while ( true ) { for ( int t = 0 ; t < i ; t ++ ) { if ( al . get ( t ) % 2 == 0 ) { al . set ( t , al . get ( t ) / 2 ) ; } else { System . out . println ( ogkuc ) ; break me ; } } ogkuc ++ ; } } } import java . util . Scanner ; public class Zufvdds { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int zufvdds = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= zufvdds ; i ++ ) { int sum = 0 ; for ( int j = 1 ; j <= zufvdds ; j ++ ) { if ( i % j == 0 ) { sum ++ ; } } if ( sum == 8 && i % 2 != 0 ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Baimmg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; Main m = new Main ( sc ) ; m . show ( m . solve ( ) ) ; sc . close ( ) ; } Scanner sc ; int baimmg ; int B ; int C ; Main ( Scanner sc ) { this . sc = sc ; this . baimmg = sc . nextInt ( ) ; this . B = sc . nextInt ( ) ; this . C = sc . nextInt ( ) ; } private String solve ( ) { String answer = " No " ; if ( baimmg == B && B != C || baimmg == C && B != C || B == C && C != baimmg ) { answer = " Yes " ; } return answer ; } public void show ( String answer ) { System . out . println ( answer ) ; } } import java . util . * ; public class Orjcbud { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String n = scan . nextLine ( ) ; String [ ] array = n . split ( " " ) ; int orjcbud = 0 ; for ( String a : array ) { if ( a . equals ( " 7 " ) ) { orjcbud = 1 ; } } if ( orjcbud == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . io . * ; public class Sfdrbsc { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int sfdrbsc = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; if ( n == 0 ) { System . out . println ( sfdrbsc ) ; System . exit ( 0 ) ; } int [ ] number = new int [ 201 ] ; Arrays . fill ( number , 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { int p = sc . nextInt ( ) ; number [ p ] = 0 ; } for ( int i = 0 ; i <= 200 ; i ++ ) { if ( sfdrbsc - i <= 0 ) continue ; if ( sfdrbsc + i > 200 ) continue ; if ( number [ sfdrbsc - i ] == 1 ) { System . out . println ( sfdrbsc - i ) ; System . exit ( 0 ) ; } if ( number [ sfdrbsc + i ] == 1 ) { System . out . println ( sfdrbsc + i ) ; System . exit ( 0 ) ; } } System . out . println ( 0 ) ; } } class Sfdrbsc { } import java . util . * ; import java . util . Arrays ; public class Zlbym { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int [ ] a = new int [ 10 ] ; for ( int zlbym = 0 ; zlbym < a . length ; zlbym ++ ) { a [ zlbym ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int zlbym = 9 ; zlbym > 6 ; zlbym -- ) { System . out . println ( a [ zlbym ] ) ; } } } import java . util . Scanner ; public class Mkwbed { public static void main ( String [ ] a ) { Scanner scan = new Scanner ( System . in ) ; String [ ] t = scan . nextLine ( ) . split ( " \\ s " ) ; int mkwbed = Integer . parseInt ( t [ 0 ] ) ; int ht = Integer . parseInt ( t [ 1 ] ) ; int count = 0 ; while ( scan . hasNextInt ( ) ) { int memHt = scan . nextInt ( ) ; if ( memHt >= ht ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Tgtfnl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String tgtfnl = sc . next ( ) ; String S1 = tgtfnl . substring ( 0 , 1 ) ; String S2 = tgtfnl . substring ( 1 , 2 ) ; String S3 = tgtfnl . substring ( 2 , 3 ) ; String S4 = tgtfnl . substring ( 3 , 4 ) ; String kekka = " Good " ; if ( S1 . equals ( S2 ) || S2 . equals ( S3 ) || S3 . equals ( S4 ) ) { kekka = " Bad " ; } System . out . println ( kekka ) ; } } import java . util . Scanner ; public class Lpfjsb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long lpfjsb = Long . parseLong ( sc . next ( ) ) ; long B = Long . parseLong ( sc . next ( ) ) ; long n = Math . abs ( lpfjsb - ( lpfjsb - B ) / 2 ) ; if ( Math . abs ( lpfjsb - n ) == Math . abs ( B - n ) ) { System . out . println ( n ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . util . Scanner ; public class Twznnx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int twznnx = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int ans = 0 ; if ( twznnx == 0 && x == 0 ) break ; for ( int i = 1 ; i < twznnx + 1 ; i ++ ) { for ( int j = i + 1 ; j < twznnx + 1 ; j ++ ) { for ( int k = j + 1 ; k < twznnx + 1 ; k ++ ) { if ( i + j + k == x ) ans ++ ; } } } System . out . println ( ans ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Bbfkg { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int bbfkg = scan . nextInt ( ) ; int inputQ = scan . nextInt ( ) ; int [ ] memory = new int [ bbfkg + 1 ] ; memory [ 0 ] = 0 ; String inputStr = scan . next ( ) ; for ( int n = 2 ; n < bbfkg + 1 ; n ++ ) { memory [ n ] = memory [ n - 1 ] ; if ( 'A' == ( inputStr . charAt ( n - 2 ) ) && 'C' == ( inputStr . charAt ( n - 1 ) ) ) { memory [ n ] ++ ; } } List < Integer > ans = new ArrayList < > ( ) ; for ( int i = 0 ; i < inputQ ; i ++ ) { int inputI = scan . nextInt ( ) ; int inputR = scan . nextInt ( ) ; ans . add ( memory [ inputR ] - memory [ inputI ] ) ; } for ( int i = 0 ; i < inputQ ; i ++ ) { System . out . println ( ans . get ( i ) ) ; } } } } import java . util . * ; public class Huzea { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int huzea = sc . nextInt ( ) ; int No = 0 ; int [ ] buka = new int [ huzea + 1 ] ; while ( sc . hasNext ( ) ) { buka [ sc . nextInt ( ) ] ++ ; } for ( int i = 1 ; i <= huzea ; i ++ ) { System . out . println ( buka [ i ] ) ; } } } import java . io . * ; public class Bszsky { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Main m = new Main ( ) ; String sec_ = br . readLine ( ) ; int bszsky = Integer . parseInt ( sec_ ) ; m . SecToTime ( bszsky ) ; } public void SecToTime ( int bszsky ) { int h = 0 , m = 0 ; while ( bszsky >= 3600 ) { h ++ ; bszsky -= 3600 ; } while ( bszsky >= 60 ) { m ++ ; bszsky -= 60 ; } System . out . println ( h + " : " + m + " : " + bszsky ) ; } } import java . util . * ; public class Wboyhj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wboyhj = sc . nextInt ( ) ; String [ ] list = new String [ wboyhj ] ; String ans = " No " ; for ( int i = 0 ; i < wboyhj ; i ++ ) { list [ i ] = sc . next ( ) ; } for ( int i = 1 ; i < wboyhj ; i ++ ) { char [ ] first = list [ i - 1 ] . toCharArray ( ) ; char [ ] second = list [ i ] . toCharArray ( ) ; if ( first [ first . length - 1 ] != second [ 0 ] ) { System . out . println ( " No " ) ; return ; } else { continue ; } } for ( int i = 0 ; i < wboyhj ; i ++ ) { String a = list [ i ] ; for ( int j = i + 1 ; j < wboyhj ; j ++ ) { String b = list [ j ] ; if ( a . equals ( b ) ) { System . out . println ( " No " ) ; return ; } else { continue ; } } } System . out . println ( " Yes " ) ; } } import java . io . * ; public class Ivsjzzb { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int ivsjzzb = Integer . parseInt ( br . readLine ( ) ) ; int currentT = 0 ; int currentX = 0 ; int currentY = 0 ; int nextT = 0 ; int nextX = 0 ; int nextY = 0 ; int amountMove = 0 ; for ( int i = 0 ; i < ivsjzzb ; i ++ ) { String [ ] data = br . readLine ( ) . split ( " " ) ; nextT = Integer . parseInt ( data [ 0 ] ) ; nextX = Integer . parseInt ( data [ 1 ] ) ; nextY = Integer . parseInt ( data [ 2 ] ) ; amountMove = Math . abs ( nextX - currentX ) + Math . abs ( nextY - currentY ) ; if ( amountMove > nextT - currentT || ( nextT - currentT - amountMove ) % 2 != 0 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Ealzvw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ealzvw = scan . nextInt ( ) ; int [ ] ar = new int [ ealzvw ] ; for ( int i = 0 ; i < ealzvw ; i ++ ) { ar [ i ] = scan . nextInt ( ) ; } Arrays . parallelSort ( ar ) ; float ans = 0 ; float [ ] lol = new float [ ealzvw ] ; lol [ 0 ] = ar [ 0 ] ; for ( int i = 1 ; i < ealzvw ; i ++ ) { lol [ i ] = ( float ) ( ( ar [ i ] + lol [ i - 1 ] ) / 2 ) ; } System . out . printf ( " %.04f " , lol [ ealzvw - 1 ] ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class Niwjtd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int niwjtd = sc . nextInt ( ) ; ArrayList < Integer > A = new ArrayList < Integer > ( ) ; ArrayList < Integer > B = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < niwjtd ; i ++ ) { int n = sc . nextInt ( ) ; A . add ( n ) ; B . add ( 0 ) ; } for ( int i = 0 ; i < niwjtd ; i ++ ) { B . set ( A . get ( i ) - 1 , i + 1 ) ; } for ( int i = 0 ; i < niwjtd ; i ++ ) { System . out . print ( B . get ( i ) + " " ) ; } sc . close ( ) ; } } import java . util . Scanner ; class Xwqzmdo { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String s ; for ( s = input . next ( ) ; ! s . equals ( " 0 " ) ; s = input . next ( ) ) { int xwqzmdo = 0 ; for ( char c : s . toCharArray ( ) ) { xwqzmdo += c - '0' ; } System . out . println ( xwqzmdo ) ; } } } import java . util . * ; public class Glmefom { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . next ( ) ; int glmefom , j , flag = 0 ; for ( glmefom = 0 ; glmefom < w . length ( ) ; glmefom ++ ) { int cnt = 0 ; for ( j = 0 ; j < w . length ( ) ; j ++ ) { if ( w . charAt ( glmefom ) == w . charAt ( j ) ) { cnt ++ ; } } if ( cnt % 2 != 0 ) { flag = 1 ; System . out . println ( " No " ) ; break ; } } if ( flag == 0 ) System . out . println ( " Yes " ) ; } } import java . util . Scanner ; class Eeaxe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int eeaxe = 1 ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; String s = scan . next ( ) ; if ( s . length ( ) != a + b + 1 ) { eeaxe = 0 ; } for ( int i = 0 ; i < a ; i ++ ) { if ( '0' <= s . charAt ( i ) && s . charAt ( i ) <= '9' ) { } else { eeaxe = 0 ; } } if ( s . charAt ( a ) != '-' ) { eeaxe = 0 ; } for ( int i = a + 1 ; i < s . length ( ) ; i ++ ) { if ( '0' <= s . charAt ( i ) && s . charAt ( i ) <= '9' ) { } else { eeaxe = 0 ; } } if ( eeaxe == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Hduzc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hduzc = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] A = new int [ M ] ; int left = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( sc . nextInt ( ) < X ) { left ++ ; } } System . out . println ( Math . min ( left , M - left ) ) ; } } import java . util . Scanner ; public class Pwejxy { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; System . out . println ( ( s . nextInt ( ) * s . nextInt ( ) ) % 2 == 0 ? " Even " : " Odd " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Obnll { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int obnll = scan . nextInt ( ) ; int [ ] length = new int [ obnll ] ; for ( int i = 0 ; i < length . length ; i ++ ) { length [ i ] = scan . nextInt ( ) ; } Arrays . sort ( length ) ; int sum = 0 ; for ( int i = 0 ; i < length . length - 1 ; i ++ ) { sum += length [ i ] ; } if ( sum > length [ length . length - 1 ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Olcbqng { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskBB solver = new TaskBB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Olcbqng { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int olcbqng = in . nextInt ( ) ; String a = in . next ( ) ; String b = in . next ( ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < olcbqng ; i ++ ) { sb . append ( a . charAt ( i ) ) ; sb . append ( b . charAt ( i ) ) ; } out . println ( sb . toString ( ) ) ; } } } import java . io . IOException ; import java . util . Scanner ; public class Wnxfz { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; int wnxfz = scanner . nextInt ( ) ; for ( int i = 3 ; i <= wnxfz ; i ++ ) { if ( i % 3 == 0 || String . valueOf ( i ) . contains ( " 3 " ) ) System . out . print ( " " + i ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class Flmxl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; long flmxl = sc . nextLong ( ) ; int x = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { x ++ ; if ( S . charAt ( i ) == '1' && x < flmxl ) { continue ; } else { System . out . println ( S . charAt ( i ) ) ; break ; } } } } import java . util . Arrays ; import java . util . Scanner ; public class Heyehw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int heyehw = sc . nextInt ( ) ; int [ ] A = new int [ heyehw ] ; for ( int i = 0 ; i < heyehw ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } Arrays . parallelSort ( A ) ; int count = 1 ; for ( int i = heyehw - 1 ; i > 0 ; i -- ) { if ( A [ i ] != A [ i - 1 ] ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class Gujtws { public void main ( Scanner sc ) { int gujtws = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int a3 = sc . nextInt ( ) ; int max = Math . max ( gujtws , Math . max ( a2 , a3 ) ) ; int min = Math . min ( gujtws , Math . min ( a2 , a3 ) ) ; System . out . println ( max - min ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Amzahd { public static void main ( String [ ] args ) { int [ ] input = new int [ 10 ] ; Scanner s = new Scanner ( System . in ) ; for ( int amzahd = 0 ; amzahd < 10 ; amzahd ++ ) { input [ amzahd ] = s . nextInt ( ) ; } Arrays . sort ( input ) ; int amzahd = input . length - 1 ; while ( amzahd > input . length - 4 ) { System . out . println ( input [ amzahd ] ) ; amzahd -- ; } } } import java . util . Scanner ; public class Mmpio { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final String mmpio = sc . next ( ) ; sc . close ( ) ; if ( Character . isUpperCase ( mmpio . charAt ( 0 ) ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } return ; } } import java . util . Arrays ; import java . util . Scanner ; public class Tutvstn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tutvstn = sc . nextInt ( ) , k = sc . nextInt ( ) ; int [ ] array = new int [ tutvstn ] ; for ( int i = 0 ; i < tutvstn ; i ++ ) array [ i ] = sc . nextInt ( ) ; Arrays . sort ( array ) ; for ( int i = tutvstn - 1 ; i >= tutvstn - k ; i -- ) { if ( i >= 0 ) array [ i ] = 0 ; else break ; } long sum = 0 ; for ( int i = 0 ; i < tutvstn ; i ++ ) sum += array [ i ] ; System . out . println ( sum ) ; } } import java . util . * ; public class Iadqlqb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { long iadqlqb = sc . nextLong ( ) ; long a1 = iadqlqb ; long b = sc . nextLong ( ) ; long b1 = b ; long i ; if ( iadqlqb > b ) { for ( ; ; ) { if ( a1 % b == 0 ) { break ; } a1 += iadqlqb ; } if ( iadqlqb % b == 0 ) { System . out . println ( b + " " + a1 ) ; } else { for ( i = b / 2 ; i > 0 ; i -- ) { if ( iadqlqb % i == 0 && b % i == 0 ) { break ; } } System . out . println ( i + " " + a1 ) ; } } else if ( iadqlqb < b ) { for ( ; ; ) { if ( b1 % iadqlqb == 0 ) { break ; } b1 += b ; } if ( b % iadqlqb == 0 ) { System . out . println ( iadqlqb + " " + b1 ) ; } else { for ( i = iadqlqb / 2 ; i > 0 ; i -- ) { if ( iadqlqb % i == 0 && b % i == 0 ) { break ; } } System . out . println ( i + " " + b1 ) ; } } else { System . out . println ( b + " " + b1 ) ; } } } } import java . util . Scanner ; public class Hjuwffs { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . nextLine ( ) ; char hjuwffs = S . charAt ( 0 ) ; System . out . println ( Character . isUpperCase ( hjuwffs ) ? " A " : " a " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Upmgacd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int upmgacd = sc . nextInt ( ) ; int su ; int num = 0 ; String mark ; Boolean [ ] s = new Boolean [ 52 ] ; Arrays . fill ( s , false ) ; for ( int i = 0 ; i < upmgacd ; i ++ ) { mark = sc . next ( ) ; su = sc . nextInt ( ) ; if ( mark . equals ( " S " ) ) num = 0 ; else if ( mark . equals ( " H " ) ) num = 13 ; else if ( mark . equals ( " C " ) ) num = 26 ; else if ( mark . equals ( " D " ) ) num = 39 ; s [ num + su - 1 ] = true ; } for ( int i = 0 ; i < 52 ; i ++ ) { if ( i < 13 && s [ i ] == false ) { System . out . println ( " S " + ( i + 1 ) ) ; } else if ( i < 26 && s [ i ] == false ) { System . out . println ( " H " + ( i - 12 ) ) ; } else if ( i < 39 && s [ i ] == false ) { System . out . println ( " C " + ( i - 25 ) ) ; } else if ( i < 52 && s [ i ] == false ) { System . out . println ( " D " + ( i - 38 ) ) ; } else continue ; } } } import java . io . * ; import java . util . * ; public class Plcvvjo { public static void main ( String [ ] args ) throws Exception { Scanner cin = new Scanner ( System . in ) ; int plcvvjo = cin . nextInt ( ) , b = cin . nextInt ( ) ; int c = plcvvjo * b ; if ( c % 2 == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Scanner ; public class Tkquca { public static void main ( String [ ] args ) { Scanner entrada = new Scanner ( System . in ) ; char tkquca = entrada . next ( ) . charAt ( 0 ) ; if ( Character . isUpperCase ( tkquca ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Spfxnfy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int spfxnfy = sc . nextInt ( ) ; String [ ] w = new String [ spfxnfy ] ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < spfxnfy ; i ++ ) { w [ i ] = sc . next ( ) ; set . add ( w [ i ] ) ; } for ( int i = 1 ; i < spfxnfy ; i ++ ) { if ( w [ i ] . charAt ( 0 ) != w [ i - 1 ] . charAt ( w [ i - 1 ] . length ( ) - 1 ) ) { System . out . println ( " No " ) ; return ; } } System . out . println ( ( set . size ( ) == spfxnfy ) ? " Yes " : " No " ) ; } } import java . util . * ; class Vnoofti { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vnoofti = Integer . parseInt ( sc . next ( ) ) ; String str = sc . next ( ) ; if ( vnoofti % 2 == 1 ) { System . out . println ( " No " ) ; return ; } else { String s_1 = str . substring ( 0 , vnoofti / 2 ) ; String s_2 = str . substring ( vnoofti / 2 , vnoofti ) ; if ( s_1 . equals ( s_2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } } import java . util . * ; public class Uzofsp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = String . valueOf ( sc . nextInt ( ) ) ; String rn = " " ; for ( int uzofsp = 0 ; uzofsp < 3 ; uzofsp ++ ) { if ( n . charAt ( uzofsp ) == '1' ) rn += " 9 " ; else rn += " 1 " ; } System . out . println ( Integer . valueOf ( rn ) ) ; } } import java . util . Scanner ; public class Wwbihrd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wwbihrd = sc . nextInt ( ) ; int min = sc . nextInt ( ) ; int ans = Integer . MIN_VALUE ; for ( int i = 0 ; i < wwbihrd - 1 ; i ++ ) { int input = sc . nextInt ( ) ; ans = Math . max ( input - min , ans ) ; min = Math . min ( input , min ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; class Pdpna { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int pdpna = 0 ; String b = stdIn . next ( ) ; char [ ] a = new char [ 4 ] ; for ( int j = 0 ; j < 4 ; j ++ ) { a [ j ] = b . charAt ( j ) ; } for ( int i = 0 ; i < 4 ; i ++ ) { if ( a [ i ] == '+' ) pdpna = pdpna + 1 ; else pdpna = pdpna - 1 ; } System . out . print ( pdpna ) ; } } import java . util . * ; import java . math . BigDecimal ; public class Fvipoi { public static void main ( String [ ] args ) { BigDecimal A , B ; Scanner sc = new Scanner ( System . in ) ; A = sc . nextBigDecimal ( ) ; B = new BigDecimal ( 2 ) . multiply ( A ) . multiply ( new BigDecimal ( 3.14159265359 ) ) ; System . out . println ( B ) ; } } import java . util . * ; public class Rtnrbl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rtnrbl = sc . nextInt ( ) ; int [ ] h = new int [ rtnrbl ] ; for ( int i = 0 ; i < rtnrbl ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int max = 1 ; for ( int i = 0 ; i < rtnrbl ; i ++ ) { if ( h [ i ] > max ) { max = h [ i ] ; } else if ( max - h [ i ] > 1 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Rjzcsw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] C = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; int rjzcsw = C . length ; int st = 0 ; for ( int i = 0 ; i < rjzcsw ; ++ i ) { if ( C [ i ] == 'A' ) { st = i ; break ; } } int gl = 0 ; for ( int i = rjzcsw - 1 ; i >= 0 ; -- i ) { if ( C [ i ] == 'Z' ) { gl = i ; break ; } } System . out . println ( gl - st + 1 ) ; } } import java . util . Scanner ; public class Znjxb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String znjxb = sc . next ( ) ; System . out . println ( znjxb . contains ( " 7 " ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class Snwuu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int snwuu = 0 ; int b = 0 ; int c = 0 ; int d = 0 ; int score = 0 ; String x = " " ; snwuu = sc . nextInt ( ) ; x = sc . next ( ) ; if ( x . length ( ) > snwuu ) { x = x . substring ( 0 , snwuu ) + " ... " ; } System . out . print ( x ) ; } } import java . util . * ; import java . io . * ; public class Qrqjvh { public static void main ( String [ ] args ) throws Exception { InputStreamReader r = new InputStreamReader ( System . in ) ; String S = nextString ( r ) ; int qrqjvh = S . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < qrqjvh / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( qrqjvh - i - 1 ) ) { ans ++ ; } } System . out . println ( ans ) ; } public static String nextString ( InputStreamReader r ) throws Exception { String str = " " ; while ( true ) { int c = r . read ( ) ; if ( c == 32 || c == 10 || c == - 1 ) { break ; } str += ( char ) c ; } return str ; } } import java . util . Scanner ; public class Vznao { static int keta ( int s ) { int vznao = 0 ; while ( s > 0 ) { vznao += ( s % 10 ) ; s /= 10 ; } return vznao ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) , A = sc . nextInt ( ) , B = sc . nextInt ( ) ; int [ ] keta = new int [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) keta [ i ] = keta ( i ) ; int vznao = 0 ; for ( int i = 1 ; i < N + 1 ; i ++ ) { if ( keta [ i ] >= A && keta [ i ] <= B ) vznao += i ; } System . out . println ( vznao ) ; } } import java . util . * ; public class Vupeb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String vupeb = sc . next ( ) ; if ( vupeb . matches ( " A[a-z]+C[a-z]+ " ) ) { System . out . println ( " AC " ) ; } else { System . out . println ( " WA " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Jsxsfwy { public static final int jsxsfwy = 200000 ; public static void main ( String [ ] args ) throws IOException { int [ ] Nums = new int [ jsxsfwy ] ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String n = br . readLine ( ) ; for ( int i = 0 ; i < Integer . parseInt ( n ) ; i ++ ) { Nums [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } int max = - 2000000000 ; int min = Nums [ 0 ] ; for ( int i = 1 ; i < Integer . parseInt ( n ) ; i ++ ) { max = Math . max ( max , Nums [ i ] - min ) ; min = Math . min ( min , Nums [ i ] ) ; } System . out . println ( max ) ; } } import java . util . * ; public class Xryvanb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xryvanb = sc . nextInt ( ) ; int max = 0 ; int result = 1 ; for ( int i = 1 ; i <= xryvanb ; i ++ ) { int tmp = i ; int cnt = 0 ; while ( true ) { if ( tmp % 2 != 0 ) { break ; } tmp = tmp / 2 ; cnt ++ ; } if ( cnt > max ) { max = cnt ; result = i ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class Xdxds { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xdxds = scan . nextInt ( ) ; String S = scan . next ( ) ; int x = S . length ( ) ; if ( x > xdxds ) { String ans = S . substring ( 0 , xdxds ) ; System . out . println ( ans + " ... " ) ; } else { System . out . println ( S ) ; } } } import java . util . * ; class Spliev { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int spliev = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; String s = String . valueOf ( spliev ) + String . valueOf ( b ) ; int c = Integer . parseInt ( s ) ; boolean isSqare = false ; for ( int i = 1 ; i <= 1000 ; i ++ ) { if ( i * i == c ) { System . out . println ( " Yes " ) ; isSqare = true ; break ; } } if ( ! isSqare ) System . out . println ( " No " ) ; } } import java . util . * ; public class Cazrps { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int cazrps = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= cazrps ; i ++ ) { int x = 1 ; int j = i ; while ( j < k ) { x *= 2 ; j *= 2 ; } x *= cazrps ; ans += ( double ) 1 / ( double ) x ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; class Ttvahpm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ttvahpm = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] m = new int [ ttvahpm ] ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < ttvahpm ; i ++ ) { m [ i ] = sc . nextInt ( ) ; x -= m [ i ] ; if ( min > m [ i ] ) { min = m [ i ] ; } } int count = m . length ; while ( x >= 0 ) { x -= min ; count ++ ; } System . out . println ( count - 1 ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Atenplz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int atenplz = sc . nextInt ( ) ; long [ ] A = new long [ atenplz ] ; for ( int i = 0 ; i < atenplz ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } sc . close ( ) ; long result = 0 ; for ( int i = 1 ; i < atenplz ; i ++ ) { if ( A [ i - 1 ] <= A [ i ] ) { } else { result = result + ( A [ i - 1 ] - A [ i ] ) ; A [ i ] = A [ i - 1 ] ; } } System . out . println ( result ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Lnelkzb { private final static String SPACE = " " ; public static void main ( String [ ] args ) { try { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String sStr ; while ( ( sStr = stdReader . readLine ( ) ) != null ) { String [ ] inputs = sStr . split ( " " ) ; int lnelkzb = Integer . valueOf ( inputs [ 0 ] ) ; int b = Integer . valueOf ( inputs [ 1 ] ) ; int c = Integer . valueOf ( inputs [ 2 ] ) ; int count = 0 ; if ( b < c ) { for ( int x = lnelkzb ; x <= b ; x ++ ) { if ( c % x == 0 ) { count ++ ; } } } else { for ( int x = lnelkzb ; x <= c ; x ++ ) { if ( c % x == 0 ) { count ++ ; } } } System . out . println ( count ) ; } stdReader . close ( ) ; } catch ( Exception e ) { System . exit ( - 1 ) ; } } } import java . util . * ; public class Pedmhm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] N = sc . next ( ) . toCharArray ( ) ; int pedmhm = 0 ; for ( int i = 0 ; i < N . length ; i ++ ) { pedmhm = ( pedmhm + Character . getNumericValue ( N [ i ] ) ) % 9 ; } if ( pedmhm % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . HashSet ; import java . util . Scanner ; public class Quirknz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int quirknz = sc . nextInt ( ) ; HashSet < Integer > A = new HashSet < > ( ) ; for ( int i = 0 ; i < quirknz ; i ++ ) { if ( ! A . add ( sc . nextInt ( ) ) ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Ylopvq { private static int ylopvq ( int aNum , int bNum , int cNum , int k ) { int ylopvq = 0 ; if ( k <= aNum ) { return k ; } else { ylopvq += aNum ; k -= aNum ; } if ( k <= bNum ) { return ylopvq ; } else { k -= bNum ; } return ylopvq + Math . min ( k , cNum ) * - 1 ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aNum = sc . nextInt ( ) , bNum = sc . nextInt ( ) , cNum = sc . nextInt ( ) , k = sc . nextInt ( ) ; System . out . println ( ylopvq ( aNum , bNum , cNum , k ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Lufcs { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long lufcs = scanner . nextLong ( ) ; long a = scanner . nextLong ( ) ; long b = scanner . nextLong ( ) ; long aa = lufcs % ( long ) ( ( long ) a + ( long ) b ) ; long as = ( long ) ( ( long ) lufcs / ( long ) ( ( long ) a + ( long ) b ) ) ; long ans = ( long ) ( ( long ) ( ( long ) as * ( long ) a ) + ( long ) Math . min ( ( long ) aa , ( long ) a ) ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; class Egfguj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int egfguj = 0 ; int hanako_score = 0 ; String taro_card ; String hanako_card ; int n = scan . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { taro_card = scan . next ( ) ; hanako_card = scan . next ( ) ; if ( taro_card . compareTo ( hanako_card ) > 0 ) { egfguj += 3 ; } else if ( taro_card . compareTo ( hanako_card ) == 0 ) { egfguj += 1 ; hanako_score += 1 ; } else { hanako_score += 3 ; } } System . out . println ( egfguj + " " + hanako_score ) ; } } import java . util . Scanner ; public class Gxduo { static class Gxduo { Integer [ ] [ ] dp ; public void find ( int k ) { dp = new Integer [ k + 1 ] [ k + 1 ] ; long gxduo = 0 ; for ( int a = 1 ; a <= k ; a ++ ) { for ( int b = 1 ; b <= k ; b ++ ) { for ( int c = 1 ; c <= k ; c ++ ) { int val = gcd ( b , c ) ; if ( dp [ b ] [ c ] == null ) { dp [ b ] [ c ] = val ; } int val2 = gcd ( a , val ) ; if ( dp [ a ] [ val ] == null ) { dp [ a ] [ val ] = val2 ; } gxduo += val2 ; } } } System . out . println ( gxduo ) ; } int gcd ( int a , int b ) { if ( dp [ a ] [ b ] != null ) { return dp [ a ] [ b ] ; } if ( a == 0 ) return b ; if ( b == 0 ) return a ; if ( a == b ) return a ; if ( a > b ) return gcd ( a - b , b ) ; return gcd ( a , b - a ) ; } } public static void main ( String [ ] args ) { Solution sol = new Solution ( ) ; Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; sol . find ( k ) ; } } import java . util . Scanner ; public class Ladhurj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ladhurj = sc . nextInt ( ) ; int cent = sc . nextInt ( ) ; int yes = 0 ; for ( int i = 0 ; i < ladhurj ; i ++ ) { int height = sc . nextInt ( ) ; if ( height >= cent ) { yes ++ ; } } System . out . print ( yes ) ; } } import java . util . * ; import java . io . * ; class Bdzfuh { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s ; int [ ] num = new int [ 26 ] ; char bdzfuh ; while ( ( s = br . readLine ( ) ) != null ) { if ( s . length ( ) >= 1200 ) break ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { bdzfuh = s . charAt ( j ) ; if ( bdzfuh >= 0x41 && bdzfuh <= 0x5a ) { bdzfuh -= 0x41 ; num [ bdzfuh ] += 1 ; } else if ( bdzfuh >= 0x61 && bdzfuh <= 0x7a ) { bdzfuh -= 0x61 ; num [ bdzfuh ] += 1 ; } } } for ( int i = 0 ; i < 26 ; i ++ ) { bdzfuh = ( char ) ( 0x61 + i ) ; System . out . println ( bdzfuh + " : " + num [ i ] ) ; } } } import java . util . Scanner ; public class Tcbelhb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tcbelhb = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( s . charAt ( tcbelhb ) != '-' ) { System . out . println ( " No " ) ; return ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i != tcbelhb ) { if ( s . charAt ( i ) < '0' || s . charAt ( i ) > '9' ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; return ; } } import java . util . Scanner ; public class Rojxyly { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rojxyly = sc . nextInt ( ) , m = sc . nextInt ( ) ; int k , a ; int [ ] [ ] food = new int [ rojxyly ] [ m + 1 ] ; for ( int i = 0 ; i < rojxyly ; ++ i ) { k = sc . nextInt ( ) ; for ( int j = 0 ; j < k ; ++ j ) { a = sc . nextInt ( ) ; food [ i ] [ a ] ++ ; } } sc . close ( ) ; int ans = 0 ; int j = 0 ; for ( int i = 1 ; i <= m ; ++ i ) { for ( j = 0 ; j < rojxyly ; ++ j ) { if ( food [ j ] [ i ] == 0 ) break ; } if ( j == rojxyly ) ++ ans ; } System . out . println ( ans ) ; } } import java . io . IOException ; import java . util . Scanner ; public class Nnmux { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int nnmux = sc . nextInt ( ) ; long a , b , c , d , e ; a = 2 ; b = sc . nextLong ( ) ; c = b ; d = b ; e = b ; while ( a <= nnmux ) { b = sc . nextLong ( ) ; c = c + b ; if ( b > d ) { d = b ; } else if ( b < e ) { e = b ; } a = a + 1 ; } System . out . println ( e + " " + d + " " + c ) ; } } import java . util . Scanner ; public class Nsggwl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long nsggwl = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = 0 ; int i = 1 ; while ( i <= b ) { if ( ( long ) nsggwl * i % b == 0 ) { c = ( long ) nsggwl * i ; break ; } else { i ++ ; } } System . out . println ( c ) ; sc . close ( ) ; } } import java . util . Scanner ; class Lyikjkn { public static void main ( String [ ] a ) { Scanner scanner = new Scanner ( System . in ) ; String input = scanner . nextLine ( ) ; scanner . close ( ) ; if ( input . length ( ) > 20 ) return ; String reverse = " " ; char [ ] c = input . toCharArray ( ) ; for ( int lyikjkn = c . length ; lyikjkn > 0 ; lyikjkn -- ) { reverse += c [ lyikjkn - 1 ] ; } System . out . println ( reverse ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Wrbuhq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Integer [ ] a = new Integer [ 10 ] ; for ( int wrbuhq = 0 ; wrbuhq < 10 ; wrbuhq ++ ) { a [ wrbuhq ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( a , Collections . reverseOrder ( ) ) ; for ( int wrbuhq = 0 ; wrbuhq < 3 ; wrbuhq ++ ) { System . out . println ( a [ wrbuhq ] ) ; } } } import java . util . Scanner ; public class Iuxuxn { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int iuxuxn = Integer . parseInt ( input . nextLine ( ) ) ; int W = Integer . parseInt ( input . nextLine ( ) ) ; int [ ] v = new int [ iuxuxn ] ; for ( int i = 0 ; i < iuxuxn ; i ++ ) v [ i ] = i ; for ( int i = 0 ; i < W ; i ++ ) { String [ ] s = input . nextLine ( ) . split ( " [,] " ) ; int a = Integer . parseInt ( s [ 0 ] ) - 1 ; int b = Integer . parseInt ( s [ 1 ] ) - 1 ; int tmp = v [ a ] ; v [ a ] = v [ b ] ; v [ b ] = tmp ; } for ( int i = 0 ; i < iuxuxn ; i ++ ) { System . out . println ( v [ i ] + 1 ) ; } System . exit ( 0 ) ; } } import java . util . Scanner ; public class Krhcb { static String str ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; str = sc . next ( ) ; int krhcb = str . length ( ) ; boolean [ ] dp = new boolean [ krhcb + 1 ] ; dp [ 0 ] = true ; for ( int i = 5 ; i <= krhcb ; i ++ ) { if ( str . substring ( i - 5 , i ) . equals ( " dream " ) ) { dp [ i ] |= dp [ i - 5 ] ; } if ( str . substring ( i - 5 , i ) . equals ( " erase " ) ) { dp [ i ] |= dp [ i - 5 ] ; } if ( i - 7 >= 0 && str . substring ( i - 7 , i ) . equals ( " dreamer " ) ) { dp [ i ] |= dp [ i - 7 ] ; } if ( i - 6 >= 0 && str . substring ( i - 6 , i ) . equals ( " eraser " ) ) { dp [ i ] |= dp [ i - 6 ] ; } } if ( dp [ krhcb ] ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class Imjtvh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long imjtvh = sc . nextLong ( ) ; int count = 1 ; long money = 100 ; while ( true ) { money *= 1.01 ; if ( money >= imjtvh ) { System . out . println ( count ) ; return ; } count ++ ; } } } import java . util . * ; public class Qtpdel { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str1 = sc . nextLine ( ) ; String str2 = sc . nextLine ( ) ; boolean qtpdel = false ; for ( int i = 0 ; i < str1 . length ( ) ; ++ i ) { String sufStr = str1 . substring ( str1 . length ( ) - i , str1 . length ( ) ) ; String preStr = str1 . substring ( 0 , str1 . length ( ) - i ) ; String compareStr = sufStr + preStr ; if ( compareStr . equals ( str2 ) ) qtpdel = true ; } if ( qtpdel ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Bxyhre { private static class Bxyhre { int bxyhre ; int to ; Range ( int bxyhre , int to ) { this . bxyhre = bxyhre ; this . to = to ; } } public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] xs = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { xs [ i ] = scanner . nextInt ( ) ; } int [ ] hs = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { hs [ i ] = 0 ; } int count = 0 ; while ( true ) { List < Range > ranges = new ArrayList < > ( ) ; Integer start = null ; boolean goal = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( xs [ i ] != hs [ i ] ) { goal = false ; if ( start == null ) { start = i ; } } else { if ( start != null ) { ranges . add ( new Range ( start , i ) ) ; start = null ; } } } if ( goal ) { System . out . println ( count ) ; return ; } if ( start != null ) { ranges . add ( new Range ( start , n ) ) ; } for ( Range range : ranges ) { for ( int i = range . bxyhre ; i < range . to ; i ++ ) { hs [ i ] += 1 ; } count ++ ; } } } } import java . util . * ; public class Ozqzxp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ozqzxp = sc . nextLong ( ) ; long bank = 100 ; long count = 0 ; for ( long i = bank ; i < ozqzxp ; bank += bank / 100 , count ++ ) { if ( bank >= ozqzxp ) { System . out . println ( count ) ; break ; } } } } import java . util . * ; public class Jykmyqa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jykmyqa = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int res = jykmyqa / b ; if ( res * b < jykmyqa ) { ++ res ; } System . out . println ( res ) ; } } import java . util . Scanner ; public class Czrjwyx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] [ ] [ ] houses = new int [ 4 ] [ 3 ] [ 10 ] ; int czrjwyx = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] [ ] a = new int [ czrjwyx ] [ m ] ; int [ ] b = new int [ m ] ; int [ ] c = new int [ czrjwyx ] ; for ( int i = 0 ; i < czrjwyx ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int element = scan . nextInt ( ) ; a [ i ] [ j ] = element ; } } for ( int i = 0 ; i < m ; i ++ ) { int element = scan . nextInt ( ) ; b [ i ] = element ; } for ( int i = 0 ; i < czrjwyx ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { c [ i ] += a [ i ] [ j ] * b [ j ] ; } System . out . println ( c [ i ] ) ; } } } import java . util . * ; public class Rupssdn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rupssdn = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] queue = new int [ rupssdn ] [ m ] ; int [ ] vector = new int [ m ] ; int [ ] vectorAns = new int [ rupssdn ] ; for ( int i = 0 ; i < queue . length ; i ++ ) { for ( int j = 0 ; j < queue [ i ] . length ; j ++ ) { queue [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < vector . length ; i ++ ) { vector [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < vectorAns . length ; i ++ ) { for ( int j = 0 ; j < queue [ i ] . length ; j ++ ) { vectorAns [ i ] += queue [ i ] [ j ] * vector [ j ] ; } } for ( int data : vectorAns ) { System . out . println ( data ) ; } } } import java . util . Scanner ; class Igdhsdg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int igdhsdg = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; double log ; log = Math . log10 ( igdhsdg ) / Math . log10 ( K ) ; int ans = ( int ) Math . floor ( log ) + 1 ; System . out . println ( ans ) ; } } import java . util . * ; public class Mjxlrw { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int mjxlrw = 5 ; int [ ] array = new int [ mjxlrw ] ; for ( int i = 0 ; i < mjxlrw ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int tmp = 0 ; int tmp2 = 10 - ( array [ 0 ] % 10 ) ; for ( int i = 0 ; i < mjxlrw ; i ++ ) { if ( array [ i ] % 10 == 0 ) continue ; if ( tmp2 < 10 - ( array [ i ] % 10 ) ) { tmp2 = 10 - ( array [ i ] % 10 ) ; tmp = i ; } } int count = 0 ; for ( int i = 0 ; i < mjxlrw ; i ++ ) { if ( tmp == i ) continue ; if ( array [ i ] % 10 != 0 ) { array [ i ] += 10 - ( array [ i ] % 10 ) ; } count += array [ i ] ; } count += array [ tmp ] ; System . out . println ( count ) ; } } import java . util . * ; class Emvsjm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . nextLine ( ) ; int emvsjm = 0 ; String t ; while ( ! ( ( t = sc . next ( ) ) . equals ( " END_OF_TEXT " ) ) ) { if ( t . toLowerCase ( ) . equals ( w ) ) emvsjm ++ ; } System . out . println ( emvsjm ) ; } } import java . io . * ; public class Hbatvq { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = reader . readLine ( ) . split ( " " ) ; int hbatvq = Integer . parseInt ( arr [ 0 ] ) ; int K = Integer . parseInt ( arr [ 1 ] ) ; int cnt = 1 ; while ( Math . pow ( K , cnt ) <= hbatvq ) cnt ++ ; System . out . println ( cnt ) ; } } import java . util . * ; public class Puiacex { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int puiacex = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; double a = sc . nextInt ( ) ; double min = 1000000 ; int ans = 0 ; int [ ] h = new int [ puiacex ] ; for ( int i = 0 ; i < puiacex ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < puiacex ; i ++ ) { double data = t - h [ i ] * 0.006 ; min = Math . min ( min , Math . abs ( a - data ) ) ; if ( min == Math . abs ( a - data ) ) { ans = i + 1 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Awsncb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int awsncb = scanner . nextInt ( ) ; int a = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int total = 0 ; for ( int i = 1 ; i <= awsncb ; i ++ ) { int one = i % 10 ; int ten = Math . floorDiv ( i % 100 , 10 ) ; int hundred = Math . floorDiv ( i % 1000 , 100 ) ; int thousand = Math . floorDiv ( i % 10000 , 1000 ) ; int man = ( i == 10000 ) ? 1 : 0 ; int sum = one + ten + hundred + thousand + man ; if ( a <= sum && sum <= b ) { total += i ; } } System . out . println ( total ) ; } } public class Gdletp { public void run ( java . io . InputStream in , java . io . PrintStream out ) { java . util . Scanner sc = new java . util . Scanner ( in ) ; int gdletp , x ; int i , j , k , count ; for ( ; ; ) { gdletp = sc . nextInt ( ) ; x = sc . nextInt ( ) ; if ( gdletp == 0 && x == 0 ) break ; count = 0 ; for ( i = 1 ; i <= gdletp ; i ++ ) { for ( j = i + 1 ; j <= gdletp ; j ++ ) { if ( x - i - j > j && x - i - j <= gdletp ) count ++ ; } } System . out . println ( count ) ; } sc . close ( ) ; } public static void main ( String [ ] args ) { ( new Main ( ) ) . run ( System . in , System . out ) ; } } import java . util . Scanner ; public class Nwogipf { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int nwogipf = s . nextInt ( ) ; int m = s . nextInt ( ) ; int i = 0 ; int j = 0 ; int count = 0 ; int [ ] ary1 = new int [ 2 * m ] ; for ( i = 0 ; i < 2 * m ; i ++ ) { ary1 [ i ] = s . nextInt ( ) ; } int [ ] ary = new int [ nwogipf ] ; for ( i = 0 ; i < nwogipf ; i ++ ) { count = 0 ; for ( j = 0 ; j < 2 * m ; j ++ ) { if ( ary1 [ j ] == i + 1 ) { count ++ ; } } ary [ i ] = count ; System . out . println ( ary [ i ] ) ; } } } import java . util . Scanner ; public class Kdxbesu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int [ ] x = new int [ 4 ] ; char [ ] y = new char [ 3 ] ; x [ 0 ] = Integer . parseInt ( s . substring ( 0 , 1 ) ) ; x [ 1 ] = Integer . parseInt ( s . substring ( 1 , 2 ) ) ; x [ 2 ] = Integer . parseInt ( s . substring ( 2 , 3 ) ) ; x [ 3 ] = Integer . parseInt ( s . substring ( 3 , 4 ) ) ; for ( int kdxbesu = 0 ; kdxbesu < 8 ; kdxbesu ++ ) { int sum = x [ 0 ] ; for ( int j = 0 ; j < 3 ; j ++ ) { if ( ( 1 & ( kdxbesu >> j ) ) == 1 ) { sum += x [ 3 - j ] ; y [ 2 - j ] = '+' ; } else { sum -= x [ 3 - j ] ; y [ 2 - j ] = '-' ; } } if ( sum == 7 ) { System . out . print ( x [ 0 ] ) ; System . out . print ( y [ 0 ] ) ; System . out . print ( x [ 1 ] ) ; System . out . print ( y [ 1 ] ) ; System . out . print ( x [ 2 ] ) ; System . out . print ( y [ 2 ] ) ; System . out . print ( x [ 3 ] ) ; System . out . print ( " =7 " ) ; return ; } } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Uiaertf { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BBounding solver = new BBounding ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Uiaertf { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long uiaertf = in . nextLong ( ) , x = in . nextLong ( ) ; long count = 1 , sum = 0 ; for ( long i = 1 ; i <= uiaertf ; i ++ ) { long y = in . nextLong ( ) ; sum += y ; if ( sum <= x ) count ++ ; } out . println ( count ) ; } } } import java . util . Scanner ; public class Kxzbkct { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kxzbkct = sc . nextInt ( ) ; int maxHigh = 0 ; int view = 0 ; for ( int i = 0 ; i < kxzbkct ; i ++ ) { int High = sc . nextInt ( ) ; if ( maxHigh <= High ) { maxHigh = High ; view ++ ; } } System . out . println ( view ) ; } } import java . util . * ; public class Bvrbr { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int bvrbr = s . nextInt ( ) ; int [ ] check = { 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; String ans = " No " ; if ( bvrbr >= 10 ) { for ( int i = 0 ; i < check . length ; i ++ ) { if ( bvrbr % check [ i ] == 0 && bvrbr / check [ i ] < 10 ) { ans = " Yes " ; break ; } } } else { ans = " Yes " ; } System . out . println ( ans ) ; } } import java . util . * ; public class Sfvzvw { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { int sfvzvw = sc . nextInt ( ) ; int [ ] arr = new int [ sfvzvw ] ; int [ ] check = new int [ sfvzvw ] ; for ( int i = 0 ; i < sfvzvw ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int res = 0 ; while ( ! Arrays . equals ( arr , check ) ) { int l = 0 ; int min = Integer . MAX_VALUE ; while ( l < sfvzvw && arr [ l ] == 0 ) { l ++ ; } int cp = l ; while ( l < sfvzvw && arr [ l ] != 0 ) { min = Math . min ( min , arr [ l ] ) ; l ++ ; } for ( int i = cp ; i < l ; i ++ ) { arr [ i ] -= min ; } res += min ; } System . out . println ( res ) ; } } import java . util . * ; import java . io . * ; public class Pakeq { public static void main ( String [ ] Args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int pakeq = s . length ( ) ; int flag = 0 ; for ( int i = 1 ; i <= pakeq ; i ++ ) { if ( i % 2 == 0 && s . charAt ( i - 1 ) == 'R' ) flag = 1 ; if ( i % 2 == 1 && s . charAt ( i - 1 ) == 'L' ) flag = 1 ; } if ( flag == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class Ytasu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ytasu = sc . nextLong ( ) ; int i = 2 ; while ( true ) { if ( i == ytasu ) { System . out . println ( i ) ; return ; } if ( ytasu % i == 0 ) { ytasu ++ ; i = 2 ; continue ; } else { i ++ ; } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Dpmpd { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int dpmpd = Integer . valueOf ( br . readLine ( ) ) ; int z = Integer . valueOf ( br . readLine ( ) ) ; if ( dpmpd == 1 ) { if ( z == 2 ) { System . out . print ( " 3 " ) ; } else if ( z == 3 ) { System . out . print ( " 2 " ) ; } } else if ( dpmpd == 2 ) { if ( z == 1 ) { System . out . print ( " 3 " ) ; } else if ( z == 3 ) { System . out . print ( " 1 " ) ; } } else if ( dpmpd == 3 ) { if ( z == 1 ) { System . out . print ( " 2 " ) ; } else if ( z == 2 ) { System . out . print ( " 1 " ) ; } } } } import java . util . Scanner ; public class Awrnyg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int awrnyg , col ; int [ ] matrix ; awrnyg = scanner . nextInt ( ) ; col = scanner . nextInt ( ) ; matrix = new int [ col ] ; int in , sum ; for ( int rowi = 0 ; rowi < awrnyg ; rowi ++ ) { sum = 0 ; for ( int coli = 0 ; coli < col ; coli ++ ) { in = scanner . nextInt ( ) ; matrix [ coli ] += in ; sum += in ; System . out . print ( in + " " ) ; } System . out . println ( sum ) ; } sum = 0 ; for ( int i : matrix ) { sum += i ; System . out . print ( i + " " ) ; } System . out . println ( sum ) ; scanner . close ( ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; class Lwoch { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; char lwoch = in . next ( ) . charAt ( 0 ) ; int integerInput = lwoch ; integerInput ++ ; char output = ( char ) integerInput ; System . out . print ( output ) ; } } import java . util . * ; import java . util . ArrayList ; import java . util . List ; import java . util . Arrays ; public class Baqez { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int baqez = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int ans = 0 ; while ( baqez > 0 ) { baqez = baqez - a ; ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; public class Rratk { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int rratk = sc . nextInt ( ) ; int [ ] a = new int [ rratk ] ; for ( int i = 0 ; i < rratk ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int count = 0 ; boolean flg = true ; while ( flg ) { for ( int i = 0 ; i < rratk ; i ++ ) { if ( a [ i ] % 2 == 0 ) { a [ i ] /= 2 ; if ( i == rratk - 1 ) count ++ ; } else { flg = false ; break ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Piswtk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int piswtk = sc . nextInt ( ) ; int z = 0 ; if ( piswtk % 2 == 0 ) { z = piswtk / 2 ; } else { z = piswtk / 2 + 1 ; } System . out . print ( z ) ; } } import java . io . IOException ; import java . util . Scanner ; public class Hgtyu { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int hgtyu = 1 ; int i = 0 ; while ( true ) { hgtyu = sc . nextInt ( ) ; i ++ ; if ( hgtyu == 0 ) { break ; } System . out . println ( " Case " + i + " : " + hgtyu ) ; } } } import java . util . * ; public class Mtorgs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mtorgs = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] p = s . toCharArray ( ) ; int flag = 0 ; for ( int i = 0 ; i < mtorgs ; i ++ ) { if ( p [ i ] < '0' || p [ i ] > '9' ) { flag = 1 ; } } if ( p [ mtorgs ] != '-' ) { flag = 1 ; } for ( int i = mtorgs + 1 ; i <= mtorgs + b ; i ++ ) { if ( p [ i ] < '0' || p [ i ] > '9' ) { flag = 1 ; } } if ( flag == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class Qqfnans { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qqfnans = sc . nextInt ( ) ; int X2 = sc . nextInt ( ) ; int X3 = sc . nextInt ( ) ; int X4 = sc . nextInt ( ) ; int X5 = sc . nextInt ( ) ; if ( qqfnans == 0 ) { System . out . println ( " 1 " ) ; } else if ( X2 == 0 ) { System . out . println ( " 2 " ) ; } else if ( X3 == 0 ) { System . out . println ( " 3 " ) ; } else if ( X4 == 0 ) { System . out . println ( " 4 " ) ; } else { System . out . println ( " 5 " ) ; } } } import java . util . Scanner ; public class Iruojgq { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int iruojgq = s . nextInt ( ) ; int B = s . nextInt ( ) ; if ( 0 < iruojgq && iruojgq < 10 && 0 < B && B < 10 ) { System . out . println ( iruojgq * B ) ; } else { System . out . println ( - 1 ) ; } s . close ( ) ; } } import java . util . * ; public class Vfrnvjj { public static void main ( String [ ] args ) { int vfrnvjj = 0 ; Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int m = Integer . parseInt ( sc . next ( ) ) ; int totalConbination = ( n + m ) * ( n + m - 1 ) / 2 ; int oddConbination = n * m ; System . out . println ( totalConbination - oddConbination ) ; } } import java . util . * ; class Kxcac { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double kxcac = sc . nextDouble ( ) ; double calc1 = Math . pow ( kxcac , 2 ) ; double calc2 = Math . pow ( kxcac , 3 ) ; System . out . println ( ( int ) kxcac + ( int ) calc1 + ( int ) calc2 ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Czgpx { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int czgpx = in . nextInt ( ) ; int t = in . nextInt ( ) ; int s = in . nextInt ( ) ; if ( t * s < czgpx ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . * ; public class Mxetdd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mxetdd = sc . nextInt ( ) ; boolean [ ] b = new boolean [ 1000001 ] ; b [ mxetdd ] = true ; int i = 2 ; while ( true ) { if ( mxetdd % 2 == 0 ) { mxetdd /= 2 ; } else { mxetdd = mxetdd * 3 + 1 ; } if ( b [ mxetdd ] ) { break ; } else { b [ mxetdd ] = true ; } i ++ ; } System . out . println ( i ) ; } } import java . util . HashSet ; import java . util . Scanner ; class Fttpcfa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fttpcfa = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int d ; int count = 0 ; HashSet hs = new HashSet ( ) ; while ( k -- > 0 ) { d = sc . nextInt ( ) ; for ( int i = 0 ; i < d ; i ++ ) { hs . add ( sc . nextInt ( ) ) ; } } System . out . println ( fttpcfa - hs . size ( ) ) ; } } import java . util . * ; public class Wmcxed { public static void main ( String [ ] args ) { int wmcxed ; double tSurf , tA ; Scanner sc = new Scanner ( System . in ) ; wmcxed = sc . nextInt ( ) ; tSurf = sc . nextDouble ( ) ; tA = sc . nextDouble ( ) ; double [ ] ts = new double [ wmcxed ] ; int result = 1 ; double min = 0 ; for ( int i = 0 ; i < wmcxed ; i ++ ) { ts [ i ] = tSurf - sc . nextInt ( ) * 0.006 ; if ( i == 0 ) { min = Math . abs ( tA - ts [ 0 ] ) ; continue ; } if ( Math . abs ( tA - ts [ i ] ) < min ) { min = Math . abs ( tA - ts [ i ] ) ; result = i + 1 ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class Ywjchd { public static void main ( String [ ] args ) { Scanner sc = null ; try { sc = new Scanner ( System . in ) ; int ywjchd = Integer . parseInt ( sc . nextLine ( ) ) ; int [ ] numBox = new int [ ywjchd ] ; String line = sc . nextLine ( ) ; String [ ] list = line . split ( " " ) ; for ( int i = 0 ; i < numBox . length ; i ++ ) { numBox [ i ] = Integer . parseInt ( list [ i ] ) ; } for ( int i2 = 0 ; i2 < numBox . length ; i2 ++ ) { int work = numBox [ i2 ] ; int j = i2 - 1 ; while ( j >= 0 && numBox [ j ] > work ) { numBox [ j + 1 ] = numBox [ j ] ; j -- ; } numBox [ j + 1 ] = work ; for ( int i = 0 ; i < numBox . length ; i ++ ) { System . out . print ( numBox [ i ] ) ; if ( i != numBox . length - 1 ) { System . out . print ( " " ) ; } } System . out . println ( " " ) ; } } catch ( NumberFormatException e ) { System . out . println ( e ) ; } finally { if ( sc != null ) { sc . close ( ) ; } } } } import java . util . Scanner ; class Uktplvs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] x = new int [ 100000 ] , y = new int [ 100000 ] ; int uktplvs = 0 , a ; while ( true ) { x [ uktplvs ] = sc . nextInt ( ) ; y [ uktplvs ] = sc . nextInt ( ) ; if ( x [ uktplvs ] == 0 && y [ uktplvs ] == 0 ) break ; if ( x [ uktplvs ] > y [ uktplvs ] ) { a = x [ uktplvs ] ; x [ uktplvs ] = y [ uktplvs ] ; y [ uktplvs ] = a ; } uktplvs ++ ; } for ( int j = 0 ; j < uktplvs ; j ++ ) { System . out . println ( x [ j ] + " " + y [ j ] ) ; } } } import java . util . Scanner ; public class Ablcf { public static void main ( String [ ] argc ) { Scanner sc = new Scanner ( System . in ) ; int ablcf = sc . nextInt ( ) ; int [ ] A = new int [ ablcf ] ; for ( int i = 0 ; i < ablcf ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int j = 0 ; j < ablcf ; j ++ ) { int min = j ; for ( int k = j ; k < ablcf ; k ++ ) { if ( A [ k ] < A [ min ] ) { min = k ; } } if ( j == min ) { int x = A [ min ] ; A [ min ] = A [ j ] ; A [ j ] = x ; } else { int x = A [ min ] ; A [ min ] = A [ j ] ; A [ j ] = x ; count ++ ; } } for ( int m = 0 ; m < ablcf ; m ++ ) { if ( m == ablcf - 1 ) { System . out . printf ( " %d " , A [ m ] ) ; } else { System . out . printf ( " %d " , A [ m ] ) ; } } System . out . printf ( " \n " ) ; System . out . println ( count ) ; } } import java . util . Scanner ; public class Awjus { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int awjus = scan . nextInt ( ) ; int num = scan . nextInt ( ) ; int C = scan . nextInt ( ) ; int [ ] B = new int [ num ] ; for ( int i = 0 ; i < B . length ; i ++ ) { B [ i ] = scan . nextInt ( ) ; } int [ ] [ ] A = new int [ awjus ] [ num ] ; for ( int i = 0 ; i < awjus ; i ++ ) { for ( int j = 0 ; j < num ; j ++ ) { A [ i ] [ j ] = scan . nextInt ( ) ; } } int sum = 0 ; int count = 0 ; for ( int i = 0 ; i < A . length ; i ++ ) { for ( int j = 0 ; j < num ; j ++ ) { sum += B [ j ] * A [ i ] [ j ] ; } if ( sum + C > 0 ) { count ++ ; } sum = 0 ; } System . out . println ( count ) ; scan . close ( ) ; } } import java . util . Map . Entry ; import java . util . * ; import java . math . * ; import org . w3c . dom . css . Counter ; public class Gxcgkkg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String gxcgkkg = sc . next ( ) ; HashMap < String , String > map = new HashMap < > ( ) ; map . put ( " ARC " , " ABC " ) ; map . put ( " ABC " , " ARC " ) ; System . out . println ( map . get ( gxcgkkg ) ) ; } } import java . util . Scanner ; public class Hwfodqt { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int hwfodqt = stdIn . nextInt ( ) ; int q = stdIn . nextInt ( ) ; int r = stdIn . nextInt ( ) ; int a = hwfodqt + q ; int b = q + r ; int c = hwfodqt + r ; int min = Integer . MAX_VALUE ; min = Math . min ( a , b ) ; min = Math . min ( min , c ) ; System . out . println ( min ) ; } } import java . util . ArrayDeque ; import java . util . Deque ; import java . util . Scanner ; public class Iupjsnf { public static void main ( String [ ] args ) { int iupjsnf , q , t ; int t_sum = 0 ; String pros ; Deque < String > name = new ArrayDeque < > ( ) ; Deque < Integer > time = new ArrayDeque < > ( ) ; Scanner sc = new Scanner ( System . in ) ; iupjsnf = sc . nextInt ( ) ; q = sc . nextInt ( ) ; for ( int i = 0 ; i < iupjsnf ; i ++ ) { name . offerLast ( sc . next ( ) ) ; time . offerLast ( sc . nextInt ( ) ) ; } while ( time . size ( ) != 0 ) { t = time . poll ( ) ; if ( t <= q ) { t_sum += t ; pros = name . poll ( ) ; System . out . println ( pros + " " + t_sum ) ; } else { t_sum += q ; time . offerLast ( t - q ) ; name . offerLast ( name . poll ( ) ) ; } } } } import java . util . * ; public class Mdxlh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mdxlh = sc . nextInt ( ) , f = 1 ; int [ ] a = new int [ mdxlh ] ; for ( int i = 0 ; i < mdxlh ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( a [ i ] % 2 == 0 ) { if ( a [ i ] % 3 == 0 || a [ i ] % 5 == 0 ) { } else { f = 0 ; break ; } } } if ( f == 0 ) { System . out . print ( " DENIED " ) ; } else { System . out . print ( " APPROVED " ) ; } } } import java . util . Scanner ; public class Zlmqdvv { public static void main ( String [ ] args ) { char [ ] ch = " abcdefghijklmnopqrstuvwxyz " . toCharArray ( ) ; Scanner scan = new Scanner ( System . in ) ; long zlmqdvv = scan . nextLong ( ) ; StringBuilder sb = new StringBuilder ( ) ; int t ; for ( ; zlmqdvv > 0 ; zlmqdvv = ( zlmqdvv - 1 ) / 26 ) { t = ( int ) ( ( zlmqdvv - 1 ) % 26 ) ; sb . append ( ch [ t ] ) ; } System . out . println ( sb . reverse ( ) . toString ( ) ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Clnqplb { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int clnqplb = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int b = Integer . parseInt ( tokenizer . nextToken ( ) ) ; String word = input . readLine ( ) ; int size = 0 ; boolean correct = true ; boolean foundMinuse = false ; for ( int i = 0 ; i < word . length ( ) ; i ++ ) { if ( Character . isDigit ( word . charAt ( i ) ) ) { size ++ ; } else { if ( size != clnqplb ) { correct = false ; break ; } size = 0 ; foundMinuse = true ; } } if ( foundMinuse && size == b ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Oqajit { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oqajit = sc . nextInt ( ) ; int [ ] a = new int [ oqajit + 1 ] ; for ( int i = 1 ; i <= oqajit ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int count = 0 ; boolean [ ] flag = new boolean [ oqajit + 1 ] ; int pos = 1 ; while ( pos != 2 && ! flag [ pos ] ) { flag [ pos ] = true ; pos = a [ pos ] ; count ++ ; } if ( pos == 2 ) { System . out . println ( count ) ; } else { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; public class Vmpknyr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long vmpknyr = sc . nextLong ( ) ; long val = log2 ( vmpknyr ) ; long dd = ( long ) Math . pow ( 2 , val + 1 ) ; System . out . println ( ( long ) dd - 1 ) ; } public static int log2 ( long x ) { return ( int ) ( Math . log ( x ) / Math . log ( 2 ) ) ; } } import java . util . * ; import java . util . stream . * ; public class Ypgkcco { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ypgkcco = sc . nextLong ( ) ; long ans = 1 ; long count = 1 ; while ( ypgkcco > 1 ) { ypgkcco = ypgkcco / 2 ; ans += Math . pow ( 2 , count ) ; count ++ ; } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; class Depsah { public static void main ( String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; String depsah ; depsah = sc . next ( ) ; solve ( depsah ) ; } static void solve ( String depsah ) { System . out . println ( calc ( depsah ) ) ; } static int calc ( String depsah ) { switch ( depsah ) { case " SUN " : return 7 ; case " MON " : return 6 ; case " TUE " : return 5 ; case " WED " : return 4 ; case " THU " : return 3 ; case " FRI " : return 2 ; case " SAT " : return 1 ; } return 0 ; } } import java . io . * ; import java . util . * ; import java . util . Map . Entry ; import java . util . stream . Collectors ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Aghoqz { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out . println ( ( int ) ceil ( ( Double . parseDouble ( br . readLine ( ) ) ) / 2 ) ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class Lrnlhs { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int lrnlhs = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 1 ] ) ; int c = Integer . parseInt ( str [ 2 ] ) ; int d = Integer . parseInt ( str [ 3 ] ) ; boolean flg = true ; for ( ; flg == true ; ) { c = c - b ; if ( c <= 0 ) { System . out . println ( " Yes " ) ; flg = false ; break ; } lrnlhs = lrnlhs - d ; if ( lrnlhs <= 0 ) { System . out . println ( " No " ) ; flg = false ; } } } } import java . util . * ; public class Kpyhzj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String kpyhzj = sc . next ( ) ; if ( kpyhzj . equals ( " AAA " ) ) { System . out . println ( " No " ) ; } else if ( kpyhzj . equals ( " BBB " ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class Zszxc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long zszxc = sc . nextLong ( ) ; int ans = ( int ) Math . log10 ( zszxc ) + 1 ; for ( int i = 1 ; i <= Math . sqrt ( zszxc ) ; i ++ ) { if ( zszxc % i == 0 ) ans = ( int ) Math . min ( ans , Math . log10 ( zszxc / i ) + 1 ) ; } System . out . println ( ans ) ; } } import java . io . * ; public class Yqoamsu { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { int yqoamsu , sum = 0 ; try { String line = reader . readLine ( ) ; if ( line . equals ( " 0 " ) ) break ; for ( yqoamsu = 0 ; yqoamsu < line . length ( ) ; yqoamsu ++ ) { char c = line . charAt ( yqoamsu ) ; sum += Character . getNumericValue ( c ) ; } } catch ( IOException e ) { System . out . println ( e ) ; } System . out . println ( sum ) ; } } } import java . util . Scanner ; public class Iyninez { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iyninez = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int count = 0 ; int n = 0 ; for ( int i = Math . max ( iyninez , b ) ; i >= 1 ; i -- ) { if ( iyninez % i == 0 && b % i == 0 ) { count ++ ; n = i ; if ( count >= k ) break ; } } System . out . println ( n ) ; } } import java . util . Scanner ; public class Hiljp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hiljp = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ hiljp ] ; long [ ] dp = new long [ hiljp ] ; for ( int i = 0 ; i < hiljp ; i ++ ) { h [ i ] = sc . nextInt ( ) ; dp [ i ] = 9223372036854775807l ; } dp [ 0 ] = 0 ; for ( int i = 1 ; i < hiljp ; i ++ ) { for ( int m = 1 ; m < k + 1 ; m ++ ) { if ( i >= m ) dp [ i ] = Math . min ( dp [ i ] , dp [ i - m ] + Math . abs ( h [ i ] - h [ i - m ] ) ) ; } } System . out . println ( dp [ hiljp - 1 ] ) ; } } import java . util . * ; public class Enwce { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; List < Integer > listN = new ArrayList < Integer > ( ) ; List < Integer > listX = new ArrayList < Integer > ( ) ; for ( ; ; ) { int enwce = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; if ( ( enwce == 0 ) && ( x == 0 ) ) { break ; } listN . add ( enwce ) ; listX . add ( x ) ; } for ( int i = 0 ; i < listN . size ( ) ; i ++ ) { int enwce = listN . get ( i ) ; int x = listX . get ( i ) ; int cnt = 0 ; for ( int a = 1 ; a <= enwce ; a ++ ) { for ( int b = a + 1 ; b <= enwce ; b ++ ) { for ( int c = b + 1 ; c <= enwce ; c ++ ) { int sum = a + b + c ; if ( sum == x ) { cnt ++ ; } } } } System . out . println ( cnt ) ; } } } import java . util . * ; public class Ppqgta { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Long N = sc . nextLong ( ) ; int ppqgta = ( int ) Math . floor ( Math . sqrt ( ( double ) N ) ) ; for ( int i = ppqgta ; i > 0 ; i -- ) { if ( N % i == 0 ) { if ( i > ( N / i ) ) { System . out . println ( String . valueOf ( i ) . length ( ) ) ; return ; } else { Long ans = ( long ) ( N / i ) ; System . out . println ( String . valueOf ( ans ) . length ( ) ) ; return ; } } } System . out . println ( String . valueOf ( N ) . length ( ) ) ; } } import java . util . * ; public class Macgkwx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long macgkwx = scan . nextLong ( ) , m = scan . nextLong ( ) ; for ( int i = 0 ; i < m ; i ++ ) { macgkwx -= scan . nextLong ( ) ; if ( macgkwx < 0 ) { System . out . println ( - 1 ) ; scan . close ( ) ; return ; } } System . out . println ( macgkwx ) ; scan . close ( ) ; return ; } } import java . util . Scanner ; public class Nenshc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nenshc = sc . nextInt ( ) ; int [ ] [ ] D = new int [ nenshc ] [ 2 ] ; for ( int i = 0 ; i < D . length ; i ++ ) { D [ i ] [ 0 ] = sc . nextInt ( ) ; D [ i ] [ 1 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < D . length - 2 ; i ++ ) { if ( D [ i ] [ 0 ] == D [ i ] [ 1 ] && D [ i + 1 ] [ 0 ] == D [ i + 1 ] [ 1 ] && D [ i + 2 ] [ 0 ] == D [ i + 2 ] [ 1 ] ) { System . out . print ( " Yes " ) ; return ; } } System . out . print ( " No " ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class Vvcul { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int vvcul = scanner . nextInt ( ) ; final int k = scanner . nextInt ( ) ; double result = 0 ; for ( int i = 1 ; i <= vvcul ; i ++ ) { final double a = Math . log ( k ) / Math . log ( 2 ) ; final double b = Math . log ( i ) / Math . log ( 2 ) ; double ceil = Math . ceil ( a - b ) ; if ( ceil < 0 ) { ceil = 0 ; } final double pow = Math . pow ( 0.5 , ceil ) ; result += pow ; } System . out . println ( result / vvcul ) ; } } import java . util . * ; import java . io . * ; public class Plgpkc { public static void main ( String [ ] args ) throws Exception { FastScanner fs = new FastScanner ( ) ; int plgpkc = fs . nextInt ( ) ; if ( plgpkc == 0 ) System . out . println ( 1 ) ; else System . out . println ( 0 ) ; } static class Plgpkc { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] readArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . util . Scanner ; public class Joqpu { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int joqpu = stdIn . nextInt ( ) ; int t = stdIn . nextInt ( ) ; int s = stdIn . nextInt ( ) ; if ( joqpu <= t * s ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Gybhhyl { public static void main ( String [ ] Args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = new String [ 3 ] ; for ( int gybhhyl = 0 ; gybhhyl < 3 ; gybhhyl ++ ) { s [ gybhhyl ] = sc . next ( ) ; } int p = 0 ; while ( s [ p ] . length ( ) != 0 ) { int np = s [ p ] . charAt ( 0 ) - 'a' ; s [ p ] = s [ p ] . substring ( 1 , s [ p ] . length ( ) ) ; p = np ; } System . out . println ( ( char ) ( 'A' + p ) ) ; } } import java . util . * ; public class Aazmr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int aazmr = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int tax8pricemin = ( int ) ( ( ( double ) aazmr ) / 0.08 ) ; int tax8pricemax = ( int ) ( ( ( double ) aazmr + 1 ) / 0.08 ) ; for ( int i = tax8pricemin ; i < tax8pricemax ; i ++ ) { int tax8 = ( int ) ( i * 0.08 ) ; int tax10 = ( int ) ( i * 0.1 ) ; if ( tax8 == aazmr && tax10 == b ) { System . out . println ( i ) ; System . exit ( 0 ) ; } } System . out . println ( - 1 ) ; } } import java . util . Scanner ; public class Pbwff { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pbwff = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int count = 0 ; while ( true ) { if ( ( pbwff - 1 ) * count + 1 >= B ) { break ; } count += 1 ; } System . out . println ( count ) ; } } import java . math . BigInteger ; import java . util . Scanner ; public class Gzjduhm { public static void main ( String [ ] args ) { BigInteger MAX = new BigInteger ( " 1000000000000000000 " ) ; Scanner sc = new Scanner ( System . in ) ; int gzjduhm = sc . nextInt ( ) ; BigInteger [ ] s = new BigInteger [ gzjduhm ] ; BigInteger ans = BigInteger . ONE ; for ( int i = 0 ; i < gzjduhm ; i ++ ) { s [ i ] = sc . nextBigInteger ( ) ; if ( s [ i ] . compareTo ( BigInteger . ZERO ) == 0 ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } } for ( int i = 0 ; i < gzjduhm ; i ++ ) { ans = ans . multiply ( s [ i ] ) ; if ( ans . compareTo ( MAX ) == 1 ) { System . out . println ( - 1 ) ; System . exit ( 0 ) ; } } System . out . println ( ans ) ; } } import java . util . * ; public class Bkdeeut { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char bkdeeut ; char [ ] ch = { 'A' , 'C' , 'G' , 'T' } ; int count = 0 ; int count_max = 0 ; boolean con ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { bkdeeut = s . charAt ( i ) ; con = true ; count ++ ; for ( int j = 0 ; j < 4 && con ; j ++ ) { if ( bkdeeut == ch [ j ] ) con = false ; } if ( con ) count = 0 ; if ( count > count_max ) count_max = count ; } System . out . println ( count_max ) ; } } import java . util . Scanner ; public class Jvwammz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long jvwammz = sc . nextLong ( ) ; for ( int i = 0 ; i < Math . min ( jvwammz , s . length ( ) ) ; i ++ ) { if ( s . charAt ( i ) != '1' ) { System . out . println ( s . charAt ( i ) ) ; return ; } } System . out . println ( 1 ) ; } } import java . util . Scanner ; public class Nzsuou { public static int func ( int n ) { int nzsuou = 0 ; if ( n % 2 == 0 ) { nzsuou = n / 2 ; } else if ( n % 2 == 1 ) { nzsuou = 3 * n + 1 ; } return nzsuou ; } public static void main ( String [ ] args ) { int ans = 0 ; int [ ] a = new int [ 1000000 ] ; Scanner sc = new Scanner ( System . in ) ; int s = sc . nextInt ( ) ; a [ 0 ] = s ; for ( int i = 1 ; i < a . length ; i ++ ) { a [ i ] = func ( a [ i - 1 ] ) ; for ( int j = 0 ; j < i ; j ++ ) { if ( a [ i ] == a [ j ] ) { ans = i + 1 ; break ; } } if ( ans != 0 ) break ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; import java . io . * ; import static java . lang . Character . isUpperCase ; public class Xroodo { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int xroodo = in . nextInt ( ) ; int K = in . nextInt ( ) ; int [ ] h = new int [ xroodo ] ; int count = 0 ; for ( int i = 0 ; i < xroodo ; i ++ ) { h [ i ] = in . nextInt ( ) ; if ( h [ i ] >= K ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; class Qprfav { static PrintStream out = System . out ; static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int qprfav = in . nextInt ( ) ; int i = 1 ; do { int x = i ; if ( x % 3 == 0 ) { out . print ( " " + i ) ; } else { do { if ( x % 10 == 3 ) { out . print ( " " + i ) ; break ; } x /= 10 ; } while ( x != 0 ) ; } } while ( ++ i <= qprfav ) ; out . println ( ) ; } } import java . util . Scanner ; public class Aovet { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str1 = sc . next ( ) ; String str2 = " 7 " ; int aovet = str1 . indexOf ( str2 ) ; if ( aovet != - 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Xgygjce { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int xgygjce = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int H = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; double angle = Math . abs ( 360.0 * H / 12.0 - 360.0 * M / 60.0 + 30.0 * M / 60.0 ) ; double length = Math . sqrt ( Math . pow ( xgygjce , 2 ) + Math . pow ( B , 2 ) - 2 * xgygjce * B * Math . cos ( Math . toRadians ( angle ) ) ) ; System . out . println ( length ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; public class Spmyuh { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; C solver = new C ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Spmyuh { int spmyuh ; int M ; boolean [ ] a ; int mod = ( int ) ( 1e9 + 7 ) ; public void solve ( int testNumber , Scanner in , PrintWriter out ) { spmyuh = in . nextInt ( ) ; M = in . nextInt ( ) ; a = new boolean [ spmyuh + 1 ] ; Arrays . fill ( a , true ) ; for ( int i = 0 ; i < M ; i ++ ) { a [ in . nextInt ( ) ] = false ; } int [ ] dp = new int [ spmyuh + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i <= spmyuh ; i ++ ) { if ( a [ i ] ) { dp [ i ] = dp [ i - 1 ] ; if ( i - 2 >= 0 ) { dp [ i ] += dp [ i - 2 ] ; } dp [ i ] %= mod ; } } out . println ( dp [ spmyuh ] ) ; } } } import java . util . Scanner ; import java . util . regex . * ; import java . math . * ; public class Mjfage { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mjfage = sc . nextInt ( ) ; int [ ] [ ] nums = new int [ 25 ] [ 15 ] ; for ( int i = 0 ; i < 25 ; i ++ ) { for ( int j = 0 ; j < 15 ; j ++ ) { nums [ i ] [ j ] = 4 * i + 7 * j ; } } boolean x = false ; yy : for ( int i = 0 ; i < 25 ; i ++ ) { for ( int j = 0 ; j < 15 ; j ++ ) { if ( mjfage == nums [ i ] [ j ] ) { x = true ; break yy ; } } } if ( x ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Tenhsma { static class Tenhsma { 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 ; } } public static void main ( String [ ] args ) { FastReader obj = new FastReader ( ) ; String s1 = obj . next ( ) , s2 = obj . next ( ) ; int tenhsma = obj . nextInt ( ) , sn2 = obj . nextInt ( ) ; String t = obj . next ( ) ; if ( t . equals ( s1 ) ) tenhsma -- ; else sn2 -- ; System . out . println ( tenhsma + " " + sn2 ) ; } } import java . util . Scanner ; class Crvrf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int crvrf , X ; crvrf = sc . nextInt ( ) ; X = sc . nextInt ( ) ; int count = X - crvrf + 1 ; for ( int i = 0 ; i < ( 2 * crvrf ) - 1 ; i ++ , count ++ ) System . out . print ( count + " " ) ; System . out . println ( ) ; } } import java . util . Scanner ; public class Ocwnmsa { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int ocwnmsa = sc . nextInt ( ) ; while ( true ) { if ( prime ( ocwnmsa ) ) { break ; } ocwnmsa ++ ; } System . out . println ( ocwnmsa ) ; sc . close ( ) ; } private boolean prime ( int ocwnmsa ) { if ( ocwnmsa == 0 || ocwnmsa == 1 ) { return false ; } if ( ocwnmsa == 2 ) return true ; if ( ocwnmsa % 2 == 0 ) return false ; for ( int i = 3 ; i * i <= ocwnmsa ; i += 2 ) { if ( ocwnmsa % i == 0 ) { return false ; } } return true ; } } import java . util . Scanner ; public class Pongnlh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; sc . close ( ) ; int pongnlh = ( int ) 'A' - ( int ) 'a' ; for ( char moji : input . toCharArray ( ) ) { if ( 'a' <= moji && moji <= 'z' ) { System . out . print ( ( char ) ( ( int ) moji + pongnlh ) ) ; } else if ( 'A' <= moji && moji <= 'Z' ) { System . out . print ( ( char ) ( ( int ) moji - pongnlh ) ) ; } else { System . out . print ( moji ) ; } } System . out . println ( ) ; } } import java . util . Scanner ; public class Ynkfo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ynkfo = scan . nextInt ( ) ; int min = 0 ; int max = 0 ; long amount = 0 ; for ( int i = 0 ; i < ynkfo ; i ++ ) { int x = scan . nextInt ( ) ; if ( i == 0 ) { min = x ; max = x ; amount = x ; } else { if ( x < min ) { min = x ; } else if ( x > max ) { max = x ; } amount = amount + x ; } } System . out . println ( min + " " + max + " " + amount ) ; } } import java . util . * ; import java . io . * ; public class Krnem { public static void main ( String ... args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String password = null ; try { password = br . readLine ( ) ; br . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } System . out . println ( isDifficultToInput ( password ) ? " Bad " : " Good " ) ; } private static boolean isDifficultToInput ( String word ) { String [ ] splitWord = word . split ( " " ) ; for ( int krnem = 0 ; krnem < splitWord . length - 1 ; krnem ++ ) { String rear = splitWord [ krnem ] ; String front = splitWord [ krnem + 1 ] ; if ( front . equals ( rear ) ) { return true ; } } return false ; } } import java . util . Scanner ; public class Raakzir { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String raakzir = scan . nextLine ( ) ; String p = scan . nextLine ( ) ; raakzir += raakzir . substring ( 0 , raakzir . length ( ) - 1 ) ; if ( raakzir . indexOf ( p ) == - 1 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class Potoprc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; for ( int potoprc = 0 ; potoprc < s . length ( ) ; potoprc ++ ) { for ( int j = 0 ; j < c . length ; j ++ ) { c [ j ] = s . charAt ( ( j + potoprc ) % c . length ) ; } if ( String . valueOf ( c ) . equals ( t ) ) { System . out . println ( " Yes " ) ; sc . close ( ) ; return ; } } System . out . println ( " No " ) ; sc . close ( ) ; } } import java . util . * ; import static java . lang . Math . * ; import java . math . BigInteger ; public class Kpivy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kpivy = sc . nextInt ( ) ; int [ ] b = new int [ kpivy - 1 ] ; int result = 0 ; int pre = 0 ; for ( int i = 0 ; i < kpivy - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; if ( i == 0 ) result = result + b [ i ] ; if ( i > 0 ) { result = result + min ( pre , b [ i ] ) ; } if ( i == kpivy - 2 ) result = result + b [ i ] ; pre = b [ i ] ; } System . out . println ( result ) ; } } import java . util . * ; public class Rqinxz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long rqinxz = sc . nextLong ( ) ; long year = 0 ; double kingaku = 100 ; do { kingaku = kingaku * 1.01 ; kingaku = Math . floor ( kingaku ) ; year ++ ; } while ( kingaku < rqinxz ) ; System . out . println ( year ) ; } } import java . util . Scanner ; public class Npqzqj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; for ( int npqzqj = 1 ; npqzqj > 0 ; npqzqj ++ ) { String r = scan . next ( ) ; int tot = 0 ; if ( r . equals ( " 0 " ) ) { break ; } for ( int a = 1 ; a <= r . length ( ) ; a ++ ) { String k = r . substring ( a - 1 , a ) ; int K = Integer . parseInt ( k ) ; tot = tot + K ; } System . out . println ( tot ) ; } } } import java . io . * ; public class Srqvpl { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String input = in . readLine ( ) ; String [ ] x = input . split ( " " ) ; int srqvpl = Integer . parseInt ( x [ 0 ] ) ; int b = Integer . parseInt ( x [ 1 ] ) ; int c = Integer . parseInt ( x [ 2 ] ) ; if ( b > srqvpl && c > b ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . File ; import java . io . FileNotFoundException ; import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Mecuj { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner s = new Scanner ( System . in ) ; int mecuj = s . nextInt ( ) ; int K = s . nextInt ( ) ; Set set = new HashSet ( ) ; for ( int i = 1 ; i <= mecuj ; i ++ ) { set . add ( i ) ; } for ( int i = 0 ; i < K ; i ++ ) { if ( set . size ( ) <= 0 ) { break ; } int di = s . nextInt ( ) ; for ( int j = 0 ; j < di ; j ++ ) { int num = s . nextInt ( ) ; if ( set . contains ( num ) ) { set . remove ( num ) ; } } } System . out . println ( set . size ( ) ) ; } } import java . util . Scanner ; public class Utcnp { public static void main ( String [ ] args ) { Scanner s = null ; try { s = new Scanner ( System . in ) ; String utcnp = s . nextLine ( ) ; System . out . println ( powBy3 ( Integer . parseInt ( utcnp ) ) ) ; } finally { if ( s != null ) { s . close ( ) ; } } } private static int powBy3 ( int i ) { return i * i * i ; } } import java . io . PrintStream ; import java . util . Scanner ; public class Qcyjg { public static void main ( String [ ] args ) { Scanner sc = null ; PrintStream out = null ; try { sc = new Scanner ( System . in ) ; out = System . out ; exec ( sc , out ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } finally { if ( out != null ) { out . close ( ) ; } if ( sc != null ) { sc . close ( ) ; } } System . exit ( 0 ) ; } public static void exec ( final Scanner sc , final PrintStream out ) throws Exception { final String S = sc . next ( ) ; final String T = sc . next ( ) ; int qcyjg = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( S . charAt ( i ) == T . charAt ( i ) ) { qcyjg ++ ; } } out . println ( qcyjg ) ; } } import java . util . * ; import java . text . * ; public class Zwmbn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zwmbn = sc . nextInt ( ) ; int count = 0 ; int a = 0 ; for ( int i = 1 ; i <= zwmbn ; i ++ ) { a = i % 2 ; if ( a == 1 ) { count += 1 ; } } double prob = ( double ) count / zwmbn ; System . out . println ( prob ) ; } } import java . util . Scanner ; public class Ntvvorh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ntvvorh = sc . nextInt ( ) ; int [ ] array = new int [ ntvvorh ] ; for ( int i = 0 ; i < ntvvorh ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } long min = 1000001 ; for ( int i = 0 ; i < ntvvorh ; i ++ ) { if ( min > array [ i ] ) { min = array [ i ] ; } } long max = - 1000001 ; for ( int i = 0 ; i < ntvvorh ; i ++ ) { if ( max < array [ i ] ) { max = array [ i ] ; } } long sum = 0 ; for ( int i = 0 ; i < ntvvorh ; i ++ ) { sum += array [ i ] ; } System . out . println ( min + " " + max + " " + sum ) ; } } import java . util . Scanner ; public class Qjckc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qjckc = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int s = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( qjckc > b ) { s += qjckc -- ; } else { s += b -- ; } } System . out . print ( s ) ; } } import java . util . Scanner ; class Pfbpzy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int pfbpzy = scan . nextInt ( ) ; int [ ] num = new int [ pfbpzy ] ; int count ; for ( int c = 0 ; c < pfbpzy ; c ++ ) { num [ c ] = scan . nextInt ( ) ; } count = bubbleSort ( num , pfbpzy ) ; for ( int i = 0 ; i < pfbpzy ; i ++ ) { if ( i != pfbpzy - 1 ) { System . out . print ( num [ i ] + " " ) ; } else { System . out . println ( num [ i ] ) ; } } System . out . println ( count ) ; } static int bubbleSort ( int [ ] data , int n ) { int temp ; int c = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = n - 1 ; j > i ; j -- ) { if ( data [ j - 1 ] > data [ j ] ) { temp = data [ j ] ; data [ j ] = data [ j - 1 ] ; data [ j - 1 ] = temp ; c ++ ; } } } return c ; } } import java . util . * ; import static java . lang . System . * ; import java . math . * ; public class Kcmpweg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kcmpweg = sc . nextInt ( ) ; int g = kcmpweg / 2 ; double ans = ( double ) ( kcmpweg - g ) / kcmpweg ; out . println ( ans ) ; } } import java . util . Scanner ; class Kceymny { private static String toString ( int [ ] numbers ) { StringBuilder ans = new StringBuilder ( ) . append ( numbers [ 0 ] ) ; for ( int kceymny = 1 ; kceymny < numbers . length ; kceymny ++ ) ans . append ( " " ) . append ( numbers [ kceymny ] ) ; return ans . toString ( ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] A = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int mini = i ; for ( int j = i ; j < n ; j ++ ) if ( A [ j ] < A [ mini ] ) mini = j ; if ( mini != i ) { int temp = A [ i ] ; A [ i ] = A [ mini ] ; A [ mini ] = temp ; count ++ ; } } System . out . println ( toString ( A ) ) ; System . out . println ( count ) ; } } import java . util . Scanner ; import java . lang . Math ; public class Plirxg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int plirxg = sc . nextInt ( ) ; int num2 = sc . nextInt ( ) ; int hour = sc . nextInt ( ) ; int min = sc . nextInt ( ) ; double degOfMin = min * 6 ; double degOfHour = hour * 30 + degOfMin / 12 ; double deg = Math . abs ( degOfHour - degOfMin ) ; if ( deg > 180 ) { deg = 360 - deg ; } double rad = Math . toRadians ( deg ) ; double num3 = ( plirxg * plirxg ) + ( num2 * num2 ) - ( 2 * plirxg * num2 * Math . cos ( rad ) ) ; System . out . print ( Math . sqrt ( num3 ) ) ; } } import java . util . Scanner ; class Cjugj { public static void main ( String [ ] args ) { Scanner s = null ; try { s = new Scanner ( System . in ) ; while ( s . hasNextLong ( ) ) { long [ ] num = { s . nextLong ( ) , s . nextLong ( ) } ; System . out . println ( gcd ( num ) + " " + lcm ( num ) ) ; } } finally { s . close ( ) ; } } private static long gcd ( long [ ] num ) { long cjugj = 0 ; long a = num [ 0 ] ; long b = num [ 1 ] ; do { cjugj = a % b ; a = b ; b = cjugj ; } while ( cjugj != 0 ) ; return a ; } private static long lcm ( long [ ] num ) { return ( num [ 0 ] * num [ 1 ] ) / gcd ( num ) ; } } import java . util . Scanner ; public class Qzsbm { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int qzsbm = input . nextInt ( ) ; int back , i , j = 1 ; while ( true ) { i = j * 1000 ; if ( i >= qzsbm ) { back = i - qzsbm ; break ; } j ++ ; } System . out . println ( back ) ; } } import java . util . Scanner ; public class Zktectl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String zktectl = sc . next ( ) ; String t = sc . next ( ) ; String T1 = t . substring ( zktectl . length ( ) - 0 ) ; if ( t . equals ( zktectl + T1 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Fyfnd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fyfnd = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int value = fyfnd + b + c ; int product = fyfnd * b * c ; if ( value == 17 & product == 175 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class Xvbzbuu { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int xvbzbuu = scanner . nextInt ( ) ; final int x = scanner . nextInt ( ) ; final int [ ] lengths = new int [ xvbzbuu ] ; for ( int i = 0 ; i < lengths . length ; i ++ ) { lengths [ i ] = scanner . nextInt ( ) ; } int i ; int distance = 0 ; for ( i = 0 ; i < xvbzbuu ; i ++ ) { distance += lengths [ i ] ; if ( distance > x ) { break ; } } System . out . println ( i + 1 ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Agyfz { public static void main ( String [ ] args ) { try { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = reader . readLine ( ) ; int agyfz = Integer . parseInt ( s ) ; String t = reader . readLine ( ) ; String [ ] u = t . split ( " " ) ; int [ ] m = new int [ agyfz ] ; for ( int i = 0 ; i < agyfz ; i ++ ) { m [ i ] = Integer . parseInt ( u [ i ] ) ; } for ( int j = agyfz - 1 ; j > - 1 ; j -- ) { System . out . print ( m [ j ] ) ; if ( j != 0 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class Qacnxv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qacnxv = sc . nextInt ( ) ; int [ ] arrs = new int [ qacnxv + 1 ] ; for ( int i = 1 ; i <= qacnxv ; i ++ ) { arrs [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int i = 1 ; i <= qacnxv ; i ++ ) { result += Math . max ( arrs [ i ] - arrs [ i - 1 ] , 0 ) ; } System . out . println ( result ) ; } } import java . util . * ; public class Kjxqi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kjxqi = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] b = new int [ m ] ; int crt = 0 ; for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < kjxqi ; i ++ ) { int a = 0 ; for ( int j = 0 ; j < m ; j ++ ) { a += sc . nextInt ( ) * b [ j ] ; } a += c ; if ( a > 0 ) crt ++ ; } System . out . print ( crt ) ; } } import java . util . Scanner ; public class Ejeih { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ejeih = sc . nextInt ( ) ; double M = sc . nextInt ( ) ; int [ ] A = new int [ ejeih ] ; double sum = 0 ; for ( int i = 0 ; i < ejeih ; i ++ ) { A [ i ] = sc . nextInt ( ) ; sum += A [ i ] ; } sc . close ( ) ; int temp ; int n = A . length ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( A [ i ] < A [ j ] ) { temp = A [ i ] ; A [ i ] = A [ j ] ; A [ j ] = temp ; } } } double line = 1 / ( 4 * M ) ; for ( int i = 0 ; i < M ; i ++ ) { if ( A [ i ] / sum < line ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class Zjrghwo { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int zjrghwo = input . nextInt ( ) ; int X = input . nextInt ( ) ; int [ ] L = new int [ zjrghwo ] ; for ( int i = 0 ; i < L . length ; i ++ ) { L [ i ] = input . nextInt ( ) ; } int count = 0 ; for ( int j = 0 ; j < L . length ; j ++ ) { X -= L [ j ] ; if ( X >= 0 ) { count += 1 ; } } System . out . println ( count + 1 ) ; } } import java . util . Scanner ; public class Kpvgxgg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int kpvgxgg = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int C = scanner . nextInt ( ) ; System . out . println ( Math . max ( 0 , C - ( kpvgxgg - B ) ) ) ; } } import java . util . Scanner ; public class Sdnkot { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sdnkot = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; int result = 0 ; for ( int i = 2 ; i < sdnkot ; i ++ ) { result = s . charAt ( i ) == 'C' && s . charAt ( i - 1 ) == 'B' && s . charAt ( i - 2 ) == 'A' ? result + 1 : result ; } System . out . println ( result ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Kvvwng { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kvvwng = 0 ; String s = sc . nextLine ( ) ; List < String > a = Arrays . asList ( s . split ( " " ) ) ; String [ ] array = a . toArray ( new String [ a . size ( ) ] ) ; String hikaku = " R " ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( array [ i ] . equals ( " R " ) ) { kvvwng ++ ; } else if ( i == 1 && kvvwng == 1 ) { break ; } } System . out . println ( kvvwng ) ; } } import java . util . * ; public class Vjftm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vjftm = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int maxL = 0 ; int minR = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( i == 0 ) { maxL = sc . nextInt ( ) ; minR = sc . nextInt ( ) ; } else { int L = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; maxL = maxL < L ? L : maxL ; minR = minR > R ? R : minR ; } } int count = maxL > minR ? 0 : minR - maxL + 1 ; println ( count ) ; } public static void println ( Object o ) { System . out . println ( o ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Stebf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int stebf = scan . nextInt ( ) ; int waza = scan . nextInt ( ) ; long [ ] hp = new long [ stebf ] ; for ( int i = 0 ; i < stebf ; i ++ ) { hp [ i ] = scan . nextInt ( ) ; } long sum = 0 ; Arrays . sort ( hp ) ; for ( int i = 0 ; i < stebf - waza ; i ++ ) { sum += hp [ i ] ; } System . out . println ( sum ) ; scan . close ( ) ; } } import java . util . * ; public class Ghnntox { private static final Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int ghnntox = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int d = ghnntox / b ; int r = ghnntox % b ; double f = ( double ) ghnntox / ( double ) b ; System . out . printf ( " %d %d %f \n " , d , r , f ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class Stxot { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int stxot = sc . nextInt ( ) ; String [ ] S = new String [ stxot ] ; for ( int i = 0 ; i < stxot ; i ++ ) { S [ i ] = sc . next ( ) ; } HashSet < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < stxot ; i ++ ) { set . add ( S [ i ] ) ; } System . out . println ( set . size ( ) ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Spjzau { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] str = ( sc . next ( ) ) . split ( " " ) ; sc . close ( ) ; List < String > list = new ArrayList < String > ( ) ; int spjzau = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( list . contains ( str [ i ] ) ) { spjzau ++ ; } else { list . add ( str [ i ] ) ; } } if ( list . size ( ) > 2 ) { System . out . println ( " No " ) ; } else { if ( spjzau == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . io . * ; import java . util . * ; public class Ivvnozp { public static void main ( String [ ] args ) throws IOException { Scanner scn = new Scanner ( System . in ) ; int ivvnozp = scn . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= ivvnozp ; i ++ ) { if ( i % 3 != 0 && i % 5 != 0 ) ans += i ; } System . out . println ( ans ) ; } static class Ivvnozp { StringTokenizer st ; BufferedReader br ; public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; } public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } } } import java . util . Scanner ; public class Boemfg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int boemfg = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( ( boemfg + b + c ) == 17 && ( boemfg * b * c ) == 175 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; class Vgegppe { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vgegppe = sc . nextInt ( ) ; String [ ] S = new String [ vgegppe ] ; int ans = 1 ; for ( int i = 0 ; i < vgegppe ; i ++ ) { S [ i ] = sc . next ( ) ; } Arrays . sort ( S ) ; for ( int i = 1 ; i < vgegppe ; i ++ ) { if ( ! S [ i - 1 ] . equals ( S [ i ] ) ) { ans ++ ; } } System . out . print ( ans ) ; } } import java . util . Scanner ; public class Mhcdxr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mhcdxr = sc . nextInt ( ) ; int [ ] a = new int [ mhcdxr ] ; for ( int i = 0 ; i < mhcdxr ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } boolean f = true ; for ( int i = mhcdxr - 1 ; i > 0 ; i -- ) { if ( a [ i - 1 ] - a [ i ] >= 2 ) { f = false ; } else if ( a [ i - 1 ] - a [ i ] == 1 ) { a [ i - 1 ] -- ; } } if ( f ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } } import java . util . Scanner ; public class Ecmqcd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String l1 = scan . nextLine ( ) ; scan . close ( ) ; int ecmqcd = Integer . valueOf ( l1 ) ; double side = ecmqcd / 3.0 ; System . out . println ( String . format ( " %.12f " , side * side * side ) ) ; } } import java . util . Scanner ; class Zfsjrx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] iro = new int [ 8 ] ; int zfsjrx = 0 ; int N = sc . nextInt ( ) ; for ( int i = 0 ; i < 8 ; i ++ ) { iro [ i ] = 0 ; } int tmp = 0 ; for ( int i = 0 ; i < N ; i ++ ) { tmp = sc . nextInt ( ) ; if ( tmp < 3200 ) { iro [ tmp / 400 ] ++ ; } else { zfsjrx ++ ; } } int clr = 0 ; for ( int i = 0 ; i < 8 ; i ++ ) { if ( iro [ i ] > 0 ) { clr ++ ; } } System . out . println ( Math . max ( 1 , clr ) + " " + ( clr + zfsjrx ) ) ; } } import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Niggdj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; while ( true ) { sb . delete ( 0 , sb . length ( ) ) ; String line = br . readLine ( ) ; sb . append ( line ) ; if ( line . equals ( " - " ) ) break ; int niggdj = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < niggdj ; i ++ ) { int hi = Integer . parseInt ( br . readLine ( ) ) ; sb . append ( sb . substring ( 0 , hi ) ) ; sb . delete ( 0 , hi ) ; } System . out . println ( sb . toString ( ) ) ; } } } import java . util . * ; import java . util . ArrayList ; public class Bmjhnhi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int bmjhnhi = scanner . nextInt ( ) ; Integer [ ] a = new Integer [ bmjhnhi ] ; boolean s = true ; int Alice = 0 ; int Bob = 0 ; for ( int i = 0 ; i < bmjhnhi ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( a , Comparator . reverseOrder ( ) ) ; for ( int i = 0 ; i < bmjhnhi ; i ++ ) { if ( s ) { Alice += a [ i ] ; } else { Bob += a [ i ] ; } s = ! s ; } System . out . println ( Alice - Bob ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Jwqdxwm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int jwqdxwm = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; System . out . println ( Math . min ( jwqdxwm * A , B ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Lmmrht { public static void main ( String [ ] args ) throws IOException { InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( is ) ; String str = br . readLine ( ) ; calc ( str ) ; } public static void calc ( String str ) { String [ ] result = str . split ( " " ) ; int lmmrht = Integer . parseInt ( result [ 0 ] ) ; int num2 = Integer . parseInt ( result [ 1 ] ) ; int num3 = Integer . parseInt ( result [ 2 ] ) ; if ( lmmrht < num2 ) { if ( num2 < num3 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class Mzrtum { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int mzrtum = scanner . nextInt ( ) ; int input = scanner . nextInt ( ) ; String str = new Integer ( mzrtum ) . toString ( mzrtum , input ) ; System . out . println ( str . length ( ) ) ; } } import java . util . Scanner ; public class Pesudp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int pesudp = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int [ ] num_road = new int [ pesudp ] ; int [ ] a = new int [ M ] ; int [ ] b = new int [ M ] ; int i ; for ( i = 0 ; i < pesudp ; i ++ ) { num_road [ i ] = 0 ; } for ( i = 0 ; i < M ; i ++ ) { a [ i ] = scan . nextInt ( ) ; b [ i ] = scan . nextInt ( ) ; num_road [ a [ i ] - 1 ] ++ ; num_road [ b [ i ] - 1 ] ++ ; } for ( i = 0 ; i < pesudp ; i ++ ) { System . out . println ( num_road [ i ] ) ; } } } import java . util . Scanner ; public class Rogho { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rogho = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = 0 ; if ( rogho % X > 0 ) A = 1 ; System . out . println ( ( rogho / X + A ) * T ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Nictfyf { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] string = br . readLine ( ) . split ( " " ) ; int nictfyf = Integer . parseInt ( string [ 0 ] ) ; int y = Integer . parseInt ( string [ 1 ] ) ; int tmp ; if ( nictfyf < y ) { tmp = nictfyf ; nictfyf = y ; y = tmp ; } int r = nictfyf % y ; while ( r != 0 ) { nictfyf = y ; y = r ; r = nictfyf % y ; } System . out . println ( y ) ; } } import java . io . * ; import java . util . * ; public class Etxsfkt { public static void main ( final String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; String S ; S = sc . next ( ) ; final Solver solver = new Solver ( ) ; solver . solve ( S ) ; } } class Etxsfkt { public void solve ( String S ) { for ( int etxsfkt = 0 ; etxsfkt < 3 ; etxsfkt ++ ) { if ( S . charAt ( etxsfkt ) == S . charAt ( etxsfkt + 1 ) ) { System . out . println ( " Bad " ) ; return ; } } System . out . println ( " Good " ) ; } } import java . util . * ; public class Sjtwh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int sjtwh = Integer . parseInt ( str ) ; if ( ( sjtwh % S ( str ) ) == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } static int S ( String str ) { int result = 0 ; for ( int ct = 0 ; ct < str . length ( ) ; ct ++ ) { result += Integer . parseInt ( str . charAt ( ct ) + " " ) ; } return result ; } } import java . util . * ; public class Ulakc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ulakc = sc . nextInt ( ) ; boolean ans = false ; for ( int i = 0 ; i <= ulakc / 7 ; i ++ ) { if ( ( ulakc - i * 7 ) % 4 == 0 ) { ans = true ; break ; } } if ( ans == true ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class Akjad { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; StringBuilder str = new StringBuilder ( ) ; int akjad = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { switch ( s . charAt ( i ) ) { case '0' : str . append ( '0' ) ; akjad ++ ; break ; case '1' : str . append ( '1' ) ; akjad ++ ; break ; case 'B' : if ( akjad == 0 ) { break ; } str . deleteCharAt ( akjad - 1 ) ; akjad -- ; break ; default : break ; } } System . out . println ( str . toString ( ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Jffnq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jffnq = Integer . parseInt ( sc . nextLine ( ) ) ; int [ ] point = new int [ 2 ] ; for ( int i = 0 ; i < jffnq ; i ++ ) { String game = sc . nextLine ( ) ; String [ ] games = game . split ( " " ) ; if ( games [ 0 ] . compareTo ( games [ 1 ] ) == 0 ) { point [ 0 ] ++ ; point [ 1 ] ++ ; } else if ( games [ 0 ] . compareTo ( games [ 1 ] ) > 0 ) { point [ 0 ] += 3 ; } else { point [ 1 ] += 3 ; } } System . out . println ( String . format ( " %d %d " , point [ 0 ] , point [ 1 ] ) ) ; } } import java . util . * ; public class Zjkiju { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zjkiju = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( zjkiju + zjkiju * zjkiju + zjkiju * zjkiju * zjkiju ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Edjmo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int edjmo = sc . nextInt ( ) ; List < Long > a = new ArrayList < Long > ( ) ; int fe = - 1 ; int count = 0 ; for ( int i = 0 ; i < edjmo ; i ++ ) { a . add ( sc . nextLong ( ) ) ; if ( a . get ( i ) % 2 == 0 ) { fe = i ; } } sc . close ( ) ; long j = 0 ; for ( int i = fe ; i >= 0 ; i -- ) { j = a . get ( i ) ; while ( j % 2 == 0 ) { count ++ ; j /= 2 ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Vamwnyz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vamwnyz = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; sc . close ( ) ; double prob = 0.0 ; for ( int i = 1 ; i <= vamwnyz ; i ++ ) { int points = i ; double diff = 1.0 / vamwnyz ; while ( points < k ) { diff *= 0.5 ; points *= 2 ; } prob += diff ; } System . out . println ( prob ) ; } } import java . util . Scanner ; public class Vwizctg { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; long vwizctg = scanner . nextLong ( ) ; if ( vwizctg <= s . length ( ) ) { for ( int i = 0 ; i < vwizctg ; i ++ ) { if ( s . charAt ( i ) == '1' ) { continue ; } else { System . out . println ( s . charAt ( i ) ) ; return ; } } System . out . println ( 1 ) ; return ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' ) { continue ; } else { System . out . println ( s . charAt ( i ) ) ; return ; } } System . out . println ( 1 ) ; } } import java . util . * ; public class Dgpoxx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] c = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; for ( int dgpoxx = 0 ; dgpoxx < c . length ; dgpoxx ++ ) { char a = c [ dgpoxx ] ; if ( dgpoxx % 2 == 0 ) { if ( ! ( a == 'R' || a == 'U' || a == 'D' ) ) { System . out . println ( " No " ) ; return ; } } else { if ( ! ( a == 'L' || a == 'U' || a == 'D' ) ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Cygsy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long cygsy = 0 ; int n = sc . nextInt ( ) ; Map < String , Long > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { char [ ] ca = sc . next ( ) . toCharArray ( ) ; Arrays . sort ( ca ) ; String s = String . valueOf ( ca ) ; if ( map . containsKey ( s ) ) map . put ( s , map . get ( s ) + 1 ) ; else map . put ( s , 1L ) ; } for ( String key : map . keySet ( ) ) { cygsy += map . get ( key ) * ( map . get ( key ) - 1 ) / 2 ; } System . out . println ( cygsy ) ; } } import java . util . Scanner ; public class Onqfkmk { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { char [ ] S = sc . next ( ) . toCharArray ( ) ; int onqfkmk = 0 ; for ( int i = 0 ; i < S . length ; i ++ ) { if ( S [ i ] == '+' ) { onqfkmk ++ ; } else { onqfkmk -- ; } } System . out . println ( onqfkmk ) ; } } } import java . util . * ; public class Gxdsf { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int gxdsf = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; double nearest = Double . MAX_VALUE ; int ans = 0 ; for ( int i = 1 ; i <= gxdsf ; i ++ ) { int H = sc . nextInt ( ) ; double avg = T - H * 0.006 ; if ( nearest > Math . abs ( A - avg ) ) { nearest = Math . abs ( A - avg ) ; ans = i ; } } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Dmvzcvm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int dmvzcvm = Integer . parseInt ( scanner . nextLine ( ) ) ; String line = scanner . nextLine ( ) ; String [ ] split = line . split ( " " ) ; List < Integer > intList = new ArrayList < Integer > ( ) ; for ( String s : split ) { intList . add ( Integer . parseInt ( s ) ) ; } int cnt = 1 ; int min = intList . get ( 0 ) ; for ( int i = 1 ; i < intList . size ( ) ; i ++ ) { int target = intList . get ( i ) ; if ( target <= min ) { cnt ++ ; min = target ; } } int result = cnt ; System . out . println ( result ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Csxbi { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; int csxbi = 0 ; int z = 0 ; while ( s . charAt ( csxbi ) != 'A' ) { csxbi ++ ; } for ( int i = csxbi + 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'Z' ) { z = i ; } } System . out . println ( z - csxbi + 1 ) ; } } import java . util . Scanner ; public class Qbsoko { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qbsoko = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int T = scan . nextInt ( ) ; int times = T / qbsoko ; int ans = times * B ; System . out . println ( ans ) ; } } import java . util . * ; class Ykofp { public void yatary ( ) { Scanner sc = new Scanner ( System . in ) ; int ykofp ; int x = sc . nextInt ( ) ; int [ ] num = new int [ x ] ; for ( ykofp = 0 ; ykofp < x ; ykofp ++ ) { num [ ykofp ] = sc . nextInt ( ) ; } for ( ykofp = x - 1 ; ykofp >= 0 ; ykofp -- ) { if ( ykofp != 0 ) { System . out . print ( num [ ykofp ] + " " ) ; } else { System . out . println ( num [ ykofp ] ) ; } } } public static void main ( String [ ] args ) { new Main ( ) . yatary ( ) ; } } import java . util . Scanner ; class Reqymz { static class Reqymz { int A [ ] , reqymz ; Stack ( int size ) { A = new int [ size + 1 ] ; reqymz = 0 ; } void show ( ) { for ( int i = 1 ; i < A . length ; i ++ ) if ( i == A . length - 1 ) System . out . println ( A [ i ] ) ; else System . out . print ( A [ i ] + " " ) ; } boolean isEmpty ( ) { return reqymz == 0 ; } boolean isFull ( ) { return reqymz == A . length - 1 ; } void push ( int key ) { if ( isFull ( ) ) return ; A [ ++ reqymz ] = key ; } int pop ( ) { if ( isEmpty ( ) ) return 0 ; return A [ reqymz -- ] ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String com ; Stack stack = new Stack ( 100 ) ; while ( sc . hasNext ( ) ) { com = sc . next ( ) ; if ( com . equals ( " + " ) ) stack . push ( stack . pop ( ) + stack . pop ( ) ) ; else if ( com . equals ( " - " ) ) stack . push ( - 1 * stack . pop ( ) + stack . pop ( ) ) ; else if ( com . equals ( " * " ) ) stack . push ( stack . pop ( ) * stack . pop ( ) ) ; else stack . push ( Integer . parseInt ( com ) ) ; } System . out . println ( stack . pop ( ) ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Subtpy { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BPalindromicNumbers solver = new BPalindromicNumbers ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Subtpy { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int subtpy = in . nextInt ( ) ; int b = in . nextInt ( ) ; int res = 0 ; for ( int i = subtpy ; i <= b ; i ++ ) if ( i / 10000 == i % 10 && i / 10 % 10 == i / 1000 % 10 ) res ++ ; out . println ( res ) ; } } } import java . util . Scanner ; public class Wxczm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wxczm = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] [ ] arrayA = new int [ wxczm ] [ m ] ; int [ ] arrayB = new int [ m ] ; for ( int i = 0 ; i < wxczm ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { arrayA [ i ] [ j ] = scan . nextInt ( ) ; } } for ( int i = 0 ; i < m ; i ++ ) { arrayB [ i ] = scan . nextInt ( ) ; } int intCount = 0 ; for ( int i = 0 ; i < wxczm ; i ++ ) { intCount = 0 ; for ( int j = 0 ; j < m ; j ++ ) { intCount += arrayA [ i ] [ j ] * arrayB [ j ] ; } System . out . println ( intCount ) ; } scan . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class Xmdzfsm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xmdzfsm = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] A = new int [ xmdzfsm ] ; for ( int i = 0 ; i < xmdzfsm ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } Arrays . parallelSort ( A ) ; for ( int i = 0 ; i < xmdzfsm ; i ++ ) { X -= A [ i ] ; } System . out . println ( xmdzfsm + X / A [ 0 ] ) ; } } import java . util . Scanner ; public class Tsviusu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tsviusu = scan . nextInt ( ) ; int [ ] b = new int [ tsviusu ] ; int [ ] f = new int [ tsviusu ] ; int [ ] r = new int [ tsviusu ] ; int [ ] v = new int [ tsviusu ] ; int [ ] [ ] [ ] num = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int i = 0 ; i < tsviusu ; i ++ ) { b [ i ] = scan . nextInt ( ) ; f [ i ] = scan . nextInt ( ) ; r [ i ] = scan . nextInt ( ) ; v [ i ] = scan . nextInt ( ) ; num [ b [ i ] - 1 ] [ f [ i ] - 1 ] [ r [ i ] - 1 ] += v [ i ] ; } for ( int i = 0 ; i < 4 ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { String str = " " ; for ( int k = 0 ; k < 10 ; k ++ ) { str += " " + num [ i ] [ j ] [ k ] ; } System . out . println ( str ) ; } if ( i != 3 ) { System . out . println ( " #################### " ) ; } } scan . close ( ) ; } } import java . io . InputStreamReader ; import java . io . LineNumberReader ; public class Tbppv { public static final int tbppv = 3 ; public static final int EVEN_POINTS = 1 ; public static void main ( String [ ] args ) { try { LineNumberReader lineNumReader = new LineNumberReader ( new InputStreamReader ( System . in ) ) ; String inputStr = null ; long turnNum = 0 ; String taro = null ; String hanako = null ; long taroPoint = 0 ; long hanakoPoint = 0 ; while ( ( inputStr = lineNumReader . readLine ( ) ) != null ) { if ( lineNumReader . getLineNumber ( ) == 1 ) { turnNum = Integer . parseInt ( inputStr ) ; } if ( lineNumReader . getLineNumber ( ) > 1 ) { String [ ] line = inputStr . split ( " " ) ; taro = line [ 0 ] ; hanako = line [ 1 ] ; if ( taro . compareTo ( hanako ) < 0 ) { hanakoPoint += tbppv ; } else if ( taro . compareTo ( hanako ) == 0 ) { taroPoint += EVEN_POINTS ; hanakoPoint += EVEN_POINTS ; } else { taroPoint += tbppv ; } } if ( lineNumReader . getLineNumber ( ) == turnNum + 1 ) { System . out . print ( taroPoint ) ; System . out . print ( " " ) ; System . out . println ( hanakoPoint ) ; break ; } } lineNumReader . close ( ) ; } catch ( Exception e ) { System . exit ( - 1 ) ; } } public static String shuffle ( String original , int h ) { StringBuilder shuffledStr = new StringBuilder ( original ) ; String temp = shuffledStr . substring ( 0 , h ) ; shuffledStr . delete ( 0 , h ) ; shuffledStr . append ( temp ) ; return shuffledStr . toString ( ) ; } } import java . util . Scanner ; public class Nvcydh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String input = sc . next ( ) ; String [ ] inputSplit = input . split ( " " ) ; int nvcydh = 0 ; for ( int i = 0 ; i < inputSplit . length ; i ++ ) { if ( inputSplit [ i ] . equals ( " 0 " ) ) { nvcydh ++ ; } } System . out . print ( Math . min ( nvcydh , inputSplit . length - nvcydh ) * 2 ) ; } } import java . util . Scanner ; public class Sbvxx { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int sbvxx = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; System . out . println ( ( ( sbvxx == 5 && B == 5 && C == 7 ) || ( sbvxx == 5 && B == 7 && C == 5 ) || ( sbvxx == 7 && B == 5 && C == 5 ) ) ? " YES " : " NO " ) ; } } } import java . util . Scanner ; public class Pkwij { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int pkwij , x , ans ; while ( true ) { pkwij = scan . nextInt ( ) ; x = scan . nextInt ( ) ; ans = 0 ; if ( pkwij == 0 && x == 0 ) break ; for ( int i = 1 ; i <= pkwij ; i ++ ) { for ( int j = i + 1 ; j <= pkwij ; j ++ ) { for ( int k = j + 1 ; k <= pkwij ; k ++ ) { if ( i + j + k == x ) { ans ++ ; break ; } if ( x < i + j + k ) { break ; } } if ( x <= i + j ) { break ; } } if ( x <= i ) { break ; } } System . out . println ( ans ) ; } scan . close ( ) ; } } import java . io . * ; import java . util . * ; public class Aahcxi { public static void main ( String [ ] args ) throws IOException { int aahcxi = 0 ; int n = 0 ; int i = 1 ; String s ; int a = 0 ; int b = 0 ; int c = 0 ; while ( i > 0 ) { BufferedReader x = new BufferedReader ( new InputStreamReader ( System . in ) ) ; s = x . readLine ( ) ; StringTokenizer st = new StringTokenizer ( s , " " ) ; a = Integer . parseInt ( st . nextToken ( ) ) ; b = Integer . parseInt ( st . nextToken ( ) ) ; c = Integer . parseInt ( st . nextToken ( ) ) ; if ( a >= 1 && a <= 10000 ) i = - 1 ; else if ( b >= 1 && b <= 10000 ) i = - 1 ; else if ( c >= 1 && c <= 10000 ) i = - 1 ; else if ( a <= b ) i = - 1 ; else i = 1 ; } for ( n = a ; n <= b ; n ++ ) { if ( c % n == 0 ) aahcxi ++ ; } System . out . println ( " " + aahcxi + " " ) ; } } import java . util . * ; public class Uuner { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uuner = sc . nextInt ( ) ; long [ ] A = new long [ uuner + 1 ] ; long [ ] B = new long [ uuner ] ; for ( int i = 0 ; i < uuner + 1 ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < uuner ; i ++ ) { B [ i ] = sc . nextLong ( ) ; } long sum = 0 ; for ( int i = 0 ; i < uuner ; i ++ ) { if ( A [ i ] > B [ i ] ) { sum += B [ i ] ; } else { sum += A [ i ] ; long temp = A [ i + 1 ] ; A [ i + 1 ] -= B [ i ] - A [ i ] ; A [ i + 1 ] = Math . max ( A [ i + 1 ] , 0 ) ; sum += temp - A [ i + 1 ] ; } } System . out . println ( sum ) ; } } import java . util . * ; public class Wfiziq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int wfiziq = sc . nextInt ( ) ; int [ ] array = new int [ wfiziq ] ; for ( int i = 0 ; i < wfiziq ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int count = 0 ; Arrays . sort ( array ) ; int a = array [ wfiziq / 2 - 1 ] ; int b = array [ wfiziq / 2 ] ; if ( a == b ) { System . out . println ( 0 ) ; } else { System . out . println ( b - a ) ; } } } import java . util . * ; public class Xyhafeu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] str = line . split ( " " ) ; int xyhafeu = Integer . parseInt ( str [ 0 ] ) ; int y = Integer . parseInt ( str [ 1 ] ) ; int z = xyhafeu * y ; if ( z % 2 == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Scanner ; public class Htuksmg { public static void main ( String [ ] args ) { String s = ( new Scanner ( System . in ) ) . next ( ) ; char [ ] acgt = { 'A' , 'C' , 'G' , 'T' } ; int htuksmg = 0 ; int tmp1 = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int tmp2 = tmp1 ; for ( int j = 0 ; j < acgt . length ; j ++ ) { if ( s . charAt ( i ) == acgt [ j ] ) { ++ tmp1 ; break ; } } if ( tmp1 == tmp2 ) { htuksmg = Math . max ( htuksmg , tmp1 ) ; tmp1 = 0 ; } } htuksmg = Math . max ( htuksmg , tmp1 ) ; System . out . println ( htuksmg ) ; } } import java . util . Scanner ; public class Ygfnj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ygfnj = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int AB = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; int ans = 1000000000 ; for ( int i = 0 ; i < 2 * ( x + y ) + 1 ; i ++ ) { int ABpizza = i ; int Apizza = Math . max ( 0 , x - ( i / 2 ) ) ; int Bpizza = Math . max ( 0 , y - ( i / 2 ) ) ; ans = Math . min ( ans , ( ABpizza * AB ) + ( Apizza * ygfnj ) + ( Bpizza * B ) ) ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Mxiehy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mxiehy = scan . nextInt ( ) ; ArrayList < Integer > result = new ArrayList < > ( ) ; for ( int i = 0 ; i < mxiehy ; i ++ ) { result . add ( 0 ) ; } for ( int i = 0 ; i < mxiehy - 1 ; i ++ ) { int tmp = scan . nextInt ( ) ; result . set ( tmp - 1 , result . get ( tmp - 1 ) + 1 ) ; } for ( Integer r : result ) { System . out . println ( r ) ; } } } import java . util . * ; public class Shydf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int shydf = sc . nextInt ( ) ; Map < String , Integer > m = new HashMap ( ) ; for ( int i = 0 ; i < shydf ; i ++ ) { String s = sc . next ( ) ; if ( m . get ( s ) != null ) m . replace ( s , m . get ( s ) + 1 ) ; else m . put ( s , 1 ) ; } int max = 0 ; for ( Integer val : m . values ( ) ) max = Math . max ( max , val ) ; ArrayList < String > al = new ArrayList ( ) ; for ( Map . Entry < String , Integer > e : m . entrySet ( ) ) { if ( e . getValue ( ) == max ) al . add ( e . getKey ( ) ) ; } Collections . sort ( al ) ; for ( String s : al ) System . out . println ( s ) ; } } import java . util . Scanner ; public class Zogjg { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int zogjg = in . nextInt ( ) ; int numM = in . nextInt ( ) ; int numC = in . nextInt ( ) ; int [ ] arrayB = new int [ numM ] ; for ( int i = 0 ; i < numM ; i ++ ) { arrayB [ i ] = in . nextInt ( ) ; } int result = 0 ; int numForcheck = 0 ; for ( int k = 0 ; k < zogjg ; k ++ ) { for ( int j = 0 ; j < numM ; j ++ ) { numForcheck += in . nextInt ( ) * arrayB [ j ] ; } if ( numForcheck + numC > 0 ) { result ++ ; } numForcheck = 0 ; } System . out . println ( result ) ; in . close ( ) ; } } import java . util . * ; import java . io . * ; import static java . lang . Character . isUpperCase ; public class Eksbxi { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String eksbxi = in . next ( ) ; if ( eksbxi . equals ( " AAA " ) || eksbxi . equals ( " BBB " ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; public class Psaurww { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int psaurww = sc . nextInt ( ) ; int [ ] array = new int [ psaurww ] ; int [ ] array_min = new int [ psaurww ] ; int min = psaurww + 1 ; for ( int i = 0 ; i < psaurww ; i ++ ) { array [ i ] = sc . nextInt ( ) ; if ( min > array [ i ] ) { min = array [ i ] ; } array_min [ i ] = min ; } int count = 0 ; for ( int i = 0 ; i < psaurww ; i ++ ) { if ( array_min [ i ] >= array [ i ] ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class Coyovmt { public static int coyovmt = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int zen = Integer . valueOf ( s . substring ( 0 , 2 ) ) ; int kou = Integer . valueOf ( s . substring ( 2 , 4 ) ) ; String res = " AMBIGUOUS " ; if ( 1 <= zen && zen <= 12 && 1 <= kou && kou <= 12 ) { System . out . println ( " AMBIGUOUS " ) ; return ; } if ( 12 < zen && 12 < kou ) { System . out . println ( " NA " ) ; return ; } if ( zen < 0 || kou < 0 ) { System . out . println ( " NA " ) ; return ; } if ( zen == 0 && kou == 0 ) { System . out . println ( " NA " ) ; return ; } if ( zen == 0 && 0 < kou && kou <= 12 ) { System . out . println ( " YYMM " ) ; return ; } else if ( zen == 0 && 12 < kou ) { System . out . println ( " NA " ) ; return ; } if ( kou == 0 && 0 < zen && zen <= 12 ) { System . out . println ( " MMYY " ) ; return ; } else if ( kou == 0 && 12 < zen ) { System . out . println ( " NA " ) ; return ; } if ( 12 < zen ) { System . out . println ( " YYMM " ) ; } else { System . out . println ( " MMYY " ) ; } } } import java . util . Scanner ; public class Mqkaxqa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mqkaxqa = sc . nextInt ( ) ; int [ ] array = new int [ mqkaxqa ] ; for ( int i = 0 ; i < mqkaxqa ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int buff = 0 ; int count = 0 ; for ( int i = 0 ; i < mqkaxqa ; i ++ ) { if ( array [ i ] == buff + 1 ) { buff = array [ i ] ; } else { count ++ ; } } if ( buff == 0 ) { System . out . println ( - 1 ) ; } else { System . out . println ( count ) ; } } } import java . util . Scanner ; public class Ouaxxe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ouaxxe = sc . nextInt ( ) ; int res = 1 ; for ( int i = 2 ; i * i <= ouaxxe ; i ++ ) { int p = i * i ; while ( p <= ouaxxe ) { res = Math . max ( res , p ) ; p *= i ; } } System . out . println ( res ) ; sc . close ( ) ; } } import java . util . * ; class Oyfqayw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String F = sc . nextLine ( ) ; String C = sc . nextLine ( ) ; int oyfqayw = 0 ; for ( int i = 0 ; i < F . length ( ) ; i ++ ) { Character c1 = F . charAt ( i ) ; Character c2 = C . charAt ( i ) ; if ( c1 == c2 ) oyfqayw ++ ; } System . out . println ( oyfqayw ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Kgjxmpe { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String kgjxmpe = br . readLine ( ) ; if ( kgjxmpe . contains ( " RRR " ) ) { System . out . println ( " 3 " ) ; } else if ( kgjxmpe . contains ( " RR " ) ) { System . out . println ( " 2 " ) ; } else if ( kgjxmpe . contains ( " R " ) ) { System . out . println ( 1 ) ; } else { System . out . println ( 0 ) ; } } } import java . util . * ; public class Hsxscx { int hsxscx = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } if ( sort ( a ) < 2 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } public static int sort ( int [ ] array ) { int hsxscx = 0 ; for ( int i = 0 ; i < array . length ; i ++ ) { int index = i ; for ( int j = i + 1 ; j < array . length ; j ++ ) { if ( array [ j ] < array [ index ] ) { index = j ; } } if ( i != index ) { int tmp = array [ index ] ; array [ index ] = array [ i ] ; array [ i ] = tmp ; hsxscx ++ ; } } return hsxscx ; } } import java . util . Scanner ; public class Nslzmw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long nslzmw = Integer . parseInt ( scan . next ( ) ) ; long b = Integer . parseInt ( scan . next ( ) ) ; long mult = nslzmw * b ; if ( nslzmw < b ) { long tmp = nslzmw ; nslzmw = b ; b = tmp ; } long r = nslzmw % b ; while ( r > 0 ) { nslzmw = b ; b = r ; r = nslzmw % b ; } System . out . println ( mult / b ) ; scan . close ( ) ; } } import java . util . * ; public class Tsllwbf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long tsllwbf = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long resultA = tsllwbf * c ; resultA = resultA < tsllwbf * d ? tsllwbf * d : resultA ; long resultB = b * c ; resultB = resultB < b * d ? b * d : resultB ; if ( resultA < resultB ) { System . out . println ( resultB ) ; } else { System . out . println ( resultA ) ; } } } import java . util . Scanner ; public class Rtbxi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rtbxi = sc . nextInt ( ) ; double probability = ( double ) ( rtbxi - ( rtbxi / 2 ) ) ; System . out . print ( probability / 1.0 / rtbxi ) ; } } import java . util . Scanner ; public class Zooxbgj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double zooxbgj = sc . nextDouble ( ) ; double are = 0 ; double circ = 0 ; are = zooxbgj * zooxbgj * Math . PI ; circ = ( zooxbgj + zooxbgj ) * Math . PI ; ; System . out . printf ( " %f %f \n " , are , circ ) ; } } import java . util . HashMap ; import java . util . Scanner ; public class Zxrxfh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int zxrxfh = scan . nextInt ( ) ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < zxrxfh - 1 ; i ++ ) { int x = scan . nextInt ( ) ; if ( ! map . containsKey ( x ) ) { map . put ( x , 1 ) ; } else { map . replace ( x , map . get ( x ) + 1 ) ; } } for ( int i = 0 ; i < zxrxfh ; i ++ ) { if ( map . containsKey ( i + 1 ) ) { System . out . println ( map . get ( i + 1 ) ) ; } else System . out . println ( 0 ) ; } } } import java . util . * ; import java . io . * ; public class Hanbu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long hanbu = sc . nextLong ( ) ; long blue = sc . nextLong ( ) ; long red = sc . nextLong ( ) ; long total = blue + red ; long ans = 0 ; long div = 0 ; long mod = 0 ; if ( blue == 0 ) { ans = 0 ; } else if ( hanbu < total ) { if ( hanbu >= blue ) { ans = blue ; } else if ( hanbu < blue ) { ans = hanbu ; } } else if ( hanbu >= total ) { div = hanbu / total ; mod = hanbu % total ; if ( mod > blue ) { mod = blue ; } ans = ( div * blue ) + mod ; } System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Ykvhf { static PrintWriter out ; public static void main ( String [ ] args ) throws IOException { out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; CF_Reader in = new CF_Reader ( ) ; long ykvhf = in . nextLong ( ) ; long rem = ykvhf % 500 ; long total = ( ykvhf - rem ) * 2 ; total += ( rem - ( rem % 5 ) ) ; out . println ( total ) ; out . close ( ) ; } static class Ykvhf { BufferedReader br ; StringTokenizer st ; public CF_Reader ( ) throws IOException { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) . trim ( ) ) ; return st . nextToken ( ) ; } long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } char nextCharacter ( ) throws IOException { return next ( ) . charAt ( 0 ) ; } String nextLine ( ) throws IOException { return br . readLine ( ) . trim ( ) ; } } } import java . io . * ; public class Ctacr { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int ctacr = Integer . parseInt ( str [ 0 ] ) ; int a = Integer . parseInt ( str [ 1 ] ) ; br . close ( ) ; System . out . println ( ( ctacr + a - 1 ) / a ) ; } } import java . util . Scanner ; public class Zwhjj { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int zwhjj = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int sum = zwhjj + f ; if ( zwhjj == - 1 && f == - 1 && r == - 1 ) break ; else if ( zwhjj == - 1 || f == - 1 || sum < 30 ) { System . out . println ( " F " ) ; } else if ( sum >= 80 ) { System . out . println ( " A " ) ; } else if ( 65 <= sum && sum < 80 ) { System . out . println ( " B " ) ; } else if ( 50 <= sum && sum < 65 ) { System . out . println ( " C " ) ; } else if ( 30 <= sum && sum < 50 ) { if ( r >= 50 ) System . out . println ( " C " ) ; else System . out . println ( " D " ) ; } } } } import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ; public class Hebua { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hebua = sc . nextInt ( ) ; Integer [ ] mochi = new Integer [ hebua ] ; int ans = 1 ; for ( int i = 0 ; i < hebua ; i ++ ) { mochi [ i ] = sc . nextInt ( ) ; } Arrays . sort ( mochi , Comparator . reverseOrder ( ) ) ; for ( int i = 0 ; i < hebua ; i ++ ) { if ( i != hebua - 1 ) { if ( mochi [ i ] > mochi [ i + 1 ] ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class Qmodbf { static int [ ] insertSort ( int [ ] x ) { int qmodbf , j ; for ( int i = 0 ; i < x . length ; i ++ ) { qmodbf = x [ i ] ; j = i - 1 ; while ( j >= 0 && x [ j ] > qmodbf ) { x [ j + 1 ] = x [ j ] ; j -- ; } x [ j + 1 ] = qmodbf ; show ( x ) ; } return x ; } static void show ( int [ ] x ) { for ( int i = 0 ; i < x . length ; i ++ ) { System . out . print ( x [ i ] ) ; if ( i + 1 != x . length ) System . out . print ( " " ) ; else System . out . println ( ) ; } } public static void main ( String [ ] args ) { Scanner number = new Scanner ( System . in ) ; int a = number . nextInt ( ) ; int [ ] x = new int [ a ] ; for ( int i = 0 ; i < a ; i ++ ) { x [ i ] = number . nextInt ( ) ; } insertSort ( x ) ; } } import java . util . Scanner ; public class Haxbs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int haxbs = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int sum = 1 ; for ( int i = 0 ; i < haxbs ; i ++ ) { sum = sum * 100 ; } if ( N == 100 ) { System . out . println ( 101 * sum ) ; return ; } System . out . println ( N * sum ) ; } } import java . util . * ; public class Tvymw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tvymw = sc . nextInt ( ) ; double [ ] v = new double [ tvymw ] ; for ( int i = 0 ; i < v . length ; i ++ ) { v [ i ] = sc . nextDouble ( ) ; } Arrays . sort ( v ) ; double res = v [ 0 ] ; for ( int i = 1 ; i < v . length ; i ++ ) { res = ( res + v [ i ] ) / 2 ; } System . out . println ( res ) ; sc . close ( ) ; } } import java . util . Scanner ; public class Khphjn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int khphjn = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '+' ) khphjn ++ ; if ( s . charAt ( i ) == '-' ) khphjn -- ; } System . out . println ( khphjn ) ; } } import java . util . * ; public class Sdqyuq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String [ ] line = sc . nextLine ( ) . split ( " " ) ; int sdqyuq = Integer . parseInt ( line [ 0 ] ) ; int S = Integer . parseInt ( line [ 1 ] ) ; int ans = 0 ; for ( int x = 0 ; x <= sdqyuq ; x ++ ) { for ( int y = 0 ; y <= sdqyuq ; y ++ ) { int target = S - x - y ; if ( target >= 0 && target <= sdqyuq ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class Epihgvf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int epihgvf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = 0 ; for ( int i = 0 ; i < ( b - epihgvf + 1 ) ; i ++ ) { String [ ] s = String . valueOf ( epihgvf + i ) . split ( " " ) ; String t = s [ 4 ] + s [ 3 ] + s [ 2 ] + s [ 1 ] + s [ 0 ] ; if ( String . valueOf ( epihgvf + i ) . equals ( t ) ) n ++ ; } System . out . println ( n ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Ukeaue { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; A solver = new A ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Ukeaue { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int ukeaue = Integer . parseInt ( in . next ( ) ) ; int b = Integer . parseInt ( in . next ( ) ) ; int c = Integer . parseInt ( in . next ( ) ) ; Set < Integer > s = new HashSet < > ( ) ; s . add ( ukeaue ) ; s . add ( b ) ; s . add ( c ) ; if ( s . size ( ) == 2 ) out . println ( " Yes " ) ; else out . println ( " No " ) ; } } } import java . util . Scanner ; import java . util . Arrays ; public class Gbeqmyk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int gbeqmyk = scan . nextInt ( ) ; int [ ] costs = new int [ gbeqmyk ] ; int [ ] cache = new int [ gbeqmyk ] ; for ( int i = 0 ; i < gbeqmyk ; i ++ ) { costs [ i ] = scan . nextInt ( ) ; cache [ i ] = 2147483647 ; } cache [ 0 ] = 0 ; cache [ 1 ] = Math . abs ( costs [ 1 ] - costs [ 0 ] ) ; System . out . println ( jump ( costs , 2 , cache ) ) ; return ; } private static int jump ( int [ ] costs , int k , int [ ] cache ) { for ( int i = 2 ; i < costs . length ; i ++ ) { for ( int j = k ; j > 0 ; j -- ) { cache [ i ] = Math . min ( cache [ i ] , cache [ i - j ] + ( Math . abs ( costs [ i ] - costs [ i - j ] ) ) ) ; } } return cache [ costs . length - 1 ] ; } } import java . util . * ; public class Udnee { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long udnee = Long . parseLong ( sc . next ( ) ) ; long h = Long . parseLong ( sc . next ( ) ) ; long x = Long . parseLong ( sc . next ( ) ) ; long y = Long . parseLong ( sc . next ( ) ) ; double ans = ( double ) ( udnee * h ) / 2 ; int hukusu = 0 ; if ( ( double ) x == ( double ) udnee / 2.0 && ( double ) y == ( double ) h / 2.0 ) { hukusu = 1 ; } System . out . println ( ans + " " + hukusu ) ; } } import java . util . * ; public class Wydvgpq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wydvgpq = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int cost_n = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int am = sc . nextInt ( ) ; if ( am > x ) { cost_n ++ ; } } System . out . println ( Math . min ( cost_n , m - cost_n ) ) ; } } import java . util . Scanner ; public class Tsbvtgh { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int tsbvtgh = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( s . length ( ) <= tsbvtgh ) { System . out . println ( s ) ; } else { System . out . println ( s . subSequence ( 0 , tsbvtgh ) + " ... " ) ; } } } } import java . util . Arrays ; import java . util . Scanner ; public class Akdcwnx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] A = new int [ 3 ] ; for ( int akdcwnx = 0 ; akdcwnx < 3 ; akdcwnx ++ ) { A [ akdcwnx ] = sc . nextInt ( ) ; } Arrays . parallelSort ( A ) ; if ( A [ 0 ] == A [ 1 ] && A [ 1 ] == 5 && A [ 2 ] == 7 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class Vdctqtf { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; int vdctqtf = s . nextInt ( ) ; int k = s . nextInt ( ) ; int [ ] a = new int [ vdctqtf ] ; for ( int i = 0 ; i < k ; i ++ ) { int d = s . nextInt ( ) ; for ( int j = 0 ; j < d ; j ++ ) { int x = s . nextInt ( ) ; a [ x - 1 ] ++ ; } } int c = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { if ( a [ i ] == 0 ) c ++ ; } System . out . println ( c ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class Tmrpzk { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int tmrpzk = sc . nextInt ( ) ; int [ ] a = new int [ tmrpzk ] ; String ans = " YES " ; int cnt = 0 ; for ( int i = 0 ; i < tmrpzk ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] b = Arrays . copyOf ( a , tmrpzk ) ; Arrays . sort ( b ) ; for ( int i = 0 ; i < tmrpzk ; i ++ ) { if ( a [ i ] != b [ i ] ) cnt ++ ; if ( cnt > 2 ) { ans = " NO " ; break ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class Pigcu { public static void main ( String [ ] args ) { final Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; final int pigcu = in . next ( ) . trim ( ) . length ( ) ; final StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < pigcu ; i ++ ) { sb . append ( " x " ) ; } System . out . println ( sb ) ; } } import java . util . Scanner ; public class Odgkfx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . nextLine ( ) ; String p = scan . nextLine ( ) ; if ( match ( s , p ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static boolean match ( String s , String p ) { int odgkfx = p . length ( ) ; String doubleS = s + s ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { String word = doubleS . substring ( i , i + odgkfx ) ; if ( word . equals ( p ) ) { return true ; } } return false ; } } import java . io . ByteArrayInputStream ; import java . util . Scanner ; public class Bozydm { private static boolean strcmp ( String s , int pos , String other ) { if ( pos >= other . length ( ) ) { int bozydm = other . length ( ) ; for ( int i = 0 ; i < bozydm ; i ++ ) { if ( s . charAt ( pos - i - 1 ) != other . charAt ( bozydm - i - 1 ) ) { return false ; } } return true ; } else { return false ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; int pos = s . length ( ) ; while ( pos > 0 ) { if ( strcmp ( s , pos , " dream " ) ) { pos -= 5 ; } else if ( strcmp ( s , pos , " dreamer " ) ) { pos -= 7 ; } else if ( strcmp ( s , pos , " erase " ) ) { pos -= 5 ; } else if ( strcmp ( s , pos , " eraser " ) ) { pos -= 6 ; } else { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; } }