import java . util . * ; public class LlnhziBz { 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 LlnhziYzr = Integer . parseInt ( sc . next ( ) ) ; Arrays . sort ( v ) ; for ( int i = 0 ; i < LlnhziYzr ; i ++ ) { v [ 2 ] *= 2 ; } System . out . println ( v [ 0 ] + v [ 1 ] + v [ 2 ] ) ; } } import java . util . Scanner ; public class bieG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int BieTnc = scan . nextInt ( ) ; int first = BieTnc / 100 ; int last = BieTnc % 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 KygpqxYopt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kygpqxE = sc . nextInt ( ) ; long [ ] a = new long [ kygpqxE ] ; boolean isZero = false ; for ( int i = 0 ; i < kygpqxE ; 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 = kygpqxE - 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 eshzcyA { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int EshzcySi = cin . nextInt ( ) ; int [ ] list = new int [ EshzcySi ] ; for ( int i = 0 ; i < EshzcySi ; 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 ziizwhH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZiizwhHw = 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 ] + ( ZiizwhHw - 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 ( ZiizwhHw - Y ) ; } } import java . util . * ; class UzksIwpnkb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int UzksIir = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] line = scanner . nextLine ( ) . split ( " " , UzksIir ) ; int [ ] arr = new int [ UzksIir ] ; for ( int i = 0 ; i < UzksIir ; i ++ ) { arr [ i ] = Integer . parseInt ( line [ i ] ) ; } Arrays . sort ( arr ) ; int sum = 0 ; for ( int i = 0 ; i < UzksIir - 1 ; i ++ ) { sum += arr [ i ] ; } if ( arr [ UzksIir - 1 ] < sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class LheNsq { 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 lheLpmf = 0 ; lheLpmf < 3 ; lheLpmf ++ ) { nums [ lheLpmf ] = sc . nextInt ( ) ; if ( nums [ lheLpmf ] == 5 ) { rep [ 0 ] ++ ; } else if ( nums [ lheLpmf ] == 7 ) { rep [ 1 ] ++ ; } } if ( rep [ 0 ] == 2 && rep [ 1 ] == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; class HolwqxAm { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int holwqxLzov = sc . nextInt ( ) ; int [ ] a = new int [ holwqxLzov + 1 ] ; a [ 0 ] = 0 ; for ( int i = 1 ; i <= holwqxLzov ; i ++ ) { a [ i ] = a [ i - 1 ] + sc . nextInt ( ) ; } int min = 10000000 ; for ( int t = 1 ; t < holwqxLzov ; t ++ ) { min = Math . min ( Math . abs ( ( a [ t ] - a [ 0 ] ) - ( a [ holwqxLzov ] - a [ t ] ) ) , min ) ; } System . out . println ( min ) ; } } import java . util . * ; public class PstynQl { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { long pstynHae = in . nextLong ( ) ; long b = in . nextLong ( ) ; long c = LCM ( pstynHae , b ) ; long d = pstynHae * b / c ; System . out . println ( c + " " + d ) ; } } static long LCM ( long pstynHae , long b ) { if ( b == 0 ) { return pstynHae ; } else { return LCM ( b , pstynHae % b ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class JcaiHpy { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int JcaiP = Integer . parseInt ( br . readLine ( ) ) ; String [ ] strArray = br . readLine ( ) . split ( " " ) ; int [ ] array = new int [ JcaiP ] ; for ( int i = 0 ; i < JcaiP ; i ++ ) { array [ i ] = Integer . parseInt ( strArray [ i ] ) ; } int count = bubbleSor ( array , JcaiP ) ; printArray ( array ) ; System . out . println ( count ) ; } static int bubbleSor ( int [ ] array , int JcaiP ) { int flag = 1 ; int count = 0 ; while ( flag == 1 ) { flag = 0 ; for ( int j = JcaiP - 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 MnnjnUsvamz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MnnjnVpc = 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 ( MnnjnVpc > 0 ) { result += 1 ; MnnjnVpc -= 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 QeichgJhjc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Deque < Integer > deq = new ArrayDeque < Integer > ( ) ; String str = " " ; int qeichgSus = 0 , b = 0 ; while ( sc . hasNext ( ) ) { str = sc . next ( ) ; if ( str . equals ( " + " ) ) { qeichgSus = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( qeichgSus + b ) ; } else if ( str . equals ( " - " ) ) { qeichgSus = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( b - qeichgSus ) ; } else if ( str . equals ( " * " ) ) { qeichgSus = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( qeichgSus * b ) ; } else if ( str . equals ( " / " ) ) { qeichgSus = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( b / qeichgSus ) ; } 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 rdteM { 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 rdteM { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { int RdteKtn = in . nextInt ( ) ; int A = in . nextInt ( ) ; out . println ( ( int ) Math . ceil ( RdteKtn / ( double ) A ) ) ; } } static class rdteM { 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 YelQros { public static void main ( String [ ] args ) { Scanner x = new Scanner ( System . in ) ; int yelKpab = x . nextInt ( ) ; int f = x . nextInt ( ) ; int r = x . nextInt ( ) ; int go = yelKpab + f ; while ( yelKpab != - 1 || f != - 1 || r != - 1 ) { if ( yelKpab == - 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 " ) ; } yelKpab = x . nextInt ( ) ; f = x . nextInt ( ) ; r = x . nextInt ( ) ; go = yelKpab + f ; } } } import java . util . Scanner ; public class caqbcA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] nums = new int [ 11 ] ; for ( int CaqbcHnb = 0 ; CaqbcHnb < 3 ; CaqbcHnb ++ ) { 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 SvyQxi { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int SvyTu = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int r = s * t - SvyTu ; System . out . println ( r >= 0 ? " Yes " : " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class XcdeyeQa { public Main ( ) { } static int XcdeyeI ; public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; XcdeyeI = Integer . parseInt ( str ) ; System . out . println ( ( int ) Math . pow ( XcdeyeI , 3 ) ) ; } } import java . util . * ; public class QyjWyat { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QyjOl = sc . nextInt ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; if ( QyjOl >= s . length ) { for ( int i = 0 ; i < s . length ; i ++ ) { System . out . print ( s [ i ] ) ; } } else { for ( int i = 0 ; i < QyjOl ; i ++ ) { System . out . print ( s [ i ] ) ; } System . out . print ( " ... " ) ; } } } import java . util . Scanner ; public class OnvuGwq { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; long onvuXu = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = lcm ( onvuXu , b ) ; System . out . println ( ans ) ; sc . close ( ) ; } public long gcd ( long onvuXu , long b ) { if ( b == 0 ) { return onvuXu ; } long ans = gcd ( b , onvuXu % b ) ; return ans ; } public long lcm ( long onvuXu , long b ) { long g = gcd ( onvuXu , b ) ; return onvuXu * b / g ; } } import java . util . * ; public class fzcdBwh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FzcdBboyq = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] num = new int [ 2 * FzcdBboyq ] ; int min = 1001 ; for ( int i = 0 ; i < 2 * FzcdBboyq ; i ++ ) { num [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < FzcdBboyq ; i ++ ) { if ( num [ 2 * i + 1 ] > T ) { num [ 2 * i ] = 1001 ; } } for ( int i = 0 ; i < FzcdBboyq ; 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 VetTxxmsn { private static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int VetKk ; while ( 0 > ( VetKk = scanner . nextInt ( ) ) || VetKk >= 86400 ) ; int hour = VetKk / 3600 ; int minute = ( VetKk - hour * 3600 ) / 60 ; int second = ( VetKk - hour * 3600 - minute * 60 ) ; System . out . println ( hour + " : " + minute + " : " + second ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class SbocrxGl { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int SbocrxX = 0 ; String s = br . readLine ( ) ; String t = br . readLine ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) { SbocrxX ++ ; } } System . out . println ( SbocrxX ) ; } catch ( Exception e ) { System . out . println ( e ) ; } } } import java . io . * ; import java . util . * ; public class WljvKywf { 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 WljvLq = 0 ; WljvLq < strings . length ; WljvLq ++ ) { if ( str . equals ( strings [ WljvLq ] ) ) { return 7 - WljvLq ; } } 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 XqeSone { 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 xqeOjkj = 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 ( " + " ) ) { xqeOjkj = ArrayA [ 0 ] + ArrayA [ 1 ] ; resultLine = resultLine + xqeOjkj + ( " \n " ) ; } else if ( op . equals ( " - " ) ) { xqeOjkj = ArrayA [ 0 ] - ArrayA [ 1 ] ; resultLine = resultLine + xqeOjkj + ( " \n " ) ; } else if ( op . equals ( " * " ) ) { xqeOjkj = ArrayA [ 0 ] * ArrayA [ 1 ] ; resultLine = resultLine + xqeOjkj + ( " \n " ) ; } else if ( op . equals ( " / " ) ) { xqeOjkj = ( ArrayA [ 0 ] / ArrayA [ 1 ] ) ; resultLine = resultLine + xqeOjkj + ( " \n " ) ; } else if ( op . equals ( " ? " ) ) { check = false ; } } System . out . print ( resultLine ) ; } } import java . util . * ; public class njvijmL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NjvijmGgy = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int a1 = NjvijmGgy + b ; int a2 = NjvijmGgy - b ; int a3 = NjvijmGgy * 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 AmophcAcajd { public static void main ( String [ ] args ) { int AmophcOaa = 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 ] ; AmophcOaa = 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 ( AmophcOaa >= 0 && A [ AmophcOaa ] > key ) { A [ AmophcOaa + 1 ] = A [ AmophcOaa ] ; AmophcOaa -- ; } A [ AmophcOaa + 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 yotT { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int YotQe = 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 + YotQe ] ; 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 zeiwUz { 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 ZeiwZe : w ) { if ( map . containsKey ( ZeiwZe ) ) { map . put ( ZeiwZe , map . get ( ZeiwZe ) + 1 ) ; } else { map . put ( ZeiwZe , 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 NyerQbykyq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String w = scan . nextLine ( ) ; String [ ] wArray = new String [ w . length ( ) ] ; for ( int NyerSe = 0 ; NyerSe < w . length ( ) ; NyerSe ++ ) { wArray [ NyerSe ] = w . substring ( NyerSe , NyerSe + 1 ) ; } List < String > wList = new ArrayList < String > ( Arrays . asList ( wArray ) ) ; List < String > wHashList = new ArrayList < String > ( new HashSet < > ( wList ) ) ; int sum = 0 ; for ( int NyerSe = 0 ; NyerSe < wHashList . size ( ) ; NyerSe ++ ) { for ( int j = 0 ; j < w . length ( ) ; j ++ ) { if ( wHashList . get ( NyerSe ) . 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 JdufAh { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strArr = br . readLine ( ) . split ( " " ) ; double jdufDyts = Double . parseDouble ( strArr [ 0 ] ) ; double area = jdufDyts * jdufDyts * Math . PI ; double length = 2 * Math . PI * jdufDyts ; System . out . printf ( " %.6f %.6f \n " , area , length ) ; } } import java . io . InputStreamReader ; import java . io . BufferedReader ; import java . io . IOException ; class UdtlepMuba { 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 UdtlepVf = Integer . parseInt ( strAry [ 0 ] ) ; int w = Integer . parseInt ( strAry [ 1 ] ) ; if ( UdtlepVf == 0 && w == 0 ) { break ; } for ( int i = 1 ; i <= UdtlepVf ; 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 kkzgnAvs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KkzgnElv = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; String s = sc . next ( ) ; for ( int i = 0 ; i < KkzgnElv ; 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 nclUyl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int NclBbj = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; double f = 1.0 * NclBbj / y ; BigDecimal g = new BigDecimal ( f ) ; g = g . setScale ( 5 , BigDecimal . ROUND_HALF_UP ) ; System . out . printf ( NclBbj / y + " " + NclBbj % y + " " + " %.5f " , g ) ; } } import java . util . * ; public class EmyiGlw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int emyiXlme = sc . nextInt ( ) ; int now = sc . nextInt ( ) ; int next = 0 ; int count = 0 ; int answer = 0 ; for ( int i = 0 ; i < emyiXlme - 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 KtuaOvg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KtuaS = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; ArrayList < Integer > arrayList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < KtuaS ; 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 YnfbupDqs { 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 ynfbupDh = 0 ; ynfbupDh < input . length - 1 ; ynfbupDh ++ ) { if ( input [ ynfbupDh ] . equals ( input [ ynfbupDh + 1 ] ) ) { return Result . Bad ; } } return Result . Good ; } enum Result { Good , Bad } } import java . util . * ; class OxhhIp { Scanner sc ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { int OxhhX = sc . nextInt ( ) ; int [ ] d = new int [ OxhhX ] ; for ( int i = 0 ; i < OxhhX ; i ++ ) d [ i ] = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < OxhhX - 1 ; i ++ ) { for ( int j = i + 1 ; j < OxhhX ; j ++ ) { sum += d [ i ] * d [ j ] ; } } System . out . println ( sum ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . * ; public class cxscY { Scanner sc = new Scanner ( System . in ) ; int CxscAoh , b , c , d , e , f , k , l , m , n , x , y , z ; int ans ; String [ ] S ; Main ( ) { n = sc . nextInt ( ) ; CxscAoh = sc . nextInt ( ) ; b = sc . nextInt ( ) ; System . out . println ( Math . min ( CxscAoh * n , b ) ) ; } public static void main ( String [ ] args ) { new Main ( ) ; } } import java . util . * ; public class KuzPuxl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kuzLfy = sc . nextInt ( ) ; int [ ] A = new int [ kuzLfy ] ; for ( int i = 0 ; i < kuzLfy ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int cnt = 0 , tmp = 0 ; for ( int i = 0 ; i < kuzLfy - 1 ; i ++ ) { for ( int j = kuzLfy - 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 < kuzLfy ; i ++ ) { if ( i == kuzLfy - 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 QhilcBz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qhilcJk = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; int diff = 1 ; char prev = s . charAt ( 0 ) ; for ( int i = 0 ; i < qhilcJk ; i ++ ) { if ( s . charAt ( i ) != prev ) { diff ++ ; } prev = s . charAt ( i ) ; } System . out . println ( diff ) ; } } import java . util . * ; public class oigedeQrg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; String [ ] nums = input . split ( " " ) ; int OigedeCumvx = Integer . parseInt ( nums [ 0 ] ) ; int A = Integer . parseInt ( nums [ 1 ] ) ; int B = Integer . parseInt ( nums [ 2 ] ) ; System . out . println ( OigedeCumvx * A < B ? OigedeCumvx * A : B ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; class BotvoRun { public static long gcd ( long BotvoN , long b ) { if ( b == 0 ) return BotvoN ; return gcd ( b , BotvoN % b ) ; } public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; long BotvoN = s . nextLong ( ) ; long b = s . nextLong ( ) ; long k = gcd ( BotvoN , b ) ; System . out . println ( ( BotvoN * b ) / k ) ; } } import java . util . * ; public class gicawHp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int GicawFjvc = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int count = 0 ; int compare = 0 ; for ( int i = GicawFjvc ; 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 LfaqYphscd { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int LfaqBpf = scanner . nextInt ( ) ; final int b = scanner . nextInt ( ) ; final int value = Integer . parseInt ( Integer . toString ( LfaqBpf ) + 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 UwzwvkOtjue { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UwzwvkC = sc . nextInt ( ) ; String [ ] s = new String [ UwzwvkC ] ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; long result = 0 ; for ( int i = 0 ; i < UwzwvkC ; 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 PvbYuew { public static void main ( String [ ] args ) throws IOException { int pvbMwt ; 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 ) { pvbMwt = a ; a = b ; b = pvbMwt ; } if ( b > c ) { pvbMwt = b ; b = c ; c = pvbMwt ; } if ( a > b ) { pvbMwt = a ; a = b ; b = pvbMwt ; } System . out . println ( a + " " + b + " " + c ) ; } } import java . util . Scanner ; class ZmhpCycz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long ZmhpF = scanner . nextLong ( ) ; long r = scanner . nextLong ( ) ; scanner . close ( ) ; int count = 0 ; while ( ZmhpF >= r ) { count += 1 ; ZmhpF = ZmhpF / r ; } System . out . println ( count + 1 ) ; } } import java . util . Scanner ; public class izabfJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long IzabfMmtr = sc . nextLong ( ) ; long R = sc . nextLong ( ) ; final int divide = 2019 ; long ans = 1000000000 ; if ( R - IzabfMmtr >= 2019 ) System . out . println ( 0 ) ; else { for ( long i = IzabfMmtr ; 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 NolHt { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final List < Integer > list = new ArrayList < > ( ) ; int nolBb = sc . nextInt ( ) ; int s1 = 0 ; int s2 = 0 ; int min = 10001 ; for ( int i = 0 ; i < nolBb ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } for ( int i = 0 ; i < nolBb ; i ++ ) { for ( int j = 0 ; j < nolBb ; 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 AcdlmkTqkrmv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] arg = sc . nextLine ( ) . split ( " " ) ; int AcdlmkH = Integer . parseInt ( arg [ 0 ] ) ; String d = arg [ 1 ] ; int count = 0 ; for ( int i = 0 ; i < AcdlmkH ; 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 CittXaet { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cittK = 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 <= cittK ; i ++ ) { al . add ( i ) ; } for ( int i = 0 ; i <= cittK ; i ++ ) { for ( int j = 0 ; j <= cittK ; j ++ ) { if ( al . contains ( s - i - j ) ) { count ++ ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; class tdravfGin { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int TdravfOw = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int x = scanner . nextInt ( ) ; int y = scanner . nextInt ( ) ; int sum = 0 ; if ( TdravfOw + b < c * 2 ) { sum = TdravfOw * x + b * y ; System . out . println ( sum ) ; } else { while ( x >= 1 && y >= 1 ) { sum += c * 2 ; x -- ; y -- ; } int sum2 = sum ; sum += TdravfOw * x + b * y ; if ( TdravfOw > c * 2 || b > c * 2 ) { while ( x >= 1 || y >= 1 ) { sum2 += c * 2 ; x -- ; y -- ; } x = 0 ; y = 0 ; } sum2 += TdravfOw * 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 SxngztKlvw { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int sxngztFfs = Integer . parseInt ( br . readLine ( ) ) ; String [ ] string = br . readLine ( ) . split ( " " ) ; int [ ] Progression = new int [ sxngztFfs ] ; for ( int i = 0 ; i < sxngztFfs ; i ++ ) { Progression [ i ] = Integer . parseInt ( string [ i ] ) ; } for ( int k = 0 ; k < sxngztFfs ; k ++ ) { System . out . print ( Progression [ k ] ) ; if ( k < sxngztFfs - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; int v ; for ( int i = 1 ; i < sxngztFfs ; 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 < sxngztFfs ; k ++ ) { System . out . print ( Progression [ k ] ) ; if ( k < sxngztFfs - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } } import java . util . * ; public class fpwfdqEy { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; double FpwfdqCpxb = 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 = ( FpwfdqCpxb * FpwfdqCpxb ) + ( B * B ) - 2 * FpwfdqCpxb * B * Math . cos ( Math . toRadians ( radian ) ) ; double ans = Math . sqrt ( result ) ; System . out . println ( ans ) ; } } public class MvdduNx { public static void main ( String [ ] args ) { java . util . Scanner scan = new java . util . Scanner ( System . in ) ; int MvdduDmd = 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 < MvdduDmd && MvdduDmd <= 100 && 0 < H && H <= 100 ) { if ( MvdduDmd >= ( 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 FpdkeLl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FpdkeM = sc . nextInt ( ) ; long result = 0 ; for ( int i = 1 ; i <= FpdkeM ; i ++ ) { for ( int j = i ; j <= FpdkeM ; j ++ ) { for ( int k = j ; k <= FpdkeM ; 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 rgtHpp { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { final String s = reader . readLine ( ) ; int RgtNu = 200001 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'A' ) { RgtNu = 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 - RgtNu + 1 ) ; } } } import java . util . * ; public class PjtiGfd { 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 pjtiN = 0 ; for ( int value : array ) pjtiN += value ; return pjtiN ; } 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 FyeViynj { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int FyeZ = 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 [ FyeZ + 1 ] ; String find = " AC " ; for ( int i = 0 ; i < FyeZ ; 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 [ FyeZ + 1 ] ; for ( int i = 0 ; i < FyeZ ; 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 QmndLcyafr { int QmndZf ; 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 ) { QmndZf = sc . nextInt ( ) ; d = new int [ QmndZf ] ; for ( int i = 0 ; i < QmndZf ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } } void solve ( ) { boolean [ ] cnt = new boolean [ 100 ] ; for ( int i = 0 ; i < QmndZf ; 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 VoblkvRkg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VoblkvJ = sc . nextInt ( ) ; int b = 0 ; int [ ] d = new int [ VoblkvJ ] ; int [ ] e = new int [ VoblkvJ ] ; for ( int i = 0 ; i < VoblkvJ ; i ++ ) { d [ i ] = sc . nextInt ( ) ; d [ i ] -- ; e [ d [ i ] ] = i + 1 ; } for ( int i = 0 ; i < VoblkvJ ; i ++ ) { System . out . print ( e [ i ] + " " ) ; } } } import java . util . * ; class XphpNgdsfe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int XphpVf = 0 ; XphpVf < 3 ; XphpVf ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { c [ XphpVf ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] d = new int [ 3 ] [ 2 ] ; for ( int XphpVf = 0 ; XphpVf < 3 ; XphpVf ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { d [ XphpVf ] [ j ] = c [ XphpVf ] [ j + 1 ] - c [ XphpVf ] [ 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 CixsidBywded { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CixsidHu = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( W >= CixsidHu ) System . out . println ( " unsafe " ) ; else System . out . println ( " safe " ) ; } } import java . util . * ; public class xkldljTve { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XkldljKf = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; boolean zero = false ; if ( XkldljKf - R >= 2019 ) zero = true ; for ( int i = XkldljKf ; i < R ; i ++ ) { if ( i % 2019 == 0 ) { zero = true ; break ; } } XkldljKf = XkldljKf % 2019 ; R = R % 2019 ; int min = 2017 * 2018 ; if ( ! zero ) { for ( int i = XkldljKf ; 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 LbbYdxssb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int LbbFj = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; int d = 0 ; ArrayList < ArrayList < Integer > > arraylist = new ArrayList < ArrayList < Integer > > ( LbbFj ) ; for ( int i = 0 ; i < LbbFj ; 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 < LbbFj ; i ++ ) { if ( arraylist . get ( i ) . size ( ) == 0 ) { count += 1 ; } } System . out . println ( count ) ; } } import java . util . * ; public class JaoMzej { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jaoV = sc . nextInt ( ) ; int [ ] arr = new int [ jaoV ] ; 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 TdfpJpr { static String blackjack ( int TdfpMoj , int a2 , int a3 ) { if ( TdfpMoj + 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 TdfpMoj = Integer . parseInt ( sc . next ( ) ) ; int a2 = Integer . parseInt ( sc . next ( ) ) ; int a3 = Integer . parseInt ( sc . next ( ) ) ; out . println ( blackjack ( TdfpMoj , a2 , a3 ) ) ; out . flush ( ) ; } } import java . util . * ; public class PklaeTltho { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String PklaeZ = scan . nextLine ( ) ; scan . close ( ) ; switch ( PklaeZ . charAt ( PklaeZ . 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 NwxdFj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NwxdOye = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ NwxdOye ] ; for ( int i = 0 ; i < NwxdOye ; 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 UkrCi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String UkrWl = sc . next ( ) ; String str2 = UkrWl . toLowerCase ( ) ; if ( UkrWl . 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 LqaoBd { 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 XlqjipTesulo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XlqjipPe = Integer . parseInt ( sc . next ( ) ) ; Map < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 1 ; i <= XlqjipPe ; i ++ ) { map . put ( Integer . parseInt ( sc . next ( ) ) , i ) ; } StringBuilder builder = new StringBuilder ( ) ; for ( int i = 1 ; i <= XlqjipPe ; i ++ ) { builder . append ( map . get ( i ) ) . append ( " " ) ; } System . out . println ( builder . toString ( ) ) ; } } import java . util . Scanner ; public class WqdrvIns { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long WqdrvO = 0 ; long answer = 0 ; double limit = 0.0 ; WqdrvO = scan . nextLong ( ) ; answer = WqdrvO ; limit = Math . sqrt ( WqdrvO ) ; for ( int i = 1 ; i <= limit ; i ++ ) { if ( WqdrvO % i == 0 && ( WqdrvO / i ) + i - 2 < answer ) { answer = ( WqdrvO / i ) + i - 2 ; } } System . out . println ( answer ) ; } } import java . util . Scanner ; class QtlVdamcl { public static final String SEVEN = " 7 " ; public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QtlEcs = scan . nextInt ( ) ; scan . close ( ) ; String numN = String . valueOf ( QtlEcs ) ; 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 CgcElclld { 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 CgcVmu = charStr . length - 1 ; CgcVmu > - 1 ; CgcVmu -- ) rvsStr . append ( charStr [ CgcVmu ] ) ; System . out . println ( rvsStr ) ; } } } import java . util . Scanner ; class ftsyZbq { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int FtsyQu ; int i = 1 ; while ( true ) { FtsyQu = scan . nextInt ( ) ; ; if ( FtsyQu != 0 ) { System . out . println ( " Case " + " " + i + " : " + " " + FtsyQu ) ; i ++ ; } else { break ; } } } } import java . util . Scanner ; class DqgKo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DqgInl = 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 YkpulDk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YkpulL = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] l = new int [ YkpulL ] ; int d = 0 ; int i = 0 ; for ( int cnt = 0 ; cnt < YkpulL ; cnt ++ ) { l [ cnt ] = sc . nextInt ( ) ; d += l [ cnt ] ; if ( d > x ) { i = cnt + 1 ; break ; } else { i = YkpulL + 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 OnfiuuNd { static Scanner sc = new Scanner ( in ) ; public static void main ( String [ ] args ) { int OnfiuuW = sc . nextInt ( ) ; int [ ] d = new int [ OnfiuuW ] ; int ans = 0 ; for ( int i = 0 ; i < OnfiuuW ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; ans = max ( 0 , d [ OnfiuuW / 2 ] - d [ OnfiuuW / 2 - 1 ] ) ; out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class NsjRbtxy { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int NsjBbv = Integer . parseInt ( br . readLine ( ) ) ; String [ ] tmpArray = br . readLine ( ) . split ( " " ) ; int [ ] input = new int [ NsjBbv ] ; for ( int i = 0 ; i < NsjBbv ; i ++ ) { input [ NsjBbv - i - 1 ] = Integer . parseInt ( tmpArray [ i ] ) ; } System . out . print ( input [ 0 ] ) ; for ( int i = 1 ; i < NsjBbv ; i ++ ) { System . out . print ( " " + input [ i ] ) ; } System . out . println ( ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class HqvesUszhrn { 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 HqvesLel = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( ss [ i ] == 'A' || ss [ i ] == 'C' || ss [ i ] == 'G' || ss [ i ] == 'T' ) { HqvesLel ++ ; } else { ans . add ( HqvesLel ) ; HqvesLel = 0 ; } } ans . add ( HqvesLel ) ; Collections . sort ( ans , Collections . reverseOrder ( ) ) ; System . out . println ( ans . get ( 0 ) ) ; } } import java . util . * ; public class AszIi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; LinkedList < Integer > ll = new LinkedList < > ( ) ; int AszS = 999 ; int x = 999 ; int cnt = 0 ; while ( AszS != 0 || x != 0 ) { AszS = sc . nextInt ( ) ; x = sc . nextInt ( ) ; int ans = 0 ; if ( AszS == 0 && x == 0 ) { break ; } else { cnt ++ ; for ( int i = 1 ; i <= AszS ; 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 QrvsUu { static final int qrvsS = 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 lemI { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int LemPndjv = stdIn . nextInt ( ) ; int y = stdIn . nextInt ( ) ; int z = stdIn . nextInt ( ) ; int temp ; if ( LemPndjv > y ) { temp = LemPndjv ; LemPndjv = y ; y = temp ; } if ( LemPndjv > z ) { temp = LemPndjv ; LemPndjv = z ; z = temp ; } if ( y > z ) { temp = z ; z = y ; y = temp ; } System . out . printf ( " %d %d %d \n " , LemPndjv , y , z ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class DbmyJq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DbmyK = Integer . parseInt ( sc . next ( ) ) ; ArrayList < String > shiritoriList = new ArrayList < > ( ) ; for ( int i = 0 ; i < DbmyK ; 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 LwgmJe { 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 lwgmKume = 0 ; lwgmKume < s . length ( ) ; lwgmKume ++ ) { int countval = s . toLowerCase ( ) . codePointAt ( lwgmKume ) - 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 xbyxryA { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String fst = br . readLine ( ) ; int XbyxryIiep = Integer . parseInt ( fst ) ; if ( XbyxryIiep == 0 ) { break ; } String line = br . readLine ( ) ; String [ ] str = line . split ( " " ) ; double [ ] s = new double [ str . length ] ; for ( int j = 0 ; j < XbyxryIiep ; j ++ ) { s [ j ] = Double . parseDouble ( str [ j ] ) ; } double sum = 0.0 ; for ( int j = 0 ; j < XbyxryIiep ; j ++ ) { sum += s [ j ] ; } double num = XbyxryIiep ; double avr = sum / num ; double a = 0.0 ; for ( int j = 0 ; j < XbyxryIiep ; 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 ZhezebEq { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ZhezebG = in . nextInt ( ) ; Integer [ ] nam = new Integer [ ZhezebG ] ; int max1 = 0 ; int max2 = 0 ; for ( int i = 0 ; i < ZhezebG ; 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 < ZhezebG ; i ++ ) { if ( nam2 [ i ] != max1 ) { System . out . println ( max1 ) ; } else { System . out . println ( max2 ) ; } } } } import java . util . * ; public class ExxKa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int exxE = Integer . parseInt ( sc . next ( ) ) ; int L = Integer . parseInt ( sc . next ( ) ) ; int [ ] appleValue = new int [ exxE ] ; int sum = 0 ; int a = 0 ; int min = 9999 ; for ( int i = 0 ; i < exxE ; 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 AhqcdkAk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long AhqcdkLf = sc . nextLong ( ) ; long min = ( long ) 999999999999.0 ; for ( long i = 1 ; i <= Math . sqrt ( AhqcdkLf ) ; i ++ ) if ( AhqcdkLf % i == 0 && min > ( i - 1 ) + ( AhqcdkLf / i ) - 1 ) min = ( i - 1 ) + ( AhqcdkLf / i ) - 1 ; System . out . println ( min ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class jqoZb { 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 JqoOmko = Integer . parseInt ( st . nextToken ( ) ) ; String op = st . nextToken ( ) ; int b = Integer . parseInt ( st . nextToken ( ) ) ; int ans = 0 ; if ( op . equals ( " + " ) ) { ans = JqoOmko + b ; System . out . println ( ans ) ; } else if ( op . equals ( " - " ) ) { ans = JqoOmko - b ; System . out . println ( ans ) ; } else if ( op . equals ( " * " ) ) { ans = JqoOmko * b ; System . out . println ( ans ) ; } else if ( op . equals ( " / " ) ) { ans = JqoOmko / b ; System . out . println ( ans ) ; } else if ( op . equals ( " ? " ) ) { break ; } } } } import java . util . * ; public class EfzDyz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EfzWa = Integer . parseInt ( scan . next ( ) ) ; int [ ] lst = new int [ EfzWa ] ; int ans = 0 ; for ( int i = 0 ; i < EfzWa ; i ++ ) { lst [ i ] = Integer . parseInt ( scan . next ( ) ) ; } for ( int i = 0 ; i < EfzWa - 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 WgvIguf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long WgvBly = sc . nextLong ( ) ; WgvBly -- ; String result = " " ; String alp = " abcdefghijklmnopqrstuvwxyz " ; while ( true ) { long syou = WgvBly / alp . length ( ) ; long mod = WgvBly % alp . length ( ) ; String tmp = alp . substring ( ( int ) mod , ( int ) mod + 1 ) ; result = tmp + result ; WgvBly = syou - 1 ; if ( syou == 0 ) { break ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class QqdhuNjus { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int QqdhuOoc = 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 ( QqdhuOoc + B , 2 * C ) * min + QqdhuOoc * ( X - min ) + B * ( Y - min ) , max * 2 * C ) ) ; } } import java . util . Scanner ; public class KmpNbl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KmpUoz = sc . nextInt ( ) ; int c = 0 ; int prev = 0 ; int max = 0 ; for ( int i = 0 ; i < KmpUoz ; 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 tnoovVhs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TnoovNflte = 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 ( TnoovNflte == Aval && B == Bval ) { System . out . println ( i ) ; System . exit ( 0 ) ; } } System . out . println ( - 1 ) ; sc . close ( ) ; } } import java . util . * ; class XwinnJs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XwinnZp = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Ans = 0 ; int Max = Math . max ( XwinnZp , B ) ; Max = Math . max ( Max , C ) ; double pow = Math . pow ( 2 , K ) ; if ( Max == XwinnZp ) { Ans = ( XwinnZp * ( int ) pow ) + B + C ; } else if ( Max == B ) { Ans = ( B * ( ( int ) pow ) ) + XwinnZp + C ; } else { Ans = ( C * ( ( int ) pow ) ) + XwinnZp + B ; } System . out . println ( Ans ) ; } } import java . util . Scanner ; public class DbpvdkOh { 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 DbpvdkOh { static void solve ( ) { final Scanner sc = new Scanner ( System . in ) ; final int DbpvdkZnw = sc . nextInt ( ) ; final int d = sc . nextInt ( ) ; final int res = calc ( DbpvdkZnw , d ) ; System . out . println ( res ) ; } static int calc ( final int DbpvdkZnw , final int d ) { final int max = ( 2 * d + 1 ) ; int res = DbpvdkZnw / max ; if ( DbpvdkZnw % max != 0 ) { res += 1 ; } return res ; } } class DbpvdkOh { 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 BhnooPo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BhnooU = sc . nextInt ( ) ; int migi = BhnooU % 100 ; int hidari = ( BhnooU - 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 KyqpbBcm { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int KyqpbDp = scn . nextInt ( ) ; int a = KyqpbDp / 100 ; int b = ( KyqpbDp % 100 ) / 10 ; int c = KyqpbDp % 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 yvmjnNy { 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 YvmjnTr = 0 , size = list . size ( ) ; YvmjnTr < size ; YvmjnTr ++ ) { System . out . println ( list . get ( YvmjnTr ) ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class IbxPi { static int [ ] h ; static int [ ] dp ; public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int ibxJhe = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; h = new int [ ibxJhe ] ; dp = new int [ ibxJhe ] ; for ( int i = 0 ; i < ibxJhe ; i ++ ) h [ i ] = scan . nextInt ( ) ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < ibxJhe ; 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 [ ibxJhe - 1 ] ) ; } } import java . util . Scanner ; public class OjeNxc { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int OjeA = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int c = stdIn . nextInt ( ) ; int d = stdIn . nextInt ( ) ; if ( c >= b || OjeA >= d ) System . out . println ( 0 ) ; else if ( ( OjeA <= c && b >= d ) || ( c <= OjeA && d >= b ) ) System . out . println ( ( b - OjeA ) < ( d - c ) ? b - OjeA : d - c ) ; else System . out . println ( ( b > c && c >= OjeA ) ? b - c : d - OjeA ) ; } } 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 LdpaXfh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int LdpaN = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] tmp = scanner . nextLine ( ) . split ( " " ) ; int [ ] list = new int [ LdpaN ] ; int ans = 0 ; for ( int i = 0 ; i < LdpaN ; i ++ ) { list [ i ] = Integer . parseInt ( tmp [ i ] ) ; } for ( int i = 0 ; i < LdpaN ; i ++ ) { int r = i ; int min = Integer . MAX_VALUE ; while ( list [ i ] != 0 ) { while ( r < LdpaN && 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 FrttFims { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FrttQ = sc . nextInt ( ) ; int [ ] h = new int [ FrttQ ] ; for ( int i = 0 ; i < FrttQ ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int sum = 0 ; boolean flag = true ; while ( flag ) { flag = false ; boolean ed = false ; for ( int i = 0 ; i < FrttQ ; 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 IcopaGyp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int icopaNhy = sc . nextInt ( ) ; long max = 0L ; int Bi = 0 ; int save = 0 ; for ( int i = 0 ; i < icopaNhy ; i ++ ) { if ( i == icopaNhy - 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 nlysWvd { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int NlysTi = sc . nextInt ( ) ; int [ ] array = new int [ NlysTi ] ; for ( int i = 0 ; i < NlysTi ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int i = 0 ; i < NlysTi ; 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 SpfRrg { public static void main ( String [ ] args ) { int [ ] arr = new int [ 5 ] ; Scanner sc = new Scanner ( System . in ) ; for ( int spfKvb = 0 ; spfKvb < 5 ; spfKvb ++ ) { arr [ spfKvb ] = sc . nextInt ( ) ; if ( arr [ spfKvb ] == 0 ) System . out . println ( spfKvb + 1 ) ; } } } import java . util . * ; public class OdlvyTt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long OdlvyBu = sc . nextLong ( ) ; HashMap < Long , Long > map = new HashMap < > ( ) ; long res = dfs ( OdlvyBu , map ) ; System . out . println ( res ) ; } public static long dfs ( long OdlvyBu , HashMap < Long , Long > map ) { long ans = 1 ; if ( OdlvyBu <= 1 ) return ans ; if ( map . get ( OdlvyBu ) != null ) return map . get ( OdlvyBu ) ; long cur = dfs ( OdlvyBu / 2 , map ) ; ans += 2 * cur ; map . put ( OdlvyBu , ans ) ; return ans ; } } import java . util . * ; public class MsyuAzl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int msyuEcmv = sc . nextInt ( ) ; Integer [ ] p = new Integer [ msyuEcmv ] ; for ( int i = 0 ; i < msyuEcmv ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Integer [ ] p_ = p . clone ( ) ; Arrays . sort ( p ) ; int count = 0 ; for ( int i = 0 ; i < msyuEcmv ; 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 KshoSengi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KshoDk = sc . nextInt ( ) ; String [ ] str = new String [ KshoDk ] ; for ( int i = 0 ; i < KshoDk ; i ++ ) { str [ i ] = sc . next ( ) ; } int acCount = 0 ; int waCount = 0 ; int tleCount = 0 ; int reCount = 0 ; for ( int j = 0 ; j < KshoDk ; 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 QymhlbBffrh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QymhlbC = 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 ) { QymhlbC = 1 ; b = 1 ; break ; } } } if ( b == 1 ) { break ; } } if ( QymhlbC == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class JpgyjLxr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jpgyjB = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int tmp ; if ( jpgyjB > b ) { tmp = jpgyjB ; jpgyjB = b ; b = tmp ; } if ( b > c ) { tmp = b ; b = c ; c = tmp ; } if ( jpgyjB > b ) { tmp = jpgyjB ; jpgyjB = b ; b = tmp ; } System . out . println ( jpgyjB + " " + b + " " + c ) ; } } import java . util . * ; public class HslmhvIpa { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; int HslmhvFsf = kb . nextInt ( ) , k = kb . nextInt ( ) ; int [ ] h = new int [ HslmhvFsf ] ; for ( int i = 0 ; i < HslmhvFsf ; i ++ ) { h [ i ] = kb . nextInt ( ) ; } int [ ] dp = new int [ HslmhvFsf ] ; boolean [ ] visited = new boolean [ HslmhvFsf ] ; dp [ 0 ] = 0 ; visited [ 0 ] = true ; for ( int i = 1 ; i < HslmhvFsf ; 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 [ HslmhvFsf - 1 ] ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class WlfpIu { 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 WlfpP = 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 ) ) { WlfpP = true ; break ; } } if ( WlfpP ) { 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 ZzezykUqdy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int zzezykQs = Integer . parseInt ( scan . next ( ) ) ; List < String > list = new ArrayList < > ( ) ; String W = scan . next ( ) ; list . add ( W ) ; String preW ; for ( int i = 1 ; i < zzezykQs ; 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 DziqTvag { int DziqV , s ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; DziqV = sc . nextInt ( ) ; s = sc . nextInt ( ) ; solve ( ) ; } void solve ( ) { long count = 0 ; for ( int x = 0 ; x <= DziqV ; x ++ ) { for ( int y = 0 ; y <= DziqV ; y ++ ) { int z = s - x - y ; if ( z >= 0 && z <= DziqV ) { count ++ ; } } } System . out . println ( count ) ; } static class DziqTvag { 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 CcmnZa { private static double CcmnB ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; CcmnB = stdIn . nextDouble ( ) ; double Pi = Math . PI ; System . out . printf ( " %.6f %.6f \n " , ( CcmnB * CcmnB * Pi ) , ( 2 * Pi * CcmnB ) ) ; } } import java . util . Scanner ; public class VymuajLimo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VymuajUus = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int count = VymuajUus / x ; int answer = 0 ; if ( VymuajUus % 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 orxmhtP { private void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] charArray = S . toCharArray ( ) ; List < Integer > counts = new ArrayList < Integer > ( ) ; int OrxmhtCa = 0 ; for ( int i = 0 ; i < charArray . length ; i ++ ) { if ( charArray [ i ] == 'A' || charArray [ i ] == 'C' || charArray [ i ] == 'G' || charArray [ i ] == 'T' ) { OrxmhtCa ++ ; if ( i == charArray . length - 1 ) { counts . add ( OrxmhtCa ) ; } } else { if ( OrxmhtCa != 0 ) { counts . add ( OrxmhtCa ) ; OrxmhtCa = 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 nhkjgFyt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NhkjgXep = sc . nextInt ( ) ; int max_first = 0 ; int max_second = 0 ; int [ ] a = new int [ NhkjgXep ] ; for ( int i = 0 ; i < NhkjgXep ; ++ 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 xvkN { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int XvkTz , b , c ; while ( true ) { XvkTz = input . nextInt ( ) ; b = input . nextInt ( ) ; c = input . nextInt ( ) ; if ( XvkTz == - 1 && b == - 1 && c == - 1 ) break ; else { if ( XvkTz == - 1 || b == - 1 ) System . out . println ( " F " ) ; else if ( XvkTz + b < 30 ) System . out . println ( " F " ) ; else if ( XvkTz + b < 50 ) { if ( c == - 1 ) { System . out . println ( " D " ) ; } else { if ( c >= 50 ) System . out . println ( " C " ) ; else System . out . println ( " D " ) ; } } else if ( XvkTz + b < 65 ) System . out . println ( " C " ) ; else if ( XvkTz + b < 80 ) System . out . println ( " B " ) ; else if ( XvkTz + b >= 80 ) System . out . println ( " A " ) ; } } } } import java . util . * ; import java . io . * ; public class JfwjtRcbtt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long JfwjtNju = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long div = JfwjtNju / ( a + b ) ; long rem = JfwjtNju % ( a + b ) ; long sum = div * a ; sum += Math . min ( rem , a ) ; System . out . println ( sum ) ; } } import java . io . * ; public class ndiisnBq { 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 NdiisnLzs = s . length ( ) ; boolean ok = checkKaibun ( s ) ; ok &= checkKaibun ( s . substring ( 0 , ( NdiisnLzs - 1 ) / 2 ) ) ; ok &= checkKaibun ( s . substring ( ( NdiisnLzs + 1 ) / 2 ) ) ; System . out . println ( ok ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class BkxQcf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bkxOzoe , B , C , X , Y ; bkxOzoe = sc . nextInt ( ) ; B = sc . nextInt ( ) ; C = sc . nextInt ( ) ; X = sc . nextInt ( ) ; Y = sc . nextInt ( ) ; int min = bkxOzoe * X + B * Y ; if ( X > Y ) { if ( C * 2 * X < min ) { min = C * 2 * X ; } if ( C * 2 * Y + ( X - Y ) * bkxOzoe < min ) { min = C * 2 * Y + ( X - Y ) * bkxOzoe ; } } 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 PweZll { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PweE = sc . nextInt ( ) ; int larger = PweE / 500 ; int smaller = PweE - larger * 500 ; int yens = smaller / 5 ; System . out . println ( ( larger * 1000 ) + ( yens * 5 ) ) ; } } import java . io . IOException ; import java . util . Scanner ; public class EvhBo { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int evhIk = sc . nextInt ( ) ; int [ ] a = new int [ evhIk ] ; for ( int b = 0 ; b < evhIk ; ++ b ) { a [ b ] = sc . nextInt ( ) ; } for ( int b = evhIk - 1 ; b >= 0 ; -- b ) { if ( b != 0 ) { System . out . print ( a [ b ] + " " ) ; } else { System . out . println ( a [ b ] ) ; } } } } import java . util . * ; public class NtqkwnBuda { public static void main ( String [ ] args ) { String alphabet = " ABCDEFGHIJKLMNOPQRSTUVWXYZ " ; Scanner sc = new Scanner ( System . in ) ; int ntqkwnO = 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 + ntqkwnO ) % alphabet . length ( ) , ( ( j + ntqkwnO ) % alphabet . length ( ) ) + 1 ) ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class MfqkYk { void run ( ) { Scanner scan = new Scanner ( System . in ) ; int MfqkEwd = scan . nextInt ( ) ; int prime = 0 ; for ( int i = 0 ; i < MfqkEwd ; 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 cciqhiAa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CciqhiJaxhz = sc . nextInt ( ) ; int [ ] b = new int [ CciqhiJaxhz ] ; for ( int i = 0 ; i < CciqhiJaxhz ; i ++ ) { int m = sc . nextInt ( ) ; b [ i ] = m ; } int w ; for ( int h = 0 ; h < ( CciqhiJaxhz / 2 ) ; h ++ ) { w = b [ h ] ; b [ h ] = b [ CciqhiJaxhz - 1 - h ] ; b [ CciqhiJaxhz - 1 - h ] = w ; } for ( int j = 0 ; j < CciqhiJaxhz - 1 ; j ++ ) { System . out . print ( b [ j ] + " " ) ; } System . out . print ( b [ CciqhiJaxhz - 1 ] ) ; System . out . println ( " " ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; class PehwXhpb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long PehwLpd = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; System . out . println ( PehwLpd * b ) ; } } import java . io . * ; import java . util . * ; class YnoApv { public static void main ( String [ ] args ) { solve ( ) ; } public static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; for ( int YnoF = 0 ; YnoF < s . length ( ) ; YnoF ++ ) { if ( YnoF == 3 ) { System . out . print ( 8 ) ; } else { System . out . print ( s . charAt ( YnoF ) ) ; } } System . out . println ( ) ; } } import java . util . Scanner ; import java . util . * ; class LawwhMn { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int lawwhMfug = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int [ ] sort = { lawwhMfug , 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 HisQtqtn { 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 HisQu : array ) { if ( map . containsKey ( HisQu ) ) { map . put ( HisQu , map . get ( HisQu ) + 1 ) ; } } System . out . println ( map . get ( '1' ) ) ; } } } import java . util . Scanner ; public class QpifvWc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int QpifvT = Integer . parseInt ( scanner . next ( ) ) ; System . out . println ( QpifvT * QpifvT * QpifvT ) ; } } import java . util . * ; public class BlqXys { public static void main ( String [ ] arg ) { Scanner scan = new Scanner ( System . in ) ; int BlqPm = scan . nextInt ( ) ; int [ ] p = new int [ BlqPm ] ; int check = 0 ; for ( int i = 0 ; i < BlqPm ; 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 mrpvH { public static void main ( String [ ] args ) throws IOException { new ABC133 ( ) . c ( ) ; } } class mrpvH { void c ( ) { long MrpvOl , R ; long M = 2019L ; Scanner in = new Scanner ( System . in ) ; MrpvOl = in . nextLong ( ) ; R = in . nextLong ( ) ; int ans = 2018 ; long maxI = ( long ) Math . min ( R , MrpvOl + M ) ; for ( long i = MrpvOl ; 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 PfnypUchf { 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 PfnypFc = Integer . parseInt ( a + b ) ; double number = Math . sqrt ( PfnypFc ) ; if ( number == Math . floor ( number ) ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } out . close ( ) ; } } import java . util . Scanner ; public class BhuqhGjpgj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int BhuqhP = scan . nextInt ( ) ; int [ ] a = new int [ BhuqhP ] ; for ( int i = 0 ; i < BhuqhP ; 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 < BhuqhP ; i ++ ) { a [ i ] /= 2 ; } count ++ ; } System . out . println ( count ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class JuodpzErcr { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str ; while ( ! ( ( str = br . readLine ( ) ) . equals ( " - " ) ) ) { int JuodpzWsg = Integer . parseInt ( br . readLine ( ) ) ; int [ ] arrH = new int [ JuodpzWsg ] ; for ( int i = 0 ; i < JuodpzWsg ; i ++ ) { arrH [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } shuff ( str , arrH , JuodpzWsg ) ; } } 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 TleNelvjc { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int TleSd = 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 < TleSd ; 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 CwzJdo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long cwzHgbi = sc . nextLong ( ) ; int ans = 0 ; for ( int i = 0 ; i < cwzHgbi ; i ++ ) { if ( s . charAt ( i ) == '1' ) { if ( i + 1 == cwzHgbi ) { ans = i ; break ; } } else { ans = i ; break ; } } System . out . println ( s . charAt ( ans ) ) ; } } import java . util . * ; public class WapavZdzz { public static void main ( String [ ] args ) { final String RESULT_YES = " Yes " ; final String RESULT_NO = " No " ; Scanner sc = new Scanner ( System . in ) ; int WapavC = sc . nextInt ( ) ; int locationCode = sc . nextInt ( ) ; String val = sc . next ( ) ; boolean result = false ; if ( val . matches ( " [0-9] { " + WapavC + " } -[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 CmmrgLs { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String readStr ; int cmmrgVod = 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 XxxnwuMmvdl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XxxnwuZi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; Set < Integer > ans1 = new TreeSet < > ( ) ; for ( int i = 1 ; i <= XxxnwuZi ; i ++ ) { if ( XxxnwuZi % 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 HczabuFde { 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 hczabuZrkk = Integer . parseInt ( array_of_li_col [ 0 ] ) ; int column = Integer . parseInt ( array_of_li_col [ 1 ] ) ; int [ ] [ ] matrix_array_A = new int [ hczabuZrkk ] [ column ] ; int [ ] vector_array_b = new int [ column ] ; for ( int line_A = 0 ; line_A < hczabuZrkk ; 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 < hczabuZrkk ; 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 FdghilRygv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int FdghilS = Integer . parseInt ( a + b ) ; for ( int i = 1 ; i < 400 ; i ++ ) { if ( i * i == FdghilS ) { 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 ZeeYrrgl { 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 ZeeIb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = 0 ; c += Main . combination ( ZeeIb , 2 ) ; c += Main . combination ( b , 2 ) ; System . out . println ( c ) ; } } import java . util . Scanner ; public class RhjId { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long rhjI = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long x1 = rhjI * c ; long x2 = rhjI * 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 AlfMej { 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 AlfMej { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int AlfDn = in . nextInt ( ) ; int b = in . nextInt ( ) ; out . println ( AlfDn * b % 2 == 1 ? " Odd " : " Even " ) ; } } static class AlfMej { 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 jdrT { public static void main ( String [ ] args ) { FastScanner scanner = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int JdrFe = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; out . println ( Math . max ( c - ( JdrFe - b ) , 0 ) ) ; out . flush ( ) ; } public static class jdrT { 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 NqdwkoLwbppz { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int NqdwkoSk = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( NqdwkoSk + b <= c * 2 ) { System . out . println ( NqdwkoSk * x + b * y ) ; return ; } int tmp = Math . min ( x , y ) ; int tmp2 = c * tmp * 2 ; int tmp3 = NqdwkoSk * ( 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 EhkUzlq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ehkDlxt = sc . nextInt ( ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; char [ ] s = new char [ ehkDlxt ] ; char [ ] t = new char [ ehkDlxt ] ; int i ; int m ; char [ ] b = new char [ 2 * ehkDlxt ] ; for ( i = 0 ; i < ehkDlxt ; i ++ ) { s [ i ] = S . charAt ( i ) ; } for ( i = 0 ; i < ehkDlxt ; i ++ ) { t [ i ] = T . charAt ( i ) ; } for ( i = 0 , m = 0 ; i < ehkDlxt ; i ++ , m = m + 2 ) { b [ m ] = s [ i ] ; } for ( i = 0 , m = 1 ; i < ehkDlxt ; i ++ , m = m + 2 ) { b [ m ] = t [ i ] ; } String str = String . valueOf ( b ) ; System . out . println ( str ) ; } } import java . util . Scanner ; public class QlqMaet { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double QlqUk = 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 = QlqUk * Math . cos ( ht ) ; double hy = QlqUk * 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 YhofrvGd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YhofrvBex = sc . nextInt ( ) ; for ( int i = 1 ; i <= 10 ; i ++ ) { if ( ( YhofrvBex - 1000 * i ) <= 0 ) { System . out . println ( ( YhofrvBex - 1000 * i ) * - 1 ) ; break ; } } } } import java . util . * ; public class KqlucJjcd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KqlucDy = sc . nextInt ( ) ; int [ ] h = new int [ KqlucDy ] ; for ( int i = 0 ; i < KqlucDy ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int [ ] q = new int [ KqlucDy ] ; Arrays . fill ( q , 0 ) ; q [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < KqlucDy ; 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 [ KqlucDy - 1 ] ) ; } } import java . util . * ; public class KqdHvb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double kqdZso = scan . nextInt ( ) ; System . out . println ( 2 * Math . PI * kqdZso ) ; scan . close ( ) ; return ; } } import java . util . * ; public class skiczBg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SkiczNptbl = sc . nextInt ( ) ; int syainj = sc . nextInt ( ) ; System . out . println ( SkiczNptbl * syainj ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class TnronkCh { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int tnronkEsz = Integer . parseInt ( str [ 0 ] ) ; int a = Integer . parseInt ( str [ 1 ] ) ; System . out . println ( ( tnronkEsz + a - 1 ) / a ) ; } } import java . util . Scanner ; public class FrshcHve { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int frshcXsts = sc . nextInt ( ) ; String S = sc . next ( ) ; int count = 0 ; for ( int i = 0 ; i < frshcXsts - 2 ; i ++ ) { if ( S . substring ( i , i + 3 ) . equals ( " ABC " ) ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class XnntdcYeq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String buff = " " ; int XnntdcWx = 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 < XnntdcWx ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < XnntdcWx - 1 ; i ++ ) { for ( int j = i + 1 ; j < XnntdcWx ; j ++ ) { count += array [ i ] * array [ j ] ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class mrstmlOp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int MrstmlNx = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int T = scanner . nextInt ( ) ; int ans = T / MrstmlNx * B ; System . out . println ( ans ) ; scanner . close ( ) ; } } import java . util . Scanner ; public class arfJv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] chars = sc . next ( ) . toCharArray ( ) ; for ( char ArfEhfm : chars ) { if ( ArfEhfm == '1' ) { System . out . print ( 9 ) ; } else if ( ArfEhfm == '9' ) { System . out . print ( 1 ) ; } else { System . out . println ( ArfEhfm ) ; } } System . out . println ( ) ; } } import java . util . Scanner ; public class LanwgzDonjx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LanwgzN = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; if ( LanwgzN <= ( 2 * D + 1 ) ) { System . out . println ( 1 ) ; } else { int num = 0 ; while ( LanwgzN > 0 ) { LanwgzN -= ( 2 * D + 1 ) ; num ++ ; } System . out . println ( num ) ; } } } import java . util . * ; public class spyelK { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int SpyelUj = sc . nextInt ( ) ; int leg = sc . nextInt ( ) ; if ( leg % 2 == 1 ) { System . out . println ( " No " ) ; } else if ( leg < 2 * SpyelUj ) { System . out . println ( " No " ) ; } else if ( leg > 4 * SpyelUj ) { 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 NxpHni { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nxpC = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( Math . max ( Math . max ( nxpC + b , nxpC - b ) , nxpC * b ) ) ; } } import java . util . * ; class NxnnJoz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NxnnT = sc . nextInt ( ) , count = 0 ; for ( int i = 0 ; i < NxnnT ; i ++ ) { if ( sc . nextInt ( ) == count + 1 ) { count ++ ; } } System . out . println ( count == 0 ? - 1 : NxnnT - count ) ; } } import java . util . Scanner ; public class zbbeoA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZbbeoWezsi = sc . nextInt ( ) ; int [ ] arrayA = new int [ ZbbeoWezsi ] ; 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 CvgdaYx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cvgdaFqnx = sc . nextInt ( ) ; int [ ] w = new int [ cvgdaFqnx ] ; for ( int i = 0 ; i < cvgdaFqnx ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } int min = 1000000000 ; for ( int i = 0 ; i < cvgdaFqnx ; i ++ ) { int s1 = 0 ; int s2 = 0 ; for ( int j = 0 ; j <= i ; j ++ ) { s1 += w [ j ] ; } for ( int k = i + 1 ; k <= cvgdaFqnx - 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 jmcxeyEs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JmcxeyYk , M ; JmcxeyYk = sc . nextInt ( ) ; M = sc . nextInt ( ) ; int [ ] broken = new int [ JmcxeyYk + 1 ] ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) ; broken [ a ] = 1 ; } int [ ] dp = new int [ JmcxeyYk + 2 ] ; dp [ JmcxeyYk ] = 1 ; for ( int i = JmcxeyYk - 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 rsideSva { 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 RsideItt = num . length ( ) ; System . out . println ( RsideItt ) ; } } import java . util . LinkedHashSet ; import java . util . Scanner ; import java . util . Set ; public class GzvrhUi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gzvrhSmv = sc . nextInt ( ) ; int [ ] numbers = new int [ gzvrhSmv ] ; for ( int i = 0 ; i < gzvrhSmv ; 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 KwuOm { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; int kwuZmc = scan . nextInt ( ) ; double sum = 0 ; for ( int i = 0 ; i < kwuZmc && scan . hasNextInt ( ) ; i ++ ) { sum += ( 1 / ( double ) scan . nextInt ( ) ) ; } System . out . println ( 1 / sum ) ; } } import java . util . * ; public class BixbnvSfab { public static void main ( String [ ] args ) { int bixbnvZt = 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 ) bixbnvZt = 1 ; System . out . println ( max_area + " " + bixbnvZt ) ; } } import java . util . * ; public class TcvblhTn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tcvblhGlrl = sc . nextInt ( ) ; int [ ] nums = new int [ tcvblhGlrl ] ; for ( int i = 0 ; i < tcvblhGlrl ; i ++ ) { nums [ i ] = sc . nextInt ( ) ; } int output = 0 ; flag2 : while ( true ) { for ( int i = 0 ; i < tcvblhGlrl ; i ++ ) { if ( nums [ i ] > 0 ) { output ++ ; for ( int j = 0 ; j < tcvblhGlrl - 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 HsrrhzMyf { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String str = in . nextLine ( ) ; char HsrrhzQum ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { HsrrhzQum = str . charAt ( i ) ; if ( Character . isUpperCase ( HsrrhzQum ) ) System . out . print ( Character . toLowerCase ( HsrrhzQum ) ) ; else System . out . print ( Character . toUpperCase ( HsrrhzQum ) ) ; } System . out . println ( ) ; } } import java . util . * ; public class ZpzpbOnqlfv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZpzpbInq = sc . nextInt ( ) ; int bInt = sc . nextInt ( ) ; int seki = ZpzpbInq * 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 VmqTjg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vmqK = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; int max = 0 ; for ( int i = 0 ; i < vmqK ; 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 CovSi { public static void main ( String [ ] args ) { Scanner t = new Scanner ( System . in ) ; String S = t . nextLine ( ) ; int covO = 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 WalptWn { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; List < Integer > heightsOfMountain = new ArrayList < Integer > ( ) ; String walptLrns = null ; while ( ( walptLrns = br . readLine ( ) ) != null ) { heightsOfMountain . add ( Integer . valueOf ( walptLrns ) ) ; } 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 jvyQjk { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int JvyMluzw = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char ss = s . charAt ( i ) ; char tt = t . charAt ( i ) ; if ( ss != tt ) JvyMluzw ++ ; } System . out . println ( JvyMluzw ) ; } } import java . util . Scanner ; public class nrbccIyx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; int NrbccEebp = input . length ( ) ; String [ ] n = new String [ 30 ] ; for ( int i = 0 ; i < NrbccEebp ; i ++ ) { n [ i ] = input . substring ( i , i + 1 ) ; } for ( int i = ( NrbccEebp - 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 XevfTsw { final static Long MAX = 1000000000000000000L ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xevfBs = sc . nextInt ( ) ; sc . nextLine ( ) ; List < Long > l = new ArrayList < Long > ( ) ; for ( int i = 0 ; i < xevfBs ; 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 NxcqQna { static boolean solve ( int NxcqGtb , int t , int s ) { if ( s * t >= NxcqGtb ) return true ; else return false ; } public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int NxcqGtb , t , s ; NxcqGtb = stdIn . nextInt ( ) ; t = stdIn . nextInt ( ) ; s = stdIn . nextInt ( ) ; boolean result = solve ( NxcqGtb , t , s ) ; if ( result ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; stdIn . close ( ) ; } } import java . util . * ; public class NktKqfexv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; long NktS = sc . nextLong ( ) ; int i = 0 ; while ( i < S . length ( ) && S . charAt ( i ) == '1' ) { i ++ ; } if ( i == S . length ( ) || NktS <= 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 LkpEcv { 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 LkpIl , W ; while ( true ) { LkpIl = sc . nextInt ( ) ; W = sc . nextInt ( ) ; if ( LkpIl == 0 && W == 0 ) break ; height . add ( LkpIl ) ; 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 cdwfhFbl { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int CdwfhXby = sc . nextInt ( ) ; int [ ] arr = new int [ CdwfhXby ] ; int [ ] dp = new int [ CdwfhXby ] ; for ( int i = 0 ; i < CdwfhXby ; i ++ ) arr [ i ] = sc . nextInt ( ) ; Arrays . fill ( dp , 0 ) ; if ( CdwfhXby == 1 ) { System . out . println ( arr [ 0 ] ) ; return ; } dp [ 1 ] = Math . abs ( arr [ 1 ] - arr [ 0 ] ) ; for ( int i = 2 ; i < CdwfhXby ; 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 [ CdwfhXby - 1 ] ) ; return ; } } import java . util . * ; class SuygYlwf { public static void main ( String [ ] args ) { int suygTk = 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 ] ) { suygTk ++ ; } else if ( a [ 0 ] == a [ 2 ] && a [ 1 ] == a [ 3 ] ) { suygTk ++ ; } else if ( a [ 0 ] == a [ 3 ] && a [ 1 ] == a [ 2 ] ) { suygTk ++ ; } System . out . print ( ans [ suygTk ] ) ; } } import java . util . * ; import java . io . * ; public class VpytduSvku { 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 vpytduC = s . length ( ) ; int m = t . length ( ) ; int gg = m ; for ( int i = 0 ; i <= vpytduC - 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 YyeixcSznxp { public static int YyeixcSz = 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 XuwsSqbxor { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int XuwsNhn = 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 <= XuwsNhn ; 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 BxurAp { 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 KpjOe { 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 KpjCw = Integer . parseInt ( br . readLine ( ) ) ; System . out . println ( ( int ) Math . pow ( KpjCw , 3 ) ) ; } } import java . util . * ; public class CpwbIocli { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CpwbC = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int ans = 0 ; ans = ( CpwbC + ( d * 2 + 1 ) - 1 ) / ( d * 2 + 1 ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class OzkBlaubw { public static void main ( String [ ] args ) throws Exception { try ( Scanner sc = new Scanner ( System . in ) ) { int OzkSli = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int L_MAX = 0 ; int R_MIN = OzkSli + 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 ClbyWss { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int clbyEi = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int hitNum = ( int ) Math . ceil ( ( double ) clbyEi / A ) ; System . out . print ( hitNum ) ; } } import java . util . * ; class SmfTodacp { Scanner sc ; String s ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { s = sc . next ( ) ; for ( int SmfN = 0 ; SmfN < s . length ( ) ; SmfN ++ ) { char c = s . charAt ( SmfN ) ; if ( ( SmfN % 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 QvkkCvjwua { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int QvkkZk = sc . nextInt ( ) , d [ ] = new int [ QvkkZk + 1 ] ; for ( int i = 0 ; i < QvkkZk ; ++ i ) d [ i ] = sc . nextInt ( ) ; sc . close ( ) ; d [ QvkkZk ] = 1000 ; Arrays . sort ( d ) ; int ans = 0 ; for ( int i = 0 ; i < QvkkZk ; ++ i ) { if ( d [ i ] != d [ i + 1 ] ) ++ ans ; } System . out . println ( ans ) ; } } import java . util . * ; public class TkbXienjn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TkbSmu = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int count = 0 ; for ( int i = TkbSmu ; 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 trbIt { public static void main ( String [ ] args ) { Scanner Str = new Scanner ( System . in ) ; int TrbXul = Integer . parseInt ( Str . next ( ) ) ; int b = Integer . parseInt ( Str . next ( ) ) ; if ( Math . floor ( TrbXul / 10 ) + Math . floor ( b / 10 ) == 0 ) { System . out . println ( TrbXul * b ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . * ; public class OxropUfg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oxropHgty = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= oxropHgty ; 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 CguhfsBik { 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 cguhfsI = 0 ; cguhfsI < s . length ; cguhfsI ++ ) que . addLast ( s [ cguhfsI ] ) ; while ( true ) { StringBuilder sb = new StringBuilder ( ) ; for ( int cguhfsI = 0 ; cguhfsI < 5 ; cguhfsI ++ ) 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 OfptugPx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; final int OfptugIbt = Integer . parseInt ( sc . next ( ) ) ; long [ ] a = new long [ OfptugIbt + 1 ] ; long [ ] b = new long [ OfptugIbt ] ; for ( int i = 0 ; i < OfptugIbt + 1 ; i ++ ) { a [ i ] = Long . parseLong ( sc . next ( ) ) ; } for ( int i = 0 ; i < OfptugIbt ; i ++ ) { b [ i ] = Long . parseLong ( sc . next ( ) ) ; } long ans = 0 ; for ( int i = 0 ; i < OfptugIbt ; 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 KqcpaAem { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kqcpaAnt = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; String ans = " " ; int max = kqcpaAnt * 5000 ; if ( kqcpaAnt * 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 <= ( kqcpaAnt - i ) ; j ++ ) { int value = sum ; value += j * 5000 ; int k = kqcpaAnt - ( 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 FjzvdUw { public static void main ( String [ ] args ) { int fjzvdPs , 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 ( fjzvdPs = 0 ; fjzvdPs < n ; fjzvdPs ++ ) array [ fjzvdPs ] = 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 DhazaiHr { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int DhazaiQ = Integer . parseInt ( in . readLine ( ) ) ; int ans = 0 ; while ( DhazaiQ >= 5 ) { if ( DhazaiQ >= 500 ) { ans += 1000 * ( DhazaiQ / 500 ) ; DhazaiQ %= 500 ; } else { ans += 5 * ( DhazaiQ / 5 ) ; DhazaiQ %= 5 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class RvcreXp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rvcrePqx = sc . nextInt ( ) ; int cnt = 1 ; while ( true ) { if ( rvcrePqx == 1 || rvcrePqx == 2 || rvcrePqx == 4 ) { System . out . println ( cnt + 3 ) ; return ; } if ( rvcrePqx % 2 == 0 ) rvcrePqx /= 2 ; else rvcrePqx = rvcrePqx * 3 + 1 ; cnt ++ ; } } } import java . util . Scanner ; public class gtlL { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] ar = scanner . nextLine ( ) . split ( " " ) ; for ( int GtlNxsu = 0 ; GtlNxsu < ar . length ; GtlNxsu ++ ) { if ( Integer . parseInt ( ar [ GtlNxsu ] ) == 0 ) { System . out . println ( GtlNxsu + 1 ) ; } } } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class OqqfynFl { public static void main ( String [ ] args ) { solve ( System . in , System . out ) ; } static void solve ( InputStream is , PrintStream os ) { Scanner sc = new Scanner ( is ) ; int oqqfynS = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < oqqfynS ; i ++ ) { int h = sc . nextInt ( ) ; if ( k <= h ) ans ++ ; } os . println ( ans ) ; } } import java . util . Scanner ; public class xhpkeD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XhpkeRgw = sc . nextInt ( ) ; int [ ] h = new int [ XhpkeRgw ] ; int count = 0 ; for ( int i = 0 ; i < XhpkeRgw ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int a = 0 ; int b = 0 ; L : while ( a <= XhpkeRgw - 1 && b <= XhpkeRgw - 1 ) { if ( h [ a ] == 0 ) { a ++ ; continue ; } b = a ; while ( b <= XhpkeRgw - 1 ) { if ( h [ b ] != 0 && b != XhpkeRgw - 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 jnrM { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int JnrPz = 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 [ JnrPz ] ; int [ ] pe = new int [ JnrPz ] ; 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 dhxqUs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DhxqQfuml = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= DhxqQfuml ; i ++ ) { int digCount = digCount ( i ) ; if ( digCount % 2 != 0 ) { ans ++ ; } } System . out . println ( ans ) ; } static int digCount ( int DhxqQfuml ) { int res = 0 ; while ( DhxqQfuml > 0 ) { res ++ ; DhxqQfuml /= 10 ; } return res ; } } import java . util . Scanner ; public class OckHzidgw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OckSof = sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; System . out . println ( e - OckSof > k ? " :( " : " Yay! " ) ; } } import java . util . Scanner ; public class TewBoiz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tewGd = sc . nextInt ( ) ; long [ ] a = new long [ tewGd + 1 ] ; long [ ] b = new long [ tewGd ] ; for ( int i = 0 ; i < tewGd + 1 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < tewGd ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } long fii1 = 0 ; long sum = 0 ; for ( int i = 0 ; i < tewGd ; 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 soiwhMf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SoiwhBkz , b , c ; SoiwhBkz = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; System . out . println ( c + " " + SoiwhBkz + " " + b ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class WygNflqt { 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 WygAd = 0 ; for ( int i = 0 ; i < tiles . length ( ) ; i ++ ) { if ( tile != tiles . charAt ( i ) ) WygAd ++ ; tile = tile == '0' ? '1' : '0' ; } return WygAd ; } } import java . util . Scanner ; class NlmantYqz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nlmantGe = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] A = new int [ nlmantGe ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < nlmantGe ; 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 < nlmantGe ; 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 zdswrM { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int ZdswrLs = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; System . out . println ( Math . max ( 0 , C - ( ZdswrLs - B ) ) ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } } import java . util . * ; public class pexbjhIcd { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int PexbjhCe = sc . nextInt ( ) ; int [ ] [ ] array = new int [ PexbjhCe ] [ 2 ] ; for ( int i = 0 ; i < PexbjhCe ; i ++ ) { array [ i ] [ 0 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < PexbjhCe ; i ++ ) { array [ i ] [ 1 ] = sc . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < PexbjhCe ; i ++ ) { int s = array [ i ] [ 0 ] - array [ i ] [ 1 ] ; if ( s > 0 ) { sum += s ; } } System . out . println ( sum ) ; } } import java . util . * ; public class atnjoMfo { Scanner sc ; public static void main ( String [ ] args ) { new Main ( ) . execute ( ) ; } public void execute ( ) { this . sc = new Scanner ( System . in ) ; int AtnjoElm = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < AtnjoElm ; 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 drpnuoXc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long DrpnuoNui = sc . nextInt ( ) ; long n = sc . nextInt ( ) ; long k = 0 ; boolean stop = false ; if ( DrpnuoNui < n ) { k = DrpnuoNui ; } else { k = n ; } for ( ; k >= 1 && stop == false ; k -- ) { if ( n % k == 0 && DrpnuoNui % k == 0 ) { stop = true ; } } long l = n * DrpnuoNui / ( 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 CuwLhncj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CuwPc = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < CuwPc ; 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 WkqwxyTda { 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 WkqwxyTda { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int wkqwxyYft = in . nextInt ( ) ; int b = in . nextInt ( ) ; out . print ( wkqwxyYft * b % 2 == 0 ? " Even " : " Odd " ) ; } } static class WkqwxyTda 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 PeozFn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PeozCk = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int C = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int a = PeozCk ; 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 ( PeozCk + b + C , PeozCk + B + c ) ) ) ; } } import java . util . Scanner ; public class uodxLfg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UodxHqgf = 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 [ UodxHqgf + 1 ] ; int [ ] waA = new int [ UodxHqgf + 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 VprayNt { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; try { while ( true ) { String line = sc . next ( ) ; if ( line . equals ( " - " ) ) { break ; } int VprayZ = sc . nextInt ( ) ; for ( int i = 0 ; i < VprayZ ; 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 bhbQ { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int BhbUye = stdIn . nextInt ( ) ; for ( int n = 1 ; BhbUye != 0 ; n ++ ) { System . out . println ( " Case " + n + " : " + BhbUye ) ; BhbUye = stdIn . nextInt ( ) ; } } } import java . util . * ; public class SnjEds { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SnjIk = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int plus = SnjIk + B ; int minus = SnjIk - B ; int kakeru = SnjIk * 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 GbgcVlrf { 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 gbgcEnw = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( gcd ( gbgcEnw , b ) ) ; } } import java . util . Scanner ; public class EajkfrGvjn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int EajkfrB = scanner . nextInt ( ) ; int [ ] h = new int [ EajkfrB ] ; int [ ] curH = new int [ EajkfrB ] ; for ( int i = 0 ; i < EajkfrB ; i ++ ) { h [ i ] = scanner . nextInt ( ) ; } int count = 0 ; outer : while ( true ) { int start = 0 , end = 0 ; for ( start = 0 ; start < EajkfrB ; start ++ ) { if ( curH [ start ] < h [ start ] ) { break ; } } if ( start >= EajkfrB ) { break ; } count ++ ; int i ; for ( i = start ; i < EajkfrB ; i ++ ) { if ( curH [ i ] < h [ i ] ) { curH [ i ] ++ ; } else { break ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class JhbhGzum { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jhbhRdf = Integer . parseInt ( scan . next ( ) ) ; int x = 0 ; int y = 0 ; int t = 0 ; boolean possible = true ; for ( int i = 0 ; i < jhbhRdf ; ++ 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 WjvkzrPzbhah { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WjvkzrTcr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; if ( WjvkzrTcr == 0 ) { WjvkzrTcr = 1 ; } else if ( WjvkzrTcr == 1 ) { WjvkzrTcr = 100 ; } else { WjvkzrTcr = 10000 ; } for ( int i = 1 ; i <= b ; i ++ ) { ans = WjvkzrTcr * i ; if ( i >= 100 ) { ans = WjvkzrTcr * ( i + 1 ) ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; public class wuyjpuF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WuyjpuQjsmp = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a % WuyjpuQjsmp == 0 || b % WuyjpuQjsmp == 0 ) { System . out . println ( " OK " ) ; return ; } int rem = a % WuyjpuQjsmp ; int temp = a - rem ; temp += WuyjpuQjsmp ; for ( int i = temp ; i < b ; i += WuyjpuQjsmp ) { if ( temp > a ) { System . out . println ( " OK " ) ; return ; } } System . out . println ( " NG " ) ; } } import java . io . IOException ; import java . util . * ; public class KvwwgNw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KvwwgVjx = sc . nextInt ( ) ; int [ ] s = new int [ KvwwgVjx ] ; for ( int i = 0 ; i < KvwwgVjx ; 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 = KvwwgVjx - 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 yiiZg { public static void main ( String [ ] args ) { Scanner sn = new Scanner ( System . in ) ; int YiiTje = sn . nextInt ( ) ; int b = sn . nextInt ( ) ; int c = sn . nextInt ( ) ; int co = 0 ; for ( int i = YiiTje ; i <= b ; i ++ ) { if ( c % i != 0 ) { continue ; } co ++ ; } System . out . println ( co ) ; } } import java . util . * ; public class OkxnmTq { 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 OkxnmBmn = 0 ; int ans = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( Y [ i ] . equals ( " # " ) ) { OkxnmBmn ++ ; ans = ( OkxnmBmn > ans ) ? OkxnmBmn : ans ; if ( OkxnmBmn == S . length ( ) ) { ans = OkxnmBmn ; } } else { ans = ( OkxnmBmn > ans ) ? OkxnmBmn : ans ; OkxnmBmn = 0 ; } } System . out . println ( ans ) ; keyboard . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class GpztEve { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String gpztPdxo = br . readLine ( ) ; char [ ] ch = gpztPdxo . 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 QdbtPb { void run ( ) { Scanner scan = new Scanner ( System . in ) ; int QdbtWla = scan . nextInt ( ) ; int [ ] a = new int [ 100 ] ; for ( int i = 0 ; i < QdbtWla ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } System . out . print ( a [ QdbtWla - 1 ] ) ; for ( int i = QdbtWla - 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 sqogmQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SqogmDza = sc . nextInt ( ) ; int [ ] H = new int [ SqogmDza ] ; 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 sezA { static DecimalFormat df = new DecimalFormat ( " 0.0000000000000000000 " ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int SezDzk = sc . nextInt ( ) ; String op = sc . next ( ) ; int b = sc . nextInt ( ) ; if ( op . equals ( " ? " ) ) break ; if ( op . equals ( " + " ) ) System . out . println ( SezDzk + b ) ; else if ( op . equals ( " - " ) ) System . out . println ( SezDzk - b ) ; else if ( op . equals ( " * " ) ) System . out . println ( SezDzk * b ) ; else System . out . println ( SezDzk / b ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class yndpNfy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int YndpIay = sc . nextInt ( ) , a = sc . nextInt ( ) , b = sc . nextInt ( ) ; if ( a % YndpIay == 0 || b % YndpIay == 0 ) { System . out . println ( " OK " ) ; } else { if ( b / YndpIay - a / YndpIay == 0 ) { System . out . println ( " NG " ) ; } else { System . out . println ( " OK " ) ; } } } } import java . util . * ; public class PzqfYwskgo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int PzqfIvp = scan . nextInt ( ) ; HashMap < Integer , Integer > a = new HashMap < Integer , Integer > ( ) ; int [ ] b = new int [ PzqfIvp ] ; for ( int i = 0 ; i < PzqfIvp ; i ++ ) { int t = scan . nextInt ( ) ; a . put ( t , i + 1 ) ; b [ i ] = t ; } Arrays . sort ( b ) ; for ( int j = 0 ; j < PzqfIvp - 1 ; j ++ ) { System . out . print ( a . get ( b [ j ] ) + " " ) ; } System . out . println ( a . get ( b [ PzqfIvp - 1 ] ) ) ; } } import java . util . * ; public class DbnYu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dbnGc = sc . nextInt ( ) ; if ( dbnGc >= 100 && dbnGc < 112 ) { System . out . println ( 111 ) ; } else if ( dbnGc >= 112 && dbnGc <= 222 ) { System . out . println ( 222 ) ; } else if ( dbnGc > 222 && dbnGc <= 333 ) { System . out . println ( 333 ) ; } else if ( dbnGc > 333 && dbnGc <= 444 ) { System . out . println ( 444 ) ; } else if ( dbnGc > 444 && dbnGc <= 555 ) { System . out . println ( 555 ) ; } else if ( dbnGc > 555 && dbnGc <= 666 ) { System . out . println ( 666 ) ; } else if ( dbnGc > 666 && dbnGc <= 777 ) { System . out . println ( 777 ) ; } else if ( dbnGc > 777 && dbnGc <= 888 ) { System . out . println ( 888 ) ; } else if ( dbnGc > 888 && dbnGc <= 999 ) { System . out . println ( 999 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class CdhvhjTbdy { static int cdhvhjNqj ; 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+ " ) ; cdhvhjNqj = Integer . parseInt ( word [ 0 ] ) ; B = Integer . parseInt ( word [ 1 ] ) ; System . out . println ( cdhvhjNqj * B ) ; br . close ( ) ; } } import java . util . Scanner ; import static java . lang . Math . ceil ; class CvngkOm { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int CvngkJbs = input . nextInt ( ) ; int b = input . nextInt ( ) ; System . out . println ( ( int ) ceil ( ( 1.0 * CvngkJbs ) / ( 1.0 * b ) ) ) ; } } import java . util . * ; public class EhyCatau { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int EhyI = scanner . nextInt ( ) ; Integer [ ] d = new Integer [ EhyI ] ; int s = 1 ; for ( int i = 0 ; i < EhyI ; i ++ ) { d [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( d , Comparator . reverseOrder ( ) ) ; for ( int i = 0 ; i < EhyI - 1 ; i ++ ) { if ( d [ i ] > d [ i + 1 ] ) s ++ ; } System . out . println ( s ) ; } } import java . util . * ; public class JmujLmt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JmujXri = sc . nextInt ( ) ; int [ ] x = new int [ JmujXri ] ; int [ ] y = new int [ JmujXri + 1 ] ; for ( int i = 0 ; i < JmujXri ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ x [ i ] ] = i + 1 ; } for ( int i = 1 ; i <= JmujXri ; i ++ ) System . out . print ( y [ i ] + " " ) ; } } import java . io . StringReader ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; class kplvakMl { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int KplvakSjqq = 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 / KplvakSjqq ; if ( ( pointSum % KplvakSjqq ) > ( ( double ) KplvakSjqq / 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 DixofFr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int DixofPbg = 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 ( DixofPbg > sum ? " No " : " Yes " ) ; } } import java . util . Scanner ; import java . util . Date ; class rspEt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RspFk , b , c , m , n ; while ( sc . hasNext ( ) ) { RspFk = sc . nextInt ( ) ; b = sc . nextInt ( ) ; m = RspFk ; 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 , RspFk / m * b ) ; } } } import java . util . Scanner ; public class UfpiyJaceb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UfpiyQ = 0 ; while ( sc . hasNext ( ) ) { String s = sc . next ( ) ; if ( s . equals ( " 0 " ) ) { break ; } UfpiyQ = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; int digit = c - '0' ; UfpiyQ += digit ; } System . out . printf ( " %d \n " , UfpiyQ ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class EpfcHk { 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 epfcIei = 0 ; epfcIei < s . length ( ) ; epfcIei ++ ) { C [ epfcIei ] = s . charAt ( epfcIei ) ; } for ( int epfcIei = 0 ; epfcIei < s . length ( ) ; epfcIei ++ ) { if ( C [ epfcIei ] == '1' ) { c . add ( '1' ) ; } if ( C [ epfcIei ] == '0' ) { c . add ( '0' ) ; } if ( C [ epfcIei ] == 'B' && c . size ( ) > 0 ) { c . remove ( c . size ( ) - 1 ) ; } } for ( int epfcIei = 0 ; epfcIei < c . size ( ) ; epfcIei ++ ) { System . out . print ( c . get ( epfcIei ) ) ; } } } import java . util . * ; public class EyfAypl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EyfYic = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { EyfYic -= sc . nextInt ( ) ; } System . out . println ( EyfYic >= 0 ? EyfYic : - 1 ) ; } } import java . util . Scanner ; public class gvdydaPxf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String [ ] strArray = scan . nextLine ( ) . split ( " " ) ; int GvdydaGi = Integer . parseInt ( strArray [ 0 ] ) ; int A = Integer . parseInt ( strArray [ 1 ] ) ; int lastCount = 0 ; for ( int i = 1 ; GvdydaGi > 0 ; i ++ ) { GvdydaGi = GvdydaGi - A ; lastCount = i ; } System . out . println ( lastCount ) ; } } import java . util . * ; class SmmgtqUbsits { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SmmgtqNr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; for ( int i = SmmgtqNr ; 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 pyjvlVdi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PyjvlKdgi = sc . nextInt ( ) ; System . out . println ( Math . ceil ( PyjvlKdgi / 2d ) / ( double ) PyjvlKdgi ) ; } } import java . util . Scanner ; public class joiRu { public static void main ( String [ ] args ) { int JoiSez , 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 ] ) { JoiSez = next [ 1 ] ; next [ 1 ] = next [ 0 ] ; next [ 0 ] = JoiSez ; } 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 OthptzXg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int othptzSbbv = scan . nextInt ( ) ; int i ; for ( i = 1 ; i <= othptzSbbv ; i ++ ) { if ( i > othptzSbbv ) 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 VrnfqsBo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; int VrnfqsX = sc . nextInt ( ) ; int [ ] a = new int [ VrnfqsX ] ; for ( int i = 0 ; i < VrnfqsX ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int t = a [ VrnfqsX - 1 ] ; int max = 0 , cnt = 0 ; for ( int i = VrnfqsX - 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 DcyhXds { private static final Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int DcyhGz = scanner . nextInt ( ) ; boolean canReach = true ; int prevT = 0 ; int prevX = 0 ; int prevY = 0 ; for ( int i = 0 ; i < DcyhGz ; 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 lzddNc { 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 LzddEznh = scan . nextInt ( ) ; for ( int d = 0 ; d < LzddEznh ; d ++ ) { sum [ d ] = 0 ; } int b = scan . nextInt ( ) ; for ( int c = 0 ; c < LzddEznh ; 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 < LzddEznh ; c ++ ) { for ( int d = 0 ; d < b ; d ++ ) { sum [ c ] += h [ c ] [ d ] * m [ d ] ; } } for ( int c = 0 ; c < LzddEznh ; c ++ ) { System . out . println ( sum [ c ] ) ; } } } import java . util . * ; public class XvvkZlbzm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XvvkGo = sc . nextInt ( ) ; int [ ] A = new int [ XvvkGo ] ; for ( int i = 0 ; i < XvvkGo ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } long [ ] L = new long [ XvvkGo ] ; for ( int i = 1 ; i < XvvkGo ; 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 < XvvkGo ; 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 SvkYp { 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 SvkYp { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int svkUwd = in . next ( ) . length ( ) ; String s = " " ; for ( int i = 0 ; i < svkUwd ; i ++ ) { s += 'x' ; } out . print ( s ) ; } } } import java . util . * ; public class pxilzJqj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int PxilzDzjx = 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 ( PxilzDzjx ) ; return ; } for ( int i = 0 ; i < n ; i ++ ) { int countm = 0 ; int countp = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( PxilzDzjx - i != p [ j ] ) { countm ++ ; } if ( PxilzDzjx + i != p [ j ] ) { countp ++ ; } } if ( countm == n ) { System . out . println ( PxilzDzjx - i ) ; return ; } else if ( countp == n ) { System . out . println ( PxilzDzjx + i ) ; return ; } } System . out . println ( PxilzDzjx - 1 ) ; } } import java . util . Scanner ; public class UboXirl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int uboRrs = 0 ; uboRrs += s . charAt ( 0 ) == '1' ? 1 : 0 ; uboRrs += s . charAt ( 1 ) == '1' ? 1 : 0 ; uboRrs += s . charAt ( 2 ) == '1' ? 1 : 0 ; System . out . println ( uboRrs ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class PpwunzBspjr { 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 PpwunzSck = Integer . parseInt ( depth_width [ 0 ] ) ; int width = Integer . parseInt ( depth_width [ 1 ] ) ; ; int perimeter = PpwunzSck * 2 + width * 2 ; int area = PpwunzSck * width ; System . out . println ( area + " " + perimeter ) ; } } import java . io . PrintStream ; import java . util . Scanner ; public class TwfznHq { static final PrintStream out = System . out ; static Scanner sc = new Scanner ( System . in ) ; static final long twfznGcz = 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 TarQmarj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int TarCb = 0 ; TarCb < s . length ( ) ; TarCb ++ ) { if ( TarCb % 2 == 0 ) { sb . append ( '0' ) ; } else { sb . append ( '1' ) ; } } String zero = sb . toString ( ) ; sb = new StringBuffer ( ) ; for ( int TarCb = 0 ; TarCb < s . length ( ) ; TarCb ++ ) { if ( TarCb % 2 == 1 ) { sb . append ( '0' ) ; } else { sb . append ( '1' ) ; } } String one = sb . toString ( ) ; int z = 0 ; int o = 0 ; for ( int TarCb = 0 ; TarCb < s . length ( ) ; TarCb ++ ) { if ( s . charAt ( TarCb ) == zero . charAt ( TarCb ) ) { z ++ ; } else { o ++ ; } } System . out . println ( Math . min ( z , o ) ) ; } } import java . io . * ; class MasxClwlq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int MasxBno = Integer . parseInt ( br . readLine ( ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; long min = 1000000 ; long max = - 1000000 ; long sum = 0 ; for ( int i = 0 ; i < MasxBno ; 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 PpjuceWnnh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ppjuceNiq = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = new Main ( ) . gcd ( Math . max ( ppjuceNiq , b ) , Math . min ( ppjuceNiq , 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 FueqdnBg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FueqdnJns = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; int Q = sc . nextInt ( ) ; long lim = K - Q ; int [ ] winCon = new int [ FueqdnJns + 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 VciDqww { int vciYc , y ; public void suzuki ( ) { Scanner sc = new Scanner ( System . in ) ; vciYc = sc . nextInt ( ) ; y = sc . nextInt ( ) ; while ( vciYc != 0 || y != 0 ) { if ( vciYc > y ) { System . out . println ( y + " " + vciYc ) ; } else { System . out . println ( vciYc + " " + y ) ; } vciYc = sc . nextInt ( ) ; y = sc . nextInt ( ) ; } } public static void main ( String [ ] args ) { new Main ( ) . suzuki ( ) ; } } import java . util . Scanner ; public class DbdPqfr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . nextLine ( ) ; int DbdYvo = Integer . parseInt ( str ) ; for ( int i = 1 ; i < 10 ; i ++ ) { if ( DbdYvo % i == 0 & DbdYvo / i < 10 ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . * ; public class YhzFz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yhzIpxu = 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 UlasWzwb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ulasXi = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < ulasXi ; 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 OikbgtZi { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int OikbgtHy = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < OikbgtHy ; 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 KbcBr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kbcXt = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long out = kbcXt ; long a1 = kbcXt ; long b1 = b ; while ( ! ( out % kbcXt == 0 && out % b == 0 ) ) { out = a1 > b1 ? a1 : b1 ; if ( a1 < out ) { a1 += kbcXt ; } if ( b1 < out ) { b1 += b ; } } System . out . println ( out ) ; } } import java . util . Scanner ; public class cwfQ { 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 CwfBxw = 0 ; CwfBxw < you . length ; CwfBxw ++ ) { if ( s . equals ( you [ CwfBxw ] ) ) { System . out . print ( 7 - CwfBxw ) ; 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 pyaM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PyaZqv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int ans = getKth ( getGcd ( PyaZqv , b ) , k ) ; System . out . println ( ans ) ; } static int getGcd ( int PyaZqv , int b ) { if ( PyaZqv == 0 ) { return b ; } return getGcd ( b % PyaZqv , PyaZqv ) ; } 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 zfhtJyr { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int ZfhtLfzm = 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 qxtrxjNd { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int QxtrxjZqf = 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 = QxtrxjZqf - aArray [ n - 1 ] + aArray [ 0 ] ; pq . add ( dist ) ; } else { pq . add ( aArray [ i ] - aArray [ i - 1 ] ) ; } } int max = pq . poll ( ) ; System . out . println ( QxtrxjZqf - max ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class fbifnV { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int FbifnAyub = Integer . parseInt ( str [ 0 ] ) , y = Integer . parseInt ( str [ 1 ] ) , rest ; if ( FbifnAyub < y ) { int temp = FbifnAyub ; FbifnAyub = y ; y = temp ; } do { rest = FbifnAyub % y ; FbifnAyub = y ; y = rest ; } while ( y != 0 ) ; System . out . println ( FbifnAyub ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . text . DecimalFormat ; public class RlhcLrv { 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 rlhcXoz = Integer . parseInt ( arrStr [ 0 ] ) ; long b = Integer . parseInt ( arrStr [ 1 ] ) ; long d = rlhcXoz / b ; long r = rlhcXoz % b ; double f = ( double ) rlhcXoz / 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 OxsFseetp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OxsNda = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= OxsNda ; i ++ ) { double tmp = 1.0 / OxsNda ; int now = i ; while ( now < K ) { now *= 2 ; tmp /= 2 ; } ans += tmp ; } System . out . println ( ans ) ; } } import java . io . * ; class GijpAr { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = buf . readLine ( ) ; int GijpJyb = Integer . parseInt ( s ) ; int res = GijpJyb * GijpJyb * GijpJyb ; System . out . println ( res ) ; } } import java . util . * ; public class KtqcDu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ktqcDxl = sc . nextInt ( ) ; int [ ] A = new int [ ktqcDxl ] ; for ( int i = 0 ; i < ktqcDxl ; i ++ ) { A [ sc . nextInt ( ) - 1 ] = i + 1 ; } for ( int j = 0 ; j < ktqcDxl ; j ++ ) { System . out . print ( A [ j ] + " " ) ; } } } import java . util . * ; public class CrinMpm { 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 kchBi { 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 KchVpwby = 0 ; for ( int i = 0 ; i <= 2 ; i ++ ) { if ( Slist [ i ] . equals ( Tlist [ i ] ) ) { KchVpwby ++ ; } } System . out . println ( KchVpwby ) ; } } import java . util . * ; class ydhjvAj { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int YdhjvCyrvp = in . nextInt ( ) ; int [ ] s = new int [ YdhjvCyrvp ] ; for ( int i = 0 ; i < YdhjvCyrvp ; 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 WphxwbXt { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int wphxwbSrg = 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 XmiWba { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xmiGytu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = Integer . valueOf ( String . valueOf ( xmiGytu ) + 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 rhaydIgn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int RhaydMsouq = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int i = 0 ; int sum = 0 ; if ( k >= RhaydMsouq ) { sum += RhaydMsouq ; k = k - RhaydMsouq ; } 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 wkefX { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int WkefYvvm , x , x1 , x2 , x3 ; int counter ; while ( true ) { counter = 0 ; WkefYvvm = scanner . nextInt ( ) ; x = scanner . nextInt ( ) ; if ( WkefYvvm == 0 && x == 0 ) break ; for ( int i = 1 ; i <= WkefYvvm ; i ++ ) { x1 = x ; x1 -= i ; if ( x1 > 1 ) { for ( int j = i + 1 ; j <= WkefYvvm ; j ++ ) { x2 = x1 ; x2 -= j ; if ( x2 > 0 ) { for ( int k = j + 1 ; k <= WkefYvvm ; k ++ ) { x3 = x2 ; x3 -= k ; if ( x3 == 0 ) counter ++ ; } } } } } System . out . println ( counter ) ; } } } import java . util . * ; class LcxbrMui { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] argv ) { int lcxbrP = scan . nextInt ( ) ; int n1 = lcxbrP % 10 ; int n2 = ( lcxbrP % 100 - n1 ) / 10 ; int n3 = ( lcxbrP - n1 - n1 ) / 100 ; if ( n3 == 9 ) { lcxbrP = 999 ; System . out . println ( lcxbrP ) ; return ; } if ( n1 > n3 || n2 > n3 ) { n3 += 1 ; } lcxbrP = n3 * 100 + n3 * 10 + n3 ; System . out . println ( lcxbrP ) ; } } import java . util . * ; public class ToczGrl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int toczBjqe = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ toczBjqe + 1 ] ; for ( int i = 1 ; i <= toczBjqe ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int [ ] b = new int [ toczBjqe + 1 ] ; b [ 0 ] = 1 ; int i = 1 ; int ans = - 1 ; while ( i <= toczBjqe ) { 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 WcgUkzv { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int wcgTex = sc . nextInt ( ) ; int m = 1 ; Set < Integer > used = new HashSet < > ( ) ; for ( ; ! used . contains ( wcgTex ) ; m ++ ) { used . add ( wcgTex ) ; if ( wcgTex % 2 == 0 ) { wcgTex /= 2 ; } else { wcgTex = wcgTex * 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 trijDnc { final static int TrijBn = 2 ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] num = new int [ TrijBn + 1 ] ; for ( int i = 0 ; i <= TrijBn ; 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 HtsYhdwzf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; char [ ] cs = sc . next ( ) . toCharArray ( ) ; for ( char HtsF : cs ) { switch ( HtsF ) { case '1' : sb . append ( HtsF ) ; break ; case '0' : sb . append ( HtsF ) ; break ; case 'B' : if ( sb . length ( ) > 0 ) { sb . deleteCharAt ( sb . length ( ) - 1 ) ; } break ; } } System . out . println ( sb ) ; } } import java . util . Scanner ; public class sviK { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int SviAkkg = 0 , A2 = 0 , A3 = 0 , result = 0 ; SviAkkg = input . nextInt ( ) ; A2 = input . nextInt ( ) ; A3 = input . nextInt ( ) ; if ( 1 <= SviAkkg && SviAkkg <= 13 && 1 <= A2 && A2 <= 13 && 1 <= A3 && A3 <= 13 ) { if ( SviAkkg + A2 + A3 == 22 || SviAkkg + A2 + A3 > 22 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } } else { } } } import java . io . * ; import java . util . * ; class NbvsrGhnw { 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 NbvsrY = Integer . parseInt ( buf [ 0 ] ) ; int m = Integer . parseInt ( buf [ 1 ] ) ; ArrayList < Integer > matrix = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < NbvsrY ; 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 < NbvsrY ; 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 < NbvsrY ; i ++ ) { System . out . println ( answer . get ( i ) ) ; } } } import java . util . * ; import java . lang . * ; public class ljhkcbVmo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LjhkcbXje , 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 ( LjhkcbXje = 0 ; LjhkcbXje < n ; LjhkcbXje ++ ) { a [ LjhkcbXje ] = sc . nextInt ( ) ; s = s + a [ LjhkcbXje ] ; } 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 PhtpozVscjsr { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; long PhtpozEb = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextInt ( ) ; long d = sc . nextInt ( ) ; long x = b - PhtpozEb + 1 - ( ( b / c ) - ( PhtpozEb / c ) + ( b / d ) - ( PhtpozEb / d ) - ( ( b / ( lcm ( c , d ) ) ) - ( PhtpozEb / ( lcm ( c , d ) ) ) ) ) ; if ( PhtpozEb % c == 0 ) x -- ; if ( PhtpozEb % d == 0 ) x -- ; if ( PhtpozEb % ( lcm ( c , d ) ) == 0 ) x ++ ; System . out . println ( x ) ; } static long gcd ( long PhtpozEb , long b ) { if ( PhtpozEb == 0 ) return b ; else return gcd ( b % PhtpozEb , PhtpozEb ) ; } static long lcm ( long PhtpozEb , long b ) { return ( PhtpozEb * b ) / gcd ( PhtpozEb , b ) ; } } import java . util . * ; public class AtwjbdAeh { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } long AtwjbdP ; long k ; long res ; public void run ( ) { Scanner sc = new Scanner ( System . in ) ; AtwjbdP = sc . nextLong ( ) ; k = sc . nextLong ( ) ; sc . close ( ) ; solve ( ) ; } private void solve ( ) { a ( AtwjbdP % 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 NzbybXpr { 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 nzbybApvj = 0 ; nzbybApvj < 4 ; nzbybApvj ++ ) { if ( map . containsKey ( s [ nzbybApvj ] ) ) { map . put ( s [ nzbybApvj ] , map . get ( s [ nzbybApvj ] ) + 1 ) ; } else { map . put ( s [ nzbybApvj ] , 1 ) ; } } String ans = " Yes " ; for ( int nzbybApvj = 0 ; nzbybApvj < 4 ; nzbybApvj ++ ) { if ( map . get ( s [ nzbybApvj ] ) == 2 ) { continue ; } else { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class gyqiigQg { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int GyqiigOmh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( GyqiigOmh >= 0 && GyqiigOmh <= 100 ) { if ( b >= 0 && b <= 100 ) { if ( c >= 0 && c <= 100 ) { if ( GyqiigOmh < b && b < c ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } } } } import java . util . * ; import java . math . BigDecimal ; public class PrknkRpcmj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long PrknkXwf = sc . nextLong ( ) ; BigDecimal x = BigDecimal . valueOf ( PrknkXwf ) ; 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 bayfriK { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long BayfriLgwht = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = BayfriLgwht / ( a + b ) ; long d = BayfriLgwht % ( 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 qpooczAl { static class qpooczAl { 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 QpooczVfmfi = ob . nextInt ( ) , a = ob . nextInt ( ) , b = ob . nextInt ( ) ; int ans = ( a - ( a % QpooczVfmfi ) ) + QpooczVfmfi ; if ( ans >= a && ans <= b || a % QpooczVfmfi == 0 ) { System . out . println ( " OK " ) ; return ; } System . out . println ( " NG " ) ; } } import java . util . Scanner ; public class tpqDwm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long TpqIkdlz = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( k == 0 ) { System . out . println ( TpqIkdlz + " " + b ) ; return ; } if ( TpqIkdlz >= k ) { System . out . println ( TpqIkdlz - k + " " + b ) ; return ; } k -= TpqIkdlz ; 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 ByuMwa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int byuWnvh = sc . nextInt ( ) ; String [ ] array = new String [ byuWnvh ] ; for ( int i = 0 ; i < byuWnvh ; 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 < byuWnvh ; 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 == byuWnvh - 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 exsrDaz { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ExsrJxa , count = 1 ; String s ; ExsrJxa = sc . nextInt ( ) ; s = sc . next ( ) ; for ( int i = 0 ; i < ExsrJxa - 1 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i + 1 ) ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class UcvfymUnd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UcvfymXlw = 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 ( UcvfymXlw - sum < 0 ? - 1 : UcvfymXlw - sum ) ; sc . close ( ) ; } } import java . util . Scanner ; public class ChaizGubhvi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ChaizOhr = scan . nextInt ( ) ; int odd , even ; if ( ChaizOhr % 2 == 1 ) { odd = ChaizOhr / 2 + 1 ; even = ChaizOhr / 2 ; } else { odd = ChaizOhr / 2 ; even = ChaizOhr / 2 ; } if ( ChaizOhr == 1 ) { System . out . println ( 1 ) ; } else { double ans = ( double ) odd / ( double ) ChaizOhr ; System . out . println ( ans ) ; } } } import java . util . Scanner ; public class fclzwF { public static void main ( String [ ] args ) { long FclzwAajs ; try ( Scanner sc = new Scanner ( System . in ) ) { FclzwAajs = sc . nextLong ( ) ; } double c = ( double ) FclzwAajs / 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 RaxrwSv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String raxrwZz = sc . next ( ) ; String result = " Heisei " ; if ( raxrwZz . compareTo ( " 2019/04/30 " ) > 0 ) result = " TBD " ; System . out . println ( result ) ; } } import java . util . * ; public class DupUtmq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DupMma = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = DupMma + B ; int c = ( DupMma + 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 wrhyrbJx { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int WrhyrbWmcs = in . nextInt ( ) ; int [ ] a = new int [ 100 ] ; for ( int i = 0 ; i < WrhyrbWmcs ; i ++ ) { int val = in . nextInt ( ) ; a [ i ] = val ; } for ( int i = 1 ; i < WrhyrbWmcs ; i ++ ) { output ( a , WrhyrbWmcs ) ; 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 , WrhyrbWmcs ) ; } static void output ( int [ ] a , int WrhyrbWmcs ) { for ( int i = 0 ; i < WrhyrbWmcs - 1 ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } System . out . println ( a [ WrhyrbWmcs - 1 ] ) ; } } import java . util . * ; class byuvP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ByuvLia = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] d = new int [ 3 ] ; d [ 0 ] = ByuvLia ; 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 CjiiudSl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cjiiudD = sc . nextInt ( ) ; int [ ] A ; A = new int [ cjiiudD ] ; for ( int i = 0 ; i < cjiiudD ; i ++ ) A [ i ] = sc . nextInt ( ) ; Arrays . sort ( A ) ; boolean ans = true ; for ( int i = 0 ; i < cjiiudD - 1 ; i ++ ) if ( A [ i ] == A [ i + 1 ] ) ans = false ; System . out . println ( ans ? " YES " : " NO " ) ; } } import java . util . * ; class QjabSwfg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qjabNrc = sc . nextInt ( ) ; int [ ] nums = new int [ qjabNrc ] ; for ( int i = 0 ; i < qjabNrc ; i ++ ) nums [ i ] = sc . nextInt ( ) ; for ( int i = 1 ; i < qjabNrc ; 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 GinkRigcs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GinkN = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( GinkN != 1 && b != 1 ) { System . out . println ( 1 ) ; } else if ( GinkN != 2 && b != 2 ) { System . out . println ( 2 ) ; } else { System . out . println ( 3 ) ; } } } import java . util . Scanner ; public class zqiCp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZqiUfdc = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; sc . close ( ) ; if ( ( double ) ZqiUfdc / T <= S ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; public class OcvghoFv { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int OcvghoQjg = s . nextInt ( ) ; int b = s . nextInt ( ) ; int c = s . nextInt ( ) ; int d = s . nextInt ( ) ; int start ; int end ; if ( OcvghoQjg < c ) { start = c ; } else { start = OcvghoQjg ; } 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 usajnoY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UsajnoGso = sc . nextInt ( ) ; String sura = sc . next ( ) ; ArrayList < Character > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < UsajnoGso ; 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 gpoqgsW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GpoqgsVoim = sc . nextInt ( ) ; int [ ] A = new int [ GpoqgsVoim ] ; int ans = 0 ; for ( int i = 0 ; i < GpoqgsVoim ; 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 iufyfgAg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long IufyfgVejfr = sc . nextLong ( ) ; double m = sc . nextLong ( ) ; long result = ( long ) Math . round ( m * 100 ) ; result = result * IufyfgVejfr / 100 ; System . out . println ( result ) ; } } import java . util . * ; public class daecdhI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; String [ ] S1 = S . split ( " / " , 0 ) ; int DaecdhQb , month , day ; DaecdhQb = 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 VfuzJi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int vfuzZirx = 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 ) == vfuzZirx ) { x = true ; } } } if ( x ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class YcciIiqwo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YcciI = sc . nextInt ( ) ; int [ ] ary = new int [ YcciI ] ; for ( int i = 0 ; i < YcciI ; i ++ ) { ary [ i ] = sc . nextInt ( ) ; } boolean flag = true ; int numSwap = 0 ; while ( flag ) { flag = false ; for ( int i = YcciI - 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 < YcciI ; i ++ ) { System . out . print ( ary [ i ] ) ; if ( i < YcciI - 1 ) { System . out . print ( " " ) ; } } System . out . println ( " " ) ; System . out . println ( numSwap ) ; } } import java . util . * ; public class dtmwBjp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DtmwAqang = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int start = Math . max ( DtmwAqang , C ) ; int end = Math . min ( B , D ) ; int reult = end - start ; System . out . println ( reult < 0 ? 0 : reult ) ; } } import java . util . * ; public class PndtwpWbc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PndtwpBn = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] alpha = new int [ PndtwpBn ] ; int i , j ; for ( i = 0 ; i < PndtwpBn ; 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 KuspqFo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kuspqMdg = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; list . add ( kuspqMdg ) ; while ( true ) { if ( kuspqMdg % 2 == 0 ) { kuspqMdg /= 2 ; } else { kuspqMdg = kuspqMdg * 3 + 1 ; } if ( list . contains ( kuspqMdg ) ) { list . add ( kuspqMdg ) ; System . out . println ( list . size ( ) ) ; break ; } else { list . add ( kuspqMdg ) ; } } } } import java . util . Scanner ; public class OqxcHl { 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 OqxcWqk = Integer . parseInt ( String . valueOf ( sA ) ) ; int b = Integer . parseInt ( String . valueOf ( sB ) ) ; if ( OqxcWqk == 0 && b == 0 ) { answer = " NA " ; } else if ( OqxcWqk == 0 ) { if ( b <= 12 ) { answer = " YYMM " ; } else { answer = " NA " ; } } else if ( b == 0 ) { if ( OqxcWqk <= 12 ) { answer = " MMYY " ; } else { answer = " NA " ; } } else if ( OqxcWqk <= 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 NneAnwg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String moji = sc . nextLine ( ) ; char [ ] chmoji = new char [ moji . length ( ) ] ; for ( int NneYsw = 0 ; NneYsw < moji . length ( ) ; NneYsw ++ ) { chmoji [ NneYsw ] = moji . charAt ( NneYsw ) ; boolean kekka = Character . isUpperCase ( chmoji [ NneYsw ] ) ; if ( kekka == true ) { chmoji [ NneYsw ] = Character . toLowerCase ( chmoji [ NneYsw ] ) ; } else { chmoji [ NneYsw ] = Character . toUpperCase ( chmoji [ NneYsw ] ) ; } System . out . print ( chmoji [ NneYsw ] ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class dmpipqH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DmpipqAfi = sc . nextInt ( ) ; for ( int i = 0 ; i < DmpipqAfi ; 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 HagvpcRyv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hagvpcFelf = 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 ; } hagvpcFelf -= D ; if ( hagvpcFelf <= 0 ) { System . out . println ( " No " ) ; break ; } } } } import java . util . Scanner ; public class didbogUux { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DidbogLo = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i <= DidbogLo ; 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 CthhNazcj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CthhMf = sc . nextInt ( ) ; int [ ] list = new int [ CthhMf - 1 ] ; for ( int i = 0 ; i < CthhMf - 1 ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } int ans = 0 ; int lastV = 0 ; for ( int i = 0 ; i < CthhMf - 1 ; i ++ ) { if ( i == 0 ) { ans += list [ i ] ; } else if ( list [ i ] > lastV ) { ans += lastV ; } else { ans += list [ i ] ; } if ( i == CthhMf - 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 PnyPvfa { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strArr = br . readLine ( ) . split ( " " ) ; long pnyBbz = Long . valueOf ( strArr [ 0 ] ) ; long b = Long . valueOf ( strArr [ 1 ] ) ; System . out . println ( gcd ( pnyBbz , b ) ) ; } private static long gcd ( long pnyBbz , long b ) { long r = pnyBbz % b ; if ( r == 0 ) return b ; else return gcd ( b , pnyBbz % b ) ; } } import java . util . Scanner ; public class tmzhqLj { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String line = sc . nextLine ( ) ; String answer = " " ; for ( int TmzhqSsb = 0 ; TmzhqSsb < line . length ( ) ; TmzhqSsb ++ ) { char ch = line . charAt ( TmzhqSsb ) ; if ( Character . isLowerCase ( ch ) ) answer = answer + Character . toUpperCase ( ch ) ; else answer = answer + Character . toLowerCase ( ch ) ; } System . out . println ( answer ) ; } } } import java . util . * ; public class KptoCgeddg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KptoCyx = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; if ( S . length ( ) <= KptoCyx ) System . out . println ( S ) ; else System . out . println ( S . substring ( 0 , KptoCyx ) + " ... " ) ; } } import java . util . Scanner ; class DxmzsJnamz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int DxmzsEyc = in . nextInt ( ) ; int Taro = 0 ; int Hanako = 0 ; while ( DxmzsEyc != 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 ; } DxmzsEyc -- ; } System . out . println ( Taro + " " + Hanako ) ; } } import java . util . Scanner ; public class GthyvHf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; for ( int GthyvS = 0 ; GthyvS < 3000 ; GthyvS ++ ) { 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 NprfTmtwty { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NprfEu = sc . nextInt ( ) ; int min = 200000 ; int cnt = 0 ; for ( int i = 0 ; i < NprfEu ; 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 VfbgloHg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long vfbgloC = sc . nextLong ( ) ; Set < Long > numSet = new HashSet < > ( ) ; boolean hasSame = false ; for ( int i = 0 ; i < vfbgloC ; 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 RpzCttp { public static void main ( String [ ] args ) { solve ( ) ; } private static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; char [ ] sCode = sc . next ( ) . toCharArray ( ) ; boolean RpzT = false ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( sCode [ i ] == sCode [ i + 1 ] ) { RpzT = true ; break ; } } if ( RpzT ) { System . out . print ( " Bad " ) ; } else System . out . print ( " Good " ) ; } } import java . util . * ; public class kwjnqzVk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String KwjnqzZdi = sc . next ( ) ; if ( KwjnqzZdi . contentEquals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } if ( KwjnqzZdi . equals ( " ARC " ) ) { System . out . println ( " ABC " ) ; } } } import java . math . * ; import java . util . * ; public class LxrphyRc { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int [ ] hills = new int [ 10 ] ; for ( int lxrphyRt = 0 ; lxrphyRt < 10 ; lxrphyRt ++ ) { hills [ lxrphyRt ] = in . nextInt ( ) * - 1 ; } Arrays . sort ( hills ) ; for ( int lxrphyRt = 0 ; lxrphyRt < 3 ; lxrphyRt ++ ) { System . out . println ( hills [ lxrphyRt ] * - 1 ) ; } } } import java . util . Scanner ; public class skgmB { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int SkgmOzhso = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= SkgmOzhso - 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 FvqnfzKn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fvqnfzJod = sc . nextInt ( ) ; ArrayList < Integer > A = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < fvqnfzJod ; i ++ ) A . add ( sc . nextInt ( ) ) ; ArrayList < Integer > output = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < fvqnfzJod ; i ++ ) output . add ( 0 ) ; for ( int i = 0 ; i < fvqnfzJod ; i ++ ) { int AIndex = A . get ( i ) - 1 ; output . set ( AIndex , i + 1 ) ; } for ( int i = 0 ; i < fvqnfzJod ; i ++ ) { System . out . print ( output . get ( i ) + " " ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class fpwlP { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int FpwlMsh = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 1 ] ) ; int c = Integer . parseInt ( str [ 2 ] ) ; System . out . println ( ( ( FpwlMsh == b ) && ( b != c ) ) || ( ( b == c ) && ( c != FpwlMsh ) ) || ( ( c == FpwlMsh ) && ( FpwlMsh != b ) ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class VxqbnChwxuf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VxqbnI = Integer . parseInt ( sc . next ( ) ) ; int [ ] p = new int [ VxqbnI ] ; for ( int i = 0 ; i < VxqbnI ; i ++ ) { p [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int cnt = 0 ; for ( int i = 1 ; i < VxqbnI - 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 OrizvbExza { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OrizvbI = 0 ; int sum = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { int x = sc . nextInt ( ) ; OrizvbI = Math . OrizvbI ( OrizvbI , x ) ; sum += x ; } System . out . println ( sum - OrizvbI ) ; } } import java . util . * ; public class NirlGdue { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int nirlIp = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int saisi = sc . nextInt ( ) ; int c = nirlIp + b ; if ( nirlIp == - 1 && b == - 1 && saisi == - 1 ) { break ; } if ( nirlIp == - 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 SrjjMksyxf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SrjjKr = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; solve ( SrjjKr , 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 YqjDxxm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int YqjSdi = 0 ; int o = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '0' ) { YqjSdi ++ ; } else { o ++ ; } } int r = Math . min ( YqjSdi , o ) * 2 ; System . out . print ( r ) ; } } import java . util . Scanner ; public class syvnvNhp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int SyvnvIe = scanner . nextInt ( ) ; String S = scanner . next ( ) ; String [ ] S1 = S . split ( " " ) ; if ( SyvnvIe >= S1 . length ) { for ( int j = 0 ; j < S1 . length ; j ++ ) { System . out . print ( S1 [ j ] ) ; } } else { for ( int j = 0 ; j < SyvnvIe ; j ++ ) { System . out . print ( S1 [ j ] ) ; } System . out . println ( " ... " ) ; } } } import java . util . Scanner ; public class itpskL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int ItpskYr = s . length ( ) ; int [ ] A = new int [ ItpskYr ] ; int [ ] B = new int [ ItpskYr ] ; int i ; for ( i = 0 ; i < ItpskYr ; i ++ ) { A [ i ] = i % 2 ; B [ i ] = ( i + 1 ) % 2 ; } int tempA = 0 ; int tempB = 0 ; int intS ; for ( i = 0 ; i < ItpskYr ; 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 LahknpGymr { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int LahknpC = in . nextInt ( ) ; int ac = 0 ; int wa = 0 ; int tle = 0 ; int re = 0 ; for ( int i = 0 ; i <= LahknpC ; ++ 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 jjosvKi { public static void main ( String [ ] argv ) { Scanner scanner = new Scanner ( System . in ) ; String line = scanner . nextLine ( ) ; String [ ] mn = line . split ( " " ) ; int JjosvLoak = Integer . parseInt ( mn [ 0 ] ) ; int n = Integer . parseInt ( mn [ 1 ] ) ; int ans = JjosvLoak * ( JjosvLoak - 1 ) / 2 + n * ( n - 1 ) / 2 ; System . out . println ( ans ) ; } } import java . io . IOException ; import java . util . Scanner ; public class ObblcjJrd { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int obblcjBd = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( obblcjBd == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < obblcjBd ; 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 BgsllfQi { 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 bgsllfBtt = 0 ; String ans = " " ; while ( true ) { switch ( C [ bgsllfBtt ] [ t [ bgsllfBtt ] ] ) { case 'a' : t [ bgsllfBtt ] ++ ; bgsllfBtt = 0 ; break ; case 'b' : t [ bgsllfBtt ] ++ ; bgsllfBtt = 1 ; break ; case 'c' : t [ bgsllfBtt ] ++ ; bgsllfBtt = 2 ; break ; } if ( t [ 0 ] == Sa . length ( ) && bgsllfBtt == 0 ) { ans = " A " ; break ; } if ( t [ 1 ] == Sb . length ( ) && bgsllfBtt == 1 ) { ans = " B " ; break ; } if ( t [ 2 ] == Sc . length ( ) && bgsllfBtt == 2 ) { ans = " C " ; break ; } } System . out . println ( ans ) ; scanner . close ( ) ; } } import java . util . * ; public class UzgXtk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int uzgMeqz = 0 ; int steps2 = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { if ( s . charAt ( i ) != '1' ) uzgMeqz ++ ; else steps2 ++ ; } else { if ( s . charAt ( i ) != '1' ) steps2 ++ ; else uzgMeqz ++ ; } } System . out . println ( Math . min ( uzgMeqz , steps2 ) ) ; } } import java . util . Scanner ; public class ioetdlBbj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long IoetdlYwvb = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; sc . close ( ) ; if ( IoetdlYwvb < c ) { c -= IoetdlYwvb ; IoetdlYwvb = 0 ; if ( b < c ) { b = 0 ; } else { b -= c ; } } else { IoetdlYwvb -= c ; } System . out . println ( IoetdlYwvb + " " + b ) ; } } import java . util . * ; public class mumdzmI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MumdzmZyhm = sc . nextInt ( ) ; int [ ] A = new int [ MumdzmZyhm ] ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < MumdzmZyhm ; i ++ ) { A [ i ] = sc . nextInt ( ) ; list . add ( A [ i ] ) ; } Collections . sort ( list ) ; for ( int i = 0 ; i < MumdzmZyhm ; i ++ ) { if ( A [ i ] == list . get ( MumdzmZyhm - 1 ) ) { System . out . println ( list . get ( MumdzmZyhm - 2 ) ) ; } else { System . out . println ( list . get ( MumdzmZyhm - 1 ) ) ; } } } } import java . util . Scanner ; public class vcopyXpk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VcopyEuxbe = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i < VcopyEuxbe ; 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 QpaCxh { private static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static void main ( String [ ] args ) throws IOException { getLine ( ) ; List < String > strings = getStrOnLine ( ) ; int QpaOg = bubbleSort ( strings ) ; String out = String . join ( " " , strings ) ; System . out . println ( out ) ; System . out . println ( QpaOg ) ; } private static int bubbleSort ( List < String > list ) { boolean flag = true ; int QpaOg = 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 ) ; QpaOg ++ ; flag = true ; } } } return QpaOg ; } 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 AvhpdwQxvr { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int avhpdwDrq = sc . nextInt ( ) ; String S = sc . next ( ) ; char [ ] C = S . toCharArray ( ) ; char x = C [ 0 ] ; for ( int i = 1 ; i < avhpdwDrq ; i ++ ) { if ( C [ i ] == x ) { C [ i ] = 0 ; } else { x = C [ i ] ; } } int ans = 0 ; for ( int i = 0 ; i < avhpdwDrq ; i ++ ) { if ( C [ i ] != 0 ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class TiaNblqj { public static void main ( String [ ] gg ) { Scanner sc = new Scanner ( System . in ) ; int TiaE = sc . nextInt ( ) ; String s = sc . next ( ) ; int counter = 0 ; int i = 0 ; while ( i < TiaE - 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 IlbtCfcdcu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IlbtHbc = sc . nextInt ( ) ; long [ ] nums = new long [ IlbtHbc ] ; for ( int i = 0 ; i < IlbtHbc ; 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 < IlbtHbc ; 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 magsNd { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int MagsHk = scan . nextInt ( ) ; boolean [ ] [ ] cards = new boolean [ 4 ] [ 13 ] ; for ( int i = 0 ; i < MagsHk ; 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 YvypKvg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YvypT = Integer . parseInt ( sc . nextLine ( ) ) ; boolean okFlag = true ; int prePosX = 0 ; int prePosY = 0 ; int preTime = 0 ; for ( int i = 1 ; i <= YvypT ; 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 QdoxtJp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qdoxtD = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int cnt = 0 ; int plug = 1 ; for ( ; ; ) { if ( plug >= b ) break ; plug = plug + qdoxtD - 1 ; cnt ++ ; } out . println ( cnt ) ; } } import java . util . * ; public class kfaaCpt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KfaaVmnx = sc . nextInt ( ) ; int tA = sc . nextInt ( ) ; int aH = sc . nextInt ( ) ; int aA = sc . nextInt ( ) ; int tCount = 0 ; while ( KfaaVmnx > 0 ) { KfaaVmnx -= 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 JlnxjoZk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = sc . next ( ) . split ( " " ) ; for ( int jlnxjoWlb = 0 ; jlnxjoWlb < s . length ; jlnxjoWlb ++ ) { if ( s [ jlnxjoWlb ] . equals ( " 1 " ) ) s [ jlnxjoWlb ] = " 9 " ; else if ( s [ jlnxjoWlb ] . equals ( " 9 " ) ) s [ jlnxjoWlb ] = " 1 " ; System . out . print ( s [ jlnxjoWlb ] ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; public class NmxBbek { 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 nmxQ = Integer . valueOf ( arr01 [ 0 ] ) ; String [ ] arr_result = new String [ nmxQ ] ; Arrays . fill ( arr_result , " 0 " ) ; for ( int i = nmxQ - 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 hpotwUe { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int HpotwNk = Integer . parseInt ( br . readLine ( ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < HpotwNk ; i ++ ) { if ( i == HpotwNk - 1 ) { System . out . println ( str [ HpotwNk - i - 1 ] ) ; } else { System . out . print ( str [ HpotwNk - i - 1 ] + " " ) ; } } } } import java . util . Scanner ; public class kxlxqkGb { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int KxlxqkOjeww = s . nextInt ( ) ; int ones = KxlxqkOjeww % 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 thiifqQq { Scanner sc = new Scanner ( System . in ) ; void run ( ) { int ThiifqOowjr = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] ret = new int [ ThiifqOowjr + 1 ] ; for ( int i = 0 ; i < ThiifqOowjr + 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 < ThiifqOowjr + 1 ; i ++ ) { System . out . println ( ret [ i ] ) ; } } public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . run ( ) ; } } import java . util . * ; public class IyvczBtrhu { 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 IyvczOj = 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 ) ) { IyvczOj ++ ; } } return IyvczOj ; } } import java . util . Arrays ; import java . util . Scanner ; public class SbiaknKdebp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SbiaknJl = sc . nextInt ( ) ; int [ ] d = new int [ SbiaknJl ] ; int mid = 0 ; int max = 0 ; int min = 100000 ; for ( int i = 0 ; i < SbiaknJl ; 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 [ SbiaknJl / 2 - 1 ] ; int count = 0 ; System . out . println ( e [ SbiaknJl / 2 ] - e [ SbiaknJl / 2 - 1 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class EllxZig { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String str = br . readLine ( ) ; int EllxPz = 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 < EllxPz ; 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 IjzxWlwmhq { public static int gcd ( int a , int b , int c ) { int IjzxIp = Math . min ( a , Math . min ( b , c ) ) ; for ( int i = IjzxIp ; 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 KeruFbzu { Scanner sc = new Scanner ( System . in ) ; void doIt ( ) { sB ( ) ; } void sB ( ) { int keruQaio = sc . nextInt ( ) ; int L ; int max = 0 ; int sum = 0 ; for ( int i = 0 ; i < keruQaio ; 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 IepfhYig { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IepfhCcl = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; for ( int i = 1 ; i < 10000 ; i ++ ) { if ( ( int ) Math . floor ( i * 0.08 ) == IepfhCcl && ( 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 YiyVtimo { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = reader . readLine ( ) ; int YiyBw = Integer . parseInt ( str ) ; long sum = 0 ; for ( int i = 1 ; i <= YiyBw ; i ++ ) { if ( i % 3 == 0 || i % 5 == 0 ) continue ; sum += i ; } System . out . print ( sum ) ; } } import java . io . * ; public class hvcgVc { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String in = br . readLine ( ) ; double HvcgYyeqg = Math . pow ( Integer . parseInt ( in ) , 3 ) ; System . out . println ( ( int ) HvcgYyeqg ) ; br . close ( ) ; } } import java . util . Scanner ; public class IebytEpag { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int iebytEx , wid , cnt_wid ; while ( true ) { iebytEx = scan . nextInt ( ) ; wid = scan . nextInt ( ) ; if ( iebytEx == 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 < iebytEx - 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 ZtpEx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ztpAyi = scanner . nextInt ( ) ; int tarop = 0 ; int hanakop = 0 ; String tarow ; String hanakow ; for ( int i = 0 ; i < ztpAyi ; 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 UawqQili { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String [ ] SSplit = S . split ( " " ) ; int UawqLad = 0 ; for ( int i = 0 ; i < SSplit . length / 2 ; i ++ ) { if ( ! SSplit [ i ] . equals ( SSplit [ SSplit . length - i - 1 ] ) ) { UawqLad ++ ; } } System . out . print ( UawqLad ) ; } } import java . text . * ; import java . util . * ; public class ShdCrcy { 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 shdLnc = date1 . compareTo ( date2 ) ; if ( shdLnc > 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 lefuyaOc { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String str = br . readLine ( ) ; String [ ] strArr = str . split ( " " ) ; int LefuyaPuwbg = Integer . parseInt ( strArr [ 0 ] ) ; int m = Integer . parseInt ( strArr [ 1 ] ) ; String [ ] [ ] a = new String [ LefuyaPuwbg ] [ m ] ; String [ ] b = new String [ m ] ; for ( int i = 0 ; i < LefuyaPuwbg ; 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 < LefuyaPuwbg ; 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 kkstaWn { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int KkstaZvtt = sc . nextInt ( ) ; int [ ] li = new int [ KkstaZvtt ] ; for ( int i = 1 ; i <= KkstaZvtt ; i ++ ) { li [ sc . nextInt ( ) - 1 ] = i ; } int i = 0 ; for ( int k : li ) { if ( i != KkstaZvtt - 1 ) { System . out . print ( li [ i ] + " " ) ; } else { System . out . println ( li [ i ] ) ; } i ++ ; } } } import java . util . Scanner ; public class VtavjnDsnp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String VtavjnC = sc . next ( ) ; String S = " Sunny " ; String C = " Cloudy " ; String R = " Rainy " ; if ( VtavjnC . equals ( S ) ) { System . out . println ( C ) ; } else if ( VtavjnC . equals ( C ) ) { System . out . println ( R ) ; } else { System . out . println ( S ) ; } } } import java . util . * ; public class sayLv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int SayRmi = 0 ; SayRmi < 3 ; SayRmi ++ ) { a [ SayRmi ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int SayRmi = 0 ; SayRmi < 2 ; SayRmi ++ ) { System . out . print ( a [ SayRmi ] + " " ) ; } System . out . println ( a [ 2 ] ) ; } } import java . util . Scanner ; public class bxxxX { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int BxxxRtnl = scan . nextInt ( ) ; String op = scan . next ( ) ; int b = scan . nextInt ( ) ; if ( op . equals ( " ? " ) ) { break ; } switch ( op ) { case " + " : System . out . println ( BxxxRtnl + b ) ; break ; case " - " : System . out . println ( BxxxRtnl - b ) ; break ; case " * " : System . out . println ( BxxxRtnl * b ) ; break ; case " / " : System . out . println ( BxxxRtnl / b ) ; break ; } } scan . close ( ) ; } } import java . io . PrintWriter ; import java . util . Scanner ; class KchMhuz { 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 KchB = Integer . parseInt ( sc . next ( ) ) ; final int f = Integer . parseInt ( sc . next ( ) ) ; final int r = Integer . parseInt ( sc . next ( ) ) ; if ( KchB == - 1 && f == - 1 && r == - 1 ) break ; if ( KchB == - 1 || f == - 1 ) out . println ( 'F' ) ; else if ( KchB + f >= 80 ) out . println ( 'A' ) ; else if ( KchB + f >= 65 ) out . println ( 'B' ) ; else if ( KchB + f >= 50 ) out . println ( 'C' ) ; else if ( KchB + 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 GndnXrbysh { public static void main ( String [ ] args ) { int GndnG ; int [ ] A ; try ( Scanner sc = new Scanner ( System . in ) ) { GndnG = sc . nextInt ( ) ; A = new int [ GndnG ] ; for ( int i = 0 ; i < GndnG ; 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 ghyywlMnn { 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 GhyywlOowzh = Integer . parseInt ( temp ) ; if ( GhyywlOowzh >= 1 && GhyywlOowzh <= 31 ) { a = a . replace ( " 2017 " , " 2018 " ) ; System . out . println ( a ) ; } } } } } import java . util . Scanner ; public class JqjjgzEx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; try { int JqjjgzRf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( " a " + ( JqjjgzRf == b ? " == " : ( JqjjgzRf < b ? " < " : " > " ) ) + " b " ) ; } finally { sc . close ( ) ; } } } import java . util . Scanner ; public class BeqbezYa { public static void select_Sort ( int n , int [ ] A ) { int beqbezEixd = 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 ) { beqbezEixd = A [ j ] ; mini = j ; } if ( beqbezEixd > A [ j ] ) { beqbezEixd = 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 KzshDa { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = input . readLine ( ) ; int KzshJxl = 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 FcypzSt { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int fcypzCnpi = s . nextInt ( ) ; long sum = 0 ; for ( int i = 0 ; i < fcypzCnpi ; i ++ ) { if ( ( i + 1 ) % 3 != 0 ) { if ( ( i + 1 ) % 5 != 0 ) { sum = sum + ( i + 1 ) ; } } } System . out . println ( sum ) ; } } import java . util . * ; class idtbSl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; boolean [ ] a = new boolean [ 3 ] ; for ( int IdtbUvx = 0 ; IdtbUvx < 2 ; IdtbUvx ++ ) { a [ sc . nextInt ( ) - 1 ] = true ; } for ( int IdtbUvx = 0 ; IdtbUvx < 3 ; IdtbUvx ++ ) { if ( ! a [ IdtbUvx ] ) System . out . println ( IdtbUvx + 1 ) ; } } } import java . util . * ; public class QqjEmkzmp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QqjCp = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int t = scan . nextInt ( ) ; System . out . println ( b * ( t / QqjCp ) ) ; scan . close ( ) ; } } import java . util . Scanner ; public class mnfufcO { public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int MnfufcYcl , b , seki , syu ; MnfufcYcl = sc . nextInt ( ) ; b = sc . nextInt ( ) ; seki = MnfufcYcl * b ; syu = ( MnfufcYcl * 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 GxmbKed { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String gxmbQsdm = sc . next ( ) ; String [ ] S2 = gxmbQsdm . 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 pyhcbRp { 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 PyhcbPc = 0 ; PyhcbPc < s . length ; PyhcbPc ++ ) { sb . append ( s [ s . length - 1 - PyhcbPc ] ) ; } System . out . println ( sb ) ; } catch ( Exception ex ) { System . exit ( 0 ) ; } } } import java . util . Scanner ; public class WcpInu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wcpS = scan . nextInt ( ) ; switch ( wcpS % 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 iernR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IernShu = sc . nextInt ( ) ; for ( int i = 1 ; i <= IernShu ; 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 ZdzvbdFote { 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 ZdzvbdFote { } class ZdzvbdFote { } void solveA ( Scanner sc ) { int zdzvbdBr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( Math . max ( c - ( zdzvbdBr - b ) , 0 ) ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class axuutuZyp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AxuutuEl = sc . nextInt ( ) , count = 0 ; for ( int i = 1 ; i <= AxuutuEl ; i += 2 ) { if ( divisorEnum ( i ) . size ( ) == 8 ) count ++ ; } System . out . println ( count ) ; } public static List < Long > divisorEnum ( long AxuutuEl ) { List < Long > l = new ArrayList < > ( ) ; for ( long i = 1 ; i <= Math . sqrt ( AxuutuEl ) ; i ++ ) { if ( AxuutuEl % i == 0 ) { l . add ( i ) ; if ( i != Math . sqrt ( AxuutuEl ) ) l . add ( AxuutuEl / i ) ; } } l . sort ( null ) ; return l ; } } import java . util . Scanner ; public class vwmngV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VwmngYqgi = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] d = new int [ VwmngYqgi + 1 ] ; d [ 0 ] = 0 ; int j ; int bound = 1 ; for ( j = 1 ; j <= VwmngYqgi ; 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 cxjFr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CxjHsrea = Integer . parseInt ( sc . next ( ) ) ; int [ ] X = new int [ CxjHsrea ] ; int minSum = 2000000 ; int sum = 0 ; for ( int i = 0 ; i < CxjHsrea ; i ++ ) { X [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( X ) ; for ( int i = X [ 0 ] ; i <= X [ CxjHsrea - 1 ] ; i ++ ) { for ( int j = 0 ; j < CxjHsrea ; 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 vlyRl { public static void main ( String [ ] args ) { new Solver ( ) . run ( ) ; } } class vlyRl { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int VlyBgvg = sc . nextInt ( ) ; int [ ] A = new int [ VlyBgvg ] ; int top1 = 0 ; int idx1 = 0 ; for ( int i = 0 ; i < VlyBgvg ; i ++ ) { A [ i ] = sc . nextInt ( ) ; if ( top1 < A [ i ] ) { top1 = A [ i ] ; idx1 = i ; } } int top2 = 0 ; for ( int i = 0 ; i < VlyBgvg ; i ++ ) { if ( i != idx1 && top2 < A [ i ] ) { top2 = A [ i ] ; } } long max = Integer . MIN_VALUE ; for ( int i = 0 ; i < VlyBgvg ; i ++ ) { if ( A [ i ] == top1 ) { System . out . println ( top2 ) ; } else { System . out . println ( top1 ) ; } } return ; } } import java . util . * ; public class ByrpGuwp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ByrpTgg = sc . nextInt ( ) ; int [ ] H = new int [ ByrpTgg ] ; for ( int i = 0 ; i < ByrpTgg ; i ++ ) H [ i ] = sc . nextInt ( ) ; int maxMove = 0 ; int currentMove = 0 ; for ( int i = 0 ; i < ByrpTgg - 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 sndtsnV { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; for ( ; ; ) { int SndtsnHzak = stdIn . nextInt ( ) ; int w = stdIn . nextInt ( ) ; if ( SndtsnHzak == 0 && w == 0 ) break ; for ( int i = 0 ; i < SndtsnHzak ; 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 AgqtJbd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int agqtT = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] answerArr = new int [ M ] ; int answer = 0 ; Arrays . fill ( answerArr , 0 ) ; for ( int i = 0 ; i < agqtT ; 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 ] == agqtT ) { answer ++ ; } } System . out . println ( answer ) ; } } import java . util . * ; public class UmvMh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int umvXzl = 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 ) ) { umvXzl = umvXzl + 1 ; } wk = 0 ; } } System . out . println ( umvXzl ) ; } } import java . util . Scanner ; public class AqzFrz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aqzPp = sc . nextInt ( ) ; int [ ] arr = new int [ aqzPp ] ; boolean flg = true ; int count = 0 ; for ( int i = 0 ; i < aqzPp ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } while ( flg ) { boolean existOdd = false ; for ( int i = 0 ; i < aqzPp ; i ++ ) { if ( arr [ i ] % 2 != 0 ) { flg = false ; } } if ( ! flg ) break ; for ( int j = 0 ; j < aqzPp ; j ++ ) { arr [ j ] = arr [ j ] / 2 ; } count ++ ; } System . out . println ( count ) ; } } import java . util . * ; import java . util . Scanner ; public class cgtvlfTxz { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String CgtvlfCwxc = sc . next ( ) ; char [ ] b = new char [ 4 ] ; b [ 0 ] = CgtvlfCwxc . charAt ( 0 ) ; b [ 1 ] = CgtvlfCwxc . charAt ( 1 ) ; b [ 2 ] = CgtvlfCwxc . charAt ( 2 ) ; b [ 3 ] = CgtvlfCwxc . 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 tzpbfPul { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TzpbfGwh = Integer . parseInt ( sc . nextLine ( ) ) ; List < Integer > nums = new ArrayList < > ( ) ; for ( int i = 0 ; i < TzpbfGwh ; i ++ ) { nums . add ( sc . nextInt ( ) ) ; } Collections . sort ( nums ) ; int n1 = nums . get ( TzpbfGwh / 2 - 1 ) ; int n2 = nums . get ( TzpbfGwh / 2 ) ; System . out . println ( n2 - n1 ) ; } } import java . util . * ; import java . io . * ; public class AjjwksDi { static StringTokenizer st ; static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static void main ( String [ ] args ) throws IOException { int ajjwksF = nextInt ( ) ; HashSet < String > kinds = new HashSet < > ( ) ; for ( int x = 0 ; x < ajjwksF ; 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 ZoqapSlw { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int zoqapHoir = stdIn . nextInt ( ) ; int x = stdIn . nextInt ( ) ; int [ ] l = new int [ zoqapHoir ] ; for ( int i = 0 ; i < zoqapHoir ; i ++ ) { l [ i ] = stdIn . nextInt ( ) ; } int counter = 1 ; long zahyou = 0 ; for ( int i = 0 ; i < zoqapHoir ; i ++ ) { zahyou += l [ i ] ; if ( x < zahyou ) { break ; } else { counter ++ ; } } System . out . println ( counter ) ; } } import java . util . * ; public class UddbctEj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uddbctC = sc . nextInt ( ) ; int over = sc . nextInt ( ) ; int outlet = 1 ; int ans = 0 ; while ( outlet < over ) { -- outlet ; outlet += uddbctC ; ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; public class RrlfMynky { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RrlfB = sc . nextInt ( ) ; int [ ] v = new int [ RrlfB ] ; int [ ] c = new int [ RrlfB ] ; for ( int i = 0 ; i < RrlfB ; i ++ ) { v [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < RrlfB ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int i = 0 ; i < RrlfB ; i ++ ) { if ( v [ i ] > c [ i ] ) { result += v [ i ] - c [ i ] ; } } System . out . println ( result ) ; } } import java . util . Scanner ; class NqwlviJogobb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String c = scan . next ( ) , str = " " ; for ( int NqwlviI = 0 ; NqwlviI < c . length ( ) ; NqwlviI ++ ) { str = c . substring ( NqwlviI , NqwlviI + 1 ) + str ; } System . out . println ( str ) ; } } import java . util . * ; public class TudncyJgl { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String S = s . nextLine ( ) ; int tudncyN = 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' ) { tudncyN ++ ; if ( ans < tudncyN ) { ans = tudncyN ; } } else { tudncyN = 0 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class FpmqGl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int FpmqZ = scan . nextInt ( ) ; if ( FpmqZ == 0 ) { break ; } double [ ] s = new double [ FpmqZ ] ; int i = 0 ; double sum = 0 ; double sumHensa = 0 ; double ans = 0 ; for ( i = 0 ; i < FpmqZ ; i ++ ) { s [ i ] = scan . nextDouble ( ) ; sum += s [ i ] ; } double average = ( double ) sum / FpmqZ ; for ( i = 0 ; i < FpmqZ ; i ++ ) { sumHensa += ( s [ i ] - average ) * ( s [ i ] - average ) ; } ans = Math . sqrt ( ( double ) sumHensa / FpmqZ ) ; 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 HccciRe { public static void main ( String [ ] args ) { int HccciSt = in . NI ( ) ; if ( HccciSt % 2 == 0 ) out . println ( HccciSt / 2 ) ; else out . println ( HccciSt / 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 HccciRe { 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 tbhijyQ { 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 TbhijyAwxsm = Integer . parseInt ( br . readLine ( ) ) ; int b = Integer . parseInt ( br . readLine ( ) ) ; int x = 1 ^ 2 ^ 3 ; x ^= TbhijyAwxsm ; x ^= b ; pw . println ( x ) ; pw . flush ( ) ; pw . close ( ) ; } } import java . util . Scanner ; public class EwaonNd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EwaonVqq = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int ab = Math . min ( EwaonVqq + b , c * 2 ) ; int ans = Math . min ( x , y ) * ab ; if ( x > y ) { ans += ( x - y ) * Math . min ( EwaonVqq , c * 2 ) ; } else { ans += ( y - x ) * Math . min ( b , c * 2 ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class RtctyuWac { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int rtctyuMxml = sc . nextInt ( ) ; String strA = sc . next ( ) ; int b = sc . nextInt ( ) ; if ( strA == " ? " ) { break ; } switch ( strA ) { case " + " : System . out . println ( rtctyuMxml + b ) ; break ; case " - " : System . out . println ( rtctyuMxml - b ) ; break ; case " * " : System . out . println ( rtctyuMxml * b ) ; break ; case " / " : System . out . println ( rtctyuMxml / 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 phgChk { 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 phgChk { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int PhgJu = Integer . parseInt ( in . next ( ) ) ; int K = Integer . parseInt ( in . next ( ) ) ; Integer [ ] H = new Integer [ PhgJu ] ; long ans = 0 ; for ( int i = 0 ; i < PhgJu ; i ++ ) { H [ i ] = Integer . valueOf ( in . next ( ) ) ; ans += H [ i ] ; } Arrays . sort ( H , Collections . reverseOrder ( ) ) ; if ( K > PhgJu ) K = PhgJu ; 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 zvgttDw { 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 ZvgttTxa = 0 ; ZvgttTxa < N . length ( ) ; ZvgttTxa ++ ) { int tmp = ( int ) ( N . charAt ( ZvgttTxa ) - '0' ) ; cubes [ tmp ] += 1 ; } System . out . println ( Math . min ( cubes [ 0 ] , cubes [ 1 ] ) * 2 ) ; } } import java . util . Scanner ; public class YoiPx { 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 yoiZb = true ; int len = s . length ( ) ; for ( int i = 0 ; i <= len / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( len - 1 - i ) ) { yoiZb = false ; break ; } } return yoiZb ; } } import java . util . Scanner ; public class jbqSvh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JbqKb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( JbqKb < 10 ) { if ( b < 10 ) { System . out . println ( JbqKb * b ) ; } else { System . out . println ( - 1 ) ; } } else { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; public class DjuchTf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int djuchOxc = sc . nextInt ( ) ; int [ ] [ ] A = new int [ djuchOxc + 1 ] [ 3 ] ; for ( int i = 1 ; i <= djuchOxc ; 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 <= djuchOxc ; 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 == djuchOxc ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class ZtcXpxt { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; double ztcFsn = scn . nextDouble ( ) ; scn . close ( ) ; double ans = 2 * ztcFsn * 3.1415926535 ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class PaceGgt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int paceZ = scan . nextInt ( ) ; int zone = scan . nextInt ( ) ; int pos = 0 ; int count = 1 ; for ( int i = 0 ; i < paceZ ; i ++ ) { pos += scan . nextInt ( ) ; if ( pos <= zone ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class LkngwmLrp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; if ( s . charAt ( 0 ) == 'A' ) { int LkngwmM = 0 ; int index = 0 ; for ( int j = 2 ; j < s . length ( ) - 1 ; j ++ ) { if ( s . charAt ( j ) == 'C' ) { LkngwmM ++ ; index = j ; } } if ( LkngwmM == 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 MyrnkWtvo { static final long myrnkE = 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 MyrnkWtvo { 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 PbyurmWy { public static void main ( String [ ] args ) throws Exception { String inputNameA ; String inputNameB ; int PbyurmHm ; 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 ( " " ) ; PbyurmHm = Integer . parseInt ( editInputNum [ 0 ] ) ; numberOfB = Integer . parseInt ( editInputNum [ 1 ] ) ; if ( inputNameA . equals ( choiceName ) ) { PbyurmHm -- ; } else if ( inputNameB . equals ( choiceName ) ) { numberOfB -- ; } System . out . println ( PbyurmHm + " " + numberOfB ) ; } } import java . util . Scanner ; public class pujMv { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; int [ ] x = new int [ 20000 ] ; x [ 0 ] = kb . nextInt ( ) ; int PujBl = 0 ; int i = 0 ; while ( x [ PujBl ] != 0 ) { PujBl ++ ; x [ PujBl ] = kb . nextInt ( ) ; } while ( x [ i ] != 0 ) { System . out . printf ( " Case %d: %d \n " , i + 1 , x [ i ] ) ; i ++ ; } } } import java . util . * ; public class PyzjrUxm { public static void main ( String [ ] args ) { int [ ] arr = new int [ 100 ] ; Scanner sc = new Scanner ( System . in ) ; int pyzjrJt = sc . nextInt ( ) ; for ( int i = 0 ; i < pyzjrJt ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } for ( int j = pyzjrJt - 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 VhkKkk { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] numbers = br . readLine ( ) . split ( " " ) ; int VhkGsr = Integer . parseInt ( numbers [ 0 ] ) ; int x = Integer . parseInt ( numbers [ 1 ] ) ; String [ ] length = br . readLine ( ) . split ( " " ) ; int [ ] len = new int [ VhkGsr ] ; for ( int i = 0 ; i < VhkGsr ; i ++ ) { len [ i ] = Integer . parseInt ( length [ i ] ) ; } int [ ] bounces = new int [ VhkGsr + 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 ikrPc { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String str = in . nextLine ( ) ; in . close ( ) ; int IkrKlqzb = 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 ( IkrKlqzb < count ) IkrKlqzb = count ; count = 0 ; } } if ( IkrKlqzb < count ) IkrKlqzb = count ; System . out . println ( IkrKlqzb ) ; } } import java . util . Scanner ; public class AtitgFc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String t = scan . next ( ) ; int atitgP = 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 ++ ; } } atitgP = Math . min ( atitgP , diff ) ; } System . out . println ( atitgP ) ; } } import java . util . Scanner ; public class HtiCzfl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int htiHarg = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] A = new int [ htiHarg ] ; for ( int i = 0 ; i < htiHarg ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < htiHarg ; 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 uhmicGoy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UhmicUwu = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < UhmicUwu ; 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 HgaagaNi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hgaagaBe = 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 == hgaagaBe && 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 KcbeAxitwm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KcbeOl = sc . nextInt ( ) ; int [ ] cities = new int [ KcbeOl + 1 ] ; int [ ] savers = new int [ KcbeOl ] ; for ( int i = 0 ; i <= KcbeOl ; i ++ ) cities [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < KcbeOl ; i ++ ) savers [ i ] = sc . nextInt ( ) ; double ans = 0 ; for ( int i = 0 ; i < KcbeOl ; 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 kjeG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KjeSs = sc . nextInt ( ) ; int [ ] v = new int [ KjeSs ] ; int sum = 0 ; for ( int i = 0 ; i < KjeSs ; ++ i ) { v [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < KjeSs ; ++ i ) { int c = sc . nextInt ( ) ; sum = ( v [ i ] > c ) ? sum + v [ i ] - c : sum ; } System . out . println ( sum ) ; } } import java . util . * ; public class NfmonqVi { private static final Scanner sc = new Scanner ( System . in ) ; private void solve ( ) { int NfmonqBb = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < NfmonqBb ; ++ i ) { set . add ( sc . next ( ) ) ; } System . out . println ( set . size ( ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . * ; public class WnyIxbbu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WnyWc = 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 < WnyWc - 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 tqfjIkk { 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 TqfjZqj = 0 ; int sb = 0 ; int sc = 0 ; char next = 'a' ; boolean flag = true ; char winner = 0 ; while ( flag ) { switch ( next ) { case 'a' : if ( TqfjZqj == SA . length ( ) ) { flag = false ; winner = 'A' ; } else { next = SA . charAt ( TqfjZqj ) ; TqfjZqj ++ ; } 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 RxlkuPww { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { solve ( sc ) ; } } static void solve ( Scanner sc ) { int RxlkuH = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; if ( d <= RxlkuH || b <= c ) { System . out . println ( 0 ) ; return ; } if ( c <= RxlkuH ) { if ( d <= b ) { System . out . println ( d - RxlkuH ) ; } else { System . out . println ( b - RxlkuH ) ; } } else if ( c < b ) { if ( d <= b ) { System . out . println ( d - c ) ; } else { System . out . println ( b - c ) ; } } } } import java . util . Scanner ; class odhHs { public static void main ( String [ ] args ) { int OdhQfzj = 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 ) ) OdhQfzj ++ ; temp = sc . next ( ) ; } System . out . println ( OdhQfzj ) ; } } import java . util . Scanner ; import java . math . BigDecimal ; public class ZkulXx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double zkulNw = scan . nextDouble ( ) ; final double CIRCLERATE = 3.141592653589 ; double s = CIRCLERATE * zkulNw * zkulNw ; double l = 2 * CIRCLERATE * zkulNw ; 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 MxdVr { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; Map < String , Integer > count = new HashMap < > ( ) ; int MxdV = in . nextInt ( ) ; long res = 0 ; for ( int i = 0 ; i < MxdV ; 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 mmoqeM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MmoqeXvh = sc . nextInt ( ) ; int [ ] list = new int [ MmoqeXvh ] ; for ( int i = 0 ; i < MmoqeXvh ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } int count = 0 ; int Max = 0 ; for ( int i = 1 ; i < MmoqeXvh ; 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 cijvqkG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CijvqkSm = 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 = CijvqkSm ; 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 KladEob { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KladNi = sc . nextInt ( ) ; int [ ] stoneHeights = new int [ KladNi ] ; for ( int i = 0 ; i < KladNi ; i ++ ) { stoneHeights [ i ] = sc . nextInt ( ) ; } int [ ] minCostForStones = new int [ KladNi ] ; Arrays . fill ( minCostForStones , Integer . MAX_VALUE ) ; minCostForStones [ 0 ] = 0 ; for ( int i = 0 ; i < KladNi ; i ++ ) { for ( int j = i + 1 ; j < i + 3 ; j ++ ) { if ( j < KladNi ) { minCostForStones [ j ] = Math . min ( minCostForStones [ j ] , minCostForStones [ i ] + Math . abs ( stoneHeights [ j ] - stoneHeights [ i ] ) ) ; } } } System . out . println ( minCostForStones [ KladNi - 1 ] ) ; } } import java . util . Scanner ; public class XkdjyjTo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XkdjyjZpo = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = Integer . parseInt ( String . valueOf ( XkdjyjZpo ) + 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 HsqOegx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hsqBwcr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int temp1 = b ; b = hsqBwcr ; hsqBwcr = temp1 ; int temp = c ; c = hsqBwcr ; hsqBwcr = temp ; System . out . print ( hsqBwcr + " " + b + " " + c ) ; } } import java . io . * ; import java . util . * ; class CeguooKby { 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 ceguooRvu : c_array ) { if ( 'a' <= ceguooRvu && ceguooRvu <= 'z' ) array [ ceguooRvu - 'a' ] ++ ; else if ( 'A' <= ceguooRvu && ceguooRvu <= 'Z' ) array [ ceguooRvu - 'A' ] ++ ; } } while ( true ) ; for ( int i = 0 ; i < 26 ; i ++ ) { System . out . println ( ( char ) ( 'a' + i ) + " : " + array [ i ] ) ; } } } import java . util . * ; public class LjcwxaZqvr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ljcwxaN = sc . nextInt ( ) ; int b = ljcwxaN ; int ans = 0 ; while ( ljcwxaN > 0 ) { ans += ljcwxaN % 10 ; ljcwxaN /= 10 ; } System . out . println ( b % ans == 0 ? " Yes " : " No " ) ; } } import java . awt . * ; import java . awt . geom . * ; import java . io . * ; import java . util . * ; class FvrakJuu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] list = new int [ 3 ] ; for ( int FvrakUdk = 0 ; FvrakUdk < 3 ; FvrakUdk ++ ) { list [ FvrakUdk ] = sc . nextInt ( ) ; } Arrays . sort ( list ) ; System . out . print ( list [ 0 ] ) ; for ( int FvrakUdk = 1 ; FvrakUdk < 3 ; FvrakUdk ++ ) { System . out . print ( " " + list [ FvrakUdk ] ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class IedDqx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String iedU = sc . next ( ) ; String b = sc . next ( ) ; String c = sc . next ( ) ; String next = iedU . substring ( 0 , 1 ) ; iedU = iedU . substring ( 1 , iedU . length ( ) ) ; for ( ; ; ) { if ( next . equals ( " a " ) ) { if ( iedU . isEmpty ( ) ) { System . out . println ( " A " ) ; return ; } next = iedU . substring ( 0 , 1 ) ; iedU = iedU . substring ( 1 , iedU . 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 AubsdtYqbw { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; double aubsdtEja = stdIn . nextDouble ( ) ; double H = stdIn . nextDouble ( ) ; double x = stdIn . nextDouble ( ) ; double y = stdIn . nextDouble ( ) ; System . out . println ( aubsdtEja * H / 2 ) ; if ( x == aubsdtEja / 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 stqnbeCf { public static void main ( String [ ] args ) { Integer [ ] input = readInput ( ) ; int StqnbeHaldv = input [ 0 ] ; int b = input [ 1 ] ; if ( StqnbeHaldv < b ) { System . out . println ( " a < b " ) ; } else if ( StqnbeHaldv > 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 MviqvbDuh { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; int MviqvbH = Integer . parseInt ( line ) ; int tarouScore = 0 ; int hanakoScore = 0 ; for ( int i = 0 ; i < MviqvbH ; 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 EbiTc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; try { int ebiN , H , x , y , r ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; String [ ] strAry = str . split ( " " ) ; ebiN = 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 <= ebiN && 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 JbrzrsTtlf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long jbrzrsPvo = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = jbrzrsPvo / ( a + b ) ; long m = jbrzrsPvo - 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 oqudS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OqudBs = 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 < OqudBs ; 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 NinkhzZhok { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NinkhzQzr = sc . nextInt ( ) ; long [ ] monster = new long [ NinkhzQzr + 1 ] ; long [ ] brave = new long [ NinkhzQzr ] ; long anser = 0 ; for ( int i = 0 ; i < NinkhzQzr + 1 ; i ++ ) { monster [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < NinkhzQzr ; 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 LodimMbh { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int LodimS = s . nextInt ( ) ; int y = s . nextInt ( ) ; int flag = 0 ; for ( int i = 0 ; i <= LodimS ; i ++ ) { if ( i * 2 + ( LodimS - 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 LazdNwmq { public static void main ( String [ ] args ) { InputReader in = new InputReader ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int lazdJ = in . nextInt ( ) ; int y = in . nextInt ( ) ; int z = in . nextInt ( ) ; int p = lazdJ ; System . out . println ( z + " " + lazdJ + " " + y ) ; } static class LazdNwmq { 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 LuiOas { 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 luiA = Integer . parseInt ( numberStr [ 0 ] ) ; int sum = Integer . parseInt ( numberStr [ 1 ] ) ; if ( ( luiA == 0 ) && ( sum == 0 ) ) { break ; } int set = 0 ; for ( int oneNum = 1 ; oneNum <= luiA - 2 ; oneNum ++ ) { for ( int twoNum = oneNum + 1 ; twoNum <= luiA + 1 ; twoNum ++ ) { for ( int threeNum = twoNum + 1 ; threeNum <= luiA ; 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 GmiWv { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int GmiX = sc . nextInt ( ) ; int max = sc . nextInt ( ) ; int count = 1 ; for ( int i = 0 ; i < GmiX - 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 dxvE { public static void main ( String [ ] args ) { int DxvNvtth = 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 ++ ) { DxvNvtth = DxvNvtth + 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 ++ ) { DxvNvtth = DxvNvtth + c [ CN . get ( l ) - 1 ] ; } System . out . println ( DxvNvtth ) ; } } import java . util . * ; public class sczfbVtt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int SczfbOxcm = scan . nextInt ( ) ; if ( SczfbOxcm % 10 == 7 || SczfbOxcm % 100 - SczfbOxcm % 10 == 70 || SczfbOxcm % 1000 - SczfbOxcm % 100 == 700 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; return ; } } import java . util . * ; public class eywlvbD { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int EywlvbWc ; EywlvbWc = in . nextInt ( ) ; int a , b , i , num ; a = in . nextInt ( ) ; b = in . nextInt ( ) ; num = a ; for ( i = num ; i <= b ; i ++ , num ++ ) { if ( i % EywlvbWc == 0 ) { System . out . println ( " OK " ) ; System . exit ( 0 ) ; } } System . out . println ( " NG " ) ; } } import java . util . Scanner ; public class IwwxTgjz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IwwxH = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( 6 - IwwxH - b ) ; } } import java . util . Scanner ; public class ZhrfeCz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zhrfeT = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int tmp = 9999 ; int min = 9999 ; int [ ] ci = new int [ zhrfeT ] ; int [ ] ti = new int [ zhrfeT ] ; int i = 0 ; for ( i = 0 ; i < zhrfeT ; 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 bsodVhf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BsodIv = 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 < BsodIv ; 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 lolrYc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double LolrEb = 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 gwahctP { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long GwahctWprki = 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 ] >= GwahctWprki ) 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 MhlfxKrfbw { private static final Scanner scn = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int MhlfxM = scn . nextInt ( ) , b = scn . nextInt ( ) , c = scn . nextInt ( ) ; System . out . println ( MhlfxM < b && b < c ? " Yes " : " No " ) ; } } import java . util . * ; class TlvqWnm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TlvqM = sc . nextInt ( ) ; if ( TlvqM < 0 ) { System . out . println ( " NA " ) ; return ; } if ( TlvqM % 100 < 13 && TlvqM % 100 != 0 ) { if ( TlvqM / 100 < 13 && TlvqM / 100 != 0 ) { System . out . println ( " AMBIGUOUS " ) ; return ; } System . out . println ( " YYMM " ) ; return ; } if ( TlvqM / 100 < 13 && TlvqM / 100 != 0 ) { System . out . println ( " MMYY " ) ; return ; } System . out . println ( " NA " ) ; } } import java . util . * ; import java . math . * ; public class TxsEvud { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long txsPoyu = 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 ) ( txsPoyu * B / 100 ) ; System . out . println ( res ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class LhkSl { public static void main ( String [ ] args ) { Scanner a = new Scanner ( System . in ) ; int [ ] numbers = new int [ 3 ] ; for ( int lhkL = 0 ; lhkL < 3 ; lhkL ++ ) { numbers [ lhkL ] = 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 ImqXgv { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int ImqXt = Integer . parseInt ( br . readLine ( ) ) ; for ( int f = 0 ; f < ImqXt ; 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 PoteRokn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int poteZhha = scan . nextInt ( ) ; int [ ] a = new int [ poteZhha ] ; for ( int i = 0 ; i < poteZhha ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; Arrays . sort ( a ) ; int check = 0 ; for ( int i = 0 ; i < poteZhha ; i ++ ) { for ( int j = i + 1 ; j < poteZhha ; 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 fktuM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FktuUnxwp = sc . nextInt ( ) ; String str = sc . next ( ) ; char [ ] c = str . toCharArray ( ) ; int count = 0 ; if ( FktuUnxwp % 2 == 0 ) { for ( int i = 0 ; i < FktuUnxwp / 2 ; i ++ ) { if ( c [ i ] == c [ FktuUnxwp / 2 + i ] ) { count ++ ; } } if ( count == FktuUnxwp / 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class zalEo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ZalEj = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; if ( ZalEj >= 0 ) { if ( d >= 0 ) { System . out . println ( b * d ) ; } else { System . out . println ( d * ZalEj ) ; } } else if ( b < 0 ) { if ( c >= 0 ) { System . out . println ( b * c ) ; } else { System . out . println ( c * ZalEj ) ; } } else { if ( d < 0 ) { System . out . println ( c * ZalEj ) ; } else if ( c >= 0 ) { System . out . println ( b * d ) ; } else { if ( ZalEj * c > b * d ) { System . out . println ( ZalEj * c ) ; } else { System . out . println ( b * d ) ; } } } } } import java . util . Scanner ; public class HrnwcgEtfy { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final StringBuilder S1 = new StringBuilder ( sc . next ( ) ) ; final int HrnwcgRaj = S1 . length ( ) ; final StringBuilder S2 = new StringBuilder ( S1 . substring ( 0 , ( HrnwcgRaj - 1 ) / 2 ) ) ; final StringBuilder S3 = new StringBuilder ( S1 . substring ( ( HrnwcgRaj + 3 ) / 2 - 1 , HrnwcgRaj ) ) ; 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 onifexOs { 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 OnifexKl = Integer . parseInt ( split [ 0 ] ) ; int N = Integer . parseInt ( split [ 1 ] ) ; info = br . readLine ( ) ; String [ ] A = info . split ( " " ) ; for ( int i = 0 ; i < N ; i ++ ) { OnifexKl = OnifexKl - Integer . parseInt ( A [ i ] ) ; } if ( OnifexKl <= 0 ) { System . out . println ( " Yes " ) ; } else System . out . println ( " No " ) ; } } import java . math . * ; import java . util . * ; import java . io . * ; import java . lang . * ; public class TpguWy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tpguLb = sc . nextInt ( ) ; if ( isPrime ( tpguLb ) ) { System . out . println ( tpguLb ) ; } else { while ( ! isPrime ( tpguLb ) ) { tpguLb ++ ; } System . out . println ( tpguLb ) ; } } 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 UuoylPqvm { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] parts = br . readLine ( ) . split ( " " ) ; int uuoylFld = Integer . parseInt ( parts [ 0 ] ) ; int A = Integer . parseInt ( parts [ 1 ] ) ; int a = uuoylFld % A ; if ( a == 0 ) { System . out . println ( uuoylFld / A ) ; } else { System . out . println ( uuoylFld / A + 1 ) ; } } } import java . util . Scanner ; public class IrhjQnpf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int irhjNqb = Integer . parseInt ( sc . nextLine ( ) ) ; sc . close ( ) ; int ans = 0 ; if ( irhjNqb < 10 ) { ans = irhjNqb ; } else if ( irhjNqb < 100 ) { ans = 9 ; } else if ( irhjNqb < 1000 ) { ans = irhjNqb - 99 + 9 ; } else if ( irhjNqb < 10000 ) { ans = 999 - 99 + 9 ; } else if ( irhjNqb < 100000 ) { ans = irhjNqb - 9999 + 999 - 99 + 9 ; } else if ( irhjNqb < 1000000 ) { ans = 99999 - 9999 + 999 - 99 + 9 ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class vtkuVxe { 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 VtkuJiid = list . get ( 0 ) ; int sum = list . get ( 1 ) ; int i = 0 ; if ( sum == 1 ) { System . out . print ( 0 ) ; } else if ( VtkuJiid >= sum ) { System . out . print ( 1 ) ; } else { sum = sum - VtkuJiid ; i ++ ; VtkuJiid -- ; while ( true ) { sum = sum - VtkuJiid ; i ++ ; if ( sum < 1 ) { System . out . print ( i ) ; break ; } } } } } import java . util . Scanner ; public class LuctPw { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int luctZv ; double [ ] b = new double [ 1111 ] ; double av ; double sum ; while ( true ) { luctZv = input . nextInt ( ) ; if ( luctZv == 0 ) break ; else { sum = 0 ; av = 0 ; for ( int i = 0 ; i < luctZv ; i ++ ) { b [ i ] = input . nextDouble ( ) ; av += b [ i ] ; } av /= luctZv ; for ( int i = 0 ; i < luctZv ; i ++ ) { sum += ( b [ i ] - av ) * ( b [ i ] - av ) / luctZv ; } System . out . println ( Math . sqrt ( sum ) ) ; } } input . close ( ) ; } } import java . util . * ; class CrrmtAtxt { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int CrrmtQi = 1 , x = 1 ; while ( x > 0 ) { x = scanner . nextInt ( ) ; if ( x == 0 ) { break ; } System . out . println ( " Case " + CrrmtQi + " : " + x ) ; CrrmtQi ++ ; } } } import java . util . * ; public class zbcqizNmk { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int ZbcqizHlwtz = input . nextInt ( ) ; int h = ( ZbcqizHlwtz / 500 ) * 1000 ; int f = ( ( ZbcqizHlwtz % 500 ) / 5 ) * 5 ; System . out . println ( h + f ) ; } } import java . util . * ; public class acyRd { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { boolean AcyYnyz = true ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a >= b ) { AcyYnyz = false ; } int c = sc . nextInt ( ) ; if ( b >= c ) { AcyYnyz = false ; } System . out . println ( AcyYnyz == true ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class QvubkRpnl { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String QvubkPn = input . nextLine ( ) ; if ( QvubkPn . equals ( " SUN " ) ) { System . out . println ( " 7 " ) ; } else if ( QvubkPn . equals ( " MON " ) ) { System . out . println ( " 6 " ) ; } else if ( QvubkPn . equals ( " TUE " ) ) { System . out . println ( " 5 " ) ; } else if ( QvubkPn . equals ( " WED " ) ) { System . out . println ( " 4 " ) ; } else if ( QvubkPn . equals ( " THU " ) ) { System . out . println ( " 3 " ) ; } else if ( QvubkPn . equals ( " FRI " ) ) { System . out . println ( " 2 " ) ; } else if ( QvubkPn . equals ( " SAT " ) ) { System . out . println ( " 1 " ) ; } } } import java . util . Scanner ; public class GqosAm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String gqosVpu = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; String t = sb . append ( gqosVpu ) . 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 StvAa { 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 stvN = 0 ; stvN < 10 ; stvN ++ ) input . add ( Integer . parseInt ( br . readLine ( ) ) ) ; Collections . sort ( input , Collections . reverseOrder ( ) ) ; for ( int stvN = 0 ; stvN < 3 ; stvN ++ ) System . out . println ( input . get ( stvN ) ) ; } } import java . util . Scanner ; public class qmdAcw { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; while ( true ) { String word = input . nextLine ( ) ; if ( word . equals ( " - " ) ) break ; int QmdSem = input . nextInt ( ) ; for ( int i = 0 ; i < QmdSem ; 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 XxuUd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xxuTe = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int judge = 0 ; while ( xxuTe >= 0 && Y >= 0 ) { if ( Y / 4 == xxuTe && Y % 4 == 0 ) { judge = 1 ; break ; } xxuTe = xxuTe - 1 ; Y = Y - 2 ; } if ( judge == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class WhpwmYvc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] list = scanner . next ( ) . split ( " " ) ; int WhpwmNc = 0 ; for ( String s : list ) { if ( Integer . parseInt ( s ) == 1 ) { WhpwmNc ++ ; } } System . out . println ( WhpwmNc ) ; scanner . close ( ) ; } } import java . util . * ; public class RftmcaDwne { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] ss = new String [ 4 ] ; for ( int RftmcaO = 0 ; RftmcaO < 4 ; RftmcaO ++ ) { ss [ RftmcaO ] = s . substring ( RftmcaO , RftmcaO + 1 ) ; } for ( int RftmcaO = 0 ; RftmcaO < 3 ; RftmcaO ++ ) { if ( ss [ RftmcaO ] . equals ( ss [ RftmcaO + 1 ] ) ) { System . out . println ( " Bad " ) ; return ; } } System . out . println ( " Good " ) ; } } import java . util . * ; public class FdihbdWhcx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FdihbdJ = 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 ( FdihbdJ ) ; } else { for ( int i = 0 ; i < a . length ; i ++ ) { if ( min <= ( int ) Math . abs ( FdihbdJ - a [ i ] ) ) { System . out . println ( a [ i - 1 ] ) ; break ; } else { min = ( int ) Math . abs ( FdihbdJ - a [ i ] ) ; } } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class zhpitwJi { public static void main ( String [ ] args ) throws IOException , Exception { BufferedReader st = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] data1 = getIntArry ( st ) ; int ZhpitwSnzr = data1 [ 0 ] ; int k = data1 [ 1 ] ; int [ ] data2 = getIntArry ( st ) ; int ans = 0 ; for ( int i = 0 ; i < ZhpitwSnzr ; 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 HvwfHhlj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HvwfTh = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( ( B + HvwfTh - 3 ) / ( HvwfTh - 1 ) ) ; } } import java . util . Scanner ; public class vvulEhr { public static void main ( String [ ] args ) { Scanner kbd = new Scanner ( System . in ) ; int VvulNl = kbd . nextInt ( ) ; int d = kbd . nextInt ( ) ; int num = 0 ; for ( int i = 0 ; i < VvulNl ; 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 NdizxIxs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int ndizxA = s . length ; char [ ] t = sc . next ( ) . toCharArray ( ) ; int tlen = t . length ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < ndizxA - 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 pdakwD { 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 PdakwVnln = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int ans = 0 ; while ( PdakwVnln >= K ) { PdakwVnln /= K ; ans ++ ; } if ( PdakwVnln != 0 ) ans ++ ; os . println ( ans ) ; } } import java . util . Scanner ; import java . lang . Math ; class WmjuydNozap { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int WmjuydScc = Integer . parseInt ( stdIn . next ( ) ) ; if ( WmjuydScc != 2 && WmjuydScc % 2 == 0 ) WmjuydScc ++ ; while ( true ) { int i ; double sqrtNum = Math . sqrt ( WmjuydScc ) ; for ( i = 3 ; i <= sqrtNum ; i += 2 ) { if ( WmjuydScc % i == 0 ) break ; } if ( i > sqrtNum ) break ; WmjuydScc += 2 ; } System . out . println ( WmjuydScc ) ; } } import java . util . Scanner ; public class ZruhYhqm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int zruhLnqu = 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 AyeocvSxgw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ayeocvJov = scan . nextInt ( ) ; int [ ] A = new int [ ayeocvJov ] ; for ( int i = 0 ; i < ayeocvJov ; i ++ ) { A [ i ] = scan . nextInt ( ) ; } double c = 0 ; Arrays . sort ( A ) ; c = ( A [ 0 ] + A [ 1 ] ) / 2.0 ; for ( int i = 2 ; i < ayeocvJov ; i ++ ) { c = ( c + A [ i ] ) / 2.0 ; } System . out . println ( c ) ; } } import java . util . * ; import java . io . * ; import java . nio . charset . StandardCharsets ; public class DsrCznymj { 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 DsrFk = new String ( str ) ; System . out . println ( DsrFk ) ; } } import java . util . * ; class wckI { 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 WckNj = ss [ ss . length - 1 ] ; if ( WckNj == '2' || WckNj == '4' || WckNj == '5' || WckNj == '7' || WckNj == '9' ) { System . out . println ( " hon " ) ; } else if ( WckNj == '0' || WckNj == '1' || WckNj == '6' || WckNj == '8' ) { System . out . println ( " pon " ) ; } else { System . out . println ( " bon " ) ; } } } import java . io . * ; import java . util . * ; public class LkbnrJsx { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int LkbnrP = 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 FyubTe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Double r = Double . parseDouble ( sc . next ( ) ) ; double FyubPoe = Math . PI ; double s = r * r * FyubPoe ; double l = 2 * r * FyubPoe ; System . out . printf ( " %.6f " , s ) ; System . out . print ( " " ) ; System . out . printf ( " %.6f \n " , l ) ; } } import java . util . * ; class axwA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AxwRmw = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] array = { 1 , 2 , 3 } ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( ( array [ i ] == AxwRmw ) || ( 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 ckuhgF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CkuhgUmsp = 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 nukvjzB { static char [ ] xx = new char [ ] { 'S' , 'H' , 'C' , 'D' } ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NukvjzBou = sc . nextInt ( ) ; boolean [ ] [ ] l = new boolean [ 4 ] [ 13 ] ; for ( int i = 0 ; i < NukvjzBou ; 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 ZcnJpnx { 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 zcnZ = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; if ( zcnZ > 2019 || ( zcnZ <= 2019 && m > 4 ) ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } } } import java . util . Scanner ; public class kdbfskW { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String [ ] t = s . split ( " " ) ; for ( int KdbfskFnvg = 0 ; KdbfskFnvg < t . length ; KdbfskFnvg ++ ) { t [ KdbfskFnvg ] = " x " ; } String u = String . join ( " " , t ) ; System . out . println ( u ) ; } } import java . util . * ; public class faxlFu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String FaxlIl = sc . next ( ) ; if ( " SAT " . equals ( FaxlIl ) ) { System . out . println ( " 1 " ) ; } else if ( " FRI " . equals ( FaxlIl ) ) { System . out . println ( " 2 " ) ; } else if ( " THU " . equals ( FaxlIl ) ) { System . out . println ( " 3 " ) ; } else if ( " WED " . equals ( FaxlIl ) ) { System . out . println ( " 4 " ) ; } else if ( " TUE " . equals ( FaxlIl ) ) { System . out . println ( " 5 " ) ; } else if ( " MON " . equals ( FaxlIl ) ) { System . out . println ( " 6 " ) ; } else if ( " SUN " . equals ( FaxlIl ) ) { 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 xiinVdl { 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 XiinTqp = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int H = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; double ax = XiinTqp * Math . cos ( Math . toRadians ( 90 - 30 * H - M / 2.0 ) ) ; double ay = XiinTqp * 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 KhsaoUk { public static void main ( String [ ] args ) { try ( final Scanner sc = new Scanner ( System . in ) ) { Resolver resolver = new Resolver ( sc ) ; resolver . resolve ( ) ; } } private static class KhsaoUk { private final int khsaoEi , b , t ; private Resolver ( final Scanner sc ) { this . khsaoEi = sc . nextInt ( ) ; this . b = sc . nextInt ( ) ; this . t = sc . nextInt ( ) ; } private void resolve ( ) { int k = t / khsaoEi ; System . out . println ( b * k ) ; } } } import java . util . Scanner ; class VorvruKwd { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int vorvruM , c , a [ ] [ ] = new int [ 101 ] [ 101 ] , i , j ; vorvruM = stdIn . nextInt ( ) ; c = stdIn . nextInt ( ) ; for ( i = 0 ; i < vorvruM ; 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 < vorvruM ; j ++ ) a [ vorvruM ] [ i ] += a [ j ] [ i ] ; a [ vorvruM ] [ c ] += a [ vorvruM ] [ i ] ; } for ( i = 0 ; i <= vorvruM ; 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 UazIz { public static void main ( String [ ] args ) { boolean UazQ = 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 ( UazQ == 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 ( ) ; UazQ = true ; } } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class BygMrj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String nyu = sc . next ( ) ; int BygUuy = 0 , mem = 0 , leng ; leng = nyu . length ( ) ; for ( int i = 0 ; i < leng ; i ++ ) { char top = nyu . charAt ( i ) ; switch ( top ) { case 'A' : BygUuy += 1 ; break ; case 'C' : BygUuy += 1 ; break ; case 'G' : BygUuy += 1 ; break ; case 'T' : BygUuy += 1 ; break ; default : if ( BygUuy > mem ) { mem = BygUuy ; BygUuy = 0 ; } } } if ( BygUuy > mem ) { mem = BygUuy ; } System . out . println ( mem ) ; } } import java . util . * ; public class ncaK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NcaIffb = sc . nextInt ( ) , T = sc . nextInt ( ) ; int [ ] c = new int [ NcaIffb ] ; int [ ] t = new int [ NcaIffb ] ; for ( int i = 0 ; i < NcaIffb ; i ++ ) { c [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; } int ans = INF ; boolean exist = false ; for ( int i = 0 ; i < NcaIffb ; 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 NzcGshyz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; long NzcHy = 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 >= NzcHy ) { int cnt1 = 0 ; for ( int i = 0 ; i < l ; i ++ ) { if ( num [ i ] == 1 ) { cnt1 ++ ; } else { break ; } } if ( cnt1 >= NzcHy ) { 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 cabflrCch { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CabflrHcgno = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ m ] ; boolean [ ] jdg = new boolean [ CabflrHcgno + 1 ] ; long [ ] Dp = new long [ CabflrHcgno + 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 <= CabflrHcgno ; 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 [ CabflrHcgno ] ) ; } } import java . util . * ; public class ipqeX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IpqeXfr , i , answer ; int sum = 0 ; int temp_a = 0 ; int temp_b = 0 ; IpqeXfr = Integer . parseInt ( sc . next ( ) ) ; int [ ] weight = new int [ IpqeXfr ] ; for ( i = 0 ; i < IpqeXfr ; i ++ ) { weight [ i ] = Integer . parseInt ( sc . next ( ) ) ; sum += weight [ i ] ; } for ( i = 0 ; i < IpqeXfr ; 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 VvzpuaAyna { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int vvzpuaI = scanner . nextInt ( ) ; int max = Integer . MAX_VALUE ; for ( int i = 0 ; i < vvzpuaI ; i ++ ) { max = Math . min ( max , Integer . numberOfTrailingZeros ( scanner . nextInt ( ) ) ) ; } System . out . println ( max ) ; } } import java . util . Scanner ; public class GgvxPk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; boolean GgvxFc = 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 uoccobBef { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int UoccobDu = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( '0' == s . charAt ( i ) ) UoccobDu ++ ; } System . out . println ( 2 * Math . min ( s . length ( ) - UoccobDu , UoccobDu ) ) ; } } import java . util . Scanner ; public class UpbddlCzykgb { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int UpbddlJhz = s . nextInt ( ) ; int [ ] ds = new int [ UpbddlJhz ] ; int sum = 0 ; for ( int i = 0 ; i < UpbddlJhz ; 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 PbqtvqRst { static String str ; static int pbqtvqB , zeroC , oneC ; static int [ ] A ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; str = sc . next ( ) ; pbqtvqB = str . length ( ) ; A = new int [ pbqtvqB ] ; for ( int i = 0 ; i < pbqtvqB ; i ++ ) { A [ i ] = Character . getNumericValue ( str . charAt ( i ) ) ; if ( A [ i ] == 0 ) { zeroC ++ ; } else { oneC ++ ; } } System . out . println ( pbqtvqB - ( Math . abs ( zeroC - oneC ) ) ) ; } } import java . util . * ; class dwyFp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DwyBs = 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 ) + ( DwyBs * ( X - Y ) ) ; price2 = C * 2 * X ; } else { price1 = ( C * 2 * X ) + ( B * ( Y - X ) ) ; price2 = C * 2 * Y ; } int price3 = DwyBs * X + B * Y ; int ans = Math . min ( price1 , price2 ) ; ans = Math . min ( ans , price3 ) ; System . out . println ( + ans ) ; } } import java . util . * ; public class ZmhbnYwglh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZmhbnIh = sc . nextInt ( ) ; int [ ] H = new int [ ZmhbnIh ] ; for ( int i = 0 ; i < ZmhbnIh ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; boolean out = false ; H [ 0 ] -- ; for ( int i = 0 ; i < ZmhbnIh - 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 NuillcOadvkg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long NuillcRtp = sc . nextLong ( ) ; long ans = Long . MAX_VALUE / 2 ; for ( int i = 1 ; ( long ) i * i <= NuillcRtp ; i ++ ) { if ( NuillcRtp % i == 0 ) { long a = i ; long b = NuillcRtp / 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 tmhnzvE { public static void main ( String [ ] args ) { int TmhnzvOh ; int endNum ; int answer = 0 ; Scanner sc = new Scanner ( System . in ) ; TmhnzvOh = sc . nextInt ( ) ; endNum = sc . nextInt ( ) ; for ( int i = TmhnzvOh ; 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 DnknjPf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dnknjLc = sc . nextInt ( ) ; int [ ] b = new int [ dnknjLc ] ; 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 bfvaRb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long BfvaWynz = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( BfvaWynz % k < k - ( BfvaWynz % k ) ) k = BfvaWynz % k ; else k = k - ( BfvaWynz % k ) ; System . out . println ( k ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class hvxkQk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HvxkVfdiv = sc . nextInt ( ) , K = sc . nextInt ( ) ; double [ ] dp = new double [ K + 1 ] ; Arrays . fill ( dp , 0 ) ; for ( int i = 1 ; i <= Math . min ( HvxkVfdiv , K ) ; ++ i ) dp [ i ] = 1.0 / HvxkVfdiv ; dp [ K ] += ( double ) Math . max ( 0 , HvxkVfdiv - K ) / HvxkVfdiv ; 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 LxxetzOw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int lxxetzBbv = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int min = 0 ; int count = 0 ; if ( lxxetzBbv < B ) { min = lxxetzBbv ; } else { min = B ; } for ( int i = min ; i >= 1 ; i -- ) { if ( lxxetzBbv % i == 0 && B % i == 0 ) { count ++ ; if ( count == K ) { System . out . println ( i ) ; break ; } } } scan . close ( ) ; } } import java . util . * ; public class oulbNpg { 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 OulbDfbxx = 0 ; OulbDfbxx < Q ; OulbDfbxx ++ ) { l [ OulbDfbxx ] = sc . nextInt ( ) ; r [ OulbDfbxx ] = sc . nextInt ( ) ; } int [ ] a = new int [ N ] ; int count = 0 ; for ( int OulbDfbxx = 1 ; OulbDfbxx < N ; OulbDfbxx ++ ) { if ( S . charAt ( OulbDfbxx - 1 ) == 'A' && S . charAt ( OulbDfbxx ) == 'C' ) { count ++ ; a [ OulbDfbxx ] = count ; } else { a [ OulbDfbxx ] = count ; } } for ( int OulbDfbxx = 0 ; OulbDfbxx < Q ; OulbDfbxx ++ ) { System . out . println ( a [ r [ OulbDfbxx ] - 1 ] - a [ l [ OulbDfbxx ] - 1 ] ) ; } } } import java . util . Scanner ; public class LbbEtqkr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LbbH = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int C = 0 ; C = LbbH * B ; System . out . println ( C ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class ueypIxt { private static int UeypAke = 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 . UeypAke ) ; } public static void me ( int [ ] nums ) { int min = Integer . MAX_VALUE ; for ( int num : nums ) { min = num < min ? num : min ; } Main . UeypAke += 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 CwtlLn { public static void main ( String [ ] args ) throws Exception { boolean cwtlZish = 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 NpbazGw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String w = scan . nextLine ( ) ; int NpbazNdo = 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 ) ) { NpbazNdo ++ ; } } } System . out . println ( NpbazNdo ) ; } } import java . util . * ; import java . lang . * ; public class CkaFku { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; int [ ] a = new int [ n . length ( ) + 1 ] ; int CkaNji = 0 ; for ( int i = 0 ; i < n . length ( ) ; i ++ ) { a [ i ] = n . charAt ( i ) - '0' ; } for ( int i = 0 ; i < n . length ( ) ; i ++ ) { CkaNji = CkaNji + a [ i ] ; } if ( CkaNji % 9 == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class leeSc { Scanner sc ; int LeeLk , 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 { LeeLk = sc . nextInt ( ) ; b = sc . nextInt ( ) ; int k = ( LeeLk + b ) / 2 ; if ( k * 2 != LeeLk + 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 bghzX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BghzWlrg = 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 ++ ) { BghzWlrg -= A [ i ] ; } if ( BghzWlrg <= 0 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; import java . util . Collections ; import java . util . ArrayList ; public class SeqMdjd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SeqYud = 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 OceoWihswd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char OceoVo = sc . next ( ) . trim ( ) . charAt ( 0 ) ; StringBuilder sb = new StringBuilder ( ) ; if ( OceoVo >= 'A' && OceoVo <= 'Z' ) sb . append ( 'A' + " \n " ) ; else if ( OceoVo >= 'a' && OceoVo <= 'z' ) sb . append ( 'a' + " \n " ) ; sc . close ( ) ; System . out . println ( sb ) ; } } import java . util . * ; public class MicbrbCn { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] nums = new int [ 3 ] ; for ( int MicbrbSgn = 0 ; MicbrbSgn < 3 ; MicbrbSgn ++ ) nums [ MicbrbSgn ] = sc . nextInt ( ) ; Arrays . sort ( nums ) ; int cost = 0 ; for ( int MicbrbSgn = 1 ; MicbrbSgn < 3 ; MicbrbSgn ++ ) cost += nums [ MicbrbSgn ] - nums [ MicbrbSgn - 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 ddzGn { static class ddzGn { 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 DdzWdn = 1 ; long ans = 0 , mod = 1000000007 ; while ( DdzWdn -- > 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 fliqYoo { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner stdin = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ ] ; for ( int FliqTsk = 0 ; FliqTsk < 3 ; FliqTsk ++ ) { c [ FliqTsk ] = new int [ 3 ] ; for ( int j = 0 ; j < 3 ; j ++ ) { c [ FliqTsk ] [ 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 TxefkHput { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TxefkTak = Integer . parseInt ( sc . next ( ) ) ; int [ ] l = new int [ TxefkTak ] ; for ( int i = 0 ; i < TxefkTak ; 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 JbggsKvaowg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long JbggsKv = sc . nextLong ( ) ; sc . close ( ) ; long p = 1 ; long sum = 0 ; for ( int i = 0 ; i < JbggsKv ; i ++ ) { if ( p % 5 == 0 || p % 3 == 0 ) { p ++ ; continue ; } else { sum += p ; p ++ ; } } System . out . println ( sum ) ; } } import java . util . * ; public class RiqlVhfd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long RiqlW = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long ans1 = Math . max ( RiqlW , b ) * Math . max ( c , d ) ; long ans2 = Math . min ( RiqlW , b ) * Math . max ( c , d ) ; long ans3 = Math . max ( RiqlW , b ) * Math . min ( c , d ) ; long ans4 = Math . min ( RiqlW , 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 AwpghdEap { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long AwpghdD = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; if ( AwpghdD - c < 0 && AwpghdD + b >= c ) { System . out . println ( " 0 " + ( b - ( c - AwpghdD ) ) ) ; } else if ( AwpghdD + b <= c ) { System . out . println ( " 0 0 " ) ; } else { System . out . println ( AwpghdD - c + " " + b ) ; } } } import java . util . Scanner ; public class monojsQa { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int MonojsFyo = sc . nextInt ( ) ; int c = 0 ; for ( int i = 0 ; i < MonojsFyo ; i ++ ) { if ( PNcheck ( sc . nextInt ( ) ) ) c ++ ; } System . out . println ( c ) ; } static boolean PNcheck ( int MonojsFyo ) { if ( MonojsFyo == 2 ) return true ; if ( ( MonojsFyo % 2 ) == 0 ) return false ; for ( int i = 3 ; i * i <= MonojsFyo ; i = i + 2 ) { if ( ( MonojsFyo % i ) == 0 ) return false ; } return true ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; class GyzhnhMayn { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static String S , T ; static int GyzhnhSv = 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 ) { GyzhnhSv ++ ; } } System . out . println ( GyzhnhSv ) ; } } import java . util . * ; public class xjtwxaKfg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double XjtwxaJici = scanner . nextDouble ( ) ; System . out . println ( String . format ( " %.6f " , Math . pow ( XjtwxaJici / 3 , 3 ) ) ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class OdrNmn { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int odrJ = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; sc . close ( ) ; R = Math . min ( odrJ + 2019 , R ) ; int ans = Integer . MAX_VALUE ; for ( int x = odrJ ; 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 dyymCb { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int DyymHi = scn . nextInt ( ) ; int d = scn . nextInt ( ) ; int [ ] [ ] dot = new int [ DyymHi ] [ d ] ; int answer = 0 ; for ( int i = 0 ; i < DyymHi ; i ++ ) { for ( int j = 0 ; j < d ; j ++ ) { dot [ i ] [ j ] = scn . nextInt ( ) ; } } for ( int i = 0 ; i < DyymHi ; i ++ ) { for ( int j = i + 1 ; j < DyymHi ; 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 romuSk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String RomuNq = sc . next ( ) ; if ( RomuNq . 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 CazcBtmvz { 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 CazcPyw = 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 tctdolJvv { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int TctdolNlnvh = scn . nextInt ( ) ; int a = scn . nextInt ( ) ; int b = scn . nextInt ( ) ; for ( ; a <= b ; a ++ ) { if ( a % TctdolNlnvh == 0 ) { System . out . printf ( " OK \n " ) ; return ; } } System . out . printf ( " NG \n " ) ; } } import java . util . * ; class UcjDjam { public Main ( ) { int ucjSul ; String S ; HashMap < String , Integer > HM = new HashMap < String , Integer > ( ) ; Scanner scanner = new Scanner ( System . in ) ; ucjSul = scanner . nextInt ( ) ; for ( int i = 0 ; i < ucjSul ; 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 WmwMo { 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 wmwCgz = Integer . parseInt ( line [ 0 ] ) ; int q = Integer . parseInt ( line [ 1 ] ) ; Queue < String [ ] > queue = new ArrayDeque < String [ ] > ( ) ; for ( int i = 0 ; i < wmwCgz ; 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 UffXso { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UffQ = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] A = new int [ UffQ ] ; 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 < UffQ ; i ++ ) { if ( 0 < A [ i ] + K - Q ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } } out . flush ( ) ; } } import java . util . Scanner ; public class QtiHdf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] country = new int [ sc . nextInt ( ) ] ; int qtiUv = sc . nextInt ( ) ; for ( int i = 0 ; i < qtiUv ; 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 RirafpQtqy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rirafpVku = Integer . parseInt ( sc . next ( ) ) ; int [ ] d = new int [ rirafpVku ] ; for ( int i = 0 ; i < rirafpVku ; i ++ ) { d [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int sum = 0 ; for ( int i = 0 ; i < rirafpVku - 1 ; i ++ ) { for ( int j = i + 1 ; j < rirafpVku ; j ++ ) { sum += d [ i ] * d [ j ] ; } } System . out . println ( sum ) ; } } import java . util . * ; public class itghnrXw { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int ItghnrNtvt = s . nextInt ( ) ; int [ ] An = new int [ ItghnrNtvt ] ; int ans = 0 ; for ( int i = 0 ; i < ItghnrNtvt ; i ++ ) { An [ i ] = s . nextInt ( ) ; } Arrays . sort ( An ) ; ans = An [ ItghnrNtvt - 1 ] - An [ 0 ] ; System . out . print ( ans ) ; } } import java . util . Scanner ; public class bemaqfRcq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; boolean BemaqfVzjiy = scanner . BemaqfVzjiy ( ) ; 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 quzuzTq { 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 QuzuzZrat = Integer . parseInt ( s . substring ( 0 , 2 ) ) ; int a2 = Integer . parseInt ( s . substring ( 2 , 4 ) ) ; boolean m1 = false ; if ( 1 <= QuzuzZrat && QuzuzZrat <= 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 PgoKeaziy { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner scanner = new Scanner ( System . in ) ; int PgoBem = scanner . nextInt ( ) ; String s = scanner . next ( ) ; System . out . println ( rotN ( PgoBem , s ) ) ; } private static String rotN ( int PgoBem , String s ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { sb . append ( rot ( PgoBem , s . charAt ( i ) ) ) ; } return sb . toString ( ) ; } private static char rot ( int PgoBem , char ch ) { int code = ( int ) ch - 'A' ; return ( char ) ( ( ( code + PgoBem ) % 26 ) + 'A' ) ; } } import java . util . * ; public class rgliodP { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; List < Integer > primes = primeList ( 200 ) ; int RgliodOqr = 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 <= RgliodOqr ; 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 aeuAe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double AeuZvop = sc . nextDouble ( ) ; double h = sc . nextDouble ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; double s = AeuZvop * h / 2.0 ; int e ; if ( x == AeuZvop / 2 && y == h / 2 && AeuZvop % 2 == 0 && h % 2 == 0 ) { e = 1 ; } else { e = 0 ; } System . out . println ( s ) ; System . out . println ( e ) ; } } public class gioaoEs { protected static String calc ( String input ) { final int GioaoPknq = Integer . parseInt ( input ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i <= GioaoPknq ; 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 hiucAsc { 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 HiucYtyg = Integer . parseInt ( ab [ 0 ] ) ; int b = Integer . parseInt ( ab [ 1 ] ) ; if ( HiucYtyg < b ) System . out . println ( " a < b " ) ; if ( HiucYtyg > b ) System . out . println ( " a > b " ) ; if ( HiucYtyg == b ) System . out . println ( " a == b " ) ; } } import java . util . * ; public class MudTa { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int mudXxbb = sc . nextInt ( ) ; int leg = sc . nextInt ( ) ; for ( int i = 0 ; i < mudXxbb + 1 ; i ++ ) { if ( ( i * 2 + ( mudXxbb - i ) * 4 ) == leg ) { System . out . println ( " Yes " ) ; System . exit ( 0 ) ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; class NffpsMpqdr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NffpsNds = sc . nextInt ( ) ; int [ ] [ ] A = new int [ 2 ] [ NffpsNds ] ; int [ ] sum = new int [ NffpsNds ] ; int x = 0 , y = 0 , collect = 0 , max = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < NffpsNds ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int j = 0 ; j < NffpsNds ; j ++ ) { for ( int i = 0 ; i < NffpsNds ; 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 EdwjyfDtqq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int EdwjyfR = Integer . parseInt ( sc . next ( ) ) ; int cnt = 0 ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 1 ; i <= EdwjyfR ; i ++ ) { if ( i % 2 != 0 ) { for ( int j = 1 ; j <= EdwjyfR ; 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 phkKz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int PhkNoiof = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String u = sc . next ( ) ; if ( s . equals ( u ) ) { System . out . println ( ( PhkNoiof - 1 ) + " " + b ) ; } else if ( t . contains ( u ) ) { System . out . println ( PhkNoiof + " " + ( b - 1 ) ) ; } sc . close ( ) ; } } import java . util . * ; import java . lang . * ; public class NbvefJefc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nbvefRioa = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < 40 ; i ++ ) { if ( nbvefRioa >= K ) { count ++ ; nbvefRioa = nbvefRioa / K ; } else { break ; } } System . out . println ( count + 1 ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class IvvhzhJq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ivvhzhXfs = sc . next ( ) ; if ( ivvhzhXfs . equals ( " Sunny " ) ) System . out . println ( " Cloudy " ) ; else if ( ivvhzhXfs . equals ( " Cloudy " ) ) System . out . println ( " Rainy " ) ; else if ( ivvhzhXfs . equals ( " Rainy " ) ) System . out . println ( " Sunny " ) ; } } import java . util . * ; public class TxiLbyv { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int TxiS = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; String ans = " " ; if ( y % 2 != 0 ) { ans = " No " ; } else { if ( ( y / 2 ) >= TxiS && TxiS >= ( ( y / 4 ) + ( y % 4 / 2 ) ) ) { ans = " Yes " ; } else { ans = " No " ; } } System . out . println ( ans ) ; } } } import java . util . * ; class HdeNutns { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HdeCge = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int count = 0 ; do { count ++ ; HdeCge -= a ; if ( HdeCge <= 0 ) { System . out . println ( count ) ; } } while ( HdeCge > 0 ) ; } } import java . util . * ; class HuhPjvb { long huhTj ; long a = 0 ; long b = 0 ; final long START_DISTANCE_FROM_ORIGIN = 2 ; public Problem ( long huhTj ) { this . huhTj = huhTj ; } public void solve ( ) { for ( long i = 1 ; i * i <= huhTj ; i ++ ) if ( huhTj % i == 0 ) update ( i ) ; } private void update ( long i ) { a = i ; b = huhTj / i ; } public void show ( ) { System . out . println ( a + b - START_DISTANCE_FROM_ORIGIN ) ; } } public class HuhPjvb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long huhTj = sc . nextLong ( ) ; Problem p = new Problem ( huhTj ) ; p . solve ( ) ; p . show ( ) ; } } import java . util . * ; public class utieEgt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; final int UtieRj = scan . nextInt ( ) ; String [ ] words = new String [ UtieRj ] ; for ( int i = 0 ; i < UtieRj ; 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 < UtieRj ; 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 HhwcpMwj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String num = sc . next ( ) ; String [ ] splitNum = num . split ( " " , 0 ) ; int HhwcpAa = Integer . parseInt ( num ) ; int N = 0 ; for ( int i = 0 ; i < num . length ( ) ; i ++ ) { N += Integer . parseInt ( splitNum [ i ] ) ; } System . out . println ( HhwcpAa % N == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class RvwXdx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int rvwCs = 0 ; rvwCs < 3 ; rvwCs ++ ) { a [ rvwCs ] = 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 XoyLygeh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XoyRtj = sc . nextInt ( ) , n = sc . nextInt ( ) , a , b , z ; int [ ] amida = new int [ XoyRtj ] ; for ( int i = 0 ; i < XoyRtj ; 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 < XoyRtj ; i ++ ) System . out . println ( amida [ i ] ) ; sc . close ( ) ; } } import java . util . * ; public class DirvgoGtf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DirvgoMlw = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; int sum = 0 ; for ( int i = 0 ; i <= DirvgoMlw ; i ++ ) { for ( int j = 0 ; j <= DirvgoMlw ; j ++ ) { sum = S - ( i + j ) ; if ( 0 <= sum && sum <= DirvgoMlw ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class WmuxwIgc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WmuxwKzl = sc . nextInt ( ) ; int [ ] b = new int [ WmuxwKzl - 1 ] ; int sum = 0 ; for ( int i = 0 ; i < WmuxwKzl - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } sum += b [ 0 ] ; for ( int i = 1 ; i < WmuxwKzl - 1 ; i ++ ) { sum += min ( b [ i - 1 ] , b [ i ] ) ; } sum += b [ WmuxwKzl - 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 ssqtNmn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int SsqtDzzh = scanner . nextInt ( ) ; int [ ] arr = new int [ SsqtDzzh ] ; for ( int i = 0 ; i < SsqtDzzh ; 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 McokvwCxhwr { 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 McokvwLl = str . split ( " " ) . length ; if ( McokvwLl > 0 ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } } import java . util . * ; import java . io . * ; import java . math . BigDecimal ; public class PivgMcg { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int pivgUt = fs . nextInt ( ) ; double y = ( double ) pivgUt / 3 ; BigDecimal x = BigDecimal . valueOf ( y ) ; BigDecimal ans = x . multiply ( x ) ; ans = ans . multiply ( x ) ; System . out . printf ( " %.12f " , ans ) ; } static class PivgMcg { 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 ykjrnrYj { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int YkjrnrXlelu = 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 = YkjrnrXlelu - sum + first ; if ( saigo > max ) { max = saigo ; } System . out . println ( YkjrnrXlelu - max ) ; } } import java . util . * ; public class nrvCo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NrvXgwje = 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 AfvxqRq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AfvxqEl = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; int left = Math . max ( X - ( AfvxqEl - 1 ) , - 1000000 ) ; int right = Math . min ( X + ( AfvxqEl - 1 ) , 1000000 ) ; for ( int i = left ; i <= right ; i ++ ) { sb . append ( i ) ; sb . append ( " " ) ; } System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; class JilpmyTeuybh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JilpmySf = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; double A = ( t - a ) * 1000 / 6.0 ; double [ ] h = new double [ JilpmySf ] ; for ( int i = 0 ; i < JilpmySf ; i ++ ) { h [ i ] = Math . abs ( sc . nextInt ( ) - A ) ; } int idx = 0 ; for ( int i = 1 ; i < JilpmySf ; i ++ ) { if ( h [ i ] < h [ idx ] ) { idx = i ; } } System . out . println ( idx + 1 ) ; } } import java . util . Scanner ; public class KfqygVg { public static void main ( String [ ] args ) { Scanner in = new java . util . Scanner ( System . in ) ; int KfqygSog = in . nextInt ( ) ; int N = in . nextInt ( ) ; if ( KfqygSog == 0 ) { if ( N == 100 ) { System . out . print ( N + 1 ) ; } else { System . out . print ( N ) ; } } else if ( KfqygSog == 1 ) { if ( N == 100 ) { System . out . print ( 100 * ( N + 1 ) ) ; } else { System . out . print ( 100 * N ) ; } } else if ( KfqygSog == 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 grvdIib { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; boolean GrvdJnxj = false ; for ( int i = 1 ; i < n . length ( ) ; i ++ ) { if ( n . charAt ( i ) > n . charAt ( 0 ) ) { GrvdJnxj = true ; break ; } } String ans = " " ; if ( GrvdJnxj ) { 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 BflcGntei { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String h = sc . nextLine ( ) ; String s = sc . nextLine ( ) ; int BflcO = Integer . parseInt ( h ) ; int len = String . valueOf ( s ) . length ( ) ; if ( len <= BflcO ) { System . out . println ( s ) ; } else { for ( int i = 0 ; i < BflcO ; i ++ ) { System . out . print ( s . charAt ( i ) ) ; } System . out . print ( " ... " ) ; } } } import java . util . Scanner ; class neiUoq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NeiDjn = sc . nextInt ( ) ; double x ; if ( NeiDjn % 2 == 0 ) x = 1.0 / 2.0 ; else x = ( double ) ( NeiDjn / 2 + 1 ) / ( double ) NeiDjn ; System . out . println ( x ) ; } } import java . util . Scanner ; public class VnxOd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VnxQmv = sc . nextInt ( ) ; int [ ] r = new int [ VnxQmv ] ; int maxv = - 999999999 ; for ( int i = 0 ; i < r . length ; i ++ ) { r [ i ] = sc . nextInt ( ) ; } int minv = r [ 0 ] ; for ( int i = 1 ; i < VnxQmv ; 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 PskcktQjf { public static void main ( String [ ] args ) { try { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String sStr = stdReader . readLine ( ) ; String [ ] inputStr = sStr . split ( " " ) ; int pskcktFnan = 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 ( pskcktFnan >= 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 SockifTfxg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int sockifUxpt , side , area , circum ; sockifUxpt = sc . nextInt ( ) ; side = sc . nextInt ( ) ; area = sockifUxpt * side ; circum = ( sockifUxpt + side ) * 2 ; System . out . println ( area + " " + circum ) ; } } import java . util . * ; public class QynZmsk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long qynSnda = 0 ; while ( s . length ( ) > 0 ) { qynSnda += Integer . parseInt ( s . substring ( 0 , 1 ) ) ; s = s . substring ( 1 ) ; } System . out . println ( qynSnda % 9 == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class IvqwbdEq { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int IvqwbdOu , B , T ; IvqwbdOu = sc . nextInt ( ) ; B = sc . nextInt ( ) ; T = sc . nextInt ( ) ; int sum = 0 ; for ( int time = 1 ; time <= T ; time ++ ) { if ( time % IvqwbdOu == 0 ) { sum += B ; } } System . out . println ( sum ) ; } catch ( Exception e ) { } } } import java . util . * ; class YiqhkRjmeq { public static void main ( String [ ] args ) { Scanner obj = new Scanner ( System . in ) ; int YiqhkK = obj . nextInt ( ) ; int m = obj . nextInt ( ) ; int [ ] a = new int [ YiqhkK ] ; for ( int i = 0 ; i < YiqhkK ; 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 LhnoitKp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lhnoitZ = sc . nextInt ( ) ; int [ ] a = new int [ lhnoitZ ] ; int max = 0 ; int m = 0 ; for ( int i = 0 ; i < lhnoitZ ; 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 WmooazVpuytz { Scanner scan = new Scanner ( System . in ) ; void compute ( ) { int WmooazVi = scan . nextInt ( ) ; int D = scan . nextInt ( ) ; double x = ( double ) WmooazVi / ( double ) ( 2 * D + 1 ) ; int y = WmooazVi / ( 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 MhmYn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MhmUot = sc . nextInt ( ) ; double [ ] data = new double [ 1000 ] ; int v ; double temp ; double lenkin ; for ( int i = 0 ; i < MhmUot ; i ++ ) { v = sc . nextInt ( ) ; data [ i ] = v ; } for ( int i = 0 ; i < MhmUot ; i ++ ) { for ( int j = i + 1 ; j < MhmUot ; 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 < MhmUot ; i ++ ) { lenkin = ( lenkin + data [ i ] ) / 2 ; } System . out . println ( lenkin ) ; } } import java . util . * ; public class vwqAs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VwqBh = 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 > VwqBh ) { break ; } if ( max < exp ) { max = ( int ) exp ; } } } System . out . println ( max ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class tabxLjj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TabxFnf = Integer . parseInt ( sc . next ( ) ) ; int [ ] l = new int [ TabxFnf ] ; for ( int i = 0 ; i < TabxFnf ; i ++ ) { l [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( l ) ; int x = 0 ; for ( int i = 0 ; i < TabxFnf - 1 ; i ++ ) { x += l [ i ] ; } if ( l [ TabxFnf - 1 ] < x ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class qxycbI { public static void main ( String [ ] args ) { int QxycbAn , k = 0 ; int [ ] A = new int [ 100 ] ; Scanner stdIn = new Scanner ( System . in ) ; QxycbAn = stdIn . nextInt ( ) ; for ( int i = 0 ; i < QxycbAn ; i ++ ) { A [ i ] = stdIn . nextInt ( ) ; } k = bubbleSort ( QxycbAn , A ) ; trace ( QxycbAn , A , k ) ; } public static void trace ( int QxycbAn , int [ ] A , int k ) { for ( int i = 0 ; i < QxycbAn ; i ++ ) { if ( i > 0 ) System . out . print ( " " ) ; System . out . print ( A [ i ] ) ; } System . out . println ( ) ; System . out . println ( k ) ; } public static int bubbleSort ( int QxycbAn , int [ ] A ) { int k = 0 ; for ( int i = 0 ; i < QxycbAn - 1 ; i ++ ) { for ( int j = QxycbAn - 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 hvacAcw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HvacUdqrg = sc . nextInt ( ) ; Integer [ ] p = new Integer [ HvacUdqrg ] ; for ( int i = 0 ; i < HvacUdqrg ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int i = 1 ; i < HvacUdqrg - 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 HnuoAz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hnuoG = sc . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= hnuoG ; i ++ ) { for ( int j = 1 ; j <= hnuoG ; j ++ ) { for ( int t = 1 ; t <= hnuoG ; 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 TloQadneb { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String TloLmo = in . nextLine ( ) ; char [ ] array = TloLmo . toCharArray ( ) ; array [ 3 ] = '8' ; System . out . println ( array ) ; } } import java . util . * ; public class CctfXio { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int CctfY = sc . nextInt ( ) ; long [ ] H = new long [ CctfY ] ; int counter = 0 ; int countMax = 0 ; for ( int i = 0 ; i < CctfY ; 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 KdxydKdlc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int KdxydNgu = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; scan . close ( ) ; if ( ( 1 <= KdxydNgu && KdxydNgu < 10 ) && ( 1 <= b && b < 10 ) ) System . out . println ( KdxydNgu * b ) ; else System . out . println ( - 1 ) ; } } import java . util . Scanner ; class jhrvA { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int JhrvXsoov , a , b ; JhrvXsoov = sc . nextInt ( ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; int sum = 0 , ans = 0 ; for ( int i = 0 ; i <= JhrvXsoov ; 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 CufuGee { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String y = sc . next ( ) ; String j = sc . next ( ) ; int cufuQu = 0 ; for ( int i = 0 ; i < y . length ( ) ; i ++ ) { if ( y . charAt ( i ) == j . charAt ( i ) ) { cufuQu += 1 ; } } System . out . println ( cufuQu ) ; } } import java . util . * ; public class EtycuTqpm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ans = " No " ; String s = sc . next ( ) ; String t = sc . next ( ) ; int EtycuGt = s . length ( ) ; int temp = 0 ; int count = 0 ; for ( int i = 0 ; i < EtycuGt ; i ++ ) { for ( int j = 0 ; j < EtycuGt ; j ++ ) { if ( s . charAt ( j ) != t . charAt ( ( j + temp ) % EtycuGt ) ) { temp ++ ; count = 0 ; break ; } else { count ++ ; } } if ( count == EtycuGt ) { ans = " Yes " ; break ; } } System . out . println ( ans ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class EgpRi { 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 EgpXi = false ; while ( sc . hasNextLine ( ) ) { word = sc . nextLine ( ) ; if ( ! wordSet . add ( word ) ) { EgpXi = true ; break ; } if ( prevWord != null ) { boolean chained = ( prevWord . charAt ( prevWord . length ( ) - 1 ) == word . charAt ( 0 ) ) ; if ( ! chained ) { EgpXi = true ; break ; } } prevWord = word ; } System . out . println ( EgpXi ? " No " : " Yes " ) ; } } import java . util . * ; public class kicgoiN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KicgoiAuoh = Integer . parseInt ( sc . nextLine ( ) ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < KicgoiAuoh ; 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 < KicgoiAuoh ; i ++ ) { check = false ; if ( i == 0 ) { t = list . get ( i ) ; count ++ ; continue ; } u = list . get ( i ) ; if ( t . equals ( u ) && i < KicgoiAuoh - 1 ) { count ++ ; } else if ( t . equals ( u ) && i == KicgoiAuoh - 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 icesXs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IcesLihzq = sc . nextInt ( ) ; int ans = IcesLihzq % 1000 ; if ( ans != 0 ) { ans = 1000 - ans ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class DubVh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dubFadg = scan . nextInt ( ) ; int [ ] a = new int [ dubFadg ] ; int [ ] b = new int [ dubFadg ] ; int [ ] c = new int [ dubFadg ] ; for ( int i = 0 ; i < dubFadg ; i ++ ) { a [ i ] = scan . nextInt ( ) - 1 ; } for ( int i = 0 ; i < dubFadg ; i ++ ) { b [ i ] = scan . nextInt ( ) ; } for ( int i = 1 ; i < dubFadg ; i ++ ) { c [ i ] = scan . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < dubFadg ; 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 oxuzgiZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int OxuzgiMrqm = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '+' ) { OxuzgiMrqm = OxuzgiMrqm + 1 ; } else { OxuzgiMrqm = OxuzgiMrqm - 1 ; } } System . out . println ( OxuzgiMrqm ) ; } } import java . io . * ; public class nbctdsJm { 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 NbctdsLi = Integer . parseInt ( ra [ 0 ] ) ; int y = Integer . parseInt ( ra [ 1 ] ) ; int d , r ; String f = String . format ( " %.5f " , ( double ) NbctdsLi / ( double ) y ) ; d = NbctdsLi / y ; y = NbctdsLi % y ; System . out . printf ( d + " " + y + " " + f ) ; } } import java . util . Scanner ; public class LkwNnjt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LkwDps = sc . nextInt ( ) ; int [ ] a = new int [ LkwDps ] ; int j = 1 ; for ( int i = 0 ; i < LkwDps ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( j == a [ i ] ) { j ++ ; } } if ( j == 1 ) { System . out . println ( - 1 ) ; return ; } System . out . println ( LkwDps - j + 1 ) ; } } import java . util . Scanner ; public class tbxoIw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int TbxoAqpv = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( TbxoAqpv == 0 && W == 0 ) break ; for ( int i = 1 ; i <= TbxoAqpv ; i ++ ) { if ( i == 1 || i == TbxoAqpv ) { 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 HbgzhRjtv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int HbgzhO = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( HbgzhO == 0 && W == 0 ) break ; for ( int i = 1 ; i <= HbgzhO ; 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 EseActpgb { public static void main ( String [ ] args ) { int EseMp , 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 ( EseMp = 0 ; EseMp < n ; EseMp ++ ) array [ EseMp ] = 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 WbhcHrndh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WbhcBl = sc . nextInt ( ) ; int be = sc . nextInt ( ) ; int ans = 0 ; boolean check1 = false , check2 = false ; for ( int i = 1 ; i < WbhcBl ; 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 CfzRcpoai { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CfzT = sc . nextInt ( ) ; int [ ] a = new int [ CfzT ] ; for ( int i = 0 ; i < CfzT ; ++ 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 < CfzT ; ++ i ) { if ( t == a [ i ] ) { an = 1 ; break ; } t = a [ i ] ; } System . out . println ( ans [ an ] ) ; } } import java . io . * ; import java . util . * ; public class VneBplg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VneS = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ VneS ] ; 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 < VneS ; 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 < VneS ; i ++ ) { System . out . println ( a [ i ] ) ; } } } import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class NpuTv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int npuWdv = sc . nextInt ( ) ; int [ ] [ ] a = new int [ 2 ] [ npuWdv + 1 ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 1 ; j <= npuWdv ; j ++ ) { a [ i ] [ j ] = a [ i ] [ j - 1 ] + sc . nextInt ( ) ; } } int ans = 0 ; for ( int i = 1 ; i <= npuWdv ; i ++ ) { for ( int j = 1 ; j <= npuWdv ; j ++ ) { ans = max ( ans , a [ 0 ] [ i ] + ( a [ 1 ] [ npuWdv ] - a [ 1 ] [ i - 1 ] ) ) ; } } out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class GzcCq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gzcV = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int count = 0 ; for ( int i = gzcV ; 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 vhhiK { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int VhhiVp = scan . nextInt ( ) ; int [ ] num = new int [ VhhiVp ] ; boolean t ; int count = 0 ; for ( int i = 0 ; i < VhhiVp ; 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 XbarBcal { public static void main ( String [ ] args ) { int xbarFz , point1 = 0 , point2 = 0 ; String card1 , card2 ; Scanner sc = new Scanner ( System . in ) ; xbarFz = sc . nextInt ( ) ; for ( int i = 0 ; i < xbarFz ; 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 xotczkSh { public static void main ( String ... args ) { int XotczkKni = new java . util . Scanner ( System . in ) . nextInt ( ) ; int sum = XotczkKni * XotczkKni * XotczkKni ; System . out . println ( sum ) ; } } import java . io . * ; import java . util . Scanner ; public class PcubeGnildn { public static void main ( String [ ] args ) { int PcubeH ; 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 ( PcubeH = i + 1 ; PcubeH < 10 ; PcubeH ++ ) if ( height [ i ] > height [ PcubeH ] ) { int temp = height [ i ] ; height [ i ] = height [ PcubeH ] ; height [ PcubeH ] = 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 wilzwfMpk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long WilzwfCnbxf = sc . nextInt ( ) ; long a = WilzwfCnbxf / 500 ; WilzwfCnbxf %= 500 ; long b = WilzwfCnbxf / 5 ; System . out . println ( 1000 * a + ( 5 * b ) ) ; } } import java . util . Scanner ; public class dwgyYfb { public static void main ( String [ ] args ) { Scanner Ahmad = new Scanner ( System . in ) ; int DwgyCrfg , y ; DwgyCrfg = Ahmad . nextInt ( ) ; y = Ahmad . nextInt ( ) ; if ( ( DwgyCrfg + y ) % 2 == 0 ) { System . out . println ( ( DwgyCrfg + y ) / 2 ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . io . IOException ; import java . util . Scanner ; class WuwxnGwz { public static void main ( String [ ] args ) throws IOException { Scanner scane = new Scanner ( System . in ) ; int WuwxnPa = 0 , f = 0 , r = 0 ; int sum = 0 ; WuwxnPa = scane . nextInt ( ) ; f = scane . nextInt ( ) ; r = scane . nextInt ( ) ; while ( ( WuwxnPa + f + r ) != - 3 ) { sum = WuwxnPa + f ; if ( WuwxnPa == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } if ( ( WuwxnPa != - 1 && f != - 1 ) && sum >= 80 ) { System . out . println ( " A " ) ; } else if ( ( WuwxnPa != - 1 && f != - 1 ) && sum < 80 && sum >= 65 ) { System . out . println ( " B " ) ; } else if ( ( WuwxnPa != - 1 && f != - 1 ) && sum < 65 && sum >= 50 ) { System . out . println ( " C " ) ; } else if ( ( WuwxnPa != - 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 " ) ; } WuwxnPa = scane . nextInt ( ) ; f = scane . nextInt ( ) ; r = scane . nextInt ( ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class IfdtoGbot { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; char IfdtoCrz ; StringBuilder build = new StringBuilder ( ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { IfdtoCrz = str . charAt ( i ) ; if ( Character . isLowerCase ( IfdtoCrz ) ) { build . append ( Character . toUpperCase ( IfdtoCrz ) ) ; } else { build . append ( Character . toLowerCase ( IfdtoCrz ) ) ; } } System . out . print ( build . toString ( ) + " \n " ) ; } } import java . util . * ; public class RvqhewNon { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Queue < String > name_queue = new ArrayDeque < > ( ) ; Queue < Integer > queue = new ArrayDeque < > ( ) ; int RvqhewGf = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; for ( int i = 0 ; i < RvqhewGf ; 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 yjpxjrMjp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YjpxjrEhxct = sc . nextInt ( ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; String ans = " " ; for ( int i = 0 ; i < YjpxjrEhxct ; i ++ ) { ans = ans + s1 . charAt ( i ) + s2 . charAt ( i ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class HdlvxzSxvf { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String input = scanner . nextLine ( ) ; String [ ] inputs = input . split ( " " ) ; int hdlvxzXvel = Integer . parseInt ( inputs [ 0 ] ) ; int x = Integer . parseInt ( inputs [ 1 ] ) ; String lineStr = scanner . nextLine ( ) ; String [ ] lines = lineStr . split ( " " ) ; int [ ] line = new int [ hdlvxzXvel ] ; for ( int i = 0 ; i < hdlvxzXvel ; i ++ ) { line [ i ] = Integer . parseInt ( lines [ i ] ) ; } int answer = 1 ; int distance = 0 ; for ( int i = 0 ; i < hdlvxzXvel ; i ++ ) { distance = distance + line [ i ] ; if ( distance > x ) { break ; } answer ++ ; } System . out . println ( answer ) ; scanner . close ( ) ; } } import java . util . Scanner ; public class jrqNpo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int JrqWnf = scan . nextInt ( ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int ans = JrqWnf * a ; if ( ans < b ) { System . out . println ( ans ) ; } else { System . out . println ( b ) ; } } } import java . util . Scanner ; import java . util . Arrays ; public class LxuniLpc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LxuniIv = sc . nextInt ( ) ; int [ ] b = new int [ LxuniIv ] ; 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 EhkpdkUxw { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; String EhkpdkTma = scan . next ( ) ; switch ( EhkpdkTma ) { 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 VnyeoySooau { 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 VnyeoyCur = list . get ( 0 ) ; int B = list . get ( 1 ) ; if ( ( VnyeoyCur == 1 && B == 2 ) || ( VnyeoyCur == 2 && B == 1 ) ) System . out . println ( 3 ) ; else if ( ( VnyeoyCur == 1 && B == 3 ) || ( VnyeoyCur == 3 && B == 1 ) ) System . out . println ( 2 ) ; else if ( ( VnyeoyCur == 2 && B == 3 ) || ( VnyeoyCur == 3 && B == 2 ) ) System . out . println ( 1 ) ; } } import java . util . Scanner ; public class bzmzxAna { public static int BzmzxXze = 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 ( BzmzxXze != 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 [ BzmzxXze ++ ] ; } public static int intDequeue ( ) { return queue2 [ head2 ++ ] ; } } import java . util . Scanner ; public class QvlztHnnx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int qvlztEkx = scanner . nextInt ( ) ; int [ ] a = new int [ qvlztEkx ] ; int count = 0 ; int v = 1 ; int flg = 0 ; for ( int i = 0 ; i < qvlztEkx ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < qvlztEkx ; i ++ ) { v = a [ v - 1 ] ; count ++ ; if ( v == 2 ) { System . out . println ( count ) ; count = 0 ; break ; } } if ( count == qvlztEkx ) { System . out . println ( - 1 ) ; } } } import java . util . * ; import java . io . * ; public class ZwdLeyn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter ou = new PrintWriter ( System . out ) ; int zwdO = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int [ ] s = new int [ zwdO ] ; int i ; Arrays . fill ( s , k - q ) ; for ( i = 0 ; i < q ; i ++ ) { s [ Integer . parseInt ( sc . next ( ) ) - 1 ] ++ ; } for ( i = 0 ; i < zwdO ; i ++ ) { if ( s [ i ] > 0 ) ou . print ( " Yes \n " ) ; else ou . print ( " No \n " ) ; } ou . flush ( ) ; } } import java . util . * ; public class EuruCtfwvi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int EuruC = S . length ( ) ; int tmp = 0 ; String [ ] part = new String [ EuruC * ( EuruC + 1 ) / 2 ] ; for ( int i = 0 ; i < EuruC ; i ++ ) { for ( int j = i ; j < EuruC ; 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 vnbvqRkh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VnbvqQmyox = Integer . valueOf ( sc . next ( ) ) ; int b = Integer . valueOf ( sc . next ( ) ) ; int t = Integer . valueOf ( sc . next ( ) ) ; System . out . println ( t / VnbvqQmyox * b ) ; } } import java . util . Scanner ; public class uezM { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { long UezSgyr = ( 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 > UezSgyr || ans < 0 ) { isOver = true ; } } if ( isOver ) { System . out . println ( " -1 " ) ; } else { System . out . println ( ans ) ; } } } } import java . util . Scanner ; public class InrFivo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int inrTtqj = sc . nextInt ( ) ; int ans = 0 ; int [ ] array = new int [ inrTtqj ] ; for ( int i = 0 ; i < inrTtqj ; 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 rqaklR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int RqaklQgkb = s . length ( ) ; int m = t . length ( ) ; int count = 0 ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < RqaklQgkb - 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 ArpgcrCfvk { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; double arpgcrQwq = s . nextDouble ( ) ; double n = s . nextDouble ( ) ; double m = 0 ; for ( int i = 0 ; i < n ; i ++ ) { m += s . nextDouble ( ) ; } if ( m >= arpgcrQwq ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; public class SqwnFz { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int SqwnNo = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i < SqwnNo ; 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 QeeqjhAkou { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = input . readLine ( ) ; String answer = " " ; for ( int QeeqjhX = 0 ; QeeqjhX < str . length ( ) ; QeeqjhX ++ ) { if ( String . valueOf ( str . charAt ( QeeqjhX ) ) . equals ( " B " ) && answer . length ( ) != 0 ) { answer = answer . substring ( 0 , answer . length ( ) - 1 ) ; } else if ( String . valueOf ( str . charAt ( QeeqjhX ) ) . equals ( " 0 " ) || String . valueOf ( str . charAt ( QeeqjhX ) ) . equals ( " 1 " ) ) { answer = answer + str . charAt ( QeeqjhX ) ; } } System . out . println ( answer ) ; } } import java . util . * ; public class HbthkFd { 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 hbthkBpg = 1 ; int bIndex = 0 ; int cIndex = 0 ; char tmp = a . charAt ( 0 ) ; while ( true ) { switch ( tmp ) { case 'a' : if ( a . length ( ) == hbthkBpg ) { System . out . println ( " A " ) ; System . exit ( 0 ) ; } tmp = a . charAt ( hbthkBpg ++ ) ; 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 tvyoTch { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TvyoIrf = 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 < TvyoIrf ; i ++ ) { ans = ans + Sarray [ i ] ; ans = ans + Tarray [ i ] ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class XtgvEhz { 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 XhplwvDnqm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String t = sc . nextLine ( ) ; int XhplwvQ = 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 ++ ; } XhplwvQ = Math . XhplwvQ ( XhplwvQ , tot ) ; } } System . out . println ( XhplwvQ ) ; } } import java . util . Scanner ; public class RifosiUun { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RifosiGzh = 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 ) ; } RifosiGzh ++ ; } } } import java . util . Scanner ; public class OqrnsQrkas { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String OqrnsSo = sc . next ( ) ; if ( ( OqrnsSo . charAt ( 0 ) == OqrnsSo . charAt ( 1 ) ) || ( OqrnsSo . charAt ( 1 ) == OqrnsSo . charAt ( 2 ) ) || ( OqrnsSo . charAt ( 2 ) == OqrnsSo . charAt ( 3 ) ) ) { System . out . println ( " Bad " ) ; } else { System . out . println ( " Good " ) ; } } } import java . util . Scanner ; public class qijokeBr { public static void main ( String [ ] args ) { int QijokeRdx = 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 [ QijokeRdx ++ ] = 2 ; prime [ QijokeRdx ++ ] = 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 [ QijokeRdx ++ ] = 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 YitcvCh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YitcvFh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( b == 1 ) { System . out . println ( 0 ) ; return ; } if ( b <= YitcvFh ) { System . out . println ( 1 ) ; return ; } int sum = 0 ; for ( int i = 1 ; ; i ++ ) { sum += YitcvFh ; if ( sum >= b ) { System . out . println ( i ) ; return ; } sum -= 1 ; } } } import java . util . Scanner ; public class LybYhnt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LybVm = Integer . parseInt ( sc . next ( ) ) ; int kR = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int [ ] np = new int [ LybVm ] ; 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 < LybVm ; j ++ ) { if ( kR - q + np [ j ] > 0 ) { sb . append ( " Yes " ) ; } else { sb . append ( " No " ) ; } if ( j < LybVm - 1 ) { sb . append ( " \n " ) ; } } System . out . println ( sb ) ; sc . close ( ) ; } } import java . util . * ; public class PshPg { static public void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PshC = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] sunuke = new int [ PshC ] ; for ( int i = 0 ; i < PshC ; 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 < PshC ; h ++ ) { if ( sunuke [ h ] == 0 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; public class UjlDael { public static int solve ( int n , int k , int [ ] arr ) { int [ ] dp = new int [ n ] ; for ( int UjlT = 1 ; UjlT < n ; UjlT ++ ) { int ans = Integer . MAX_VALUE ; for ( int j = UjlT - 1 ; j >= 0 && ( UjlT - j ) <= k ; j -- ) { int diff = Math . abs ( arr [ UjlT ] - arr [ j ] ) ; ans = Math . min ( ans , diff + dp [ j ] ) ; } dp [ UjlT ] = 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 UjlT = 0 ; UjlT < n ; UjlT ++ ) { arr [ UjlT ] = 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 AppXtgt { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String appJ = br . readLine ( ) ; String [ ] str2 = appJ . 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 wazrpjRlz { public static void main ( String [ ] s ) { long WazrpjOsx = 1 , a = 101 , o = new java . util . Scanner ( System . in ) . nextLong ( ) ; for ( ; a < o ; WazrpjOsx ++ ) a += a / 100 ; System . out . print ( WazrpjOsx ) ; } } import java . io . * ; class XrbgEw { 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 XrbgT = 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 ( XrbgT >= ( 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 dbdkZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String H = sc . next ( ) ; int DbdkFpq = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String U = sc . next ( ) ; if ( U . equals ( S ) ) { DbdkFpq -- ; } else if ( U . equals ( H ) ) { B -- ; } System . out . println ( DbdkFpq ) ; System . out . println ( B ) ; } } import java . util . Scanner ; public class SrwzCro { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int srwzNp = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int c = 0 ; for ( int x = 0 ; x <= srwzNp ; x ++ ) { for ( int y = 0 ; y <= srwzNp ; y ++ ) { int z = S - x - y ; if ( 0 <= z && z <= srwzNp ) { c += 1 ; } } } System . out . println ( c ) ; } } import java . util . Scanner ; public class DmlyoDxi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dmlyoBz , T , A ; dmlyoBz = sc . nextInt ( ) ; T = sc . nextInt ( ) ; A = sc . nextInt ( ) ; int [ ] H = new int [ dmlyoBz ] ; double max = 99999 ; int ans = 0 ; for ( int i = 0 ; i < dmlyoBz ; 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 JcquxvMqm { 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 JcquxvBl = Integer . parseInt ( br . readLine ( ) ) ; if ( JcquxvBl == 0 ) break ; int [ ] s = new int [ JcquxvBl ] ; String [ ] dataset = br . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < JcquxvBl ; i ++ ) { s [ i ] = Integer . parseInt ( dataset [ i ] ) ; } int goukei = 0 ; for ( int i : s ) { goukei += i ; } double m = ( double ) goukei / ( double ) JcquxvBl ; double alfa2 = 0.0 ; for ( int i : s ) { alfa2 += ( i - m ) * ( i - m ) ; } alfa2 = alfa2 / JcquxvBl ; double alfa = Math . sqrt ( alfa2 ) ; System . out . println ( alfa ) ; } } } import java . util . * ; import java . io . * ; public class OumxwlQfgv { public static void main ( String [ ] args ) throws Exception { FastReader s = new FastReader ( ) ; int oumxwlLdh = s . nextInt ( ) ; long sum = 0 ; int max = Integer . MIN_VALUE ; int [ ] arr = new int [ oumxwlLdh ] ; for ( int i = 0 ; i < oumxwlLdh ; 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 OumxwlQfgv { 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 HpanlFptz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hpanlA = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( Math . max ( Math . max ( hpanlA + b , hpanlA - b ) , hpanlA * b ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class lqpmHc { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int LqpmNt = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; int min = 2018 ; if ( R - LqpmNt > 2019 ) { System . out . print ( 0 ) ; } else { int LMod = Math . floorMod ( LqpmNt , 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 OqxBd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; int OqxYa = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { OqxYa += ( Math . pow ( 10 , i ) * ( s . charAt ( 3 - i ) - 48 ) ) ; } OqxYa *= 10000 ; OqxYa += ( s . charAt ( 5 ) - 48 ) * 1000 ; OqxYa += ( s . charAt ( 6 ) - 48 ) * 100 ; OqxYa += ( s . charAt ( 8 ) - 48 ) * 10 ; OqxYa += s . charAt ( 9 ) - 48 ; if ( OqxYa < 20190431 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . Scanner ; public class etvkO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EtvkSf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int sum = 0 ; for ( int x = EtvkSf ; x <= b ; x ++ ) { if ( c % x == 0 ) { sum ++ ; } } System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . Scanner ; public class DmfxnjYqd { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int dmfxnjH = stdIn . nextInt ( ) ; int [ ] a = new int [ dmfxnjH ] ; for ( int i = 0 ; i < dmfxnjH ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; } long ans = 0 ; for ( int i = 1 ; i < dmfxnjH ; 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 AeaMxqufu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AeaNgn = sc . nextInt ( ) ; int [ ] A = new int [ AeaNgn ] ; for ( int i = 0 ; i < AeaNgn ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } bubbleSort ( A , AeaNgn ) ; } public static void bubbleSort ( int [ ] A , int AeaNgn ) { int flag = 1 , count = 0 ; while ( flag == 1 ) { flag = 0 ; int i = 0 ; for ( int j = i ; j < AeaNgn - 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 < AeaNgn ; i ++ ) { System . out . print ( A [ i ] ) ; if ( i != AeaNgn - 1 ) System . out . print ( " " ) ; } System . out . printf ( " \n %d \n " , count ) ; } } import java . util . Scanner ; class YitgunNeyoq { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long YitgunHn , 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 ( ) ; } YitgunHn = a [ 0 ] [ 0 ] ; for ( i = 0 ; i < t ; i ++ ) YitgunHn = YitgunHn + a [ i ] [ 1 ] ; max = YitgunHn ; for ( i = 1 ; i < t ; i ++ ) { YitgunHn = YitgunHn - a [ i - 1 ] [ 1 ] + a [ i ] [ 0 ] ; if ( YitgunHn > max ) max = YitgunHn ; } System . out . println ( max ) ; } } import java . util . * ; public class jbtSr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JbtReayc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int cnt = 0 ; while ( true ) { if ( JbtReayc > k ) { cnt += k ; k = 0 ; break ; } else { cnt += JbtReayc ; k -= JbtReayc ; } 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 SannEfk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long sannOqzu = scan . nextLong ( ) ; long moveCnt = ( long ) Math . pow ( 10 , 18 ) ; for ( long i = 1 ; i * i <= sannOqzu ; i ++ ) { if ( sannOqzu % i != 0 ) continue ; long j = sannOqzu / i ; if ( moveCnt > i + j - 2 ) { moveCnt = i + j - 2 ; } } System . out . println ( moveCnt ) ; } } import java . util . Scanner ; public class FjxuZq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fjxuMw = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] A = new int [ fjxuMw ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < fjxuMw ; 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 [ fjxuMw ] ; for ( int i = 0 ; i < fjxuMw ; 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 IniybRmbj { static int IniybVzg ; 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 SpqvZffax { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SpqvOt = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ SpqvOt ] ; for ( int i = 0 ; i < SpqvOt ; i ++ ) { A [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; Arrays . sort ( A ) ; System . out . println ( Math . abs ( A [ 0 ] - A [ SpqvOt - 1 ] ) ) ; } } import java . util . Scanner ; public class MnelfKclp { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; StringBuilder out ; int mnelfXe = sc . nextInt ( ) ; int [ ] a = new int [ mnelfXe ] ; 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 tthQo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int TthBwqzo = 0 ; int h = 0 ; int t = s . length ( ) - 1 ; while ( h < t ) { if ( s . charAt ( h ) != s . charAt ( t ) ) { TthBwqzo += 1 ; } h += 1 ; t -= 1 ; } System . TthBwqzo . println ( TthBwqzo ) ; } } import java . util . Scanner ; public class DkrjcoBa { 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 DkrjcoPx = Integer . parseInt ( S . substring ( 0 , 2 ) ) ; int back = Integer . parseInt ( S . substring ( 2 , 4 ) ) ; if ( isMonth ( DkrjcoPx ) ) { 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 UabVmlv { public static void main ( String [ ] args ) throws Exception { InputStreamReader r = new InputStreamReader ( System . in ) ; long uabGuh = nextInt ( r ) ; long B = nextInt ( r ) ; long ans = uabGuh > B ? calcLCM ( uabGuh , B ) : calcLCM ( B , uabGuh ) ; 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 qesxqlNy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; int QesxqlTek = 0 ; int one = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '0' ) { QesxqlTek ++ ; } else { one ++ ; } } System . out . println ( 2 * Math . min ( QesxqlTek , one ) ) ; } } import java . util . * ; public class YichdsFxztv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YichdsU = sc . nextInt ( ) ; int height = sc . nextInt ( ) ; int [ ] fh = new int [ YichdsU ] ; int count = 0 ; for ( int i = 0 ; i < YichdsU ; i ++ ) { fh [ i ] = sc . nextInt ( ) ; if ( fh [ i ] >= height ) { count ++ ; } } System . out . println ( count ) ; } } import java . io . * ; import java . util . * ; public class RngHa { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int RngVi = in . nextInt ( ) ; int x = in . nextInt ( ) ; int t = in . nextInt ( ) ; System . out . println ( ( int ) Math . ceil ( 1.0 * RngVi / x ) * t ) ; } } class RngHa { 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 nhnNs { 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 NhnHgf = Integer . parseInt ( arrStr [ 0 ] ) ; int w = Integer . parseInt ( arrStr [ 1 ] ) ; if ( NhnHgf == 0 && w == 0 ) { break ; } boolean iKisu = false ; for ( int i = 0 ; i < NhnHgf ; 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 vzapCg { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int VzapOrvrh ; VzapOrvrh = in . nextInt ( ) ; System . out . println ( VzapOrvrh * VzapOrvrh * VzapOrvrh ) ; } } import java . util . Scanner ; public class oryytTi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OryytEaoz = sc . nextInt ( ) ; sc . nextLine ( ) ; String S = sc . next ( ) ; System . out . println ( solve ( OryytEaoz , 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 HofwNdh { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; String HofwZnz = kb . next ( ) ; String j = kb . next ( ) ; kb . close ( ) ; String k = " 123 " . replace ( HofwZnz , " " ) ; 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 JtqLpw { 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 JtqLpw { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int jtqF = in . nextInt ( ) ; int sum = 0 ; int tmp = jtqF ; while ( tmp > 0 ) { sum += tmp % 10 ; tmp /= 10 ; } out . println ( jtqF % sum == 0 ? " Yes " : " No " ) ; } } static class JtqLpw { 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 YrqSz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yrqPds = sc . nextInt ( ) ; int yoko = sc . nextInt ( ) ; int men ; int syu ; men = yrqPds * yoko ; syu = yrqPds * 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 YihjfaAepo { 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 yihjfaD = 0 ; yihjfaD < b . length ; yihjfaD ++ ) { word . add ( b [ yihjfaD ] ) ; rev_word . add ( b [ yihjfaD ] ) ; } 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 ZlgwgSqsl { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String s = stdIn . next ( ) ; int ZlgwgV = s . indexOf ( " 7 " ) ; if ( ZlgwgV == - 1 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . * ; import java . util . Map . Entry ; class OclhnHrgyr { static int OclhnIwm = ( 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 FxzwrbVyi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int fxzwrbDp = 0 ; fxzwrbDp < 3 ; fxzwrbDp ++ ) { c [ fxzwrbDp ] [ 0 ] = Integer . parseInt ( scanner . next ( ) ) ; c [ fxzwrbDp ] [ 1 ] = Integer . parseInt ( scanner . next ( ) ) ; c [ fxzwrbDp ] [ 2 ] = Integer . parseInt ( scanner . next ( ) ) ; } scanner . close ( ) ; for ( int fxzwrbDp = 0 ; fxzwrbDp < c . length ; fxzwrbDp ++ ) { int min = Integer . MAX_VALUE ; for ( int j = 0 ; j < c [ fxzwrbDp ] . length ; j ++ ) { int num = c [ fxzwrbDp ] [ j ] ; if ( min > num ) { min = num ; } } for ( int j = 0 ; j < c [ fxzwrbDp ] . length ; j ++ ) { c [ fxzwrbDp ] [ j ] -= min ; } } for ( int fxzwrbDp = 0 ; fxzwrbDp < c . length ; fxzwrbDp ++ ) { if ( c [ 0 ] [ fxzwrbDp ] != c [ 1 ] [ fxzwrbDp ] || c [ 1 ] [ fxzwrbDp ] != c [ 2 ] [ fxzwrbDp ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class EsgVqkw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double esgHwyq = sc . nextDouble ( ) ; double r = esgHwyq * 2 * 3.14 ; System . out . println ( r ) ; } } import java . util . Scanner ; class GjnzKxpp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gjnzFcuf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int cnt = 0 ; int z ; for ( int i = 0 ; i <= gjnzFcuf ; 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 BmqWnh { public static void main ( String [ ] args ) { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int bmqSpv , b , c ; String [ ] arange = null ; try { arange = in . readLine ( ) . split ( " " , 0 ) ; } catch ( Exception e ) { } bmqSpv = Integer . parseInt ( arange [ 0 ] ) ; b = Integer . parseInt ( arange [ 1 ] ) ; c = Integer . parseInt ( arange [ 2 ] ) ; if ( bmqSpv <= b && bmqSpv <= c ) { if ( b < c ) System . out . println ( bmqSpv + " " + b + " " + c ) ; else System . out . println ( bmqSpv + " " + c + " " + b ) ; } else if ( b <= bmqSpv && b <= c ) { if ( bmqSpv < c ) System . out . println ( b + " " + bmqSpv + " " + c ) ; else System . out . println ( b + " " + c + " " + bmqSpv ) ; } else { if ( bmqSpv < b ) System . out . println ( c + " " + bmqSpv + " " + b ) ; else System . out . println ( c + " " + b + " " + bmqSpv ) ; } } } import java . util . Scanner ; class XggceGh { public void fun ( ) { Scanner sc = new Scanner ( System . in ) ; int xggceTxx = 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 ) { xggceTxx = xggceTxx - a [ i ] ; i ++ ; } if ( xggceTxx <= 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 EkbuqHmebh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; char EkbuqL ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { EkbuqL = s . charAt ( i ) ; if ( EkbuqL >= 'A' && EkbuqL <= 'Z' ) { EkbuqL += 'a' - 'A' ; } else if ( EkbuqL >= 'a' && EkbuqL <= 'z' ) { EkbuqL += 'A' - 'a' ; } System . out . print ( EkbuqL ) ; } System . out . println ( " " ) ; sc . close ( ) ; } } import java . util . * ; public class ctpsnVo { 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 CtpsnNjzs = Integer . parseInt ( Ss ) ; if ( CtpsnNjzs <= 20190430 ) System . out . println ( " Heisei " ) ; else System . out . println ( " TBD " ) ; } } import java . util . * ; public class spqkvSi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SpqkvOc = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; for ( int i = x - SpqkvOc + 1 ; i <= x + SpqkvOc - 1 ; i ++ ) { System . out . print ( i ) ; if ( i < x + SpqkvOc - 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 XjoKqjavi { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int XjoNf = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; String res = " TLE " ; int minCost = Integer . MAX_VALUE ; for ( int i = 0 ; i < XjoNf ; 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 XjoKqjavi { 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 kbulR { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int KbulMi = Integer . parseInt ( br . readLine ( ) ) ; String [ ] inputData = br . readLine ( ) . split ( " " ) ; Integer [ ] number = new Integer [ KbulMi ] ; 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 xmnpP { public static void main ( String [ ] args ) { Main mainObj = new Main ( ) ; mainObj . exec ( ) ; } public void exec ( ) { Scanner sc = new Scanner ( System . in ) ; int XmnpUhufm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; sc . close ( ) ; if ( ! inRange ( XmnpUhufm ) || ! inRange ( b ) ) { System . out . println ( - 1 ) ; return ; } System . out . println ( XmnpUhufm * b ) ; } boolean inRange ( int XmnpUhufm ) { if ( XmnpUhufm >= 1 && XmnpUhufm <= 9 ) { return true ; } else { return false ; } } } import java . util . * ; class czdK { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int CzdVkneb = sc . nextInt ( ) ; double [ ] v = new double [ CzdVkneb ] ; for ( int i = 0 ; i < CzdVkneb ; i ++ ) { v [ i ] = sc . nextDouble ( ) ; } Arrays . sort ( v ) ; for ( int i = 0 ; i < CzdVkneb - 1 ; i ++ ) { v [ i + 1 ] = ( v [ i ] + v [ i + 1 ] ) / 2d ; } System . out . println ( v [ CzdVkneb - 1 ] ) ; sc . close ( ) ; } } import java . util . Scanner ; import java . util . Collections ; import java . util . List ; import java . util . ArrayList ; public class xuwdGbc { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; int XuwdTbza = 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 ObmnfZxca { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String obmnfPs = sc . next ( ) ; System . out . println ( obmnfPs . charAt ( 2 ) == obmnfPs . charAt ( 3 ) && obmnfPs . charAt ( 4 ) == obmnfPs . charAt ( 5 ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class KnemKpdo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String sub ; int KnemGd = - 1 ; sub = s . substring ( s . indexOf ( " A " ) , s . lastIndexOf ( " Z " ) + 1 ) ; KnemGd = sub . length ( ) ; System . out . println ( KnemGd ) ; } } import java . util . * ; public class BpiocTsrhs { public static void main ( String [ ] args ) { Scanner sn = new Scanner ( System . in ) ; int BpiocQkw = sn . nextInt ( ) ; int B = sn . nextInt ( ) ; int C = sn . nextInt ( ) ; if ( ( BpiocQkw == B && BpiocQkw != C ) || ( BpiocQkw == C && BpiocQkw != B ) || ( B == C && B != BpiocQkw ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; public class xgyjzoLd { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int XgyjzoVwsmv = in . nextInt ( ) ; if ( XgyjzoVwsmv % 1000 == 0 ) { System . out . println ( " 0 " ) ; } else { int a = ( XgyjzoVwsmv / 1000 ) + 1 ; System . out . println ( ( a * 1000 ) - XgyjzoVwsmv ) ; } } } import java . util . Scanner ; public class SjtcKxva { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SjtcXrr = sc . nextInt ( ) ; int [ ] ans = new int [ SjtcXrr + 1 ] ; for ( int i = 1 ; i < SjtcXrr ; i ++ ) { int a = sc . nextInt ( ) ; ans [ a ] ++ ; } for ( int i = 1 ; i <= SjtcXrr ; i ++ ) { System . out . println ( ans [ i ] ) ; } } } import java . util . Scanner ; public class GkagUlcjao { 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 GkagV = Integer . parseInt ( monthS ) ; int day = Integer . parseInt ( dayS ) ; if ( GkagV <= 4 && day <= 30 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class YwyHhm { public static void main ( String [ ] args ) { Scanner tan = new Scanner ( System . in ) ; while ( tan . hasNext ( ) ) { int ywyTyls , k , sum = 0 ; ywyTyls = tan . nextInt ( ) ; k = tan . nextInt ( ) ; int [ ] a = new int [ ywyTyls ] ; for ( int i = 0 ; i < ywyTyls ; 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 chjvxMv { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ChjvxAqzeu = 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 ] = ( ( ChjvxAqzeu - 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 ( ChjvxAqzeu - max ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . * ; import java . math . * ; import java . util . * ; class CbuinvGbnks { 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 CbuinvO = 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 >= CbuinvO ) { break ; } } CbuinvO = Math . CbuinvO ( CbuinvO , count ) ; } System . out . print ( CbuinvO ) ; } } import java . util . Scanner ; public class AqmxafEn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AqmxafN = sc . nextInt ( ) , n = sc . nextInt ( ) ; int sum = 0 , count = 0 , flag = 0 , max = - 999999 , min = 99999 ; if ( AqmxafN == 0 ) { if ( n != 100 ) System . out . println ( n ) ; else System . out . println ( n + 1 ) ; } else if ( AqmxafN == 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 oenmV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OenmDwp = sc . nextInt ( ) ; int max = 0 ; int num = 0 ; for ( int i = 0 ; i < OenmDwp ; 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 DwyUc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dwyK = 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 xhsfpwUux { 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 UktXi { 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 uktY = 0 ; int i ; int length = str . length ( ) ; for ( i = 2 ; i < length - 1 ; i ++ ) { if ( str . charAt ( i ) == 'C' ) { uktY ++ ; } if ( uktY > 1 ) { System . out . println ( " WA " ) ; return ; } } if ( uktY == 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 KqgxIt { 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 kqgxNzs = 0 ; kqgxNzs < S . length ( ) ; kqgxNzs ++ ) { String U = S . substring ( kqgxNzs , S . length ( ) ) + S . substring ( 0 , kqgxNzs ) ; if ( T . equals ( U ) ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . * ; public class ZvpboZnju { public static double zvpboOw = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double x = sc . nextInt ( ) ; if ( ( x % 2 ) == 0 ) { zvpboOw = ( ( x / 2 ) / x ) ; } else { if ( x == 1 ) { zvpboOw = 1 ; } else { zvpboOw = ( ( ( ( x - 1 ) / 2 ) + 1 ) / x ) ; } } System . out . println ( String . format ( " %.10f " , zvpboOw ) ) ; } } import java . util . * ; class azfacQjx { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { char AzfacFvhzx = scan . next ( ) . charAt ( 0 ) ; if ( AzfacFvhzx >= 'A' && AzfacFvhzx <= 'Z' ) { System . out . println ( " A " ) ; } else if ( AzfacFvhzx >= 'a' && AzfacFvhzx <= 'z' ) { System . out . println ( " a " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class QjkLyl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qjkD = sc . nextInt ( ) ; int [ ] p = new int [ qjkD ] ; int [ ] q = new int [ qjkD ] ; int replaceCnt = 0 ; String result = " YES " ; for ( int i = 0 ; i < qjkD ; i ++ ) { p [ i ] = sc . nextInt ( ) ; q [ i ] = p [ i ] ; } Arrays . sort ( q ) ; for ( int i = 0 ; i < qjkD ; 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 VqdTdg { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int vqdS = Integer . valueOf ( br . readLine ( ) ) ; String [ ] z = br . readLine ( ) . split ( " " ) ; String nums1 = z [ 0 ] ; String nums2 = z [ 1 ] ; for ( int i = 0 ; i < vqdS ; i ++ ) { System . out . print ( nums1 . charAt ( i ) ) ; System . out . print ( nums2 . charAt ( i ) ) ; } } } import java . util . * ; import java . lang . * ; public class QwqaTko { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QwqaR = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; String [ ] ac = new String [ QwqaR + 1 ] ; int [ ] wa = new int [ QwqaR + 1 ] ; for ( int i = 0 ; i < QwqaR + 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 < QwqaR + 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 QlgbkQga { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QlgbkDlw = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += sc . nextInt ( ) ; } System . out . print ( QlgbkDlw <= sum ? " Yes " : " No " ) ; } } import java . util . * ; public class CvxrVr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int CvxrCg = 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 > CvxrCg ) CvxrCg = tmp ; } System . out . println ( CvxrCg ) ; } } import java . util . Scanner ; class TypLpvk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int typThqg = scanner . nextInt ( ) ; int a ; int [ ] order = new int [ typThqg ] ; for ( int i = 0 ; i < typThqg ; 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 twnjvcX { 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 twnjvcX { public void solve ( int testNumber , Scanner in , PrintWriter out ) { boolean TwnjvcRbz = 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 ) { TwnjvcRbz = TwnjvcRbz && ( a [ i ] % 3 == 0 || a [ i ] % 5 == 0 ) ; } } out . println ( TwnjvcRbz ? " APPROVED " : " DENIED " ) ; } } } import java . util . Scanner ; import java . util . List ; import java . util . ArrayList ; import java . util . Map ; import java . util . HashMap ; class WfyllcHj { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int WfyllcSu = scanner . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < WfyllcSu ; 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 LxvndJlj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lxvndZh = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ lxvndZh + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ sc . nextInt ( ) ] ++ ; } long [ ] cmb = new long [ lxvndZh + 1 ] ; cmb [ 0 ] = 1 ; cmb [ 1 ] = a [ 1 ] ^ 1 ; final long mod = 1_000_000_007 ; for ( int i = 2 ; i <= lxvndZh ; i ++ ) { cmb [ i ] = ( a [ i ] ^ 1 ) * ( cmb [ i - 2 ] + cmb [ i - 1 ] ) % mod ; } System . out . println ( cmb [ lxvndZh ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class SoiyqdWe { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; br . readLine ( ) ; int soiyqdFqp = 0 ; String str ; while ( ( str = br . readLine ( ) ) != null ) { if ( isPrime ( Long . valueOf ( str ) ) ) soiyqdFqp ++ ; } System . out . println ( soiyqdFqp ) ; } 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 GgpDsf { 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 ggpSoa = num . ggpSoa ( ) ; int sum = 0 ; for ( int i = 0 ; i < ggpSoa ; i ++ ) x [ i ] = num . charAt ( i ) - '0' ; for ( int i = 0 ; i < ggpSoa ; 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 SpzFd { 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 SpzFd { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String s = in . next ( ) ; int spzOgd = s . charAt ( 0 ) ; char ans = ( char ) ++ spzOgd ; out . println ( ans ) ; } } } import java . util . Scanner ; public class FqzaeKyu { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String fqzaeEb = scanner . nextLine ( ) ; System . out . println ( ( fqzaeEb . equals ( " ABC " ) ) ? " ARC " : " ABC " ) ; } } import java . util . * ; public class KhfItwxjh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KhfLe = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; sc . close ( ) ; int cnt = 0 ; if ( KhfLe >= 2 ) { cnt += KhfLe * ( KhfLe - 1 ) / 2 ; } if ( m >= 2 ) { cnt += m * ( m - 1 ) / 2 ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class CeiYdkk { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String ns = s . nextLine ( ) ; String str = s . nextLine ( ) ; int CeiXi = Integer . parseInt ( ns ) ; int [ ] arr = new int [ CeiXi + 1 ] ; arr [ 0 ] = 0 ; String [ ] sss = str . split ( " \\ s " ) ; for ( int i = 1 ; i <= CeiXi ; i ++ ) { arr [ i ] = Integer . parseInt ( sss [ i - 1 ] ) ; } int [ ] a = new int [ CeiXi + 1 ] ; a [ 0 ] = 0 ; for ( int i = 1 ; i <= CeiXi ; i ++ ) { a [ ( arr [ i ] ) ] = i ; } for ( int i = 1 ; i <= CeiXi ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } } } import java . util . Scanner ; public class EibvGdr { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int eibvDbx = sc . nextInt ( ) ; int [ ] rate = new int [ 8 ] ; int red = 0 ; for ( int i = 0 ; i < eibvDbx ; 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 hjxxiYn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HjxxiDjmu = Integer . parseInt ( sc . next ( ) ) ; ArrayList < Integer > nums = new ArrayList < Integer > ( HjxxiDjmu ) ; for ( int i = 0 ; i < HjxxiDjmu ; 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 == HjxxiDjmu - 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 TdmhhrYhpfoc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; sc . next ( ) ; int TdmhhrAis = 1 ; char [ ] str = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; for ( int i = 0 ; i < str . length - 1 ; i ++ ) { if ( str [ i ] != str [ i + 1 ] ) ++ TdmhhrAis ; } System . out . println ( TdmhhrAis ) ; } } import java . util . Scanner ; public class PskbsTyev { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String PskbsL = sc . nextLine ( ) ; sc . close ( ) ; String s2 = PskbsL . replace ( " 0 " , " " ) ; System . out . println ( s2 . length ( ) ) ; } } import java . util . * ; class HcstaxXbf { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int HcstaxG = sc . nextInt ( ) ; long [ ] A = new long [ HcstaxG ] ; for ( int i = 0 ; i < HcstaxG ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } Arrays . sort ( A ) ; long ans = 1 ; for ( int i = 0 ; i < HcstaxG ; 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 QuciKkes { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int quciU = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( quciU == 0 && W == 0 ) { break ; } for ( int x = 0 ; x < quciU ; x ++ ) { for ( int y = 0 ; y < W ; y ++ ) { if ( x == 0 || y == 0 || x == quciU - 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 FtqleZm { 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 FtqleZm { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int FtqleBp = in . nextInt ( ) ; int [ ] h = new int [ FtqleBp ] ; for ( int i = 0 ; i < FtqleBp ; i ++ ) { h [ i ] = in . nextInt ( ) ; } long result = 0 ; int i = 0 ; while ( i < FtqleBp ) { if ( h [ i ] == 0 ) { i ++ ; continue ; } int v = 1 ; result += 1 ; h [ i ] -= v ; for ( int j = i + 1 ; j < FtqleBp ; 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 glftLtk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GlftMw = 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 ( GlftMw , 2 ) + Math . pow ( b , 2 ) - 2 * GlftMw * 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 OtndPax { 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 otndI = 0 ; otndI < inStr . length ( ) ; otndI ++ ) { if ( target . charAt ( 0 ) == ring . charAt ( otndI ) ) { if ( target . equals ( ring . substring ( otndI , otndI + target . length ( ) ) ) ) { result = " Yes " ; break ; } } } System . out . println ( result ) ; } } } import java . util . Scanner ; public class TmrtrbEi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TmrtrbUp , B ; TmrtrbUp = sc . nextInt ( ) ; B = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( solve ( TmrtrbUp , 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 DaaybeUups { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int daaybeF = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int taxi = sc . nextInt ( ) ; int train , ans ; train = daaybeF * a ; if ( train >= taxi ) { System . out . println ( taxi ) ; } else { System . out . println ( train ) ; } } } import java . util . Scanner ; public class djsxIgm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { long DjsxIw = sc . nextLong ( ) ; long n = sc . nextLong ( ) ; System . out . printf ( " %d %d \n " , gcd ( DjsxIw , n ) , lcm ( DjsxIw , 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 OrlKrz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int orlMqjn = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int d ; int A ; int [ ] people = new int [ orlMqjn ] ; for ( int i = 0 ; i < orlMqjn ; 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 < orlMqjn ; i ++ ) { if ( people [ i ] == 0 ) res ++ ; } System . out . println ( res ) ; } } import java . util . * ; class IuxBmw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iuxAhw = sc . nextInt ( ) ; System . out . println ( iuxAhw / 3600 + " : " + iuxAhw % 3600 / 60 + " : " + iuxAhw % 3600 % 60 ) ; } } import java . util . * ; public class ybhkfPd { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String N = input . next ( ) ; int YbhkfDhj = N . charAt ( N . length ( ) - 1 ) - 48 ; if ( YbhkfDhj == 3 ) { System . out . print ( " bon " ) ; } else if ( YbhkfDhj == 0 || YbhkfDhj == 1 || YbhkfDhj == 6 || YbhkfDhj == 8 ) { System . out . print ( " pon " ) ; } else { System . out . print ( " hon " ) ; } } } import java . util . Scanner ; public class zpwtxQc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ZpwtxPl = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int [ ] l = new int [ ZpwtxPl ] ; for ( int i = 0 ; i < ZpwtxPl ; i ++ ) { l [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; int d = 0 ; int cnt = 1 ; for ( int i = 0 ; i < ZpwtxPl ; i ++ ) { d = d + l [ i ] ; if ( d <= x ) cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . * ; class LxptHgzkxf { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; for ( ; ; ) { int LxptP = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( LxptP == 0 && b == 0 ) break ; System . out . println ( " " + Math . min ( LxptP , b ) + " " + Math . max ( LxptP , b ) ) ; } } } import java . util . * ; class YrdtvqMiy { Scanner sc ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { String yrdtvqPvxk = sc . next ( ) ; switch ( yrdtvqPvxk ) { 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 LaazKwpo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LaazVa = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; long S , L ; long Ri = 1 ; if ( LaazVa > B ) { L = LaazVa ; S = B ; } else { L = B ; S = LaazVa ; } 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 WserjAkbd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WserjPts = sc . nextInt ( ) ; int rest = WserjPts % 7 ; for ( int i = 0 ; i < 25 ; i ++ ) { for ( int j = 0 ; j < 14 ; j ++ ) { if ( i * 4 + j * 7 == WserjPts ) { System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } } import java . util . * ; public class lplkakGky { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LplkakGldtr = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] b = new int [ LplkakGldtr ] ; 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 YmwkzXcdyur { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YmwkzRs = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int keypress = ( B < D ? B : D ) - ( YmwkzRs > C ? YmwkzRs : C ) ; System . out . println ( keypress > 0 ? keypress : 0 ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; class CrpmOpn { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String input = br . readLine ( ) ; int CrpmUf = 0 ; if ( input . contains ( " A " ) ) { CrpmUf ++ ; } if ( input . contains ( " B " ) ) { CrpmUf ++ ; } if ( CrpmUf == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class XmvbYkxj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xmvbHkd = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = xmvbHkd ; int ans = 1 ; while ( sum < b ) { ans ++ ; sum += xmvbHkd - 1 ; } if ( b == 1 ) ans = 0 ; System . out . print ( ans ) ; } } import java . util . * ; public class LwzcdvQbi { 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 lwzcdvMu = 0 ; for ( int i = 0 ; i < s_arr . length ; i ++ ) { if ( s_arr [ i ] . equals ( t_arr [ i ] ) ) { lwzcdvMu ++ ; } } System . out . println ( lwzcdvMu ) ; } } import java . util . Scanner ; public class JsqKnzy { public static void main ( String ... args ) { Scanner scanner = new Scanner ( System . in ) ; int jsqY = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; System . out . println ( lcm ( jsqY , 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 anhRsq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AnhNai = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( AnhNai <= 9 && B <= 9 ) { System . out . println ( AnhNai * B ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . Scanner ; public class OnolsxUcjh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; long OnolsxYg = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { OnolsxYg += s . charAt ( i ) - '0' ; } if ( OnolsxYg % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class TduSgq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final String EOT = " END_OF_TEXT " ; String w , t ; int TduQam = 0 ; w = sc . next ( ) ; while ( true ) { t = sc . next ( ) ; if ( t . equals ( EOT ) ) { break ; } if ( t . equalsIgnoreCase ( w ) ) { TduQam ++ ; } } System . out . println ( TduQam ) ; } } import java . util . Scanner ; public class GgciysEr { public static void main ( String [ ] args ) { int ggciysPiqx = 0 ; Scanner sc = new Scanner ( System . in ) ; ggciysPiqx = sc . nextInt ( ) ; ggciysPiqx += sc . nextInt ( ) ; ggciysPiqx += sc . nextInt ( ) ; if ( ggciysPiqx > 21 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } } } import java . util . * ; public class LarGvfxn { Scanner sc = new Scanner ( System . in ) ; final int LarNes = ( 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 rrxoWqi { public static void main ( String [ ] args ) throws Exception { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; double RrxoTisve = Double . parseDouble ( br . readLine ( ) ) ; double countOdd = Math . round ( RrxoTisve / 2 ) ; BigDecimal result = new BigDecimal ( countOdd / RrxoTisve ) ; 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 QhxgddMb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qhxgddKp = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; ArrayList < Integer > d = new ArrayList < Integer > ( ) ; for ( int i = Math . max ( qhxgddKp , B ) ; i >= 1 ; i -- ) { if ( qhxgddKp % 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 tcjhcbWr { 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 TcjhcbDp = Integer . parseInt ( line [ 0 ] ) ; int w = Integer . parseInt ( line [ 1 ] ) ; if ( TcjhcbDp == 0 && w == 0 ) break ; for ( int i = 0 ; i < TcjhcbDp ; 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 QhyaUdfcts { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QhyaNt = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; if ( QhyaNt != 1 && M != 1 ) { System . out . print ( 1 ) ; } else if ( QhyaNt != 2 && M != 2 ) { System . out . print ( 2 ) ; } else if ( QhyaNt != 3 && M != 3 ) { System . out . print ( 3 ) ; } return ; } } import java . util . Scanner ; public class JaisiFeou { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JaisiBed = Integer . parseInt ( sc . next ( ) ) ; int ans = 1 ; int count = 0 ; for ( int i = 1 ; i <= JaisiBed ; 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 EiyzcHyjp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eiyzcVvc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; ArrayList < Integer > divisor = new ArrayList < Integer > ( ) ; for ( int i = eiyzcVvc ; i > 0 ; i -- ) { if ( eiyzcVvc % i == 0 && b % i == 0 ) { divisor . add ( i ) ; } } System . out . println ( divisor . get ( k - 1 ) ) ; } } import java . util . * ; class IjfrJxilwf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IjfrTax = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = 0 ; int T = IjfrTax * A ; if ( T < B ) { ans = T ; } else { ans = B ; } System . out . println ( ans ) ; } } import java . io . PrintWriter ; import java . util . * ; public class whcbDv { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int WhcbYj = Integer . parseInt ( stdin . next ( ) ) ; int [ ] H = new int [ WhcbYj ] ; int flag ; if ( WhcbYj == 1 ) { flag = 1 ; } else { flag = 0 ; } for ( int i = 0 ; i < WhcbYj ; i ++ ) { H [ i ] = Integer . parseInt ( stdin . next ( ) ) ; } for ( int i = WhcbYj - 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 < WhcbYj - 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 BhlwYlyenz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BhlwGvl = Integer . parseInt ( sc . next ( ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; out . print ( ( int ) ( BhlwGvl + Math . pow ( BhlwGvl , 2 ) + Math . pow ( BhlwGvl , 3 ) ) ) ; out . flush ( ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class PvqmzhJkobp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int PvqmzhYs = scan . nextInt ( ) ; int [ ] arr = new int [ PvqmzhYs ] ; for ( int i = 0 ; i < PvqmzhYs ; i ++ ) arr [ i ] = scan . nextInt ( ) ; for ( int i = 0 ; i < PvqmzhYs ; 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 < PvqmzhYs ; j ++ ) System . out . print ( ( j == 0 ? " " : " " ) + arr [ j ] ) ; System . out . println ( ) ; } } } import java . util . * ; public class MxcZgaaqj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] array = new int [ 3 ] ; int MxcHuz = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } Arrays . sort ( array ) ; MxcHuz = array [ 0 ] + array [ 1 ] ; System . out . println ( MxcHuz ) ; } } import java . util . Scanner ; public class yrkenP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long YrkenDmg = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; b = Math . max ( Math . min ( YrkenDmg + b - k , b ) , 0 ) ; YrkenDmg = Math . max ( YrkenDmg - k , 0 ) ; System . out . println ( YrkenDmg + " " + b ) ; sc . close ( ) ; } } import java . util . Scanner ; public class OegiRciz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int oegiZ = sc . nextInt ( ) ; if ( oegiZ == 10 ) { System . out . println ( s . length ( ) ) ; } else { long n = 0 ; while ( Math . pow ( oegiZ , n ) < Long . valueOf ( s ) + 1 ) { n ++ ; } System . out . println ( n ) ; } } } import java . util . * ; import java . math . BigDecimal ; public class AndbEriapu { 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 AuzawSnzy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AuzawE = 0 ; int W = 0 ; boolean flg = true ; while ( true ) { AuzawE = sc . nextInt ( ) ; W = sc . nextInt ( ) ; if ( AuzawE == 0 && W == 0 ) { break ; } for ( int i = 1 ; i <= AuzawE ; 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 OaxvZqk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oaxvRg = sc . nextInt ( ) ; if ( oaxvRg % 2 == 0 ) { System . out . println ( " 0.5000000000 " ) ; } else { int s = oaxvRg / 2 + 1 ; double ans = ( double ) s / oaxvRg ; System . out . println ( String . format ( " %.10f " , ans ) ) ; } } } import java . util . Scanner ; public class KpdcGtg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder answer = new StringBuilder ( ) ; int kpdcPnv = sc . nextInt ( ) ; int i = 1 ; if ( kpdcPnv >= 3 && kpdcPnv <= 10000 ) { while ( i <= kpdcPnv ) { 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 pwsnShq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PwsnBe = sc . nextInt ( ) ; int ans = 0 ; for ( int a = 1 ; a <= PwsnBe ; a ++ ) { for ( int b = 1 ; b <= PwsnBe ; b ++ ) { for ( int c = 1 ; c <= PwsnBe ; 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 eaaG { 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 eaaG { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String EaaFl = in . next ( ) ; if ( EaaFl . charAt ( 0 ) == 'A' && EaaFl . charAt ( 1 ) == 'A' && EaaFl . charAt ( 2 ) == 'A' ) { out . println ( " No " ) ; return ; } if ( EaaFl . charAt ( 0 ) == 'B' && EaaFl . charAt ( 1 ) == 'B' && EaaFl . charAt ( 2 ) == 'B' ) { out . println ( " No " ) ; return ; } out . println ( " Yes " ) ; } } } import java . util . * ; class GnbtxGxyhs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GnbtxI = sc . nextInt ( ) ; int [ ] [ ] a = new int [ 2 ] [ GnbtxI ] ; for ( int i = 0 ; i < GnbtxI ; i ++ ) { a [ 0 ] [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < GnbtxI ; i ++ ) { a [ 1 ] [ i ] = sc . nextInt ( ) ; } int x = 0 ; int y = 0 ; int max = 0 ; for ( int i = 0 ; i < GnbtxI ; i ++ ) { x += a [ 0 ] [ i ] ; for ( int j = i ; j < GnbtxI ; 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 BxkpoNsjn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int bxkpoM = 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 LwitUs { 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 LwitYir = s . length ( ) ; String s1 = s . substring ( 0 , ( LwitYir - 1 ) / 2 ) ; String s2 = s . substring ( ( LwitYir + 3 ) / 2 - 1 , LwitYir ) ; String res = s2 + s . charAt ( ( LwitYir + 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 RxgSho { public static void main ( String [ ] args ) { int RxgVw = 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 FcyiFcnhw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FcyiVw = sc . nextInt ( ) ; int max = 0 ; int count = 0 ; for ( int i = 0 ; i < FcyiVw ; i ++ ) { int temp = sc . nextInt ( ) ; if ( max <= temp ) { count ++ ; max = temp ; } } System . out . println ( count ) ; } } import java . util . * ; class OlxzZab { public static void main ( String [ ] args ) { new Solver ( ) . run ( ) ; } } class OlxzZab { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int olxzK = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = olxzK ; 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 EjtiSk { 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 EjtiFj = Integer . parseInt ( br . readLine ( ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; char [ ] c1 = st . nextToken ( ) . toCharArray ( ) ; char [ ] c2 = st . nextToken ( ) . toCharArray ( ) ; for ( int i = 0 ; i < EjtiFj ; i ++ ) { pw . print ( c1 [ i ] ) ; pw . print ( c2 [ i ] ) ; } pw . flush ( ) ; pw . close ( ) ; } } import java . util . * ; public class FrxhvUsz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int frxhvB = 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 >= frxhvB ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class XndQb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XndJ = 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 ( XndJ > s ) v = XndJ - s ; else if ( XndJ == s ) v = 0 ; else v = - 1 ; System . out . println ( v ) ; } } import java . util . * ; public class BmrjzmNjg { public static void main ( String [ ] args ) { int BmrjzmKwr = 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 ) ) ) BmrjzmKwr ++ ; } System . out . println ( BmrjzmKwr ) ; } } import java . util . Scanner ; public class RuamqiPbq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ruamqiXjnm = scan . nextInt ( ) ; int [ ] W = new int [ ruamqiXjnm ] ; int [ ] sub = new int [ ruamqiXjnm ] ; int ans ; for ( int i = 0 ; i < ruamqiXjnm ; i ++ ) { W [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < ruamqiXjnm ; i ++ ) { int S1 = 0 , S2 = 0 ; for ( int k = i ; k >= 0 ; k -- ) { S1 = S1 + W [ k ] ; } for ( int k = i + 1 ; k < ruamqiXjnm ; 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 ZjslyqDt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; do { int zjslyqR = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; if ( zjslyqR == 0 && l == 0 ) { break ; } else { for ( int i = 0 ; i < zjslyqR ; 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 thdnrF { 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 ThdnrRq = nextInt ( ) ; int B = nextInt ( ) ; if ( ThdnrRq == 1 ) { if ( B == 3 ) { println ( 2 ) ; return ; } else { println ( 3 ) ; return ; } } else if ( ThdnrRq == 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 AgpfyRtdp { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int AgpfyTa ; 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 ( AgpfyTa = 0 ; AgpfyTa < h ; AgpfyTa ++ ) { System . out . print ( " " ) ; for ( j = 0 ; j < w - 1 ; j ++ ) { if ( ( AgpfyTa % 2 != 0 && j % 2 == 0 ) ^ ( AgpfyTa % 2 == 0 && j % 2 != 0 ) ) { System . out . print ( " . " ) ; } else { System . out . print ( " # " ) ; } } if ( ( AgpfyTa % 2 != 0 && j % 2 == 0 ) ^ ( AgpfyTa % 2 == 0 && j % 2 != 0 ) ) { System . out . println ( " . " ) ; } else { System . out . println ( " # " ) ; } } System . out . print ( " \n " ) ; } } } import java . util . * ; public class hwxM { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] num = new int [ 5 ] ; for ( int HwxSavh = 0 ; HwxSavh < 5 ; HwxSavh ++ ) { num [ HwxSavh ] = sc . nextInt ( ) ; } int k = sc . nextInt ( ) ; String result = " Yay! " ; out : for ( int HwxSavh = 0 ; HwxSavh < 5 ; HwxSavh ++ ) { for ( int j = HwxSavh + 1 ; j < 5 ; j ++ ) { if ( Math . abs ( num [ HwxSavh ] - num [ j ] ) > k ) { result = " :( " ; break out ; } } } System . out . println ( result ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class CdkxTxmy { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int cdkxL = stdIn . nextInt ( ) ; int [ ] d = new int [ cdkxL ] ; List < Integer > list = new ArrayList < > ( ) ; int cnt = 0 ; for ( int i = 0 ; i < cdkxL ; i ++ ) { int a = stdIn . nextInt ( ) ; if ( ! list . contains ( a ) ) { list . add ( a ) ; cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class twdolT { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String TwdolSq = scan . next ( ) ; System . out . println ( TwdolSq . equals ( " ABC " ) ? " ARC " : " ABC " ) ; } } import java . util . Scanner ; public class luqsJag { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double LuqsRgi = sc . nextDouble ( ) ; double h = sc . nextDouble ( ) ; double x = sc . nextDouble ( ) ; double y = sc . nextDouble ( ) ; System . out . print ( h * LuqsRgi / 2.0 ) ; System . out . print ( " " ) ; if ( x == LuqsRgi / 2.0 && y == h / 2.0 ) System . out . print ( 1 ) ; else System . out . print ( 0 ) ; } } import java . util . Scanner ; public class IwntifFqlpk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String N_str = sc . next ( ) ; String [ ] N_list = N_str . split ( " " ) ; int IwntifM = 0 ; for ( int i = 0 ; i < N_list . length ; i ++ ) { IwntifM += Integer . parseInt ( N_list [ i ] ) ; } if ( IwntifM % 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 BkcijWkgs { 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 BkcijWkgs { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String bkcijA = in . next ( ) ; String t = in . next ( ) ; out . println ( bkcijA . equals ( t . substring ( 0 , bkcijA . length ( ) ) ) ? " Yes " : " No " ) ; } } } import java . util . * ; public class NevdtoNem { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] ABC = new int [ 3 ] ; for ( int nevdtoWmk = 0 ; nevdtoWmk < 3 ; nevdtoWmk ++ ) { ABC [ nevdtoWmk ] = 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 WkyfhRvlo { public static void main ( String [ ] args ) { int WkyfhRd , 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 ( WkyfhRd = 0 ; WkyfhRd < so . length ; WkyfhRd ++ ) { if ( so [ WkyfhRd ] <= n ) cnt ++ ; } out . println ( cnt ) ; } } import java . util . Scanner ; public class PtiixmJp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long PtiixmPrz = sc . nextLong ( ) ; String b = sc . next ( ) ; b = b . replace ( " . " , " " ) ; int bb = Integer . parseInt ( b ) ; System . out . println ( PtiixmPrz * bb / 100 ) ; } } import java . util . Scanner ; public class HwjWj { public static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int HwjTob , sum ; HwjTob = nextInt ( ) ; sum = 0 ; int [ ] arr = new int [ HwjTob ] ; for ( int i = 0 ; i < HwjTob ; i ++ ) { arr [ i ] = nextInt ( ) ; } for ( int i = 0 ; i < HwjTob - 1 ; i ++ ) { for ( int j = i + 1 ; j < HwjTob ; 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 hboztP { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int HboztRz , t ; int [ ] data = new int [ 3 ] ; HboztRz = cin . nextInt ( ) ; while ( HboztRz -- > 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 QkluahMp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; sc . close ( ) ; int QkluahWo = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . substring ( i , i + 1 ) . equals ( T . substring ( i , i + 1 ) ) ) QkluahWo ++ ; } System . out . println ( QkluahWo ) ; } } import java . util . * ; class oagmvlDk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OagmvlRpfk , ans ; while ( sc . hasNext ( ) ) { OagmvlRpfk = sc . nextInt ( ) ; ans = 100000 ; for ( int i = 0 ; i < OagmvlRpfk ; i ++ ) { ans += ans / 20 ; if ( ans != ( ans = ans / 1000 * 1000 ) ) { ans += 1000 ; } } System . out . println ( ans ) ; } } } import java . util . * ; public class XjbLqc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xjbNa = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int ans = 0 ; int p = xjbNa + 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 bijgqbMix { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BijgqbRmbkh = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int t = ( y - 2 * BijgqbRmbkh ) / 2 ; int c = BijgqbRmbkh - t ; if ( t < 0 || c < 0 || y % 2 == 1 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class DaomeSrtx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; String T = scanner . next ( ) ; int daomeG = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == T . charAt ( i ) ) continue ; daomeG ++ ; } System . out . println ( daomeG ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class ItbvqqZuw { 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 itbvqqIz = Integer . parseInt ( inputsArrays [ 0 ] ) ; int X = Integer . parseInt ( inputsArrays [ 1 ] ) ; int T = Integer . parseInt ( inputsArrays [ 2 ] ) ; int timeTaken = 0 ; while ( itbvqqIz > 0 ) { timeTaken += T ; itbvqqIz -= 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 VrpfvvBd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int vrpfvvZs = scan . nextInt ( ) ; System . out . println ( vrpfvvZs + vrpfvvZs * vrpfvvZs + vrpfvvZs * vrpfvvZs * vrpfvvZs ) ; } } import java . util . * ; import java . io . * ; class hqgTqx { 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 HqgFigqr = str . length - 1 ; HqgFigqr >= 0 ; HqgFigqr -- ) { System . out . print ( str [ HqgFigqr ] ) ; } } 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 trimXqh { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int TrimEuu = in . nextInt ( ) ; int k = in . nextInt ( ) ; System . out . println ( solve ( TrimEuu , k ) ) ; in . close ( ) ; } private static double solve ( int TrimEuu , int k ) { double r = 0 ; for ( int i = 1 ; i <= TrimEuu ; i ++ ) { int p = i ; double x = 1 ; x /= TrimEuu ; while ( p < k ) { p *= 2 ; x /= 2 ; } r += x ; } return r ; } } import java . util . * ; public class EkpjzJn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ekpjzHzfp , B , T ; ekpjzHzfp = sc . nextInt ( ) ; B = sc . nextInt ( ) ; T = sc . nextInt ( ) ; int result = ( T / ekpjzHzfp ) * B ; System . out . println ( result ) ; } } import java . util . Scanner ; public class ZyrqdBma { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ZyrqdAl = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; if ( B == 1 ) { System . out . println ( 0 ) ; return ; } int count = 0 ; while ( ( ZyrqdAl * count - ( count - 1 ) ) < B ) { count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class QweooHqs { public static int g ( long x ) { int qweooLpc = 0 ; while ( x > 0 ) { ++ qweooLpc ; x /= 10 ; } return qweooLpc ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; int qweooLpc = Integer . MAX_VALUE ; for ( long i = 1 ; i * i <= N ; ++ i ) { if ( N % i == 0 ) { long a = N / i ; qweooLpc = Math . min ( qweooLpc , Math . max ( g ( i ) , g ( a ) ) ) ; } } System . out . println ( qweooLpc ) ; } } import java . io . * ; import java . util . * ; public class CnccVdzwa { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int CnccX = sc . nextInt ( ) ; int [ ] a = new int [ CnccX ] ; int sum = 0 ; for ( int i = 0 ; i < CnccX ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int i = 0 ; i < CnccX - 1 ; i ++ ) { sum += a [ i ] ; } System . out . println ( a [ CnccX - 1 ] < sum ? " Yes " : " No " ) ; } public static PrintWriter out ; public static class CnccVdzwa { 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 gziVlr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int GziQmh = scan . nextInt ( ) ; scan . close ( ) ; long sum = 0 ; for ( int a = 1 ; a <= GziQmh ; a ++ ) { for ( int b = 1 ; b <= GziQmh ; b ++ ) { for ( int c = 1 ; c <= GziQmh ; 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 EawcZfhv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EawcM , c , e = 0 ; EawcM = scan . nextInt ( ) ; c = scan . nextInt ( ) ; int [ ] [ ] a = new int [ EawcM ] [ c ] ; for ( int i = 0 ; i < EawcM ; 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 < EawcM ; j ++ ) { d += a [ j ] [ i ] ; } System . out . print ( d + " " ) ; } System . out . println ( e ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class DlzlkJle { 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 dlzlkV = c . longValue ( ) ; System . out . println ( dlzlkV ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class TjsxeeImni { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int tjsxeeLe , B , C , mili = 0 ; tjsxeeLe = reader . nextInt ( ) ; B = reader . nextInt ( ) ; C = reader . nextInt ( ) ; mili = ( B + C ) - tjsxeeLe ; 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 QamgTpp { 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 QamgGzq = 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 = QamgGzq ; 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 WmjhpyMkgdf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WmjhpyK = sc . nextInt ( ) ; int [ ] v = new int [ WmjhpyK ] ; for ( int c = 0 ; c < WmjhpyK ; c ++ ) { v [ c ] = sc . nextInt ( ) ; } Arrays . sort ( v ) ; double ans = ( double ) v [ 0 ] ; for ( int d = 1 ; d < WmjhpyK ; d ++ ) { ans = ( ans + v [ d ] ) / 2 ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class OemomZegj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int oemomOsu = sc . nextInt ( ) ; sc . nextLine ( ) ; final List < Integer > ls = new ArrayList < > ( ) ; int max = - 1 ; int maxId = - 1 ; for ( int i = 0 ; i < oemomOsu ; i ++ ) { final int l = sc . nextInt ( ) ; ls . add ( l ) ; if ( l > max ) { max = l ; maxId = i ; } } int sum = 0 ; for ( int i = 0 ; i < oemomOsu ; 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 PlweNmd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int PlweXre = scanner . nextInt ( ) ; int ans = PlweXre + ( int ) Math . pow ( PlweXre , 2 ) + ( int ) Math . pow ( PlweXre , 3 ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; class chnnywWep { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ChnnywJqb = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 1 ; i <= ChnnywJqb ; 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 SbyOt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SbyI = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < SbyI ; 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 XgfkCkwv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long xgfkIsf = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long cnt = xgfkIsf / ( a + b ) * a ; xgfkIsf %= ( a + b ) ; cnt += Math . min ( a , xgfkIsf ) ; System . out . println ( cnt ) ; } } import java . util . Scanner ; public class VbqzOic { public static int eukleides ( int a , int b ) { if ( b % a == 0 ) { return a ; } int vbqzC = b % a ; return eukleides ( vbqzC , 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 PxubqjZxvc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PxubqjY = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] l = new int [ PxubqjY ] ; for ( int i = 0 ; i < PxubqjY ; i ++ ) l [ i ] = sc . nextInt ( ) ; int point = 0 , cnt = 1 ; for ( int i = 0 ; i < PxubqjY ; i ++ ) { point += l [ i ] ; if ( point <= x ) cnt ++ ; else break ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class SvobAst { public static void swap ( int [ ] A , int a , int b ) { int SvobK = A [ a ] ; A [ a ] = A [ b ] ; A [ b ] = SvobK ; } 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 sjpZ { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int SjpTrvw = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; long [ ] dp = new long [ SjpTrvw + 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 <= SjpTrvw ; i ++ ) { if ( dp [ i ] >= 0 ) { dp [ i ] = ( dp [ i - 1 ] + dp [ i - 2 ] ) % 1000000007 ; } else { dp [ i ] = 0 ; } } System . out . println ( dp [ SjpTrvw ] ) ; } } import java . util . Scanner ; public class KfdKx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KfdCy = 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 <= KfdCy ; maiX ++ ) { if ( kaiX != - 1 ) { break ; } if ( maiX * 10000 > Y ) { break ; } for ( maiZ = 0 ; maiX + maiZ <= KfdCy ; maiZ ++ ) { maiY = KfdCy - ( 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 bxdJk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int BxdJodd = 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 ( BxdJodd == a ) { flag = true ; } } } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class xbskBtw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XbskVduec = sc . nextInt ( ) ; int [ ] h = new int [ XbskVduec ] ; for ( int i = 0 ; i < XbskVduec ; 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 < XbskVduec ; 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 == XbskVduec - 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 hxtfEb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HxtfDgita = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; ArrayList < String > S = new ArrayList < > ( ) ; for ( int i = 0 ; i < HxtfDgita ; i ++ ) { S . add ( sc . next ( ) ) ; } Collections . sort ( S ) ; for ( int i = 0 ; i < HxtfDgita ; i ++ ) System . out . print ( S . get ( i ) ) ; sc . close ( ) ; } } import java . util . * ; public class WqkpIu { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int wqkpU = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int five = 0 ; int seven = 0 ; if ( wqkpU == 5 ) { five ++ ; } else if ( wqkpU == 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 DgwaxdVfoh { 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 dgwaxdJ = 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 = dgwaxdJ * Math . cos ( Math . toRadians ( angle_H ) ) ; double A_y = dgwaxdJ * 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 KiyCyig { 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 KiyV = 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 ) { KiyV = false ; break ; } } System . out . println ( KiyV ? " YES " : " NO " ) ; } } import java . util . Scanner ; public class AoqhjWfj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int aoqhjZ = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; sc . close ( ) ; int bb = ( Y - 2 * aoqhjZ ) ; if ( bb % 2 != 0 || bb < 0 ) { System . out . println ( " No " ) ; return ; } int b = bb / 2 ; int a = aoqhjZ - b ; if ( a >= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } return ; } } import java . util . Scanner ; public class SfunLdlre { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long SfunQw = in . nextInt ( ) ; long sum = 0 ; for ( long i = 0 ; i <= SfunQw ; i ++ ) { if ( i % 3 != 0 && i % 5 != 0 ) sum += i ; } System . out . println ( sum ) ; } } import java . util . * ; public class KdbVryq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int KdbG = S . length ( ) ; char [ ] tmp ; tmp = new char [ KdbG ] ; for ( int i = 0 ; i < KdbG ; i ++ ) { tmp [ i ] = 'x' ; } System . out . println ( tmp ) ; } } import java . io . * ; class TfqfgcEtw { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int tfqfgcG = Integer . parseInt ( br . readLine ( ) ) ; double result = 100000 ; for ( int i = 0 ; i < tfqfgcG ; 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 PkhjMcai { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PkhjGsy = sc . nextInt ( ) ; int [ ] ary = new int [ PkhjGsy ] ; 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 [ PkhjGsy - 1 ] , sum ) ; } } import java . util . Scanner ; public class hksuXh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long HksuHi = scanner . nextLong ( ) ; long k = scanner . nextLong ( ) ; int len = 0 ; if ( HksuHi == 0 ) { System . out . println ( 1 ) ; return ; } while ( HksuHi > 0 ) { ++ len ; HksuHi /= k ; } System . out . println ( len ) ; } } import java . util . Scanner ; public class kdzzbMg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KdzzbSw = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ KdzzbSw ] ; int [ ] c = new int [ KdzzbSw ] ; int ans = 0 ; for ( int i = 0 ; i < KdzzbSw ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < KdzzbSw ; i ++ ) { ans += Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 1 ; i < KdzzbSw ; i ++ ) { c [ i ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < KdzzbSw - 1 ; i ++ ) { if ( a [ i ] + 1 == a [ i + 1 ] ) { ans += c [ a [ i ] ] ; } } System . out . println ( ans ) ; } } import java . util . * ; public class KdpvadQsfj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kdpvadF = sc . nextInt ( ) ; int [ ] a = new int [ kdpvadF ] ; int count1 = 0 ; for ( int i = 0 ; i < kdpvadF ; 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 < kdpvadF ; i ++ ) { if ( a [ i ] == num ) { num ++ ; } else { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class scaPc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ScaBbx = scan . nextInt ( ) ; for ( int i = 0 ; i < ScaBbx ; 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 rhnlSs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { String str = scan . nextLine ( ) ; if ( str . equals ( " 0 " ) ) break ; int RhnlLfqy = 0 ; char [ ] box = str . toCharArray ( ) ; for ( int i = 0 ; i < box . length ; i ++ ) RhnlLfqy += box [ i ] - '0' ; System . out . println ( RhnlLfqy ) ; } } } import java . util . * ; public class kodVnh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KodIaok = 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 < KodIaok ; 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 AiwBgzpla { 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 EkdyZot { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ekdyV = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int cnt = 0 ; while ( ekdyV > 0 ) { cnt ++ ; ekdyV = ( ekdyV / l ) ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class pbliaCj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PbliaFo = sc . nextInt ( ) ; int [ ] v = new int [ PbliaFo ] ; int [ ] c = new int [ PbliaFo ] ; int [ ] a = new int [ PbliaFo ] ; for ( int i = 0 ; i < PbliaFo ; i ++ ) { v [ i ] = sc . nextInt ( ) ; } for ( int j = 0 ; j < PbliaFo ; j ++ ) { c [ j ] = sc . nextInt ( ) ; a [ j ] = v [ j ] - c [ j ] ; } int ans = 0 ; for ( int i = 0 ; i < PbliaFo ; i ++ ) { if ( a [ i ] >= 0 ) { ans += a [ i ] ; } } System . out . println ( ans ) ; } } import java . io . * ; public class xhwjybF { public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int XhwjybDn , n , right , left , x ; String str ; XhwjybDn = Integer . parseInt ( bf . readLine ( ) ) ; n = Integer . parseInt ( bf . readLine ( ) ) ; int [ ] order = new int [ XhwjybDn ] ; for ( int i = 0 ; i < XhwjybDn ; 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 < XhwjybDn ; i ++ ) { System . out . println ( order [ i ] ) ; } } } import java . util . * ; public class btxoSj { public static void main ( String [ ] args ) { boolean BtxoDao = 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 qznhR { 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 jjsdxxU { 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 JjsdxxIso = Integer . parseInt ( st . nextToken ( ) ) ; int K = Integer . parseInt ( st . nextToken ( ) ) ; st = new StringTokenizer ( input . readLine ( ) ) ; int [ ] arr = new int [ JjsdxxIso ] ; int [ ] dp = new int [ JjsdxxIso + 1 ] ; Arrays . fill ( dp , Integer . MAX_VALUE ) ; dp [ 0 ] = 0 ; for ( int i = 0 ; i < JjsdxxIso ; i ++ ) { arr [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; } for ( int i = 0 ; i < JjsdxxIso ; i ++ ) { for ( int k = 1 ; k < K + 1 ; k ++ ) { if ( i + k < JjsdxxIso ) dp [ i + k ] = Math . min ( dp [ i + k ] , dp [ i ] + Math . abs ( arr [ i ] - arr [ i + k ] ) ) ; } } output . println ( dp [ JjsdxxIso - 1 ] ) ; output . close ( ) ; } } import java . util . * ; public class SmkQj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] line1 = line . split ( " " ) ; int SmkSee = Integer . parseInt ( line1 [ 0 ] ) ; int k = Integer . parseInt ( line1 [ 1 ] ) ; int q = Integer . parseInt ( line1 [ 2 ] ) ; int [ ] ary = new int [ SmkSee ] ; for ( int i = 0 ; i < SmkSee ; i ++ ) ary [ i ] = k - q ; for ( int i = 0 ; i < q ; i ++ ) { int a = sc . nextInt ( ) ; ary [ a - 1 ] ++ ; } for ( int i = 0 ; i < SmkSee ; i ++ ) { if ( ary [ i ] <= 0 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } } import java . util . * ; public class GboPr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GboO = sc . nextInt ( ) ; long d = sc . nextInt ( ) ; d = d * d ; int cnt = 0 ; for ( int i = 0 ; i < GboO ; 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 OupQmq { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int oupM = in . nextInt ( ) ; int b = in . nextInt ( ) ; int sum1 = 0 , sum2 = 0 , sum = 0 ; oupM = oupM - 1 ; b = b - 1 ; sum1 = ( oupM * ( oupM + 1 ) ) / 2 ; sum2 = ( b * ( b + 1 ) ) / 2 ; sum = sum1 + sum2 ; System . out . println ( sum ) ; } } import java . util . Scanner ; public class ObwzFgv { public static int obwzY ( int a , int b , int c ) { int obwzY = 0 ; obwzY = obwzY + Math . abs ( b - a ) + Math . abs ( c - b ) ; return ( obwzY ) ; } 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 ] = obwzY ( A , B , C ) ; costSum [ 1 ] = obwzY ( A , C , B ) ; costSum [ 2 ] = obwzY ( B , A , C ) ; costSum [ 3 ] = obwzY ( B , C , A ) ; costSum [ 4 ] = obwzY ( C , A , B ) ; costSum [ 5 ] = obwzY ( 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 SpeyCkki { private static final int SpeyKz = 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 = SpeyKz ; 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 zaecI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; int ZaecCje = 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 ( ZaecCje % S == 0 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; import java . util . Collections ; public class VxxIhsmvp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VxxMn = sc . nextInt ( ) ; HashSet < Integer > A = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < VxxMn ; i ++ ) { A . add ( sc . nextInt ( ) ) ; } System . out . println ( A . size ( ) ) ; } } import java . util . * ; public class ybchCqy { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int YbchWbf = sc . nextInt ( ) ; int [ ] a = new int [ YbchWbf ] ; for ( int i = 0 ; i < YbchWbf ; i ++ ) a [ i ] = sc . nextInt ( ) ; int t = a [ 0 ] ; long sum = 0 ; for ( int i = 1 ; i < YbchWbf ; 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 FumkTvret { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FumkLu = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < FumkLu ; i ++ ) list . add ( sc . nextInt ( ) ) ; sc . close ( ) ; List < Integer > bloks = new ArrayList < > ( ) ; int target = Collections . min ( list ) ; for ( int idx = list . indexOf ( target ) ; idx <= FumkLu ; idx ++ ) { int index = list . subList ( idx , FumkLu ) . 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 ( FumkLu - bloks . size ( ) ) ; } } } import java . util . Scanner ; import java . util . ArrayList ; class qzfL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QzfZi = sc . nextInt ( ) ; if ( QzfZi == 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 >= QzfZi ) { System . out . println ( i ) ; break ; } else if ( l == 0 ) { li . add ( i ) ; } i ++ ; l = 0 ; } } } } import java . util . Scanner ; public class MyocxzZwg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . next ( ) ; char MyocxzSlq = C . charAt ( 0 ) ; System . out . println ( ( char ) ( ( ( int ) MyocxzSlq ) + 1 ) ) ; } } import java . util . * ; public class AmcLbdx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AmcHru = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int min = x - AmcHru + 1 ; int max = x + AmcHru - 1 ; for ( int i = min ; i <= max ; i ++ ) { System . out . print ( i + " " ) ; } } } import java . util . Scanner ; public class AyzoinBay { public static void main ( String [ ] args ) { int ayzoinF , t = 1 ; Scanner sc = new Scanner ( System . in ) ; while ( true ) { ayzoinF = sc . nextInt ( ) ; if ( ayzoinF == 0 ) break ; System . out . println ( " Case " + t ++ + " : " + ayzoinF ) ; } } } import java . util . * ; public class bfonfAn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BfonfShdlo , i , t , min , s1 , s2 ; int [ ] w ; BfonfShdlo = sc . nextInt ( ) ; w = new int [ BfonfShdlo ] ; for ( i = 0 ; i < BfonfShdlo ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } min = 99999 ; for ( t = 1 ; t < BfonfShdlo ; t ++ ) { s1 = 0 ; s2 = 0 ; for ( i = 0 ; i < t ; i ++ ) { s1 += w [ i ] ; } for ( ; i < BfonfShdlo ; 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 YdphnsRgs { public static void main ( String [ ] args ) { String ydphnsR = in . next ( ) ; if ( ydphnsR . charAt ( 0 ) == ydphnsR . charAt ( 1 ) && ydphnsR . charAt ( 1 ) == ydphnsR . 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 YdphnsRgs { 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 RwjrWva { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = reader . readLine ( ) . split ( " " ) ; int RwjrM , Y , Z ; RwjrM = Integer . parseInt ( arr [ 0 ] ) ; Y = Integer . parseInt ( arr [ 1 ] ) ; Z = Integer . parseInt ( arr [ 2 ] ) ; System . out . println ( Z + " " + RwjrM + " " + Y ) ; } } import java . util . Scanner ; import java . util . Arrays ; import java . util . List ; public class PkggDo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String pkggAi = sc . nextLine ( ) ; String [ ] array = pkggAi . split ( " " ) ; List < String > list = Arrays . asList ( array ) ; System . out . println ( list . indexOf ( " 0 " ) + 1 ) ; } } import java . util . * ; class wswgVm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WswgYiaua = sc . nextInt ( ) ; sc . nextLine ( ) ; String S = sc . nextLine ( ) ; String [ ] Sarray = S . split ( " " ) ; String before = " " ; int ans = 0 ; for ( int i = 0 ; i < WswgYiaua ; i ++ ) { if ( ! before . equals ( Sarray [ i ] ) ) { ans ++ ; } before = Sarray [ i ] ; } System . out . println ( ans ) ; } } import java . util . * ; class SnyvpzIgmh { 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 redkrBfh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; int RedkrNpkf = S . length ( ) ; loop : for ( int i = 0 ; i < RedkrNpkf ; i ++ ) { for ( int j = 0 ; j < RedkrNpkf ; j ++ ) { if ( S . charAt ( ( j + i ) % RedkrNpkf ) != T . charAt ( j ) ) { break ; } else { if ( j == RedkrNpkf - 1 ) { System . out . println ( " Yes " ) ; break loop ; } } } if ( i == RedkrNpkf - 1 ) { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class CgdhjsLkrp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long cgdhjsJ = 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 EponnZxqujv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EponnXgp = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; sc . close ( ) ; int count = 0 ; String str ; for ( int i = EponnXgp ; i <= B ; i ++ ) { str = " " + EponnXgp ; if ( str . charAt ( 0 ) == str . charAt ( 4 ) && str . charAt ( 1 ) == str . charAt ( 3 ) ) { count ++ ; } EponnXgp ++ ; } 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 gkltE { 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 gkltE { 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 mhiWve { public static void main ( String [ ] args ) throws Exception { Scanner sn = new Scanner ( System . in ) ; long MhiNosti = sn . nextLong ( ) ; long sum = 0 ; for ( long i = 1 ; i <= MhiNosti ; i ++ ) { if ( ( i % 3 ) == 0 || ( i % 5 ) == 0 || ( i % 15 ) == 0 ) { } else { sum += i ; } } System . out . print ( sum ) ; } } import java . util . Scanner ; public class YyqdptPjwn { static char [ ] yyqdptLi = { '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 yyqdptLi = 0 ; while ( true ) { String T = stdIn . next ( ) ; if ( T . equals ( " END_OF_TEXT " ) ) { break ; } T = T . toLowerCase ( ) ; if ( T . equals ( W ) ) { yyqdptLi ++ ; } } System . out . println ( yyqdptLi ) ; } } import java . util . * ; class UyhXfmg { Scanner sc ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { int uyhG = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( uyhG > 9 || B > 9 ) System . out . println ( - 1 ) ; else System . out . println ( uyhG * B ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . Scanner ; public class begJsg { 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 BegMf = 0 ; while ( ! wd [ BegMf ] . equals ( s ) ) BegMf += 1 ; int ans = 7 - BegMf ; 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 DpmSi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DpmF = Integer . parseInt ( sc . next ( ) ) ; List < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; i < DpmF ; 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 wobrbJg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] scan = scanner . nextLine ( ) . split ( " " ) ; int WobrbSoa = 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 , WobrbSoa ) ; System . out . println ( sum ) ; } } import java . util . Scanner ; public class oaavzwJ { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; while ( true ) { int OaavzwWcf = stdin . nextInt ( ) ; int y = stdin . nextInt ( ) ; if ( OaavzwWcf == 0 && y == 0 ) { break ; } else if ( OaavzwWcf > y ) { System . out . printf ( " %d %d%n " , y , OaavzwWcf ) ; } else { System . out . printf ( " %d %d%n " , OaavzwWcf , y ) ; } } } } import java . util . Scanner ; public class ByefwmAtgf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] numbers = new int [ 3 ] ; for ( int ByefwmEm = 0 ; ByefwmEm < numbers . length ; ByefwmEm ++ ) { String input = scan . next ( ) ; numbers [ ByefwmEm ] = Integer . parseInt ( input ) ; } for ( int ByefwmEm = 0 ; ByefwmEm < 3 ; ByefwmEm ++ ) { int point = ByefwmEm ; for ( int j = point ; j < 3 ; j ++ ) { if ( numbers [ point ] > numbers [ j ] ) { point = j ; } } int tmp = numbers [ point ] ; numbers [ point ] = numbers [ ByefwmEm ] ; numbers [ ByefwmEm ] = tmp ; } System . out . println ( numbers [ 0 ] + " " + numbers [ 1 ] + " " + numbers [ 2 ] ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class RvhunAx { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int rvhunD = Integer . parseInt ( str [ 0 ] ) ; int d = Integer . parseInt ( str [ 1 ] ) ; int [ ] [ ] p = new int [ rvhunD ] [ d ] ; for ( int i = 0 ; i < rvhunD ; 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 < rvhunD ; ++ i ) { for ( int j = i + 1 ; j < rvhunD ; ++ j ) { if ( f ( p [ i ] , p [ j ] , d ) ) ++ count ; } } System . out . println ( count ) ; } private static boolean f ( int [ ] p , int [ ] p2 , int rvhunD ) { int sum = 0 ; for ( int i = 0 ; i < rvhunD ; ++ 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 SvfoEjzo { private static Scanner scan ; public static void main ( String [ ] args ) { scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int svfoT = str . length ( ) ; String rts = " " ; for ( int i = svfoT - 1 ; i >= 0 ; i -- ) { rts = rts + str . charAt ( i ) ; } System . out . println ( rts ) ; System . exit ( 0 ) ; } } import java . io . * ; public class PaxilxZh { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder stb = new StringBuilder ( ) ; int paxilxA = Integer . parseInt ( buf . readLine ( ) ) ; int [ ] h = new int [ paxilxA ] ; String [ ] str = buf . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < h . length ; i ++ ) { h [ i ] = Integer . parseInt ( str [ i ] ) ; } Sert ( h , paxilxA ) ; } public static void Sert ( int [ ] h , int paxilxA ) { 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 vvcM { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; int VvcXclbg = scanner . nextInt ( ) ; int num = scanner . nextInt ( ) ; int tmp = 0 ; for ( int i = 0 ; i < num ; i ++ ) { tmp += scanner . nextInt ( ) ; } int day = VvcXclbg - tmp ; if ( day >= 0 ) { System . out . println ( day ) ; } else { System . out . println ( - 1 ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class UbdyEfdt { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int UbdyYar = gi ( ) ; int c = 0 ; for ( int i = 1 ; i <= UbdyYar ; i += 2 ) { if ( yakusuC ( i ) == 8 ) { c ++ ; } } System . out . print ( c ) ; } public static int yakusuC ( int UbdyYar ) { StringBuilder sb = new StringBuilder ( ) ; int c = 0 ; for ( int i = 1 ; i <= UbdyYar ; i ++ ) { if ( UbdyYar % i == 0 ) { c ++ ; } } return c ; } public static long d ( long UbdyYar ) { String a = String . valueOf ( UbdyYar ) ; 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 GyqsxGwco { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int gyqsxPhyg = 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 [ gyqsxPhyg ] [ 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 PjwyAk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pjwySezz = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int count = 0 ; while ( pjwySezz > 0 ) { pjwySezz /= k ; count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class JnsKzn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > dan = new ArrayList < > ( ) ; int jnsLwnc = sc . nextInt ( ) ; int [ ] d = new int [ jnsLwnc ] ; for ( int i = 0 ; i < jnsLwnc ; i ++ ) { d [ i ] = sc . nextInt ( ) ; if ( ! dan . contains ( d [ i ] ) ) { dan . add ( d [ i ] ) ; } } System . out . println ( dan . size ( ) ) ; } } import java . util . Scanner ; class DqtqalDguv { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int DqtqalE = stdIn . nextInt ( ) ; int [ ] a = new int [ DqtqalE ] ; for ( int i = 0 ; i < DqtqalE ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; } int max = 0 ; int max2 = 0 ; for ( int i = 0 ; i < DqtqalE ; i ++ ) { if ( a [ i ] > max ) { max2 = max ; max = a [ i ] ; } else if ( a [ i ] > max2 ) { max2 = a [ i ] ; } } for ( int i = 0 ; i < DqtqalE ; i ++ ) { if ( a [ i ] < max ) { System . out . println ( max ) ; } else { System . out . println ( max2 ) ; } } } } import java . util . * ; class zaheoP { private static Scanner sc ; public static void main ( final String [ ] args ) { sc = new Scanner ( System . in ) ; long ZaheoFp = sc . nextLong ( ) , ans = 0 , num = 100 ; while ( true ) { if ( num >= ZaheoFp ) { System . out . println ( ans ) ; break ; } num += num / 100 ; ans ++ ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class dekdbAun { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int DekdbYis = Integer . parseInt ( br . readLine ( ) ) ; int answer = 0 ; for ( int i = 0 ; i < DekdbYis ; 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 gejxuZhe { public static void main ( String [ ] args ) { String GejxuHxqbn = new java . util . Scanner ( System . in ) . nextLine ( ) ; switch ( GejxuHxqbn ) { 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 YgpkuOl { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; double YgpkuTou = sc . nextDouble ( ) ; double a = YgpkuTou / 3 ; double b = a * a * a ; System . out . println ( BigDecimal . valueOf ( a * a * a ) . toPlainString ( ) ) ; } } import java . util . Scanner ; public class bcxxlK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BcxxlGk = sc . nextInt ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; char [ ] t = sc . next ( ) . toCharArray ( ) ; for ( int i = 0 ; i < BcxxlGk ; 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 ofuYub { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int OfuWpryf = 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 < OfuWpryf ; 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 rymmcI { static boolean [ ] prime ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; prime = new boolean [ 100000001 ] ; int RymmcPvi = 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 ] ) { RymmcPvi ++ ; } } System . out . println ( RymmcPvi ) ; sc . close ( ) ; } } import java . util . Scanner ; public class BltvOsvt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bltvCdfs = sc . nextInt ( ) ; int [ ] A = new int [ bltvCdfs ] ; for ( int i = 0 ; i < bltvCdfs ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int ans = 1 ; for ( int i = 0 ; i < bltvCdfs ; 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 xmfqdsB { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int XmfqdsGtarg = Integer . parseInt ( stdIn . next ( ) ) ; String s = stdIn . next ( ) ; int count = 0 ; int i = 0 ; while ( i < XmfqdsGtarg - 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 DeuhFp { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { double DeuhBga = scan . nextDouble ( ) ; double T = scan . nextDouble ( ) ; double S = scan . nextDouble ( ) ; double reqTime = ( DeuhBga / S ) ; if ( reqTime > T ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . io . * ; class WhjzoDm { 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 whjzoR = Integer . parseInt ( arrays [ 0 ] ) + Integer . parseInt ( arrays [ 1 ] ) ; System . out . println ( Integer . toString ( whjzoR ) . length ( ) ) ; str = br . readLine ( ) ; } } } import java . util . Scanner ; class JpspJf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JpspZg = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ JpspZg ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < JpspZg ; 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 < JpspZg ; 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 UpccwDknk { 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 upccwM = 0 ; upccwM < s . length ( ) ; upccwM ++ ) count [ s . charAt ( upccwM ) - 97 ] ++ ; for ( int upccwM = 0 ; upccwM < 26 ; upccwM ++ ) { if ( count [ upccwM ] % 2 == 1 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class umdC { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { while ( true ) { int UmdFbspr = sc . nextInt ( ) ; int sum = 0 ; if ( UmdFbspr == 0 ) { break ; } int [ ] scores = new int [ UmdFbspr ] ; 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 / UmdFbspr ; for ( int i = 0 ; i < scores . length ; i ++ ) { double x = Math . pow ( ( scores [ i ] - average ) , 2 ) ; y = x + y ; } variance = y / UmdFbspr ; System . out . println ( Math . sqrt ( variance ) ) ; } } } } import java . io . * ; public class TcgfXxyt { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] line = br . readLine ( ) . split ( " " ) ; int TcgfUuk = Integer . parseInt ( line [ 0 ] ) ; int c = Integer . parseInt ( line [ 1 ] ) ; int [ ] [ ] sheet = new int [ TcgfUuk + 1 ] [ c + 1 ] ; for ( int i = 0 ; i < TcgfUuk ; 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 [ TcgfUuk ] [ c ] += a [ j ] ; sheet [ i ] [ c ] += a [ j ] ; sheet [ TcgfUuk ] [ j ] += a [ j ] ; } } for ( int i = 0 ; i <= TcgfUuk ; 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 HldwyQcgu { Scanner sc = new Scanner ( System . in ) ; final int HldwyO = 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 LxattyUnsq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String W = scan . next ( ) ; String end = " END_OF_TEXT " ; int lxattyEmsy = 0 ; for ( ; ; ) { String T = scan . next ( ) ; if ( T . equals ( end ) ) { break ; } else if ( T . equalsIgnoreCase ( W ) ) { lxattyEmsy ++ ; } } System . out . println ( lxattyEmsy ) ; } } import java . util . Scanner ; public class RydwyeIenq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RydwyeOv = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; String S = " " ; if ( 2 * RydwyeOv <= Y && Y <= 4 * RydwyeOv && Y % 2 == 0 ) { S = " Yes " ; } else { S = " No " ; } System . out . println ( S ) ; } } import java . util . Scanner ; class TjjhHkmx { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tjjhXr = scan . nextInt ( ) ; int [ ] h = new int [ tjjhXr ] ; for ( int i = 0 ; i < tjjhXr ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } int ans = 0 ; int len = 0 ; for ( int i = 0 ; i < tjjhXr - 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 EuonQlmcak { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double EuonZsk = sc . nextDouble ( ) ; sc . close ( ) ; double l = EuonZsk / 3 ; System . out . println ( Math . pow ( l , 3 ) ) ; } } import java . util . * ; public class ujefqOtx { 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 UjefqWv = 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 ] ) { UjefqWv ++ ; } } System . out . println ( UjefqWv ) ; } } import java . util . Scanner ; public class LpkoRp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LpkoP = sc . nextInt ( ) ; int count = 0 ; int [ ] flag = new int [ 101 ] ; for ( int i = 0 ; i < LpkoP ; 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 EzjiXy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ezjiSmnw = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; for ( int i = 0 ; i < M ; i ++ ) { ezjiSmnw -= sc . nextInt ( ) ; } if ( ezjiSmnw < 0 ) { System . out . println ( - 1 ) ; } else System . out . println ( ezjiSmnw ) ; } } import java . io . IOException ; public class FwmxNgf { public static void main ( String [ ] args ) throws IOException { int fwmxFn = 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 ) { fwmxFn |= 1 ; } else if ( num < 2 ) { fwmxFn |= 2 ; } else if ( num < 3 ) { fwmxFn |= 4 ; } else if ( num < 4 ) { fwmxFn |= 8 ; } else if ( num < 5 ) { fwmxFn |= 16 ; } else if ( num < 6 ) { fwmxFn |= 32 ; } else if ( num < 7 ) { fwmxFn |= 64 ; } else if ( num < 8 ) { fwmxFn |= 128 ; } else { over ++ ; } if ( buf == '\n' ) break ; } int count = Integer . bitCount ( fwmxFn ) ; int max = count + over ; if ( count == 0 ) count = 1 ; System . out . print ( count + " " + max ) ; } } import java . util . Scanner ; public class OnoDw { public static void main ( String [ ] args ) throws Exception { Scanner s = new Scanner ( System . in ) ; String onoFx = s . next ( ) ; onoFx = onoFx . replaceAll ( " eraser " , " " ) ; onoFx = onoFx . replaceAll ( " erase " , " " ) ; onoFx = onoFx . replaceAll ( " dreamer " , " " ) ; onoFx = onoFx . replaceAll ( " dream " , " " ) ; System . out . println ( onoFx . 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 trzLp { 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 TrzRae = Integer . parseInt ( line ) ; StringTokenizer tokens ; for ( int i = 0 ; i < TrzRae ; 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 qxfjnCce { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int QxfjnYsg = in . nextInt ( ) ; int [ ] a = new int [ QxfjnYsg ] ; for ( int i = 0 ; i < QxfjnYsg ; i ++ ) { a [ i ] = in . nextInt ( ) ; } int [ ] dp = new int [ QxfjnYsg ] ; int max = - 1 ; for ( int i = QxfjnYsg - 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 OszlZcyi { public static int getCvalue ( int n , int m ) { if ( n < 2 ) { return 0 ; } else { int oszlTx = n - m ; int a = 1 ; while ( n > oszlTx ) { 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 RqlOvpvy { 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 MhcOyqy { 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 MhcQpw = 0 ; MhcQpw < ary . length ; MhcQpw ++ ) { list . add ( new Integer ( ary [ MhcQpw ] ) ) ; } Collections . reverse ( list ) ; for ( int MhcQpw = 0 ; MhcQpw < list . size ( ) ; MhcQpw ++ ) { System . out . print ( list . get ( MhcQpw ) ) ; if ( MhcQpw == list . size ( ) - 1 ) { System . out . println ( ) ; } else { System . out . print ( " " ) ; } } } } import java . util . * ; public class LxqZied { public static void main ( String [ ] args ) { Scanner sp = new Scanner ( System . in ) ; int lxqDswx = sp . nextInt ( ) ; int b = sp . nextInt ( ) ; int l = 0 ; int n = 0 ; if ( lxqDswx < b ) { l = b ; } else { l = lxqDswx ; } for ( int k = 0 ; k < l ; k ++ ) { if ( Math . abs ( lxqDswx - 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 BybkpGlw { static int bybkpFw = 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]+ " ) ; bybkpFw = Integer . parseInt ( nyuryokuStr [ 0 ] ) ; weight = Integer . parseInt ( nyuryokuStr [ 1 ] ) ; if ( bybkpFw == 0 && weight == 0 ) { zeroFlag = false ; } else { for ( int h = 0 ; h < bybkpFw ; h ++ ) { for ( int w = 0 ; w < weight ; w ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } line = br . readLine ( ) ; } } } import java . util . * ; class QxlfUicpnj { 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 QxlfI = 0 ; if ( s1 . equals ( t1 ) ) { QxlfI += 1 ; } else { QxlfI += 0 ; } if ( s2 . equals ( t2 ) ) { QxlfI += 1 ; } else { QxlfI += 0 ; } if ( s3 . equals ( t3 ) ) { QxlfI += 1 ; } else { QxlfI += 0 ; } System . out . println ( QxlfI ) ; } } import java . util . * ; import java . io . * ; public class czoniA { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int CzoniGzpwh = scan . nextInt ( ) ; int max = 0 ; int ans = 0 ; int cnt = 0 ; for ( int i = 1 ; i <= CzoniGzpwh ; 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 sjoeBj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SjoeXv = sc . nextInt ( ) ; PriorityQueue < Integer > queue = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < SjoeXv ; i ++ ) { queue . add ( sc . nextInt ( ) ) ; } int sum = 0 ; for ( int i = 0 ; i < SjoeXv - 1 ; i ++ ) { sum += queue . poll ( ) ; } System . out . println ( queue . poll ( ) < sum ? " Yes " : " No " ) ; } } import java . util . Scanner ; class SvfTkil { 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 SvfWu = 0 ; SvfWu < t . length ( ) ; SvfWu ++ ) { if ( c [ 0 ] == al [ SvfWu ] ) { System . out . println ( al [ SvfWu + 1 ] ) ; } } } } import java . io . * ; import java . lang . Math ; class HtnhLg { public static void main ( String [ ] args ) throws IOException { double HtnhVbh , s , l ; InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String buf = br . readLine ( ) ; HtnhVbh = Double . parseDouble ( buf ) ; s = HtnhVbh * HtnhVbh * Math . PI ; l = 2 * HtnhVbh * Math . PI ; System . out . printf ( " %.6f %.6f \n " , s , l ) ; } } import java . util . * ; public class AqruawUomy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String ans = " " ; for ( char aqruawZ : S . toCharArray ( ) ) { if ( aqruawZ == '0' ) { ans += " 0 " ; } else if ( aqruawZ == '1' ) { ans += " 1 " ; } else if ( aqruawZ == 'B' && ans . length ( ) == 0 ) { continue ; } else { ans = ans . substring ( 0 , ans . length ( ) - 1 ) ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . math . * ; class xfeyxT { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String XfeyxOkeda = sc . next ( ) ; String ans = " " ; if ( XfeyxOkeda . 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 npeXx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NpeWma = Integer . parseInt ( sc . next ( ) ) ; int ex = Integer . parseInt ( sc . next ( ) ) ; int [ ] teki = new int [ NpeWma ] ; for ( int i = 0 ; i < NpeWma ; i ++ ) { teki [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( teki ) ; NpeWma -= ex ; long res = 0L ; for ( int i = 0 ; i < NpeWma ; 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 YwiEvoe { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int YwiF = scanner . nextInt ( ) ; int routeCnt = scanner . nextInt ( ) ; Map < Integer , Integer > map = initMap ( YwiF ) ; 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 YwiF ) { Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 1 ; i <= YwiF ; i ++ ) { map . put ( i , 0 ) ; } return map ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class NhmoRf { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int nhmoAvyg = Integer . parseInt ( br . readLine ( ) ) ; String [ ] tmpArray = br . readLine ( ) . split ( " " ) ; int [ ] input = new int [ nhmoAvyg ] ; for ( int i = 0 ; i < nhmoAvyg ; i ++ ) { input [ i ] = Integer . parseInt ( tmpArray [ i ] ) ; } int target = 1 ; int length = 0 ; for ( int i = 0 ; i < nhmoAvyg ; i ++ ) { if ( input [ i ] == target ) { target ++ ; length ++ ; } } System . out . println ( length > 0 ? nhmoAvyg - length : - 1 ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class SzmoZm { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String str ; String [ ] arr ; int SzmoVe ; int j ; while ( ( str = br . readLine ( ) ) != null ) { arr = str . split ( " " ) ; SzmoVe = Integer . parseInt ( arr [ 0 ] ) ; j = Integer . parseInt ( arr [ 1 ] ) ; if ( SzmoVe == 0 && j == 0 ) { break ; } if ( SzmoVe <= 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 OcmLon { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ocmVjk = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int [ ] n = new int [ 5 ] ; int count = 0 ; int temp = 0 ; for ( int i = ocmVjk ; 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 sktU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SktWdq = 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 [ SktWdq ] ; for ( int i = 0 ; i < SktWdq ; 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 JxwfuvHemle { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JxwfuvZtc = sc . nextInt ( ) ; int q = JxwfuvZtc ; int num = 0 ; while ( q > 0 ) { num += q % 10 ; q = q / 10 ; } if ( JxwfuvZtc % 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 YopdyPw { 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 YopdyPw { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int YopdyM = in . nextInt ( ) ; int q = in . nextInt ( ) ; int r = in . nextInt ( ) ; out . println ( Math . min ( Math . min ( YopdyM + q , YopdyM + r ) , q + r ) ) ; } } static class YopdyPw { 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 GdsFfv { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int GdsE = scanner . nextInt ( ) ; int N6 = GdsE / 100000 % 10 ; int N5 = GdsE / 10000 % 10 ; int N4 = GdsE / 1000 % 10 ; int N3 = GdsE / 100 % 10 ; int N2 = GdsE / 10 % 10 ; int result = 0 ; if ( N6 == 1 ) { result = 90909 ; } else if ( N5 != 0 ) { result = ( GdsE - 9999 ) + 909 ; } else if ( N4 != 0 ) { result = 909 ; } else if ( N3 != 0 ) { result = ( GdsE - 99 ) + 9 ; } else if ( N2 != 0 ) { result = 9 ; } else { result = GdsE ; } 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 VejblAi { static final int VejblBo = 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 CxekFti { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int CxekVd = scan . nextInt ( ) ; scan . close ( ) ; String str = String . valueOf ( CxekVd ) ; 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 KgrfZb { public static void main ( String [ ] args ) throws Exception { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int KgrfB = Integer . parseInt ( br . readLine ( ) ) ; Map < String , Integer > map = new TreeMap < > ( ) ; int max = 0 ; for ( int i = 0 ; i < KgrfB ; 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 NfmobaXivt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NfmobaE = sc . nextInt ( ) ; String ans = " No " ; int jdg = NfmobaE % 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 XfuAufb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xfuQx = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; String ans = " NO " ; if ( xfuQx * b * c == 5 * 7 * 5 ) ans = " YES " ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . StringTokenizer ; public class KsiasYh { 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 KsiasUoc = nin ( ) ; boolean res = false ; int c = 0 ; for ( int i = 0 ; i < KsiasUoc ; ++ 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 YxenVaj { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int yxenAi = Integer . parseInt ( br . readLine ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] s ; int a , b , c ; for ( int i = 0 ; i < yxenAi ; ++ 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 LaigwgMms { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { int laigwgAgd = Integer . parseInt ( br . readLine ( ) ) ; if ( laigwgAgd == 0 ) { break ; } int [ ] su = new int [ laigwgAgd ] ; 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 / laigwgAgd ; double result = 0 ; for ( int i = 0 ; i < laigwgAgd ; i ++ ) { result += ( Math . pow ( ( su [ i ] - avg ) , 2 ) / laigwgAgd ) ; } System . out . println ( Math . sqrt ( result ) ) ; } } } import java . util . * ; class hnsmAmd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long HnsmGfxdy = sc . nextLong ( ) ; long [ ] A = new long [ ( int ) HnsmGfxdy ] ; int k = 1 ; int ans = 0 ; for ( int i = 0 ; i < HnsmGfxdy ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < HnsmGfxdy ; i ++ ) { if ( A [ i ] == k ) { k ++ ; } else { ans ++ ; } } if ( ans == HnsmGfxdy ) { ans = - 1 ; } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; public class wtkrPac { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WtkrPysri = Integer . parseInt ( sc . next ( ) ) ; int x = WtkrPysri ; int num = 0 ; while ( x > 0 ) { num += x % 10 ; x /= 10 ; } if ( WtkrPysri % num == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class hmrlgPdk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HmrlgVoyy = sc . nextInt ( ) ; int cnt = 0 ; boolean isWin = false ; for ( int i = 0 ; i < HmrlgVoyy ; 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 DmrtbYpthf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int DmrtbMwh = scan . nextInt ( ) ; int [ ] a = new int [ DmrtbMwh ] ; int max = Integer . MIN_VALUE ; int subMax = Integer . MIN_VALUE ; for ( int i = 0 ; i < DmrtbMwh ; 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 < DmrtbMwh ; i ++ ) { if ( a [ i ] == max ) { System . out . println ( subMax ) ; } else { System . out . println ( max ) ; } } } } import java . util . Scanner ; public class WhtfUvoak { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int WhtfPi = sc . nextInt ( ) ; System . out . println ( ( WhtfPi + 2 - 1 ) / 2 ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class HflInrr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hflXv = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] D = new int [ K ] ; int [ ] A = new int [ hflXv + 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 ( hflXv - count ) ; } } public class MzrDytp { public static void main ( String [ ] args ) { java . util . Scanner scan = new java . util . Scanner ( System . in ) ; int mzrLjfp , b , c , d , e ; long f ; mzrLjfp = scan . nextInt ( ) ; d = - 1000000 ; e = 1000000 ; f = 0 ; if ( 0 <= mzrLjfp && mzrLjfp <= 10000 ) { for ( b = 1 ; b <= mzrLjfp ; 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 JyblOdr { 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 JyblNp = 0 ; JyblNp < oneline . length ; JyblNp ++ ) { data [ JyblNp ] = Integer . parseInt ( oneline [ JyblNp ] ) ; } int area = data [ 0 ] * data [ 1 ] ; int length = 2 * ( data [ 0 ] + data [ 1 ] ) ; System . out . println ( area + " " + length ) ; } } import java . util . Scanner ; public class OlaZvngop { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int OlaIxt = scn . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= OlaIxt ; i ++ ) { for ( int j = 1 ; j <= OlaIxt ; j ++ ) { for ( int k = 1 ; k <= OlaIxt ; 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 XmdjhMsr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XmdjhWy = 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 >= XmdjhWy && temp <= r ) { count ++ ; } } } } System . out . println ( count ) ; } } import java . util . * ; public class LsmavRvjxvv { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] tokens = in . nextLine ( ) . split ( " " ) ; in . close ( ) ; int LsmavFyb = 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 ( LsmavFyb > min ) { result -= 1 ; } if ( B < max ) { result -= 1 ; } System . out . println ( result ) ; } } import java . util . * ; public class FixfzaJm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long fixfzaU = scan . nextLong ( ) ; long a = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long c = a + b ; long d = fixfzaU % c ; if ( ( a == 0 ) || ( c == 0 ) ) { System . out . println ( " 0 " ) ; return ; } long g = ( long ) ( fixfzaU - d ) / c ; if ( g == 0 ) { if ( fixfzaU <= a ) { System . out . println ( fixfzaU ) ; } 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 ThoDjaa { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { Scanner scanner = new Scanner ( System . in ) ; int thoRuu = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; if ( thoRuu < 1 || thoRuu > 9 || B < 1 || B > 9 ) { System . out . println ( - 1 ) ; return ; } System . out . println ( thoRuu * B ) ; } } import java . util . Scanner ; public class QkuwHag { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qkuwP = sc . nextInt ( ) , n = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; if ( n == 100 ) n ++ ; sb . append ( n ) ; for ( int i = 0 ; i < qkuwP ; 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 OekZe { 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 OekZe { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long oekDl = in . nextLong ( ) ; long base = 100 ; long year = 1 ; while ( true ) { base += Math . floor ( base / 100 ) ; if ( oekDl <= base ) { out . println ( year ) ; return ; } else { year ++ ; } } } } } import java . util . Scanner ; public class yerrQfl { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; char [ ] S = scanner . next ( ) . toCharArray ( ) ; for ( int YerrZlatn = 0 ; YerrZlatn < S . length ; YerrZlatn ++ ) { if ( ( YerrZlatn + 1 ) % 2 == 1 ) { if ( S [ YerrZlatn ] == 'L' ) { System . out . println ( " No " ) ; return ; } } else { if ( S [ YerrZlatn ] == 'R' ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class BkrxrdOs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bkrxrdJpjc = 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 ; bkrxrdJpjc > 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 ] > bkrxrdJpjc - 1 ) count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class jffgFu { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int JffgDzkkv = s . nextInt ( ) ; System . out . println ( ( double ) JffgDzkkv * JffgDzkkv * JffgDzkkv / 27 ) ; s . close ( ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class TpwtbjAer { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TpwtbjPx = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < TpwtbjPx ; i ++ ) { map . put ( i , sc . nextInt ( ) ) ; } int cnt = 0 ; cnt += map . get ( 0 ) ; for ( int i = 1 ; i < TpwtbjPx ; 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 glqIrv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GlqNym = 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 [ GlqNym ] ; int t = 0 ; for ( int i = 1 ; i < GlqNym ; ++ 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 FycjeTa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FycjeS = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( FycjeS > 9 || b > 9 ? " -1 " : FycjeS * b ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class HfjzwHhwr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String hfjzwFaux = sc . nextLine ( ) ; System . out . println ( " 2018 " + hfjzwFaux . substring ( 4 ) ) ; } } import java . util . Scanner ; public class UyilnpCpaoi { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int UyilnpU = sc . nextInt ( ) ; int [ ] a = new int [ UyilnpU ] ; for ( int i = 0 ; i < UyilnpU ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } printArray ( a ) ; for ( int i = 1 ; i < UyilnpU ; 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 WfeatkBazx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String wfeatkB = sc . next ( ) ; if ( wfeatkB . equals ( " SSS " ) ) { System . out . println ( 0 ) ; return ; } if ( wfeatkB . equals ( " RRR " ) ) { System . out . println ( 3 ) ; return ; } if ( wfeatkB . equals ( " RRS " ) || wfeatkB . equals ( " SRR " ) ) { System . out . println ( 2 ) ; return ; } System . out . println ( 1 ) ; } } import java . util . * ; public class GkembnDnckq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GkembnKzh = sc . nextInt ( ) ; PriorityQueue < Double > q = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < GkembnKzh ; 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 VgmowRrgylf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VgmowHgi = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; int ans = 0 ; for ( int i = 0 ; i < VgmowHgi ; i ++ ) { String s = sc . next ( ) ; if ( ! set . contains ( s ) ) { set . add ( s ) ; ans ++ ; } } System . out . print ( ans ) ; } } import java . util . Scanner ; public class MoyVsuj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double MoyU = sc . nextInt ( ) ; double b = sc . nextInt ( ) ; double c = sc . nextInt ( ) ; double d = sc . nextInt ( ) ; double tturn = Math . ceil ( c / b ) ; double aturn = Math . ceil ( MoyU / 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 SorGvtg { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int SorG = 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 <= SorG && y - r >= 0 && y + r <= H ) ? " Yes " : " No " ) ; } } import java . util . * ; public class hlmoX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HlmoVmlse = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; double ans = 100001.0 ; double bef ; int answer = 0 ; for ( int i = 0 ; i < HlmoVmlse ; 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 XpdrbhRb { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int xpdrbhTcwa = Integer . parseInt ( sc . next ( ) ) ; List < Integer > a = new ArrayList < > ( ) ; a . add ( xpdrbhTcwa ) ; 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 DunCwpt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DunHn = sc . nextInt ( ) ; int [ ] d = new int [ DunHn ] ; for ( int i = 0 ; i < DunHn ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; int ans = 1 ; for ( int i = 1 ; i < DunHn ; i ++ ) { if ( d [ i - 1 ] != d [ i ] ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class yvvVwp { 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 YvvBoqh = 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 >= YvvBoqh ) { 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 qkrseKl { static class qkrseKl { 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 QkrseWvjn = " " ; try { QkrseWvjn = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return QkrseWvjn ; } 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 bmlheLt { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int BmlheZku = sc . nextInt ( ) ; String [ ] str = new String [ BmlheZku ] ; for ( int i = 0 ; i < BmlheZku ; 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 UrkpoNzep { 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 urkpoYx ; for ( int i = 0 ; i < a . length ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( a [ i ] < a [ j ] ) { urkpoYx = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = urkpoYx ; } } } urkpoYx = a [ 1 ] - a [ 0 ] ; urkpoYx += a [ 2 ] - a [ 1 ] ; System . out . println ( urkpoYx ) ; } } import java . util . Scanner ; public class YmtWei { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ymtM = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int count = 0 ; if ( ymtM == b ) { count ++ ; } if ( b == c ) { count ++ ; } if ( c == ymtM ) { count ++ ; } System . out . println ( count == 1 ? " Yes " : " No " ) ; } } import java . util . * ; public class XrcZujwt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Integer n = Integer . valueOf ( sc . nextLine ( ) ) ; String XrcKf = sc . nextLine ( ) ; Map < Integer , Integer > vList = str2List ( XrcKf ) ; 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 GewygKq { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int gewygHhuw = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] m = new int [ gewygHhuw ] ; int minCost = Integer . MAX_VALUE ; int total = 0 ; for ( int i = 0 ; i < gewygHhuw ; i ++ ) { m [ i ] = sc . nextInt ( ) ; minCost = Math . min ( minCost , m [ i ] ) ; total += m [ i ] ; } System . out . println ( ( x - total ) / minCost + gewygHhuw ) ; } } import java . util . Scanner ; public class wfcbKc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; int WfcbRh = Integer . parseInt ( String . join ( " " , S . split ( " / " ) ) ) ; System . out . println ( WfcbRh <= 20190430 ? " Heisei " : " TBD " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class gomdhEnd { 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 gomdhEnd { int GomdhHeoo ; int cnt ; public void init ( ) { GomdhHeoo = 0 ; cnt = 0 ; } public void readHead ( String str ) { String [ ] strArr = str . split ( " " ) ; GomdhHeoo = 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 < GomdhHeoo ; } public void readBody ( String str ) { cnt ++ ; } public void solve ( ) { } } import java . util . ArrayList ; import java . util . Scanner ; class CntBo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cntB = sc . nextInt ( ) ; int firstPoint = sc . nextInt ( ) ; ArrayList < Integer > playerPoint = new ArrayList < > ( ) ; for ( int i = 0 ; i < cntB ; 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 < cntB ; i ++ ) { System . out . println ( firstPoint - cnt + playerPoint . get ( i ) > 0 ? " Yes " : " No " ) ; } } } import java . math . BigDecimal ; import java . util . Scanner ; public class PzcdVujtrc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long PzcdQ = sc . nextLong ( ) ; BigDecimal ans = new BigDecimal ( 1 ) ; BigDecimal over = new BigDecimal ( 1000000000000000000L ) ; boolean ov = false ; boolean ze = false ; for ( int i = 0 ; i < PzcdQ ; 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 CfbvhmPiwwzg { 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 CfbvhmZhl : chars ) { if ( CfbvhmZhl == '1' ) { System . out . print ( 9 ) ; } else { System . out . print ( 1 ) ; } } } } import java . util . Scanner ; class tayfpcE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TayfpcPu = sc . nextInt ( ) ; String temp = String . valueOf ( TayfpcPu / 100 ) ; int tem = Integer . parseInt ( temp + temp + temp ) ; if ( TayfpcPu <= tem ) { System . out . println ( tem ) ; } else { System . out . println ( tem + 111 ) ; } } } import java . util . Scanner ; public class MxqjGbko { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mxqjAks = 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 ) == mxqjAks ) { System . out . println ( price ) ; f ++ ; break ; } } if ( f == 0 ) { System . out . println ( - 1 ) ; } } } import java . util . * ; public class bhpcsmOma { public static void main ( String [ ] args ) { Scanner read = new Scanner ( System . in ) ; int BhpcsmLpa = read . nextInt ( ) ; int [ ] d = new int [ BhpcsmLpa ] ; d [ 0 ] = read . nextInt ( ) - 1 ; boolean ban = true ; for ( int i = 1 ; i < BhpcsmLpa ; 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 KafGbd { 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 KafI = 0 ; KafI < a . length ; KafI ++ ) { if ( Character . isLowerCase ( a [ KafI ] ) ) System . out . print ( Character . toUpperCase ( a [ KafI ] ) ) ; else if ( Character . isUpperCase ( a [ KafI ] ) ) System . out . print ( Character . toLowerCase ( a [ KafI ] ) ) ; else System . out . print ( a [ KafI ] ) ; if ( KafI == a . length - 1 ) System . out . println ( ) ; } } } import java . util . Scanner ; public class VskkYxig { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner scan = new Scanner ( System . in ) ; String W = scan . nextLine ( ) . toLowerCase ( ) ; int vskkFtyg = 0 ; while ( scan . hasNext ( ) ) { String t = scan . next ( ) ; if ( t . equals ( " END_OF_TEXT " ) ) break ; t = t . toLowerCase ( ) ; if ( t . equals ( W ) ) vskkFtyg ++ ; } System . out . println ( vskkFtyg ) ; System . exit ( 0 ) ; } } import java . util . * ; public class DmpqPunram { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DmpqE = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < DmpqE ; i ++ ) { int x = sc . nextInt ( ) ; while ( x > 0 && x % 2 == 0 ) { count ++ ; x /= 2 ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class HchfHcauji { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long HchfHq , b , g , l ; while ( sc . hasNext ( ) ) { HchfHq = sc . nextLong ( ) ; b = sc . nextLong ( ) ; g = gcd ( HchfHq , b ) ; l = ( HchfHq * b ) / g ; System . out . println ( g + " " + l ) ; } } private static long gcd ( long HchfHq , long b ) { if ( HchfHq == 0 ) return b ; else if ( b == 0 ) return HchfHq ; return gcd ( b , HchfHq % b ) ; } } import java . io . * ; import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class zcikRhr { 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 ZcikHwsvw = Integer . parseInt ( s [ 0 ] ) ; int B = Integer . parseInt ( s [ 1 ] ) ; String U = br . readLine ( ) ; if ( U . equals ( S ) ) out . println ( ( ZcikHwsvw - 1 ) + " " + B ) ; else out . println ( ZcikHwsvw + " " + ( B - 1 ) ) ; } } import java . util . Scanner ; class xgciD { public static void main ( String [ ] a ) { Scanner scan = new Scanner ( System . in ) ; int XgciEtkl = scan . nextInt ( ) ; int debt = 100000 ; for ( int i = 0 ; i < XgciEtkl ; 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 ZzgtZzz { static int ZzgtAcp ; static int [ ] a ; private static void init ( ) { Scanner scanner = new Scanner ( System . in ) ; ZzgtAcp = scanner . nextInt ( ) ; a = new int [ ZzgtAcp ] ; for ( int i = 0 ; i < ZzgtAcp ; i ++ ) a [ i ] = scanner . nextInt ( ) ; scanner . close ( ) ; } private static boolean check ( ) { boolean ok = true ; for ( int i = 0 ; i < ZzgtAcp ; 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 < ZzgtAcp ; j ++ ) { a [ j ] = a [ j ] / 2 ; } } else { break ; } } System . out . println ( count ) ; } } import java . util . Scanner ; class VnzmOj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; double VnzmVau = Double . parseDouble ( s1 ) ; double s = Math . PI * VnzmVau * VnzmVau ; double l = Math . PI * ( VnzmVau + VnzmVau ) ; System . out . println ( String . format ( " %1$3f " , s ) + " " + String . format ( " %1$3f " , l ) ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class OpwwtDy { 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 OpwwtTpx = Integer . parseInt ( st . nextToken ( ) ) ; int y = Integer . parseInt ( st . nextToken ( ) ) ; int z = Integer . parseInt ( st . nextToken ( ) ) ; int temp = OpwwtTpx ; OpwwtTpx = y ; y = temp ; temp = OpwwtTpx ; OpwwtTpx = z ; z = temp ; System . out . println ( OpwwtTpx + " " + y + " " + z ) ; } } import java . util . * ; public class QkkNia { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; int QkkNwp = keyboard . nextInt ( ) ; int Y = keyboard . nextInt ( ) ; int turu = 2 ; int kame = 4 ; String ans = " No " ; for ( int i = 0 ; i < QkkNwp + 1 ; i ++ ) { if ( i * turu + ( QkkNwp - i ) * kame == Y ) { ans = " Yes " ; } } System . out . println ( ans ) ; keyboard . close ( ) ; } } import java . util . Scanner ; public class cqqoQh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String t ; String h ; int CqqoUqaz = 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 ) { CqqoUqaz += 3 ; } else if ( t . compareTo ( h ) < 0 ) { h_point += 3 ; } else { CqqoUqaz += 1 ; h_point += 1 ; } } System . out . println ( CqqoUqaz + " " + h_point ) ; } } import java . util . Scanner ; public class WrzwjcTrkj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String line = sc . next ( ) ; if ( line . equals ( " - " ) ) { break ; } ; int wrzwjcHnlj = line . length ( ) ; char [ ] str = new char [ wrzwjcHnlj ] ; for ( int i = 0 ; i < wrzwjcHnlj ; 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 [ wrzwjcHnlj ] ; System . arraycopy ( str , 0 , hoge , 0 , wrzwjcHnlj ) ; for ( int j = 0 ; j < wrzwjcHnlj ; j ++ ) { str [ j ] = hoge [ ( j + h ) % wrzwjcHnlj ] ; } } for ( int k = 0 ; k < wrzwjcHnlj ; 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 DngdNngxe { 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 DngdNngxe { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int DngdG = in . nextInt ( ) ; int x = in . nextInt ( ) ; int d = 0 ; int best = 1 ; for ( int i = 0 ; i < DngdG ; i ++ ) { d += in . nextInt ( ) ; if ( d > x ) { best = i + 1 ; break ; } if ( i == DngdG - 1 ) best = DngdG + 1 ; } out . println ( best ) ; } } } import java . util . Scanner ; public class gccvohLkn { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int GccvohNdi = in . nextInt ( ) ; int i = 1000 ; while ( i < GccvohNdi ) { i += 1000 ; } System . out . println ( i - GccvohNdi ) ; } } import java . util . * ; public class RkhkxZdy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rkhkxZhpw = sc . nextInt ( ) ; int [ ] a = new int [ rkhkxZhpw ] ; for ( int i = 0 ; i < rkhkxZhpw ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; boolean is_odd = false ; while ( ! is_odd ) { for ( int i = 0 ; i < rkhkxZhpw ; 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 HpeGll { public static void main ( String [ ] args ) throws IOException { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String hpeRc = br . readLine ( ) ; StringBuffer sb = new StringBuffer ( hpeRc ) ; System . out . println ( sb . reverse ( ) ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class gxpyYi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int GxpyKkmpd = scanner . nextInt ( ) ; String s ; HashSet < String > list = new HashSet < String > ( GxpyKkmpd ) ; for ( int i = 0 ; i < GxpyKkmpd ; i ++ ) { s = scanner . next ( ) ; list . add ( s ) ; } System . out . println ( list . size ( ) ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class KqjtRrx { public static void main ( String [ ] args ) { Scanner f = new Scanner ( System . in ) ; while ( true ) { int KqjtN = f . nextInt ( ) ; if ( KqjtN == 0 ) break ; BigDecimal [ ] entries = new BigDecimal [ KqjtN ] ; BigDecimal sum = new BigDecimal ( 0 ) ; BigDecimal std = new BigDecimal ( 0 ) ; for ( int i = 0 ; i < KqjtN ; i ++ ) { BigDecimal temp = new BigDecimal ( f . nextInt ( ) ) ; entries [ i ] = temp ; sum = sum . add ( temp ) ; } BigDecimal average = sum . divide ( new BigDecimal ( KqjtN ) , 6 , BigDecimal . ROUND_HALF_UP ) ; for ( int i = 0 ; i < KqjtN ; i ++ ) { std = std . add ( entries [ i ] . subtract ( average ) . pow ( 2 ) ) ; } System . out . println ( Math . sqrt ( std . divide ( new BigDecimal ( KqjtN ) , 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 SowsZt { 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 SowsZt { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String sowsDg = in . nextString ( ) ; out . println ( sowsDg . replaceAll ( " 1 " , " 2 " ) . replaceAll ( " 9 " , " 1 " ) . replaceAll ( " 2 " , " 9 " ) ) ; } } static class SowsZt { 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 qnshK { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] num = new int [ 3 ] ; for ( int QnshUzekh = 0 ; QnshUzekh < 3 ; QnshUzekh ++ ) { num [ QnshUzekh ] = scan . nextInt ( ) ; } int k = scan . nextInt ( ) ; Arrays . sort ( num ) ; for ( int QnshUzekh = 1 ; QnshUzekh <= k ; QnshUzekh ++ ) { num [ 2 ] *= 2 ; } int sum = 0 ; for ( int QnshUzekh = 0 ; QnshUzekh < 3 ; QnshUzekh ++ ) { sum += num [ QnshUzekh ] ; } System . out . println ( sum ) ; } } import java . lang . reflect . Array ; import java . util . * ; public class DqjhuSdo { static int dqjhuZ ; 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 HjndfCcikth { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int HjndfSw = scan . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= HjndfSw ; 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 IslhJhj { public static void main ( String [ ] arges ) { List < String > klist = new ArrayList < String > ( ) ; int islhPi = 0 ; Scanner sc = new Scanner ( System . in ) ; while ( islhPi < 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 jeqdrPwi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long JeqdrLp = scanner . nextLong ( ) ; String S = scanner . next ( ) ; scanner . close ( ) ; long ans = 1 ; for ( int i = 0 ; i < JeqdrLp - 1 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( i + 1 ) ) ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; class AfiFdkf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int afiDnf = Integer . parseInt ( sc . next ( ) ) ; int W = Integer . parseInt ( sc . next ( ) ) ; while ( afiDnf != 0 && W != 0 ) { if ( afiDnf > 300 || W > 300 ) break ; for ( int i = 0 ; i < afiDnf ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; afiDnf = Integer . parseInt ( sc . next ( ) ) ; W = Integer . parseInt ( sc . next ( ) ) ; } } } import java . util . Scanner ; class YmnvmnZz { public static void main ( String [ ] args ) { int YmnvmnK , H , x , y , r ; Scanner sc = new Scanner ( System . in ) ; YmnvmnK = sc . nextInt ( ) ; H = sc . nextInt ( ) ; x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; r = sc . nextInt ( ) ; if ( x + r > YmnvmnK || x - r < 0 ) { System . out . println ( " No " ) ; } else if ( y + r > H || y - r < 0 ) { System . out . println ( " No " ) ; } else if ( x > YmnvmnK || y > H ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; public class WywaCpnn { public static void main ( String [ ] args ) { Scanner sc1 = new Scanner ( System . in ) ; int WywaQh = sc1 . nextInt ( ) ; int b = sc1 . nextInt ( ) ; int max = WywaQh + b ; if ( max < WywaQh - b ) { max = WywaQh - b ; } if ( max < WywaQh * b ) { max = WywaQh * b ; } System . out . print ( max ) ; } } import java . util . Scanner ; public class NbtePy { void run ( ) { Scanner s = new Scanner ( System . in ) ; String W = s . next ( ) ; int nbteLbtc = 0 ; while ( true ) { String T = s . next ( ) ; if ( T . equals ( " END_OF_TEXT " ) ) break ; if ( W . compareToIgnoreCase ( T ) == 0 ) { nbteLbtc ++ ; } } System . out . println ( nbteLbtc ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; class DnbqkpIy { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int dnbqkpUu = sc . nextInt ( ) ; int [ ] ar = new int [ dnbqkpUu ] ; for ( int i = 0 ; i < dnbqkpUu ; 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 < dnbqkpUu ; 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 xmlsFjp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XmlsFhpgx = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] P = new int [ XmlsFhpgx ] ; for ( int i = 0 ; i < XmlsFhpgx ; 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 yboibgXeb { void reverse ( ) { Scanner s = new Scanner ( System . in ) ; int YboibgYjjcb = s . nextInt ( ) ; int [ ] a = new int [ YboibgYjjcb ] ; for ( int i = 0 ; i < YboibgYjjcb ; i ++ ) { a [ i ] = s . nextInt ( ) ; } for ( int i = YboibgYjjcb - 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 DmuSkj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dmuR = sc . nextInt ( ) ; int [ ] n = new int [ dmuR ] ; int [ ] m = new int [ dmuR ] ; for ( int i = 0 ; i < dmuR ; i ++ ) { n [ i ] = sc . nextInt ( ) ; m [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; for ( int i = 0 ; i < dmuR ; 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 ZtbenqFney { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] a = sc . next ( ) . toCharArray ( ) ; int ztbenqBiax = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( a [ i ] == '1' ) { ztbenqBiax += 1 ; } } System . out . print ( ztbenqBiax ) ; } } import java . util . * ; public class ugbUz { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int UgbAwb = 0 ; char p = '.' ; for ( char ch : sc . next ( ) . toCharArray ( ) ) { UgbAwb = ( ( p == '.' || p == 'S' ) && ch == 'R' ) ? 1 : UgbAwb ; if ( ch == 'R' && p == 'R' ) UgbAwb ++ ; p = ch ; } System . out . println ( UgbAwb ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { solve ( ) ; } } import java . util . Scanner ; public class vcjpbsEq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String VcjpbsOuv = sc . next ( ) ; if ( VcjpbsOuv . equals ( " AAA " ) || VcjpbsOuv . equals ( " BBB " ) ) { System . out . print ( " No " ) ; } else { System . out . print ( " Yes " ) ; } } } import java . util . Scanner ; public class hpclmoEh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int HpclmoVah ; int b ; HpclmoVah = scan . nextInt ( ) ; b = scan . nextInt ( ) ; sizeComparison ( HpclmoVah , b ) ; } public static void sizeComparison ( int HpclmoVah , int b ) { String i = " == " ; if ( HpclmoVah < b ) { i = " < " ; } else if ( HpclmoVah > b ) { i = " > " ; } System . out . println ( " a " + i + " b " ) ; } } import java . util . Scanner ; public class AzuVnu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long azuRmj = Integer . parseInt ( sc . next ( ) ) ; long B = Integer . parseInt ( sc . next ( ) ) ; System . out . print ( azuRmj * B / gcd ( azuRmj , 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 sovwafVt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String word ; String [ ] sen = new String [ 1000 ] ; int SovwafGz = 0 ; word = scan . next ( ) ; while ( true ) { sen [ SovwafGz ] = scan . next ( ) ; if ( sen [ SovwafGz ] . equals ( " END_OF_TEXT " ) ) break ; SovwafGz ++ ; } int ans = 0 ; int num = word . length ( ) ; ; for ( int j = 0 ; j < SovwafGz + 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 sijCji { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] numberArray = br . readLine ( ) . split ( " " ) ; int SijWuqjv = Integer . parseInt ( numberArray [ 0 ] ) ; int K = Integer . parseInt ( numberArray [ 1 ] ) ; String [ ] inputArray = br . readLine ( ) . split ( " " ) ; int [ ] priceArray = new int [ SijWuqjv ] ; for ( int i = 0 ; i < SijWuqjv ; 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 RummaeSjwn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rummaeQn = 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 == rummaeQn && b_tax == B ) { ans = i ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; public class VohukhIy { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int VohukhJiw = Integer . parseInt ( sc . nextLine ( ) ) ; String line = sc . nextLine ( ) ; String [ ] line1 = line . split ( " " ) ; int [ ] ary = new int [ VohukhJiw ] ; for ( int i = 0 ; i < VohukhJiw ; i ++ ) ary [ i ] = Integer . parseInt ( line1 [ i ] ) ; int [ ] ary1 = new int [ VohukhJiw ] ; for ( int i = 0 ; i < VohukhJiw ; i ++ ) ary1 [ ary [ i ] - 1 ] = i + 1 ; for ( int i = 0 ; i < VohukhJiw ; i ++ ) System . out . print ( ary1 [ i ] + " " ) ; } } import java . util . * ; import java . io . * ; public class CpwUzl { 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 CpwL = " " + nextInt ( ) ; if ( CpwL . 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 JeageQjr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String answer = " Heisei " ; int JeageU , month , day ; JeageU = Integer . parseInt ( s . substring ( 0 , 4 ) ) ; month = Integer . parseInt ( s . substring ( 5 , 7 ) ) ; if ( JeageU > 2019 ) answer = " TBD " ; if ( JeageU == 2019 && month >= 5 ) answer = " TBD " ; System . out . println ( answer ) ; } } import java . io . PrintStream ; import java . util . Scanner ; public class LwqpwXzsg { private static final PrintStream so = System . out ; private static final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int lwqpwC = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x <= lwqpwC ; x ++ ) { for ( int y = 0 ; y <= lwqpwC ; y ++ ) { int z = S - ( x + y ) ; if ( 0 <= z && z <= lwqpwC ) { count ++ ; } } } so . println ( count ) ; } } import java . util . Scanner ; class LmmPsb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int [ ] A = new int [ str . length ( ) ] ; for ( int LmmU = 0 ; LmmU < str . length ( ) ; LmmU ++ ) { A [ LmmU ] = str . charAt ( LmmU ) ; } 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 dkohdyF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DkohdyZimxr = sc . nextInt ( ) ; int h = 0 ; int m = 0 ; int s = 0 ; while ( DkohdyZimxr >= 3600 ) { DkohdyZimxr = DkohdyZimxr - 3600 ; h ++ ; } while ( DkohdyZimxr >= 60 ) { DkohdyZimxr = DkohdyZimxr - 60 ; m ++ ; } s = DkohdyZimxr ; System . out . println ( h + " : " + m + " : " + s ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class WcePondgl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WceRzr = sc . nextInt ( ) ; int [ ] arr = new int [ WceRzr ] ; for ( int i = 0 ; i < WceRzr ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; boolean isDistinct = true ; for ( int i = 1 ; i < WceRzr ; 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 AtqqlyLop { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int atqqlyWd = Integer . parseInt ( sc . next ( ) ) ; int [ ] numList = new int [ atqqlyWd ] ; for ( int i = 0 ; i < atqqlyWd ; i ++ ) { numList [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int r = 0 ; for ( int i = 0 ; i < atqqlyWd ; i ++ ) { for ( int j = i + 1 ; j < atqqlyWd ; j ++ ) { r += numList [ i ] * numList [ j ] ; } } System . out . println ( r ) ; } } import java . util . * ; class JytkdxImvbqt { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int JytkdxJnj = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = - 1 ; for ( int i = 12 ; i <= 1000 ; i ++ ) { if ( i * 8 / 100 == JytkdxJnj && 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 WqplviCgkr { private static final String WqplviFme = " 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 ( WqplviFme ) ) { tomorrow = WATHER_CLOUDY ; } else if ( today . equals ( WATHER_CLOUDY ) ) { tomorrow = WATHER_RAINY ; } else if ( today . equals ( WATHER_RAINY ) ) { tomorrow = WqplviFme ; } 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 XvnCj { static class XvnCj { 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 XvnSh = 1 ; while ( XvnSh -- > 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 JknmSug { private final static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int jknmOg = sc . nextInt ( ) ; long K = sc . nextInt ( ) ; long Q = sc . nextInt ( ) ; long [ ] array = new long [ jknmOg ] ; for ( int i = 0 ; i < Q ; i ++ ) { array [ sc . nextInt ( ) - 1 ] ++ ; } for ( int i = 0 ; i < jknmOg ; i ++ ) { if ( ( K + array [ i ] - Q ) > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; public class QvdqfFlu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qvdqfFh = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; char [ ] p = { 'A' , 'B' , 'C' } ; int idx = 0 ; int count = 0 ; for ( int i = 0 ; i < qvdqfFh ; 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 YodwoLkdsp { 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 YodwoK = Integer . parseInt ( st . nextToken ( ) ) ; long m = Integer . parseInt ( st . nextToken ( ) ) ; long gcd ; long lcm = YodwoK * m ; while ( YodwoK % m != 0 ) { long t = m ; m = YodwoK % m ; YodwoK = t ; } gcd = m ; lcm = lcm / gcd ; System . out . println ( gcd + " " + lcm ) ; } } catch ( Exception e ) { System . out . println ( " Exception! " ) ; } } } import java . util . Scanner ; public class ZpfUjm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZpfGe = sc . nextInt ( ) ; int a , b , c ; for ( int i = 0 ; i < ZpfGe ; 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 JfdfHmvfo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String JfdfCkj = sc . next ( ) ; StringBuilder sb = new StringBuilder ( JfdfCkj ) ; String ans = JfdfCkj . replace ( " eraser " , " " ) . replace ( " erase " , " " ) . replace ( " dreamer " , " " ) . replace ( " dream " , " " ) ; System . out . println ( ans . equals ( " " ) ? " YES " : " NO " ) ; } } import java . util . Scanner ; class XdyoOl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xdyoCk = sc . nextInt ( ) ; int [ ] height = new int [ xdyoCk ] ; for ( int i = 0 ; i < xdyoCk ; i ++ ) { height [ i ] = Integer . parseInt ( sc . next ( ) ) ; } boolean pos = true ; for ( int i = 0 ; i < xdyoCk - 1 ; i ++ ) { if ( height [ xdyoCk - i - 2 ] - height [ xdyoCk - i - 1 ] <= 0 ) { continue ; } else if ( height [ xdyoCk - i - 2 ] - height [ xdyoCk - i - 1 ] == 1 ) { height [ xdyoCk - 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 rtjW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RtjAa = Integer . parseInt ( sc . next ( ) ) ; int Y = Integer . parseInt ( sc . next ( ) ) ; int k = 0 ; PrintWriter out = new PrintWriter ( System . out ) ; for ( int i = 0 ; i <= RtjAa ; i ++ ) { for ( int j = 0 ; j <= RtjAa - i ; j ++ ) { k = RtjAa - 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 RgfuciVlwr { 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 KmxUihm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KmxNl = sc . nextInt ( ) ; HashMap < String , Long > map = new HashMap < > ( ) ; for ( int i = 0 ; i < KmxNl ; 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 ziurMx { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int ZiurFjoy = in . nextInt ( ) ; int [ ] d = new int [ ZiurFjoy ] ; for ( int i = 0 ; i < ZiurFjoy ; i ++ ) { d [ i ] = in . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < ZiurFjoy ; i ++ ) { for ( int j = i + 1 ; j < ZiurFjoy ; j ++ ) { sum += d [ i ] * d [ j ] ; } } System . out . println ( sum ) ; } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class QuxPsj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QuxSy = sc . nextInt ( ) ; Set < String > used = new HashSet < String > ( ) ; String s = sc . next ( ) ; used . add ( s ) ; for ( int i = 1 ; i < QuxSy ; 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 == QuxSy - 1 ) { System . out . println ( " Yes " ) ; } s = t ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class roilxtZa { public static void main ( String [ ] args ) throws Exception { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String [ ] array = reader . readLine ( ) . split ( " " ) ; int RoilxtDurr = Integer . parseInt ( array [ 0 ] ) ; int B = Integer . parseInt ( array [ 1 ] ) ; int C = Integer . parseInt ( array [ 2 ] ) ; System . out . println ( Math . max ( B + C - RoilxtDurr , 0 ) ) ; } } } import java . util . * ; public class sncykR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String word = sc . next ( ) ; String mae = " " ; String usiro = " " ; while ( ! word . equals ( " - " ) ) { int SncykJji = sc . nextInt ( ) ; for ( int i = 0 ; i < SncykJji ; 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 PoxzkqQu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int poxzkqWj = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { int button = 0 ; if ( poxzkqWj > B ) { sum += poxzkqWj ; poxzkqWj -= 1 ; } else { sum += B ; B -= 1 ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class HkdnziJse { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int HkdnziXgo = Integer . parseInt ( str ) ; str = scan . next ( ) ; int b = Integer . parseInt ( str ) ; if ( HkdnziXgo < b ) System . out . println ( " a < b " ) ; else if ( HkdnziXgo > b ) System . out . println ( " a > b " ) ; else if ( HkdnziXgo == b ) System . out . println ( " a == b " ) ; } } import java . util . Scanner ; public class fvrjrPsg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] result = new int [ 26 ] ; for ( int FvrjrBy = 0 ; FvrjrBy < result . length ; FvrjrBy ++ ) { result [ FvrjrBy ] = 0 ; } while ( sc . hasNext ( ) ) { String input = sc . nextLine ( ) ; for ( int FvrjrBy = 0 ; FvrjrBy < input . length ( ) ; FvrjrBy ++ ) { char ch = input . charAt ( FvrjrBy ) ; 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 FvrjrBy = 0 ; FvrjrBy < result . length ; FvrjrBy ++ ) { char alphabet = ( char ) ( FvrjrBy + 'a' ) ; System . out . println ( alphabet + " : " + result [ FvrjrBy ] ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class DsgxnqWh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DsgxnqNm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; while ( DsgxnqNm > 0 || c > 0 ) { c -= b ; if ( c <= 0 ) break ; DsgxnqNm -= d ; } if ( DsgxnqNm > 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . * ; import java . util . * ; public class hbmsqrUlm { 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 saipajQ { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int SaipajEuucn = stdIn . nextInt ( ) ; int [ ] d = new int [ SaipajEuucn ] ; for ( int i = 0 ; i < SaipajEuucn ; i ++ ) { d [ i ] = stdIn . nextInt ( ) ; } Arrays . sort ( d ) ; int count = 0 ; for ( int i = 0 ; i < SaipajEuucn ; 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 OevwEcykxg { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int OevwCvd = scn . nextInt ( ) ; ArrayList < Integer > element = new ArrayList < Integer > ( ) ; for ( int i = 1 ; ; ) { if ( i == 1 ) { element . add ( OevwCvd ) ; } else { if ( OevwCvd % 2 == 1 ) { OevwCvd = odd ( OevwCvd ) ; } else { OevwCvd = even ( OevwCvd ) ; } if ( element . indexOf ( OevwCvd ) == - 1 ) { element . add ( OevwCvd ) ; } 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 cxqhG { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int CxqhDyo = in . nextInt ( ) ; double side = ( double ) CxqhDyo / 3 ; System . out . println ( side * side * side ) ; } } import java . util . * ; public class JaujZss { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JaujVmi = sc . nextInt ( ) ; int [ ] value = new int [ JaujVmi ] ; for ( int i = 0 ; i < JaujVmi ; 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 mzkssIya { public static void main ( String [ ] args ) { int MzkssTzwjl ; int M ; int temp ; int sum = 0 ; int P ; ArrayList < Integer > A = new ArrayList < Integer > ( ) ; Scanner sc = new Scanner ( System . in ) ; MzkssTzwjl = sc . nextInt ( ) ; M = sc . nextInt ( ) ; int i ; for ( i = 0 ; i < MzkssTzwjl ; 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 FlgkrpQgla { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Integer int1 = scanner . nextInt ( ) ; Integer int2 = scanner . nextInt ( ) ; int FlgkrpChs = int1 * int2 ; System . out . println ( FlgkrpChs ) ; } } import java . util . * ; class BkudczWh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BkudczDv = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < BkudczDv ; 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 JprtnnJqdv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int jprtnnQ = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String u = sc . next ( ) ; if ( s . equals ( u ) ) jprtnnQ -- ; if ( t . equals ( u ) ) b -- ; System . out . println ( jprtnnQ + " " + b ) ; } } import java . util . * ; public class QwnglEoqg { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int qwnglHw = scn . nextInt ( ) ; int k = scn . nextInt ( ) ; int [ ] a = new int [ qwnglHw ] ; 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 BygiAa { 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 bygiB = 0 ; bygiB < 2 ; bygiB ++ ) { x [ bygiB ] = Integer . parseInt ( str2 [ bygiB ] ) ; } 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 PsxJe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double PsxA = scan . nextDouble ( ) ; double area = PsxA * PsxA * Math . PI ; double circumference = 2 * PsxA * Math . PI ; System . out . printf ( " %f %f \n " , area , circumference ) ; } } import java . util . Scanner ; import java . lang . Math ; class HyqNxfps { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] alp = s . toCharArray ( ) ; int HyqTtt = ( int ) ( alp [ 0 ] ) ; alp [ 0 ] = ( char ) ( HyqTtt + 1 ) ; System . out . print ( alp [ 0 ] ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; class YglGg { public static void main ( String [ ] args ) throws Exception { int [ ] antenna = new int [ 5 ] ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; for ( int yglPdnz = 0 ; yglPdnz < antenna . length ; yglPdnz ++ ) { antenna [ yglPdnz ] = 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 EyabotBxsgfb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int EyabotNtq = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( EyabotNtq == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < W ; i ++ ) { System . out . printf ( " # " ) ; } System . out . printf ( " %n " ) ; for ( int i = 0 ; i < EyabotNtq - 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 SlaLgiw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int slaV = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int ans = 0 ; if ( b <= c || d <= slaV ) { ans = 0 ; } else if ( c <= slaV && b <= d ) { ans = b - slaV ; } else if ( slaV <= c && d <= b ) { ans = d - c ; } else if ( slaV <= c && c <= b && b <= d ) { ans = b - c ; } else if ( c <= slaV && slaV <= d && d <= b ) { ans = d - slaV ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class YbfwGzqqzw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YbfwO = sc . nextInt ( ) ; int [ ] t = new int [ YbfwO + 1 ] ; int [ ] x = new int [ YbfwO + 1 ] ; int [ ] y = new int [ YbfwO + 1 ] ; t [ 0 ] = 0 ; x [ 0 ] = 0 ; y [ 0 ] = 0 ; boolean result = true ; for ( int i = 1 ; i <= YbfwO ; 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 rdciiNyh { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int RdciiAy = 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 < RdciiAy ; 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 awoyjUu { 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 AwoyjWdd = 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 ] ) { AwoyjWdd = false ; System . out . println ( " No " ) ; break outside ; } } } if ( AwoyjWdd ) { System . out . println ( " Yes " ) ; } } } import java . util . * ; public class IgdxghJcf { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s ; int igdxghYzxh ; int i ; Deck d = new Deck ( ) ; while ( ! ( s = sc . next ( ) ) . equals ( " - " ) ) { d . setDeck ( s ) ; igdxghYzxh = sc . nextInt ( ) ; for ( i = 0 ; i < igdxghYzxh ; i ++ ) { d . shuffle ( sc . nextInt ( ) ) ; } d . printDeck ( ) ; } } } class IgdxghJcf { 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 FmovmLilk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] an = new int [ 5 ] ; for ( int fmovmV = 0 ; fmovmV < 5 ; fmovmV ++ ) { an [ fmovmV ] = 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 JdcLd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jdcEix = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( jdcEix > b ) { System . out . println ( 2 * jdcEix - 1 ) ; } else if ( jdcEix == b ) { System . out . println ( 2 * jdcEix ) ; } 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 IztbeXc { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int IztbeQb = fs . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= IztbeQb ; ++ i ) { if ( i % 3 != 0 && i % 5 != 0 ) ans += i ; } System . out . println ( ans ) ; } static class IztbeXc { 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 IztbeQb ) { int [ ] a = new int [ IztbeQb ] ; for ( int i = 0 ; i < IztbeQb ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . io . * ; import java . util . * ; class nkfwhRdz { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int NkfwhGdvd = 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 < NkfwhGdvd - arr [ n - 1 ] + arr [ 0 ] ) { System . out . println ( NkfwhGdvd - ( NkfwhGdvd - arr [ n - 1 ] + arr [ 0 ] ) ) ; } else { System . out . println ( NkfwhGdvd - maxdiff ) ; } } } import java . io . IOException ; import java . util . ArrayList ; import java . util . Scanner ; class KxusdRn { 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 kxusdJbp = 1 ; int x = 1 ; int kumi = 0 ; while ( kxusdJbp != 0 || x != 0 ) { kxusdJbp = scan . nextInt ( ) ; x = scan . nextInt ( ) ; NN . add ( kxusdJbp ) ; 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 WisaYn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int wisaC = Integer . parseInt ( scanner . next ( ) ) ; double x ; x = ( double ) wisaC / 3.0 ; System . out . println ( Math . pow ( x , 3 ) ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class CqfbsLd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cqfbsX = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; List < Integer > cList = new ArrayList < > ( ) ; List < Integer > tList = new ArrayList < > ( ) ; for ( int i = 0 ; i < cqfbsX ; i ++ ) { cList . add ( sc . nextInt ( ) ) ; tList . add ( sc . nextInt ( ) ) ; } Integer minCost = null ; for ( int i = 0 ; i < cqfbsX ; 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 IibPi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IibCk = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int c = 0 ; for ( int i = 0 ; i < IibCk ; i ++ ) { int b = sc . nextInt ( ) ; if ( a <= b ) c ++ ; } System . out . println ( c ) ; } } import java . util . Scanner ; public class RqenSgg { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int rqenXtba = stdIn . nextInt ( ) ; int Q = stdIn . nextInt ( ) ; int [ ] ans = new int [ rqenXtba ] ; int [ ] kota = new int [ Q ] ; String S = stdIn . next ( ) ; int z = 1 , y = 0 , l = 0 , r = 0 , num = 0 ; while ( z < rqenXtba ) { 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 PbhSpew { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int pbhZol = sc . nextInt ( ) ; if ( pbhZol == 2 ) { System . out . println ( pbhZol ) ; return ; } ArrayList < Integer > list = getPrime ( pbhZol ) ; while ( true ) { if ( check ( pbhZol , list ) ) { System . out . println ( pbhZol ) ; return ; } pbhZol ++ ; } } 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 JiikSl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jiikTzwc = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ jiikTzwc ] ; int [ ] B = new int [ jiikTzwc - 1 ] ; for ( int i = 0 ; i < jiikTzwc - 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 < jiikTzwc - 1 ; i ++ ) { sum += Math . min ( B [ i ] , B [ i - 1 ] ) ; } } sum += B [ jiikTzwc - 2 ] ; System . out . println ( sum ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class phiuaK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PhiuaKex = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < PhiuaKex ; 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 XqtbkoXeb { public static void main ( String [ ] args ) { new Main ( ) ; } public Main ( ) { Scanner sc = new Scanner ( System . in ) ; int xqtbkoAle = Integer . parseInt ( sc . next ( ) ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int remainder = xqtbkoAle % A ; int n = xqtbkoAle / A ; System . out . println ( remainder > 0 ? n + 1 : n ) ; } } import java . io . * ; import java . util . Scanner ; public class NkwSx { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] s = br . readLine ( ) . split ( " " ) ; long nkwGria = 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 = nkwGria % sum ; if ( sum > a ) sum = a ; long x = nkwGria / ( a + b ) ; System . out . println ( x * a + sum ) ; } } } import java . util . * ; public class GmvxxkWo { 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 ckmkbrS { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( System . in ) ; long CkmkbrEzj = sc . nextLong ( ) ; long f = CkmkbrEzj / 500 , f2 = ( CkmkbrEzj % 500 ) / 5 ; System . out . println ( f * 1000 + f2 * 5 ) ; } } import java . util . * ; import java . io . * ; import java . math . BigInteger ; public class XxlUi { 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 xxlUqdc = Integer . parseInt ( st1 . nextToken ( ) ) ; int k = Integer . parseInt ( st1 . nextToken ( ) ) ; int q = Integer . parseInt ( st1 . nextToken ( ) ) ; int [ ] arr = new int [ xxlUqdc ] ; for ( int i = 0 ; i < q ; i ++ ) { arr [ Integer . parseInt ( br . readLine ( ) ) - 1 ] ++ ; } for ( int i = 0 ; i < xxlUqdc ; i ++ ) { if ( k - ( q - arr [ i ] ) > 0 ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } } out . flush ( ) ; out . close ( ) ; } } import java . util . Scanner ; public class FyalkrQov { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int FyalkrOa = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( FyalkrOa > b ) { ans += FyalkrOa ; FyalkrOa -- ; } else { ans += b ; b -- ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; public class UpdqnZreq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int updqnHwpj = sc . nextInt ( ) ; String s = sc . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int start = ( int ) s . charAt ( i ) ; int ans = start + updqnHwpj ; 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 RoxnAhyl { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { final String s = reader . readLine ( ) ; boolean roxnRoc = 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 ) { roxnRoc = true ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( i == at ) continue ; if ( s . charAt ( i ) < 'a' || 'z' < s . charAt ( i ) ) { roxnRoc = false ; break ; } } } } System . out . println ( roxnRoc ? " AC " : " WA " ) ; } } } import java . util . Scanner ; public class OwuiCqtk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OwuiQ = sc . nextInt ( ) ; int [ ] P = new int [ OwuiQ + 1 ] ; for ( int i = 1 ; i <= OwuiQ ; i ++ ) { P [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int ans = 1 ; int min = P [ 1 ] ; for ( int i = 2 ; i <= OwuiQ ; i ++ ) { min = Math . min ( min , P [ i ] ) ; if ( P [ i ] <= min ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; class LqsaogJrbd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LqsaogZkz = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; boolean flag = true ; long aa = LqsaogZkz , bb = b ; while ( flag ) { if ( aa < bb ) { aa += LqsaogZkz ; } else if ( bb < aa ) { bb += b ; } else if ( aa == bb ) { flag = false ; } } System . out . println ( aa ) ; } } import java . util . Scanner ; public class ObeiJx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int obeiHg = sc . nextInt ( ) + sc . nextInt ( ) ; int [ ] nums = { 1 , 2 , 3 } ; switch ( obeiHg ) { 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 NuqcyXg { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; int nuqcyGj = 1 ; while ( ! str . equals ( " 0 " ) ) { System . out . println ( " Case " + nuqcyGj + " : " + str ) ; nuqcyGj ++ ; str = br . readLine ( ) ; } } } import java . util . HashMap ; import java . util . Scanner ; class YaafWfdl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yaafMc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( ( long ) yaafMc * b / gcd ( yaafMc , b ) ) ; } public static int gcd ( int yaafMc , int b ) { if ( yaafMc % b == 0 ) { return b ; } return gcd ( b , yaafMc % b ) ; } } import java . io . * ; public class PlawAol { public static void main ( String [ ] args ) { int PlawY = 0 , f = 0 , r = 0 ; try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String [ ] strAry = br . readLine ( ) . split ( " " ) ; PlawY = Integer . parseInt ( strAry [ 0 ] ) ; f = Integer . parseInt ( strAry [ 1 ] ) ; r = Integer . parseInt ( strAry [ 2 ] ) ; if ( PlawY == - 1 && f == - 1 && r == - 1 ) break ; System . out . printf ( " %s \n " , judge ( PlawY , f , r ) ) ; } } catch ( Exception e ) { System . err . println ( e ) ; } } private static String judge ( int PlawY , int f , int r ) { if ( ( PlawY == - 1 || f == - 1 ) || PlawY + f < 30 ) return " F " ; else if ( PlawY + f < 50 ) { if ( r >= 50 ) return " C " ; else return " D " ; } else if ( PlawY + f < 65 ) return " C " ; else if ( PlawY + f < 80 ) return " B " ; else return " A " ; } } import java . util . * ; class GgokFw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ggokGs = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; System . out . println ( ggokGs <= f * t ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class YyobqMwxk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int yyobqMqz = scan . nextInt ( ) ; int n1 = yyobqMqz + 1 ; long [ ] m = new long [ n1 ] ; long [ ] h = new long [ yyobqMqz ] ; for ( int i = 0 ; i < n1 ; i ++ ) { m [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < yyobqMqz ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } long result = 0 ; for ( int i = 0 ; i < yyobqMqz ; 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 AxlhUfx { 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 AxlhCr = 0 ; AxlhCr < nANDmStr . length ; AxlhCr ++ ) { nANDm [ AxlhCr ] = Integer . parseInt ( nANDmStr [ AxlhCr ] ) ; } 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 AxlhCr = 0 ; AxlhCr < vector . length ; AxlhCr ++ ) { vectorStr [ AxlhCr ] = input . readLine ( ) ; vector [ AxlhCr ] = Integer . parseInt ( vectorStr [ AxlhCr ] ) ; } 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 VpmtVqt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int vpmtSns = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; if ( vpmtSns == 0 ) break ; int count = 0 ; for ( int i = 1 ; i <= vpmtSns - 2 ; i ++ ) { for ( int j = i + 1 ; j <= vpmtSns - 1 ; j ++ ) { int check_number = x - i - j ; if ( check_number <= vpmtSns && check_number > j ) { count ++ ; } } } System . out . println ( count ) ; } } } import java . util . Scanner ; public class EatugBjsl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final String S = sc . next ( ) ; int eatugP ; if ( " RRR " . equals ( S ) ) { eatugP = 3 ; } else if ( " RRS " . equals ( S ) || " SRR " . equals ( S ) ) { eatugP = 2 ; } else if ( S . contains ( " R " ) ) { eatugP = 1 ; } else { eatugP = 0 ; } System . out . println ( eatugP ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class UymfXnnm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int uymfGnjf = scan . nextInt ( ) ; String [ ] s = new String [ uymfGnjf ] ; int [ ] cnt = new int [ uymfGnjf ] ; String [ ] scheck = new String [ uymfGnjf ] ; for ( int i = 0 ; i < uymfGnjf ; 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 < uymfGnjf ; i ++ ) { if ( i != 0 && s [ i ] . equals ( s [ i - 1 ] ) == false ) { scheck [ suffix ] = s [ i - 1 ] ; suffix += 1 ; } if ( i == uymfGnjf - 1 ) scheck [ suffix ] = s [ i ] ; if ( i == uymfGnjf - 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 aouNf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AouCf = sc . nextInt ( ) ; int i = 0 ; for ( i = AouCf ; 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 zivceZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZivceFldtm = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int a = - 1 ; int b = - 1 ; int c = - 1 ; for ( int i = 0 ; i <= ZivceFldtm ; i ++ ) { for ( int j = 0 ; j <= ZivceFldtm - i ; j ++ ) { if ( Y == ( 10000 * i + 5000 * j + 1000 * ( ZivceFldtm - i - j ) ) ) { a = i ; b = j ; c = ZivceFldtm - i - j ; } } } System . out . print ( a + " " ) ; System . out . print ( b + " " ) ; System . out . print ( c ) ; } } import java . util . Scanner ; class ZfqmdzDpf { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) , t ; int zfqmdzY = 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 ) ) zfqmdzY ++ ; } 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 ( zfqmdzY , countEven ) ) ; } } import java . util . * ; public class ElgDn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int elgN = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] allList = new int [ 2 * elgN ] ; for ( int i = 0 ; i < 2 * elgN ; i ++ ) { allList [ i ] = sc . nextInt ( ) ; } int cost = 10001 ; for ( int i = 1 ; i < 2 * elgN ; 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 hnlwfcUxu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int HnlwfcZovd = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( HnlwfcZovd == 0 && b == 0 ) break ; if ( HnlwfcZovd < b ) System . out . println ( HnlwfcZovd + " " + b ) ; else System . out . println ( b + " " + HnlwfcZovd ) ; } } } import java . util . Scanner ; public class YtgvbzZsij { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long YtgvbzMg = sc . nextLong ( ) ; if ( YtgvbzMg < 10 ) { System . out . println ( YtgvbzMg ) ; } else if ( YtgvbzMg < 100 ) { System . out . println ( 9 ) ; } else if ( YtgvbzMg < 1000 ) { System . out . println ( 9 + YtgvbzMg - 99 ) ; } else if ( YtgvbzMg < 10000 ) { System . out . println ( 909 ) ; } else if ( YtgvbzMg < 100000 ) { System . out . println ( 909 + YtgvbzMg - 9999 ) ; } else { System . out . println ( 90909 ) ; } sc . close ( ) ; } } import java . util . * ; public class LthgqkKlvr { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int lthgqkF = s . nextInt ( ) ; int k = s . nextInt ( ) ; long [ ] h = new long [ lthgqkF ] ; for ( int i = 0 ; i < lthgqkF ; i ++ ) { h [ i ] = s . nextLong ( ) ; } long [ ] dp = new long [ lthgqkF ] ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < lthgqkF ; 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 [ lthgqkF - 1 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class BmvNoq { 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 AiryqDns { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] line = br . readLine ( ) . split ( " " ) ; int airyqJ = Integer . parseInt ( line [ 0 ] ) ; int n = Integer . parseInt ( line [ 1 ] ) ; line = br . readLine ( ) . split ( " " ) ; br . close ( ) ; boolean flg = false ; for ( String s : line ) { if ( ( airyqJ -= Integer . parseInt ( s ) ) <= 0 ) { flg = true ; break ; } } if ( flg ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class gourQii { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GourAqp = 2 ; int m = sc . nextInt ( ) ; int [ ] [ ] table = new int [ GourAqp ] [ m ] ; for ( int i = 0 ; i < GourAqp ; 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 IelfylXfd { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int IelfylKb = 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 ( IelfylKb * A , B ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class cyddqH { 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 CyddqOi = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < CyddqOi ; 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 YkpmvkNnvy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ykpmvkTo = sc . nextInt ( ) ; int [ ] arr = new int [ 1000000 ] ; arr [ 0 ] = ykpmvkTo ; Set < Integer > set = new HashSet < > ( ) ; set . add ( ykpmvkTo ) ; 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 icaCsa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String val = S . substring ( 0 , 4 ) ; int IcaOoqy = Integer . parseInt ( val ) ; String val2 = S . substring ( 5 , 7 ) ; int mm = Integer . parseInt ( val2 ) ; if ( ( IcaOoqy == 2019 && mm < 5 ) || IcaOoqy <= 2018 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . Scanner ; public class BprzBkw { public static void main ( String [ ] args ) { int bprzNg ; String S ; String T ; StringBuilder ans = new StringBuilder ( ) ; Scanner sc = new Scanner ( System . in ) ; bprzNg = sc . nextInt ( ) ; S = sc . next ( ) ; T = sc . next ( ) ; for ( int i = 0 ; i < bprzNg ; i ++ ) { ans . append ( S . charAt ( i ) ) . append ( T . charAt ( i ) ) ; } System . out . println ( ans ) ; } } import java . io . * ; public class FmmMny { 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 fmmLb = Integer . parseInt ( text [ 0 ] ) ; String b = text [ 1 ] ; int c = Integer . parseInt ( text [ 2 ] ) ; while ( b . equals ( " ? " ) == false ) { if ( b . equals ( " + " ) ) { System . out . println ( fmmLb + c ) ; } else if ( b . equals ( " - " ) ) { System . out . println ( fmmLb - c ) ; } else if ( b . equals ( " * " ) ) { System . out . println ( fmmLb * c ) ; } else if ( b . equals ( " / " ) ) { System . out . println ( fmmLb / c ) ; } str = br . readLine ( ) ; text = str . split ( " " ) ; fmmLb = 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 KqjOdtt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KqjPhe = sc . nextInt ( ) ; int [ ] a = new int [ KqjPhe ] ; for ( int i = 0 ; i < KqjPhe ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Set < Integer > lhs = new LinkedHashSet < Integer > ( ) ; for ( int i = 0 ; i < KqjPhe ; 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 LurkltYjb { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int LurkltY = Integer . parseInt ( st . nextToken ( ) ) ; int N = Integer . parseInt ( st . nextToken ( ) ) ; String regex = String . format ( " [0-9] { %d } -[0-9] { %d } " , LurkltY , 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 BigVu { public static void main ( String [ ] args ) { int bigKxnp , 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 ] ; bigKxnp = 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 SynlGtg { 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 synlZsss = sc . nextInt ( ) ; sc . close ( ) ; long sum = 0 ; if ( synlZsss >= a [ 0 ] ) { sum += a [ 0 ] ; synlZsss -= a [ 0 ] ; } else { sum += synlZsss ; synlZsss = 0 ; } if ( synlZsss >= a [ 1 ] ) { synlZsss -= a [ 1 ] ; } else { synlZsss = 0 ; } if ( synlZsss >= a [ 2 ] ) { sum -= a [ 2 ] ; synlZsss -= a [ 2 ] ; } else { sum -= synlZsss ; synlZsss = 0 ; } System . out . println ( sum ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class XteUgfxbx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int XteLhu = scan . nextInt ( ) ; if ( XteLhu <= 100 ) { List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < XteLhu ; 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 BzhlpWfedei { 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 BzhlpP = Integer . parseInt ( n ) ; int xx = Integer . parseInt ( x ) ; int tt = Integer . parseInt ( t ) ; int times ; if ( BzhlpP % xx == 0 ) { times = BzhlpP / xx ; } else { times = ( BzhlpP / xx ) + 1 ; } int answer = tt * times ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class PqzquAx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pqzquEuck = 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 <= pqzquEuck ; i ++ ) System . out . println ( d [ i ] ) ; } } import java . util . Scanner ; public class AykkCwpq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String AykkZtp = scan . nextLine ( ) ; if ( AykkZtp . equals ( " ABC " ) ) { AykkZtp = AykkZtp . replace ( " ABC " , " ARC " ) ; } else { AykkZtp = AykkZtp . replace ( " ARC " , " ABC " ) ; } System . out . println ( AykkZtp ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . lang . Math ; public class ClsdjZawvz { static class ClsdjZawvz { 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 ClsdjX = 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 == ClsdjX && k2 == b ) { System . out . println ( i ) ; return ; } } System . out . println ( " -1 " ) ; } } import java . util . * ; public class AtsplYhxuq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int AtsplLvz = sc . nextInt ( ) ; int sweet = AtsplLvz ; if ( AtsplLvz % 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 CgdznYh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double CgdznZjb = ( double ) Integer . parseInt ( sc . next ( ) ) ; System . out . println ( String . format ( " %.12f " , Math . pow ( CgdznZjb / 3 , 3 ) ) ) ; } } import java . util . Scanner ; public class WklchRnwpgm { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int WklchHiv = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int c = stdIn . nextInt ( ) ; int x = b + c ; if ( WklchHiv < x ) System . out . println ( x - WklchHiv ) ; else System . out . println ( " 0 " ) ; } } import java . util . * ; public class XgjcwPql { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int xgjcwFn = s . nextInt ( ) ; int [ ] H = new int [ xgjcwFn ] ; for ( int i = 0 ; i < xgjcwFn ; i ++ ) { H [ i ] = s . nextInt ( ) ; } int cnt = 0 ; List < Integer > l = new ArrayList < > ( ) ; for ( int j = 0 ; j < xgjcwFn ; 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 EpzrMpzm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int EpzrBhf = scanner . nextInt ( ) ; int Q = scanner . nextInt ( ) ; int R = scanner . nextInt ( ) ; int t = EpzrBhf + Q ; if ( t > R + EpzrBhf ) { t = R + EpzrBhf ; } if ( t > Q + R ) { t = Q + R ; } System . out . println ( t ) ; } } import java . util . * ; public class MydSym { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; String S = scn . nextLine ( ) ; int mydYxhn = S . length ( ) ; String str_before = S . substring ( 0 , ( mydYxhn - 1 ) / 2 ) ; String str_after = S . substring ( ( mydYxhn + 2 ) / 2 , mydYxhn ) ; 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 XeaybwJjrh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xeaybwYqmr = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ xeaybwYqmr ] ; for ( int i = 0 ; i < xeaybwYqmr ; i ++ ) { A [ i ] = Integer . parseInt ( sc . next ( ) ) ; } double sum = 0 ; for ( int i = 0 ; i < xeaybwYqmr ; i ++ ) { sum += ( 1.0 / A [ i ] ) ; } System . out . println ( 1.0 / sum ) ; } } import java . util . * ; public class IccgsAaozm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IccgsF = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; String [ ] s = new String [ IccgsF ] ; for ( int i = 0 ; i < IccgsF ; i ++ ) { s [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < IccgsF ; i ++ ) { for ( int j = IccgsF - 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 WevBhhx { public static void main ( String [ ] args ) { Scanner sca = new Scanner ( System . in ) ; String s = sca . next ( ) ; String t = sca . next ( ) ; int WevGcr = sca . nextInt ( ) ; int b = sca . nextInt ( ) ; String u = sca . next ( ) ; if ( u . equals ( s ) ) { WevGcr -- ; } else { b -- ; } System . out . print ( WevGcr ) ; System . out . print ( " " ) ; System . out . println ( b ) ; sca . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class JttmgzMyqq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jttmgzZ = scan . nextInt ( ) ; int [ ] array = new int [ jttmgzZ ] ; int [ ] copy = new int [ jttmgzZ ] ; for ( int count = 0 ; count < jttmgzZ ; count ++ ) { int n = scan . nextInt ( ) ; array [ count ] = n ; copy [ count ] = n ; } scan . close ( ) ; Arrays . sort ( copy ) ; int counter = 0 ; for ( int count = 0 ; count < jttmgzZ ; 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 HnqCaa { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { String s = in . next ( ) ; int hnqSv = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' ) { hnqSv ++ ; } } System . out . println ( hnqSv ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class IpvhkSulvv { public static void main ( String [ ] args ) throws IOException { int IpvhkIn , nTaro = 0 , nHana = 0 ; String str ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; IpvhkIn = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < IpvhkIn ; 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 cwqXgp { 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 CwqJoi = Integer . parseInt ( num [ 0 ] ) ; int numB = Integer . parseInt ( num [ 1 ] ) ; if ( strU . equals ( strS ) ) { CwqJoi -= 1 ; } else { numB -= 1 ; } System . out . println ( CwqJoi + " " + numB ) ; } } import java . util . Scanner ; public class EsejOm { public static void main ( String [ ] args ) { final int esejNzrj = 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 ] ) % esejNzrj ; if ( i + 2 < a . length && a [ i + 2 ] != - 1 ) { a [ i + 2 ] = ( a [ i ] + a [ i + 2 ] ) % esejNzrj ; } } System . out . println ( a [ N ] % esejNzrj ) ; } } import java . util . * ; public class PcrpzDgwsm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PcrpzBc = sc . nextInt ( ) ; Map < String , Integer > s = new HashMap < String , Integer > ( ) ; char [ ] c ; String ds ; long ans = 0 ; int tmp ; for ( int i = 0 ; i < PcrpzBc ; 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 BzhgJhs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Long N = sc . nextLong ( ) ; Long total = 0L ; for ( int BzhgN = 1 ; BzhgN <= N ; ++ BzhgN ) { if ( BzhgN % 3 == 0 && BzhgN % 5 == 0 ) { continue ; } else if ( BzhgN % 3 == 0 ) { continue ; } else if ( BzhgN % 5 == 0 ) { continue ; } else { total += BzhgN ; } } 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 YzveYjvjdr { 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 YzveYjvjdr { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { String S = in . next ( ) ; int YzveP = 0 ; for ( int i = 0 ; i < S . length ( ) / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( S . length ( ) - 1 - i ) ) { YzveP ++ ; } } out . println ( YzveP ) ; } } static class YzveYjvjdr { 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 obfO { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ObfAj = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; int a = 0 ; for ( int i = 1 ; i <= ObfAj ; 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 SbqmlpCpaiez { 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 SbqmlpR = 0 ; SbqmlpR < s . length ( ) ; SbqmlpR ++ ) { char ch = s . charAt ( SbqmlpR ) ; if ( SbqmlpR % 2 == 0 ) { if ( ch == 'L' ) return false ; } else { if ( ch == 'R' ) return false ; } } return true ; } } import java . util . Scanner ; class hjlrnkTol { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int HjlrnkCzhcc = scanner . nextInt ( ) ; int [ ] array = new int [ HjlrnkCzhcc ] ; for ( int i = 0 ; i < HjlrnkCzhcc ; i ++ ) { array [ i ] = scanner . nextInt ( ) ; } insertionSort ( array , HjlrnkCzhcc ) ; scanner . close ( ) ; } public static int [ ] insertionSort ( int [ ] array , int HjlrnkCzhcc ) { int sub ; int comp = 0 ; int i ; for ( int cou = 0 ; cou < HjlrnkCzhcc ; cou ++ ) { System . out . print ( array [ cou ] ) ; if ( cou == HjlrnkCzhcc - 1 ) { System . out . print ( " \n " ) ; } else { System . out . print ( " " ) ; } } for ( i = 1 ; i <= HjlrnkCzhcc - 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 < HjlrnkCzhcc ; cou ++ ) { System . out . print ( array [ cou ] ) ; if ( cou == HjlrnkCzhcc - 1 ) { System . out . print ( " \n " ) ; } else { System . out . print ( " " ) ; } } } return array ; } } import java . util . Scanner ; public class CbpbMi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cbpbLnd = sc . nextInt ( ) ; sc . nextLine ( ) ; int [ ] p = new int [ cbpbLnd ] ; for ( int i = 0 ; i < cbpbLnd ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < cbpbLnd ; 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 NvkaNqam { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int nvkaWzl = scan . nextInt ( ) ; boolean flag = true ; PriorityQueue in = new PriorityQueue ( ) ; for ( int x = 0 ; x < nvkaWzl ; x ++ ) { int input = scan . nextInt ( ) ; in . offer ( input ) ; } int before = ( int ) in . poll ( ) ; int after ; for ( int x = 1 ; x < nvkaWzl ; 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 ZelhOax { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zelhNdna = 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 ( zelhNdna % 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 UnmvYxsux { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String UnmvVgr = sc . next ( ) ; if ( Character . isUpperCase ( UnmvVgr . charAt ( 0 ) ) ) { System . out . println ( 'A' ) ; } else System . out . println ( 'a' ) ; } } import java . util . Scanner ; public class QhfXj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qhfF = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = a ; i <= qhfF ; 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 HdhEq { 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 HdhCy = in . nextInt ( ) ; int M = in . nextInt ( ) ; int cL = 0 ; int cR = HdhCy + 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 HdhEq 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 iydybR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IydybJe = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int t = IydybJe - 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 MjwrjiXnc { public static void main ( String [ ] args ) { Scanner dataScanner = new Scanner ( System . in ) ; String [ ] data = dataScanner . nextLine ( ) . split ( " " ) ; int MjwrjiW = 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 ( MjwrjiW , 0 ) + 1 ; i ++ ) { for ( Integer j = 0 ; j < Math . max ( MjwrjiW - i , 0 ) + 1 ; j ++ ) { int k = MjwrjiW - 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 mnsgxUlz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int MnsgxIxay = scanner . nextInt ( ) ; int D = scanner . nextInt ( ) ; int [ ] [ ] X = new int [ MnsgxIxay ] [ D ] ; for ( int i = 0 ; i < MnsgxIxay ; i ++ ) { for ( int j = 0 ; j < D ; j ++ ) { X [ i ] [ j ] = scanner . nextInt ( ) ; } } int resultNumber = 0 ; int temp = 0 ; for ( int i = 0 ; i < MnsgxIxay - 1 ; i ++ ) { for ( int j = i + 1 ; j < MnsgxIxay ; 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 qjetbmHaf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QjetbmLn = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = - 1 ; if ( ( QjetbmLn < 10 ) && ( b < 10 ) ) ans = ( QjetbmLn * b ) ; System . out . println ( ans ) ; } } import java . util . * ; public class PekczEky { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PekczZ = 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 ( PekczZ <= all ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; class InpgTyon { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int inpgLx = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( inpgLx >= s . length ( ) ) { System . out . println ( s ) ; } else { System . out . println ( s . substring ( 0 , inpgLx ) + " ... " ) ; } } catch ( Exception e ) { } finally { } } } import java . util . Scanner ; public class UpgihpAnc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double upgihpLrdo = sc . nextDouble ( ) ; double ans ; ans = Math . ceil ( upgihpLrdo / 2 ) ; int a ; a = ( int ) ans ; System . out . println ( a ) ; return ; } } import java . util . Scanner ; import java . lang . Math ; public class RqmwwBbev { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( scan . hasNext ( ) ) { String input = scan . nextLine ( ) ; String [ ] inputs = input . split ( " " ) ; int rqmwwDp = Integer . parseInt ( inputs [ 0 ] ) ; int width = Integer . parseInt ( inputs [ 1 ] ) ; if ( rqmwwDp == 0 && width == 0 ) { break ; } for ( int i = 0 ; i < rqmwwDp ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . Scanner ; class qhglaB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QhglaBr = Integer . parseInt ( sc . next ( ) ) ; boolean aa = false ; boolean bb = true ; for ( int i = 0 ; i < QhglaBr ; 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 LtwywwTh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String a = " " ; for ( int ltwywwTy = 0 ; ltwywwTy < s . length ( ) ; ltwywwTy ++ ) { switch ( s . charAt ( ltwywwTy ) ) { 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 UpmoaFl { public static void main ( String [ ] args ) throws IOException { Scanner S = new Scanner ( System . in ) ; String Str = S . nextLine ( ) ; int upmoaDdbd = Integer . parseInt ( Str ) ; int seconds = upmoaDdbd % 60 ; int hour = upmoaDdbd / 3600 ; int minute = upmoaDdbd / 60 - hour * 60 ; System . out . println ( hour + " : " + minute + " : " + seconds ) ; } } import java . util . * ; public class FyeBosp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fyeO = sc . nextInt ( ) , x = sc . nextInt ( ) ; int cnt = fyeO <= x ? 1 : 0 , cur = 0 , temp ; for ( int i = 0 ; i < fyeO ; ++ i ) { temp = sc . nextInt ( ) ; cur += temp ; if ( cur <= x ) ++ cnt ; } System . out . printf ( " %d \n " , cnt ) ; } } import java . util . * ; public class NvmqvfVmn { public static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int nvmqvfYcnr = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; int [ ] stones = new int [ nvmqvfYcnr + 1 ] ; int [ ] dp = new int [ nvmqvfYcnr + 1 ] ; for ( int i = 1 ; i <= nvmqvfYcnr ; i ++ ) { stones [ i ] = scanner . nextInt ( ) ; } System . out . println ( solve ( stones , dp , nvmqvfYcnr , k ) ) ; } public static int solve ( int [ ] stones , int [ ] dp , int nvmqvfYcnr , int k ) { if ( nvmqvfYcnr <= 1 ) { return 0 ; } for ( int i = 2 ; i <= nvmqvfYcnr ; 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 [ nvmqvfYcnr ] ; } } import java . util . Scanner ; public class ecmbhsYw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EcmbhsVe = sc . nextInt ( ) ; int [ ] a = new int [ EcmbhsVe ] ; int b = 0 ; int [ ] c = new int [ EcmbhsVe - 1 ] ; for ( int i = 0 ; i < EcmbhsVe ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < EcmbhsVe ; i ++ ) { b += sc . nextInt ( ) ; } for ( int i = 0 ; i < EcmbhsVe - 1 ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < EcmbhsVe ; 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 VhyhRwxno { void solve ( Scanner in , PrintWriter out ) { int VhyhY = in . nextInt ( ) ; int cpt = 0 ; for ( int i = 0 ; i < VhyhY ; ++ 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 CvnMf { 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 cvnQ = 0 ; cvnQ < ss . length ; cvnQ ++ ) { a [ cvnQ ] = ss [ cvnQ ] . length ( ) ; } Arrays . sort ( a , Collections . reverseOrder ( ) ) ; out . println ( a [ 0 ] ) ; } out . flush ( ) ; } } import java . util . Scanner ; public class EnakQt { 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 enakIho = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( forecast . charAt ( i ) == weather . charAt ( i ) ) { enakIho ++ ; } } return enakIho ; } } import java . util . * ; public class TmjoUvvv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TmjoTj = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] [ ] mrxA = new int [ TmjoTj ] [ m ] ; int [ ] [ ] mrxB = new int [ m ] [ l ] ; long [ ] [ ] mrxC = new long [ TmjoTj ] [ l ] ; for ( int i = 0 ; i < TmjoTj ; 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 < TmjoTj ; 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 ElvuTtbht { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ElvuIpf = 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 ( ElvuIpf > 0 ) { ElvuIpf = ElvuIpf - numd ; } else { System . out . println ( " No " ) ; break ; } } } scan . close ( ) ; } } import java . util . * ; public class slvpzqZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SlvpzqPdmv = 0 ; int [ ] line = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { line [ i ] = sc . nextInt ( ) ; SlvpzqPdmv += line [ i ] ; } int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < 3 ; i ++ ) { min = Math . min ( min , SlvpzqPdmv - line [ i ] ) ; } System . out . println ( min ) ; } } import java . util . * ; public class TyeeuXxg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TyeeuGjp = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ TyeeuGjp ] ; int x = 0 ; int aa = 0 ; for ( int i = 0 ; i < TyeeuGjp ; i ++ ) { a [ i ] = sc . nextInt ( ) ; aa += a [ i ] ; } for ( int i = 0 ; i < TyeeuGjp ; 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 LnhlyvWzumk { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { Scanner scanner = new Scanner ( System . in ) ; int LnhlyvHs = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; if ( ( LnhlyvHs + B ) % 2 == 0 ) { System . out . println ( ( LnhlyvHs + B ) / 2 ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . util . Scanner ; import java . util . Stack ; public class IdjuOyw { 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 idjuR = stack . pop ( ) ; int v2 = stack . pop ( ) ; stack . push ( v2 + idjuR ) ; break ; } case " - " : { int idjuR = stack . pop ( ) ; int v2 = stack . pop ( ) ; stack . push ( v2 - idjuR ) ; break ; } case " * " : { int idjuR = stack . pop ( ) ; int v2 = stack . pop ( ) ; stack . push ( v2 * idjuR ) ; 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 OwaqwEc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int owaqwRak = Integer . parseInt ( sc . next ( ) ) ; int [ ] v = new int [ owaqwRak ] ; int [ ] c = new int [ owaqwRak ] ; for ( int i = 0 ; i < owaqwRak ; i ++ ) { v [ i ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < owaqwRak ; i ++ ) { c [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int count = 0 ; for ( int i = 0 ; i < owaqwRak ; i ++ ) { if ( c [ i ] < v [ i ] ) { count += v [ i ] - c [ i ] ; } } System . out . println ( count ) ; } } import java . util . * ; class xgrlGh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long XgrlHp = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ret = 0 ; long rep = ( long ) ( XgrlHp / ( a + b ) ) ; ret += rep * a ; long remain = XgrlHp - ( 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 AheKtrkh { 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 AheP = 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 ) ) AheP = true ; } System . out . println ( AheP == true ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class XfomyMdyv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int XfomyXsa = scan . nextInt ( ) ; int [ ] a = new int [ XfomyXsa ] ; for ( int i = 0 ; i < XfomyXsa ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } int max = 0 ; int count = 0 ; for ( int i = 0 ; i < XfomyXsa ; i ++ ) { if ( a [ i ] >= max ) { max = a [ i ] ; count = count + 1 ; } } System . out . println ( count ) ; } } import java . util . * ; class HdxDga { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hdxYts = sc . nextInt ( ) ; if ( hdxYts % 2 == 0 ) { int [ ] d = new int [ hdxYts ] ; for ( int i = 0 ; i < hdxYts ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; int ans = d [ hdxYts / 2 ] - d [ hdxYts / 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 UigfEdkc { static class UigfEdkc { 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 uigfSv = fr . next ( ) . charAt ( 0 ) ; if ( uigfSv >= 65 && uigfSv <= 90 ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . Scanner ; import java . util . Arrays ; public class UnanTbes { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UnanIn = sc . nextInt ( ) ; int [ ] array = new int [ UnanIn ] ; for ( int i = 0 ; i < UnanIn ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int i ; for ( i = 0 ; i < UnanIn - 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 == ( UnanIn - 1 ) ) { System . out . println ( " Yes " ) ; } } } import java . math . BigInteger ; import java . util . Scanner ; public class TykmyFbco { private static long tykmyLni ; private static String [ ] numeralSystem ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; BigInteger bigInteger = new BigInteger ( scanner . next ( ) ) ; tykmyLni = 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 ( tykmyLni > 26 ) { res = numeralSystem [ ( int ) ( tykmyLni % 26 ) ] . concat ( res ) ; tykmyLni -- ; tykmyLni /= 26 ; } res = numeralSystem [ ( int ) tykmyLni ] . concat ( res ) ; return res ; } } import java . util . * ; import javax . lang . model . util . ElementScanner6 ; public class XekapvRn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xekapvPhuw = sc . nextInt ( ) ; HashSet < String > s = new HashSet < > ( ) ; for ( int i = 0 ; i < xekapvPhuw ; i ++ ) { String a = sc . next ( ) ; s . add ( a ) ; } int out = s . size ( ) ; System . out . println ( out ) ; } } import java . util . Scanner ; public class ZpxdTty { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zpxdGwgo = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( zpxdGwgo <= b ) { String stringA = String . valueOf ( zpxdGwgo ) ; for ( int i = 1 ; i < b ; i ++ ) { stringA += zpxdGwgo ; } System . out . println ( stringA ) ; } else { String stringB = String . valueOf ( b ) ; for ( int i = 1 ; i < zpxdGwgo ; i ++ ) { stringB += b ; } System . out . println ( stringB ) ; } sc . close ( ) ; } } import java . util . * ; public class QvjkaGg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QvjkaEai = scan . nextInt ( ) ; int l = scan . nextInt ( ) ; int [ ] arr = new int [ QvjkaEai ] ; int sum = 0 ; int min = 0 ; for ( int i = 0 ; i < QvjkaEai ; i ++ ) { arr [ i ] = l + i ; sum += arr [ i ] ; } if ( l >= 0 ) { System . out . print ( sum - l ) ; } else { if ( QvjkaEai + l > 0 ) { min = sum ; } else { min = sum - ( QvjkaEai + l - 1 ) ; } System . out . print ( min ) ; } } } import java . util . Scanner ; public class EqsjcrWl { public static void main ( String [ ] args ) throws Exception { Scanner stdin = new Scanner ( System . in ) ; int EqsjcrXyk = 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 klifpcV { 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 KlifpcRkz = Integer . parseInt ( st . nextToken ( ) ) ; if ( KlifpcRkz == 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 RctZqiygm { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String K = sc . next ( ) ; int RctQzf = 101 ; if ( K . length ( ) <= 3 ) RctQzf = 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 ( RctQzf <= index0 + 1 ) System . out . println ( 1 ) ; else System . out . println ( S . charAt ( index0 + 1 ) ) ; } } } import java . util . * ; public class ZxbHrg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double ZxbT = 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 ( ZxbT , 2 ) + Math . pow ( longB , 2 ) - 2.0 * ZxbT * 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 TjikSub { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; long tjikD = 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 >= tjikD ) { System . out . println ( " 1 " ) ; } else { System . out . println ( str [ ( int ) one ] ) ; } } } import java . util . Scanner ; public class EybhGm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EybhTh = scan . nextInt ( ) ; int [ ] array = new int [ EybhTh + 1 ] ; for ( int i = 1 ; i <= EybhTh ; i ++ ) { array [ i ] = scan . nextInt ( ) ; } int [ ] result = new int [ EybhTh + 1 ] ; for ( int i = 1 ; i <= EybhTh ; i ++ ) { result [ array [ i ] ] = i ; } for ( int i = 1 ; i <= EybhTh ; i ++ ) { if ( i != EybhTh ) { System . out . print ( result [ i ] + " " ) ; } else { System . out . print ( result [ i ] ) ; } } } } import java . util . Scanner ; public class AkbacDcps { public static void main ( String [ ] args ) { ( new Main ( ) ) . execute ( ) ; } public void execute ( ) { Scanner sc = new Scanner ( System . in ) ; int akbacHt = sc . nextInt ( ) ; int [ ] p = new int [ akbacHt + 1 ] ; int ngPos = 0 ; int ngNum = 0 ; int changeCount = 0 ; boolean ok = true ; for ( int i = 1 ; i <= akbacHt ; 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 zqqaZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZqqaRflc = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( ZqqaRflc >= S . length ( ) ) { System . out . println ( S ) ; } else { System . out . println ( S . substring ( 0 , ZqqaRflc ) + " ... " ) ; } } } import java . util . Scanner ; public class LuakPfcot { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LuakDi = sc . nextInt ( ) ; long sum = 0 ; for ( int a = 1 ; a <= LuakDi ; a ++ ) { for ( int b = 1 ; b <= LuakDi ; b ++ ) { int sur_1 = gcd ( a , b ) ; for ( int c = 1 ; c <= LuakDi ; 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 suzscjKgv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SuzscjNaso = sc . nextInt ( ) ; int [ ] in = new int [ SuzscjNaso ] ; for ( int i = 0 ; i < SuzscjNaso ; i ++ ) { in [ i ] = sc . nextInt ( ) ; } int count = 0 ; int ans = 0 ; for ( int i = 0 ; i < SuzscjNaso - 1 ; i ++ ) { if ( in [ i ] >= in [ i + 1 ] ) { count ++ ; } else { ans = Math . max ( ans , count ) ; count = 0 ; } if ( i == SuzscjNaso - 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 ZrnyhfOalf { 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 zrnyhfVq = Integer . parseInt ( in . readLine ( ) ) ; int lim = 1000000 , i = 2 , a = zrnyhfVq ; HashSet < Integer > set = new HashSet ( ) ; set . add ( zrnyhfVq ) ; 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 ebxtsBgl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EbxtsZxk = sc . nextInt ( ) ; ArrayList < Integer > asiba = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < EbxtsZxk ; 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 < EbxtsZxk ; 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 ( EbxtsZxk - 1 ) ) ; } } import java . util . * ; public class RoigtLou { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int roigtG = sc . nextInt ( ) ; String S = sc . next ( ) ; String [ ] ABCList = S . split ( " ABC " , - 1 ) ; System . out . println ( ABCList . length - 1 ) ; } } import java . util . * ; public class XherwlMn { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int xherwlNtjp = scanner . nextInt ( ) ; int n = scanner . nextInt ( ) ; if ( n == 100 ) { n ++ ; } System . out . println ( ( int ) Math . pow ( 100 , xherwlNtjp ) * n ) ; } } import java . util . Scanner ; class QylRbml { 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 qylNgnb = 0 ; qylNgnb < 3 ; ++ qylNgnb ) { if ( n [ qylNgnb ] == '1' ) n [ qylNgnb ] = '9' ; else if ( n [ qylNgnb ] == '9' ) n [ qylNgnb ] = '1' ; } System . out . print ( n ) ; } } import java . util . Scanner ; public class bhrfPoj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] a = new char [ 10 ] ; for ( int BhrfDfq = 0 ; BhrfDfq < s . length ( ) ; BhrfDfq ++ ) { a [ BhrfDfq ] = s . charAt ( BhrfDfq ) ; } a [ 3 ] = '8' ; for ( int BhrfDfq = 0 ; BhrfDfq < a . length ; BhrfDfq ++ ) { System . out . print ( a [ BhrfDfq ] ) ; } } } import java . util . Scanner ; public class JbqbsEfqb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int JbqbsOb = Integer . parseInt ( scanner . next ( ) ) ; int breakCount = 0 ; int kIndex = 1 ; for ( int i = 0 ; i < JbqbsOb ; i ++ ) { int num = Integer . parseInt ( scanner . next ( ) ) ; if ( kIndex != num ) { breakCount ++ ; } else { kIndex ++ ; } } scanner . close ( ) ; if ( breakCount == JbqbsOb ) { System . out . println ( " -1 " ) ; } else { System . out . println ( breakCount ) ; } } } import java . util . Scanner ; public class vuyuciX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VuyuciMzwrj = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int a3 = sc . nextInt ( ) ; int sa12 = Math . abs ( VuyuciMzwrj - a2 ) ; int sa23 = Math . abs ( a2 - a3 ) ; int sa31 = Math . abs ( a3 - VuyuciMzwrj ) ; 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 VhpMet { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long vhpS = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; long result1 = Math . max ( 0 , vhpS - K ) ; long result2 = Math . max ( 0 , Math . min ( vhpS + B - K , B ) ) ; System . out . println ( result1 + " " + result2 ) ; } } import java . util . * ; import java . math . * ; public class xbhEuw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String XbhWuie = sc . next ( ) ; String sb = sc . next ( ) ; BigDecimal A = new BigDecimal ( XbhWuie ) ; BigDecimal B = new BigDecimal ( sb ) ; System . out . println ( A . multiply ( B ) . setScale ( 0 , BigDecimal . ROUND_DOWN ) ) ; } } import java . util . Scanner ; public class NdjzXo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NdjzO = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int [ ] h = new int [ NdjzO ] ; for ( int i = 0 ; i < NdjzO ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } double ansDiff = 1000000 ; int ansNum = 0 ; for ( int i = 0 ; i < NdjzO ; 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 KvpYjaupg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int KvpJe = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] ary = new int [ KvpJe ] ; for ( int i = 0 ; i < KvpJe ; i ++ ) ary [ i ] = sc . nextInt ( ) ; sc . close ( ) ; Arrays . sort ( ary ) ; for ( int i = 0 ; i < KvpJe ; i ++ ) { if ( ary [ i ] >= k ) { System . out . println ( KvpJe - i ) ; System . exit ( 0 ) ; } } System . out . println ( " 0 " ) ; } } import java . util . Scanner ; public class AthyPoo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int athyQe = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int n = athyQe / X ; if ( athyQe % 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 vikUg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VikCt = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sc . close ( ) ; List < Integer > ary = new ArrayList < > ( ) ; int flg = 1 ; while ( flg <= VikCt || flg <= B ) { if ( VikCt % 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 ydalveAio { static class ydalveAio { double YdalveOd , s ; pair ( double YdalveOd , double s ) { this . YdalveOd = YdalveOd ; 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 GpopgtTwfw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . nextLine ( ) . toLowerCase ( ) ; int gpopgtOcd = 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 ( ) ) ) { gpopgtOcd += 1 ; } } } System . out . println ( gpopgtOcd ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class NmdgxRvfz { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int nmdgxXz = 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 ( nmdgxXz % 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 jwiA { 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 jwiA { public void solve ( Scanner in , PrintWriter out ) { int JwiZlil = in . nextInt ( ) , b = in . nextInt ( ) ; out . println ( ( JwiZlil * b ) % 2 == 0 ? " Even " : " Odd " ) ; } } } import java . util . Scanner ; public class UlnkKtobkj { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; int UlnkWf = stdin . nextInt ( ) ; int b = stdin . nextInt ( ) ; System . out . printf ( " %d %d %f " , UlnkWf / b , UlnkWf % b , ( double ) UlnkWf / b ) ; } } import java . util . * ; import java . math . * ; import java . io . * ; public class YfxReztev { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int [ ] a = new int [ 5 ] ; for ( int YfxZq = 0 ; YfxZq < 5 ; YfxZq ++ ) { a [ YfxZq ] = sc . nextInt ( ) ; } int ans = 3928237 ; for ( int YfxZq = 0 ; YfxZq < 5 ; YfxZq ++ ) { int sum = 0 ; for ( int j = 0 ; j < 5 ; j ++ ) { if ( YfxZq != 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 TlxavoEmf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tlxavoX = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int min = x - tlxavoX + 1 ; int max = x + tlxavoX - 1 ; for ( int i = min ; i <= max ; i ++ ) { System . out . print ( i + ( i == max ? " " : " " ) ) ; } System . out . println ( ) ; } } import java . io . * ; public class OywakgVe { public static void main ( String [ ] arg ) throws IOException { InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( is ) ; String OywakgKe = br . readLine ( ) ; String [ ] spl = OywakgKe . 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 ufepfCii { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = reader . readLine ( ) ; char UfepfRjzju = line . charAt ( 0 ) ; UfepfRjzju ++ ; System . out . println ( UfepfRjzju ) ; } } import java . util . * ; public class HuwHidz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String huwKyen = in . next ( ) ; String res ; if ( huwKyen . equals ( " Sunny " ) ) { res = " Cloudy " ; } else if ( huwKyen . equals ( " Cloudy " ) ) { res = " Rainy " ; } else { res = " Sunny " ; } System . out . println ( res ) ; in . close ( ) ; } } import java . util . Scanner ; class IoslEjocyd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IoslF = 0 ; int b = 0 ; int c = 0 ; IoslF = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; if ( IoslF < b && b < c && IoslF < c ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class ItnhVlf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ItnhO = Integer . parseInt ( sc . next ( ) ) ; switch ( ItnhO % 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 PlnqvWs { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int plnqvYs = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int T = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( ( T / plnqvYs ) * B ) ; } } } import java . util . Scanner ; public class gscueZm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 100 ] ; int GscueTh = 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 ) { GscueTh ++ ; } } System . out . println ( GscueTh ) ; } } import java . io . * ; import java . util . * ; import java . util . function . * ; final class KkpQodk { static final Solver INSTANCE = new Solver ( ) ; void solve ( Supplier < String > sc ) { String S = sc . get ( ) ; int kkpLqx = Integer . parseInt ( S . substring ( 0 , 2 ) , 10 ) ; int right = Integer . parseInt ( S . substring ( 2 ) , 10 ) ; if ( isYear ( kkpLqx ) && isYear ( right ) ) { System . out . println ( " NA " ) ; } else if ( isYear ( kkpLqx ) ) { 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 KkpQodk { 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 YpjzqbKukgu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YpjzqbCp = sc . nextInt ( ) ; int [ ] len = new int [ YpjzqbCp ] ; int sum = 0 ; int max = 0 ; for ( int i = 0 ; i < YpjzqbCp ; i ++ ) { int temp = sc . nextInt ( ) ; if ( temp > max ) { max = temp ; } sum += temp ; } System . out . println ( max < sum - max ? " Yes " : " No " ) ; } } import java . util . * ; class OxyXjx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OxyDu = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; Integer [ ] h = new Integer [ OxyDu ] ; long ans = 0 ; for ( int i = 0 ; i < OxyDu ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } if ( k >= OxyDu ) { 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 < OxyDu ; i ++ ) { ans += h [ i ] ; } System . out . println ( ans ) ; } } } import java . util . * ; public class zdmplOws { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZdmplKnaty = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] cities = new int [ ZdmplKnaty ] ; 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 < ZdmplKnaty ; j ++ ) { System . out . println ( cities [ j ] ) ; } } } import java . util . * ; public class WvzqvLc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WvzqvNv = sc . nextInt ( ) ; Integer [ ] dArr = new Integer [ WvzqvNv ] ; for ( int i = 0 ; i < WvzqvNv ; i ++ ) { dArr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( dArr , Collections . reverseOrder ( ) ) ; int count = 1 ; for ( int i = 1 ; i < WvzqvNv ; 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 udofkmGlu { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int UdofkmKx = 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 ( UdofkmKx , 2 ) + Math . pow ( B , 2 ) - ( double ) ( ( double ) ( 2 * UdofkmKx * B ) * Math . cos ( sita ) ) ) ) ; System . out . print ( answer ) ; } } } import java . util . Scanner ; public class BkhrsKmfb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BkhrsGa = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; long [ ] x = new long [ BkhrsGa ] ; long [ ] y = new long [ BkhrsGa ] ; int count = 0 ; for ( int i = 0 ; i < BkhrsGa ; i ++ ) { x [ i ] = sc . nextLong ( ) ; y [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < BkhrsGa ; 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 EgqmbyYotj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int egqmbyPav = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; sc . close ( ) ; int answer = 0 ; answer += ( egqmbyPav * ( egqmbyPav - 1 ) ) / 2 ; answer += ( m * ( m - 1 ) ) / 2 ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class jlcFt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JlcMok = sc . nextInt ( ) ; int yoke = 0 ; int count = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { count += JlcMok % 10 ; JlcMok -= JlcMok % 10 ; JlcMok /= 10 ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class DsiruHre { public static int total ( int t ) { int dsiruBd = 0 ; while ( t != 0 ) { dsiruBd += t % 10 ; t /= 10 ; } return dsiruBd ; } 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 LavxmwQt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lavxmwU = sc . nextInt ( ) ; int [ ] B = new int [ lavxmwU ] ; for ( int i = 0 ; i < lavxmwU - 1 ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } int total = 0 ; for ( int i = 0 ; i < lavxmwU ; i ++ ) { if ( i == 0 ) total += B [ i ] ; else if ( i == lavxmwU - 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 QzfzeTkfuc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QzfzeRke = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; System . out . println ( t / QzfzeRke * b ) ; } } import java . util . * ; public class OenHozbv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OenZt = sc . nextInt ( ) ; int [ ] arr = new int [ OenZt + 1 ] ; arr [ 0 ] = - 1 ; for ( int i = 1 ; i < OenZt + 1 ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } String ans = " Yes " ; for ( int i = 1 ; i < OenZt ; 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 TsmpUe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TsmpV = sc . nextInt ( ) ; int x_500 = TsmpV / 500 ; TsmpV = TsmpV - TsmpV / 500 * 500 ; int x_5 = TsmpV / 5 ; int ans = x_500 * 1000 + x_5 * 5 ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class YsymapMssp { 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 ysymapE = readInt ( ) ; if ( ysymapE % 1000 == 0 ) pw . println ( 0 ) ; else pw . println ( 1000 - ysymapE % 1000 ) ; pw . close ( ) ; } } import java . util . * ; import java . lang . * ; public class xaeatpJr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String XaeatpYfwc = scan . next ( ) ; if ( XaeatpYfwc . equals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } if ( XaeatpYfwc . equals ( " ARC " ) ) { System . out . println ( " ABC " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class OxyeuhOn { public static void main ( String [ ] args ) throws IOException { int [ ] data = new int [ 10 ] ; final String BR = System . getProperty ( " line.separator " ) ; int OxyeuhRl = 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 ( OxyeuhRl < datum ) { temp1 = OxyeuhRl ; temp2 = second ; OxyeuhRl = datum ; second = temp1 ; third = temp2 ; } else if ( second < datum ) { temp2 = second ; second = datum ; third = temp2 ; } else if ( third < datum ) { third = datum ; } } System . out . println ( OxyeuhRl + BR + second + BR + third ) ; } } import java . util . Scanner ; public class ZxkVqz { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] menu = new int [ 5 ] ; int zxkYlrf = 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 ) { zxkYlrf += menu [ i ] ; } else { zxkYlrf += menu [ i ] + ( 10 - ( menu [ i ] % 10 ) ) ; } } } zxkYlrf += menu [ idx ] ; System . out . println ( zxkYlrf ) ; } } import java . util . * ; public class QvjhpTh { public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . exec ( ) ; } private void exec ( ) { Scanner scan = new Scanner ( System . in ) ; int qvjhpGwz = 0 ; int count7 = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { switch ( scan . nextInt ( ) ) { case 5 : qvjhpGwz ++ ; break ; case 7 : count7 ++ ; break ; default : } } if ( qvjhpGwz == 2 && count7 == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } scan . close ( ) ; } } import java . util . * ; public class NpasifXeuv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int npasifRgjy = 0 ; int count7 = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { switch ( sc . nextInt ( ) ) { case 5 : npasifRgjy ++ ; break ; case 7 : count7 ++ ; break ; } } if ( npasifRgjy == 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 CnhekNedh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CnhekI = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; String [ ] name = new String [ CnhekI ] ; 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 < CnhekI ; ++ 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 DrthhnSjqrsv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DrthhnDq = sc . nextInt ( ) ; int c0 = 0 ; int c1 = 0 ; int c2 = 0 ; int c3 = 0 ; for ( int i = 0 ; i < DrthhnDq + 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 uuygbmBl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UuygbmZwbz = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; boolean [ ] sunukes = new boolean [ UuygbmZwbz ] ; 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 OpuyllRxifoe { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int OpuyllHz = 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 < OpuyllHz ; 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 clgrK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ClgrFv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] surp = new int [ Math . min ( ClgrFv , b ) + 1 ] ; for ( int i = 1 ; i <= Math . min ( ClgrFv , b ) ; i ++ ) { if ( ClgrFv % i == 0 && b % i == 0 ) { surp [ i ] = i ; } } Arrays . sort ( surp ) ; System . out . println ( surp [ Math . min ( ClgrFv , b ) - k + 1 ] ) ; } } import java . util . * ; import java . io . * ; class dogsBte { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out , true ) ; String str = sc . nextLine ( ) ; int DogsUng = 0 ; int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == 'R' ) { count ++ ; DogsUng = Math . DogsUng ( count , DogsUng ) ; } else { count = 0 ; } } out . println ( DogsUng ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class WzehJe { public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; boolean wzehCi = 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 ; wzehCi = true ; } } if ( wzehCi ) System . out . println ( cost ) ; else System . out . println ( " TLE " ) ; } static class WzehJe { 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 FemrgzCihr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int femrgzDfm = 0 ; while ( femrgzDfm == 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 JzmdgCsj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jzmdgWr = scan . nextInt ( ) ; int [ ] h = new int [ jzmdgWr + 1 ] ; for ( int i = 1 ; i <= jzmdgWr ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } h [ 0 ] = 0 ; for ( int i = 1 ; i <= jzmdgWr ; i ++ ) { if ( h [ i ] > h [ i - 1 ] ) { h [ i ] -- ; } } for ( int i = 1 ; i <= jzmdgWr ; i ++ ) { if ( h [ i ] >= h [ i - 1 ] ) { } else { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; class BqwghfAgry { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; double bqwghfK = cin . nextDouble ( ) ; System . out . printf ( " %.6f %.6f \n " , cal_area ( bqwghfK ) , cal_cirum ( bqwghfK ) ) ; } private static double cal_cirum ( double bqwghfK ) { return ( bqwghfK * 2 * Math . PI ) ; } private static double cal_area ( double bqwghfK ) { return ( bqwghfK * bqwghfK * Math . PI ) ; } } import java . util . Scanner ; public class pzvnBvo { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int PzvnOh = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] ary = new int [ PzvnOh ] ; long sum = 0 ; for ( int i = 0 ; i < PzvnOh ; i ++ ) { ary [ i ] = sc . nextInt ( ) ; sum += ary [ i ] ; } sc . close ( ) ; int m2 = 0 ; for ( int i = 0 ; i < PzvnOh ; 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 CegFid { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long cegFej = scanner . nextLong ( ) ; long count = 0 ; while ( cegFej > 1 ) { cegFej = cegFej / 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 WylhsEeuxvq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int WylhsV = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] r = new int [ 2 * m ] ; int [ ] rr = new int [ WylhsV + 1 ] ; for ( int i = 0 ; i < 2 * m ; i ++ ) { r [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < WylhsV + 1 ; i ++ ) { rr [ i ] = 0 ; } for ( int i = 0 ; i < 2 * m ; i ++ ) { rr [ r [ i ] ] ++ ; } for ( int i = 1 ; i <= WylhsV ; i ++ ) { System . out . println ( rr [ i ] ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class VvbyxYla { 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 VvbyxC = Integer . parseInt ( data [ 0 ] ) ; int b = Integer . parseInt ( data [ 1 ] ) ; if ( VvbyxC == 0 && b == 0 ) break ; for ( int y = 0 ; y < VvbyxC ; 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 tcvMkm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TcvIhfqd = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; sc . close ( ) ; if ( Y % 2 == 1 ) { System . out . println ( " No " ) ; return ; } double ans = Y / 2 - TcvIhfqd ; if ( ans < 0 || ans > TcvIhfqd || ans % 1 != 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class ejfnrRnv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EjfnrHm , m , l ; EjfnrHm = sc . nextInt ( ) ; m = sc . nextInt ( ) ; l = sc . nextInt ( ) ; long [ ] [ ] A = new long [ EjfnrHm ] [ m ] ; long [ ] [ ] B = new long [ m ] [ l ] ; for ( int i = 0 ; i < EjfnrHm ; 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 < EjfnrHm ; 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 InzPkm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int inzWnai = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int res10000 = - 1 , res5000 = - 1 , res1000 = - 1 ; sc . close ( ) ; for ( int a = 0 ; a <= inzWnai ; a ++ ) { for ( int b = 0 ; b + a <= inzWnai ; b ++ ) { int c = inzWnai - 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 WlrBsoy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = sc . nextLine ( ) . split ( " " ) ; int WlrF = Integer . parseInt ( s [ 0 ] ) ; int b = Integer . parseInt ( s [ 1 ] ) ; int d = WlrF / b ; int r = WlrF % b ; double af = ( double ) WlrF ; 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 WlntwoSwbisz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WlntwoKrh = sc . nextInt ( ) ; int [ ] A = new int [ WlntwoKrh + 1 ] ; int [ ] B = new int [ WlntwoKrh ] ; for ( int i = 0 ; i < WlntwoKrh + 1 ; i ++ ) A [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < WlntwoKrh ; i ++ ) B [ i ] = sc . nextInt ( ) ; long res = 0 ; for ( int i = 0 ; i < WlntwoKrh ; 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 ZgkPzg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String zgkSrv = sc . next ( ) ; String t = sc . next ( ) ; if ( zgkSrv . equals ( t . substring ( 0 , zgkSrv . length ( ) ) ) && ( t . length ( ) - zgkSrv . length ( ) == 1 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class IznyBifh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int iznyPaw = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; int [ ] [ ] a = new int [ iznyPaw ] [ m ] ; int [ ] b = new int [ m ] ; for ( int y = 0 ; y < iznyPaw ; 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 < iznyPaw ; 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 ZkpElhz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zkpVruw = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; true ; i ++ ) { zkpVruw -= m ; ans ++ ; if ( zkpVruw <= 0 ) { break ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; public class dmyiBy { public static void main ( String [ ] hi ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; int DmyiRnxia = Integer . parseInt ( st . nextToken ( ) ) ; int X = Integer . parseInt ( st . nextToken ( ) ) ; int T = Integer . parseInt ( st . nextToken ( ) ) ; int time = DmyiRnxia / X ; time *= T ; if ( DmyiRnxia % X > 0 ) time += T ; System . out . println ( time ) ; } } import java . util . * ; import java . math . BigDecimal ; import java . math . RoundingMode ; public class DnrqaKkj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DnrqaCdb = 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 == DnrqaCdb && t1 == B ) { ans = i ; break ; } } System . out . print ( ans ) ; } } import java . util . * ; public class QseZnq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String result = " " ; for ( int QseDjq = 0 ; QseDjq < s . length ( ) ; QseDjq ++ ) { switch ( s . charAt ( QseDjq ) ) { 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 VoyrNte { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int voyrOfkx = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int powD = 1 ; for ( int i = 0 ; i < voyrOfkx ; 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 zlisbFbw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int ZlisbIxd = Integer . parseInt ( s . substring ( 0 , 2 ) ) ; int b = Integer . parseInt ( s . substring ( 2 ) ) ; String ans = " NA " ; if ( ( ZlisbIxd >= 1 && ZlisbIxd <= 12 ) && ( b >= 1 && b <= 12 ) ) { ans = " AMBIGUOUS " ; } else if ( ZlisbIxd >= 1 && ZlisbIxd <= 12 ) { ans = " MMYY " ; } else if ( b >= 1 && b <= 12 ) { ans = " YYMM " ; } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; class jvonhiU { static int JvonhiWvk , 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 ( ) , " " ) ; JvonhiWvk = Integer . parseInt ( tok . nextToken ( ) ) ; k = Integer . parseInt ( tok . nextToken ( ) ) ; arr = new int [ JvonhiWvk ] ; tok = new StringTokenizer ( br . readLine ( ) , " " ) ; for ( int i = 0 ; i < JvonhiWvk ; i ++ ) { arr [ i ] = Integer . parseInt ( tok . nextToken ( ) ) ; } dp = new long [ JvonhiWvk ] ; 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 < JvonhiWvk ; 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 ZjrCnw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZjrMvi = sc . nextInt ( ) ; int [ ] H = new int [ ZjrMvi ] ; for ( int i = 0 ; i < ZjrMvi ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < ZjrMvi ; 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 wujPf { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int WujCx = gi ( ) ; int [ ] A = new int [ WujCx ] ; for ( int i = 0 ; i < WujCx ; i ++ ) { A [ i ] = gi ( ) ; } Arrays . parallelSort ( A ) ; System . out . println ( A [ A . length - 1 ] - A [ 0 ] ) ; } public static int s ( int WujCx ) { String S = String . valueOf ( WujCx ) ; 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 WujCx ) { String a = String . valueOf ( WujCx ) ; 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 NpauoVgeqme { public static void main ( String [ ] args ) { int NpauoHup ; int i , j ; int v ; Scanner scan = new Scanner ( System . in ) ; String str = new String ( ) ; NpauoHup = scan . nextInt ( ) ; int [ ] A = new int [ NpauoHup ] ; for ( i = 0 ; i < NpauoHup ; i ++ ) A [ i ] = scan . nextInt ( ) ; for ( i = 0 ; i < NpauoHup ; 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 mqqvgSt { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int MqqvgNepzy = 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 ] [ MqqvgNepzy ] ; 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 < MqqvgNepzy ; 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 axcI { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; long AxcBiale = sc . nextLong ( ) ; int m = sc . nextInt ( ) ; long sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) sum += sc . nextLong ( ) ; System . out . println ( ( sum <= AxcBiale ) ? AxcBiale - sum : " -1 " ) ; } static class axcI { 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 LzmfvKduv { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int lzmfvT = scanner . nextInt ( ) ; int result = 0 ; int max = 0 ; for ( int i = 0 ; i < lzmfvT ; i ++ ) { int a = scanner . nextInt ( ) ; if ( a >= max ) { max = a ; result ++ ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class xvscSwj { 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 XvscLxrb = 0 ; XvscLxrb < 3 ; XvscLxrb ++ ) { if ( a [ XvscLxrb ] . equals ( " 1 " ) ) { a [ XvscLxrb ] = " 9 " ; } else if ( a [ XvscLxrb ] . equals ( " 9 " ) ) { a [ XvscLxrb ] = " 1 " ; } } System . out . println ( a [ 0 ] + a [ 1 ] + a [ 2 ] ) ; } } import java . util . Scanner ; public class AwappeIfagyt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AwappeG = sc . nextInt ( ) ; int [ ] nums = new int [ AwappeG ] ; for ( int i = 0 ; i < AwappeG ; i ++ ) { nums [ i ] = sc . nextInt ( ) ; } boolean result = true ; for ( int i = 0 ; i < AwappeG ; 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 SsobSplzjt { 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 SsobBw ; SsobBw = a ; a = b ; b = SsobBw % 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 mdvuqKb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MdvuqSn = sc . nextInt ( ) ; int [ ] [ ] a = new int [ 2 ] [ MdvuqSn ] ; for ( int i = 0 ; i < MdvuqSn ; i ++ ) { a [ 0 ] [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < MdvuqSn ; i ++ ) { a [ 1 ] [ i ] = sc . nextInt ( ) ; } int max = 0 ; int first = 0 ; for ( int i = 0 ; i < MdvuqSn ; i ++ ) { first += a [ 0 ] [ i ] ; int second = 0 ; for ( int j = i ; j < MdvuqSn ; j ++ ) { second += a [ 1 ] [ j ] ; } max = Math . max ( max , first + second ) ; } System . out . println ( max ) ; sc . close ( ) ; } } import java . util . Scanner ; public class ibshlsZj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long IbshlsPwak = sc . nextLong ( ) ; long A = 1 ; for ( long i = 1 ; i * i <= IbshlsPwak ; i ++ ) { if ( IbshlsPwak % i == 0 && i > A ) { A = i ; } } long B = IbshlsPwak / A ; System . out . println ( A + B - 2 ) ; sc . close ( ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class WjdgiUdo { 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 ltsBml { public static void main ( String [ ] args ) { try ( Scanner cs = new Scanner ( System . in ) ) { String line = cs . nextLine ( ) ; String answer = " " ; int LtsDlt = line . LtsDlt ( ) ; for ( int i = 0 ; i < LtsDlt ; 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 ujyynrMln { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int UjyynrUncj = scan . nextInt ( ) ; int [ ] a = new int [ UjyynrUncj ] ; for ( int i = 0 ; i < UjyynrUncj ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } long sum = 0 ; while ( true ) { boolean flag = true ; for ( int i = 0 ; i < UjyynrUncj ; 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 dndplnM { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String DndplnMcl = scan . next ( ) ; String b = scan . next ( ) ; if ( DndplnMcl . equals ( b . substring ( 0 , b . length ( ) - 1 ) ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; } } import java . util . * ; class LqlvLo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long LqlvZ = sc . nextLong ( ) ; long r = sc . nextLong ( ) ; long min = LqlvZ * ( LqlvZ + 1 ) % 2019 ; if ( ( r - LqlvZ ) >= 2018 ) { System . out . println ( 0 ) ; } else if ( ( r - LqlvZ ) < ( 2019 - LqlvZ % 2019 ) ) { for ( long e = LqlvZ ; 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 tdjygyH { public static void main ( String [ ] a ) { Scanner scan = new Scanner ( System . in ) ; int TdjygyNmd = scan . nextInt ( ) ; Map < Integer , Integer > numMap = new HashMap < > ( ) ; for ( int i = 1 ; i < TdjygyNmd + 1 ; i ++ ) { int s = scan . nextInt ( ) ; int dis = TdjygyNmd - s ; numMap . put ( TdjygyNmd - dis , i ) ; } for ( int j = 1 ; j < numMap . size ( ) + 1 ; j ++ ) { System . out . printf ( " %d " , numMap . get ( j ) ) ; } } } import java . util . * ; public class swwxmIy { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final String SwwxmNt = sc . next ( ) ; final String t = sc . next ( ) ; sc . close ( ) ; String result = " No " ; if ( t . length ( ) == SwwxmNt . length ( ) + 1 && t . substring ( 0 , SwwxmNt . length ( ) ) . equals ( SwwxmNt ) ) { result = " Yes " ; } System . out . println ( result ) ; } } import java . util . * ; public class PqekVp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pqekAt = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int base = 1 ; for ( int i = 0 ; i < pqekAt ; i ++ ) { base *= 100 ; } if ( N % 100 == 0 ) { System . out . println ( base * ( N + 1 ) ) ; } else { System . out . println ( base * N ) ; } } } import java . util . * ; public class PwidwvKpsh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pwidwvQb = sc . nextInt ( ) ; Set < Integer > visited = new HashSet < > ( ) ; int cnt = 0 ; while ( pwidwvQb > 0 ) { pwidwvQb -- ; int num = sc . nextInt ( ) ; if ( visited . contains ( num ) ) continue ; visited . add ( num ) ; cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . * ; public class gimjjOoy { 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 GimjjCpe = sArray . length - tArray . length + 1 ; String part = new String ( ) ; int count = 9999 ; for ( int i = 0 ; i < GimjjCpe ; 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 ymxfeQal { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YmxfeVksg = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] arr = new int [ YmxfeVksg ] ; int totalVotes = 0 ; for ( int i = 0 ; i < YmxfeVksg ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; totalVotes += arr [ i ] ; } double popular = totalVotes / ( 4 * m ) ; int ans = 0 ; for ( int i = 0 ; i < YmxfeVksg ; 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 QqdhUcxd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qqdhYc = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < qqdhYc ; ++ 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 BoduMphean { static String a ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int BoduXs = stdIn . nextInt ( ) ; int count = 0 ; IN : for ( int i = 0 ; i < BoduXs ; 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 ludAye { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int LudCqpgu = sc . nextInt ( ) ; int sum = 0 ; int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < LudCqpgu ; 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 yprW { void solve ( ) { char [ ] a = incharar ( ) ; int YprIpfuk = 0 ; for ( int i = 0 ; i < a . length / 2 ; i ++ ) { if ( a [ i ] != a [ a . length - i - 1 ] ) YprIpfuk ++ ; } out . println ( YprIpfuk ) ; } 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 UgvOx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UgvAim = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ UgvAim ] ; for ( int i = 0 ; i < UgvAim ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int count = 0 ; uncode : while ( true ) { for ( int i = 0 ; i < UgvAim ; 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 GwznNovjp { public static void main ( String [ ] args ) throws IOException { PrintWriter out = new PrintWriter ( System . out ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int GwznImb = Integer . parseInt ( br . readLine ( ) ) ; int answer = ( int ) ( Math . ceil ( GwznImb / 1000.0 ) ) ; out . println ( answer * 1000 - GwznImb ) ; out . flush ( ) ; out . close ( ) ; } static class GwznNovjp { 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 tvqnrTj { 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 TvqnrKkkeo = s . equals ( Arrays . asList ( 2L , 2L ) ) ? " Yes " : " No " ; System . out . println ( TvqnrKkkeo ) ; } } 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 UcsxKfbh { 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 UcsxPd = 0 ; UcsxPd < firstRow . size ( ) ; UcsxPd ++ ) { ballsCountAndColor . put ( firstRow . get ( UcsxPd ) , ballsCount . get ( UcsxPd ) ) ; } 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 gnzdxJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GnzdxMjpq = sc . nextInt ( ) ; int a ; ArrayList < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; i < GnzdxMjpq ; 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 oejHe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OejLi = sc . nextInt ( ) ; int [ ] youso1 = new int [ OejLi ] ; for ( int i = 0 ; i < OejLi ; i ++ ) { youso1 [ i ] = sc . nextInt ( ) ; } int [ ] youso2 = youso1 . clone ( ) ; Arrays . sort ( youso2 ) ; for ( int i = 0 ; i < OejLi ; i ++ ) { if ( youso1 [ i ] < youso2 [ OejLi - 1 ] ) { System . out . println ( youso2 [ OejLi - 1 ] ) ; } else { System . out . println ( youso2 [ OejLi - 2 ] ) ; } } } } import java . util . ArrayList ; import java . util . Iterator ; import java . util . Scanner ; public class vacbW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long VacbVsb = sc . nextLong ( ) ; long result = 0 ; long num = sc . nextLong ( ) ; for ( int i = 1 ; i < VacbVsb ; 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 YjafvBcli { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int yjafvLn = scan . nextInt ( ) ; boolean f = false ; for ( int i = 0 ; i < yjafvLn ; i ++ ) { for ( int j = 0 ; j < yjafvLn ; j ++ ) { if ( ( 4 * i ) + ( 7 * j ) == yjafvLn ) { f = true ; System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } } import java . io . * ; import java . util . * ; public class mtqxkrVw { static PrintWriter out = new PrintWriter ( ( System . out ) ) ; public static void main ( String [ ] args ) throws IOException { Kioken sc = new Kioken ( ) ; char MtqxkrQrpno = sc . next ( ) . charAt ( 0 ) ; if ( Character . isUpperCase ( MtqxkrQrpno ) ) { out . println ( " A " ) ; } else { out . println ( " a " ) ; } out . close ( ) ; } public static void kamehameha ( ) { } static class mtqxkrVw { 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 WzvnxiUqaio { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WzvnxiEz = sc . nextInt ( ) ; int [ ] color = new int [ 9 ] ; int ans = 0 ; for ( int i = 0 ; i < WzvnxiEz ; 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 TqydpxTi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] a = sc . nextLine ( ) . split ( " " ) ; int TqydpxQc = a . length ; String answer = " " ; for ( int i = 0 ; i < TqydpxQc ; 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 fkyS { long FkyPhtdo = 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 bhqhsN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; for ( int BhqhsQph = 1 ; ; BhqhsQph ++ ) { int x = sc . nextInt ( ) ; if ( x == 0 ) { break ; } System . out . printf ( " Case %d: %d \n " , BhqhsQph , x ) ; } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class aneA { 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 aneA { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int AneYddla = Integer . parseInt ( in . next ( ) ) ; int preT = 0 ; int preX = 0 ; int preY = 0 ; for ( int i = 0 ; i < AneYddla ; 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 uxsuhXb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; StringBuilder output = new StringBuilder ( ) ; for ( int UxsuhWudfk = 0 ; UxsuhWudfk < input . length ( ) ; ++ UxsuhWudfk ) { if ( input . charAt ( UxsuhWudfk ) != 'B' ) { output . append ( input . charAt ( UxsuhWudfk ) ) ; } else { int len = output . length ( ) ; if ( len > 0 ) { output . deleteCharAt ( len - 1 ) ; } } } sc . close ( ) ; System . out . println ( output ) ; } } import java . util . Scanner ; public class EhvqqRnn { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int EhvqqC = in . nextInt ( ) ; int lim = in . nextInt ( ) ; int pos = 0 ; int ans = 0 ; for ( int i = 0 ; i < EhvqqC ; i ++ ) { pos += in . nextInt ( ) ; if ( lim < pos ) { ans = i + 1 ; break ; } else if ( lim == pos ) { ans = i + 2 ; break ; } else if ( i == EhvqqC - 1 ) { ans = EhvqqC + 1 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class SqcbsrGa { public static void main ( String [ ] args ) { int sqcbsrVf = 0 ; Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; sc . close ( ) ; for ( int i = 0 ; i < x ; i ++ ) { sqcbsrVf += 2 ; if ( ( i + 1 ) == x ) { if ( sqcbsrVf == y ) { System . out . println ( " Yes " ) ; } else { for ( int j = i ; j >= 0 ; j -- ) { sqcbsrVf -= 2 ; sqcbsrVf += 4 ; if ( sqcbsrVf == y ) { System . out . println ( " Yes " ) ; break ; } if ( j == 0 ) { System . out . println ( " No " ) ; } } } } } } } import java . util . * ; public class uvzezO { void solve ( ) { Scanner scan = new Scanner ( System . in ) ; int UvzezJq = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int [ ] h = new int [ UvzezJq ] ; for ( int i = 0 ; i < UvzezJq ; i ++ ) h [ i ] = scan . nextInt ( ) ; int [ ] dp = new int [ UvzezJq ] ; for ( int i = 0 ; i < UvzezJq ; i ++ ) dp [ i ] = Integer . MAX_VALUE ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 0 ; i < UvzezJq ; 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 [ UvzezJq - 1 ] ) ; scan . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class BfwroMmrxr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BfwroJm = sc . nextInt ( ) ; int [ ] a1 = new int [ BfwroJm + 2 ] ; int [ ] a2 = new int [ BfwroJm + 1 ] ; a1 [ 0 ] = 0 ; a2 [ 0 ] = 0 ; int sum = 0 ; int subsum = 0 ; int sum1 = 0 ; int sum2 = 0 ; for ( int i = 1 ; i <= BfwroJm ; i ++ ) { a1 [ i ] = sc . nextInt ( ) ; } sum1 = a1 [ 1 ] ; a1 [ BfwroJm + 1 ] = 0 ; for ( int i = 1 ; i <= BfwroJm ; i ++ ) { a2 [ i ] = sc . nextInt ( ) ; sum2 += a2 [ i ] ; } for ( int i = 1 ; i <= BfwroJm ; 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 VgbaoAc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vgbaoFhz = 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 ) * vgbaoFhz + Math . max ( 0 , Y - i ) * B ; min = Math . min ( min , amount ) ; } System . out . println ( min ) ; } } import java . util . Scanner ; public class UhkvMvcv { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int uhkvY = scanner . nextInt ( ) ; System . out . println ( 2 * uhkvY * Math . PI ) ; } } import java . util . Scanner ; public class qszkohQm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long QszkohEgs = sc . nextLong ( ) ; System . out . println ( hit ( QszkohEgs ) ) ; } private static long hit ( long QszkohEgs ) { return QszkohEgs == 1 ? 1 : hit ( QszkohEgs / 2 ) * 2 + 1 ; } } import java . util . Scanner ; class OqicirMd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str1 = scan . next ( ) ; String str2 = scan . next ( ) ; int oqicirWqzp = Integer . parseInt ( str1 ) ; int b = Integer . parseInt ( str2 ) ; System . out . println ( oqicirWqzp * b + " " + ( oqicirWqzp * 2 + b * 2 ) ) ; } } import java . util . * ; public class UphzXxz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UphzK = 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 ( UphzK - count ) ) ) ) { System . out . println ( UphzK - count ) ; break ; } if ( ! ( Arrays . asList ( nums ) . contains ( String . valueOf ( UphzK + count ) ) ) ) { System . out . println ( UphzK + count ) ; break ; } } } } import java . util . Scanner ; public class ebitSa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EbitTdp = sc . nextInt ( ) ; int c = 0 ; while ( EbitTdp > c ) { c = c + 1000 ; } c = c - EbitTdp ; System . out . println ( c ) ; } } import java . util . Scanner ; public class LlkvlFnqm { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int llkvlTcm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( k <= llkvlTcm ) { System . out . println ( k ) ; return ; } if ( k <= llkvlTcm + b ) { System . out . println ( llkvlTcm ) ; return ; } System . out . println ( llkvlTcm - ( k - llkvlTcm - b ) ) ; } } import java . util . Scanner ; public class TworLb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] lines = line . split ( " " ) ; int tworU = Integer . parseInt ( lines [ 0 ] ) ; int B = Integer . parseInt ( lines [ 1 ] ) ; System . out . println ( tworU * B ) ; } } import java . util . Arrays ; import java . util . Scanner ; class ijlwWs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IjlwIq = sc . nextInt ( ) ; int [ ] a = new int [ IjlwIq ] ; for ( int i = 0 ; i < IjlwIq ; i ++ ) a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; int ans = a [ IjlwIq / 2 ] - a [ IjlwIq / 2 - 1 ] ; System . out . println ( ans ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class VzhXhxa { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int VzhE = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; if ( VzhE <= m ) { System . out . println ( " unsafe " ) ; } else { System . out . println ( " safe " ) ; } } } import java . util . Scanner ; public class psmKzf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] list = sc . next ( ) . toCharArray ( ) ; boolean PsmQn = 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 ( ! PsmQn ) { PsmQn = true ; tmp = 0 ; } tmp ++ ; } else { if ( PsmQn ) { PsmQn = false ; max = Math . max ( max , tmp ) ; } } } System . out . println ( Math . max ( max , tmp ) ) ; } } import java . util . * ; import java . io . * ; class WoqMxa { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String [ ] input = br . readLine ( ) . split ( " " ) ; int woqZxv = Integer . parseInt ( input [ 0 ] ) ; int M = Integer . parseInt ( input [ 1 ] ) ; int result = 0 ; if ( woqZxv > 1 ) { result += ( woqZxv * ( woqZxv - 1 ) ) / 2 ; } if ( M > 1 ) { result += ( M * ( M - 1 ) ) / 2 ; } System . out . println ( result ) ; } } } import java . util . Scanner ; public class XgiwfvDh { public static void main ( String [ ] args ) { Scanner nine = new Scanner ( System . in ) ; int XgiwfvW = nine . nextInt ( ) ; int number2 = nine . nextInt ( ) ; if ( 1 <= XgiwfvW && XgiwfvW <= 9 && 1 <= number2 && number2 <= 9 ) { int answer = XgiwfvW * number2 ; System . out . println ( answer ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . * ; public class gqlRyp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long GqlNf = sc . nextLong ( ) ; long num = 2 ; while ( num <= GqlNf ) num *= 2 ; System . out . println ( num - 1 ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class GnskkBd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gnskkQdk = sc . nextInt ( ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < gnskkQdk ; 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 < gnskkQdk - 1 ; i ++ ) { if ( a . get ( i + 1 ) == flg + 1 ) { flg ++ ; } else { cnt ++ ; } } } System . out . println ( cnt ) ; } } import java . util . * ; public class ttnflZi { public static void main ( String [ ] args ) throws java . io . IOException { int TtnflWaro , h , m , s ; Scanner in = new Scanner ( System . in ) ; TtnflWaro = in . nextInt ( ) ; h = TtnflWaro / 3600 ; TtnflWaro = TtnflWaro % 3600 ; m = TtnflWaro / 60 ; s = TtnflWaro % 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 jrxzisCw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int JrxzisDwc = scan . nextInt ( ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; List < Integer > totalList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i <= JrxzisDwc ; 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 EblcvlHzxg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long eblcvlW = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( k <= eblcvlW ) { eblcvlW = eblcvlW - k ; k = 0 ; } else { k = k - eblcvlW ; eblcvlW = 0 ; } if ( k <= b ) { b = b - k ; k = 0 ; } else { k = k - b ; b = 0 ; } System . out . println ( eblcvlW + " " + b ) ; } } import java . util . Scanner ; public class rozP { public static void main ( String [ ] args ) { int RozDpxj , 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 ( RozDpxj = 0 ; RozDpxj < n ; RozDpxj ++ ) { name [ RozDpxj ] = sc . next ( ) ; time [ RozDpxj ] = 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 IbmEh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IbmZfh = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int [ ] [ ] table = new int [ IbmZfh + 1 ] [ y + 1 ] ; for ( int i = 0 ; i < IbmZfh ; i ++ ) { for ( int j = 0 ; j < y ; j ++ ) { table [ i ] [ j ] = sc . nextInt ( ) ; table [ i ] [ y ] += table [ i ] [ j ] ; table [ IbmZfh ] [ j ] += table [ i ] [ j ] ; table [ IbmZfh ] [ y ] += table [ i ] [ j ] ; } } for ( int i = 0 ; i < IbmZfh + 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 KomdcDyez { public static void main ( String [ ] args ) { int komdcZvdr , b , i , small , sum = 0 ; String s = " " ; Scanner sc = new Scanner ( System . in ) ; komdcZvdr = sc . nextInt ( ) ; b = sc . nextInt ( ) ; if ( komdcZvdr < b ) { small = komdcZvdr ; for ( i = b - 1 ; i >= 0 ; i -- ) { sum = sum + ( int ) Math . pow ( 10 , i ) ; } small = komdcZvdr * sum ; s = " " + small ; } else { small = b ; for ( i = komdcZvdr - 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 UqwgVql { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; long uqwgAkd = scn . nextInt ( ) ; System . out . println ( ( long ) ( uqwgAkd + Math . pow ( uqwgAkd , 2 ) + Math . pow ( uqwgAkd , 3 ) ) ) ; } } import java . util . Scanner ; public class DbgpuaJs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dbgpuaEqd = sc . nextInt ( ) ; int [ ] A = new int [ dbgpuaEqd ] ; for ( int i = 0 ; i < dbgpuaEqd ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < dbgpuaEqd ; i ++ ) { int minj = i ; for ( int j = i ; j < dbgpuaEqd ; 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 < dbgpuaEqd - 1 ; i ++ ) { System . out . print ( A [ i ] + " " ) ; } System . out . println ( A [ dbgpuaEqd - 1 ] ) ; System . out . print ( count ) ; System . out . printf ( " \n " ) ; } } import java . io . * ; import java . util . StringTokenizer ; public class DnqbKlqz { 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 DnqbLd = read . readLine ( ) ; if ( DnqbLd . charAt ( 0 ) == '7' ) { prnt . println ( " Yes " ) ; } else if ( DnqbLd . charAt ( 1 ) == '7' ) { prnt . println ( " Yes " ) ; } else if ( DnqbLd . charAt ( 2 ) == '7' ) { prnt . println ( " Yes " ) ; } else { prnt . println ( " No " ) ; } prnt . close ( ) ; } } import java . util . * ; public class ZdxmPdj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long zdxmUpuq = sc . nextLong ( ) ; long ans = 100 ; long sum = 0 ; while ( ans < zdxmUpuq ) { ans = ans + ( long ) ( ans / 100 ) ; sum ++ ; } System . out . println ( sum ) ; } } import java . util . * ; public class TkjPq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tkjHbp = sc . nextInt ( ) ; sc . close ( ) ; int sum = 0 ; int count = 0 ; while ( sum <= tkjHbp ) { count ++ ; sum = ( int ) Math . pow ( 2 , count ) ; } System . out . println ( ( int ) Math . pow ( 2 , count - 1 ) ) ; } } import java . util . * ; class cqijN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CqijOpqoj = sc . nextInt ( ) ; int count = 1 ; int Answer = 0 ; for ( int i = 0 ; i < CqijOpqoj ; i ++ ) { if ( sc . nextInt ( ) == count ) { count ++ ; } else { Answer ++ ; } } if ( Answer == CqijOpqoj ) { Answer = - 1 ; } System . out . println ( Answer ) ; } } import java . util . Scanner ; class KziVec { public static void main ( String [ ] ag ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; int kziH = 0 ; int gl = a . length ( ) - 1 ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) == 'A' ) { kziH = 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 - kziH + 1 ) ; } } import java . util . Scanner ; public class JnkvjOdeb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String inputId = sc . nextLine ( ) ; String inputAddId = sc . nextLine ( ) ; int jnkvjOoni = 0 ; for ( int i = 0 ; i < inputId . length ( ) ; i ++ ) { if ( inputId . charAt ( i ) != inputAddId . charAt ( i ) ) { jnkvjOoni ++ ; } } if ( jnkvjOoni == 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 ddxelrBmb { public static void main ( String [ ] args ) { final Scanner cin = new Scanner ( System . in ) ; int DdxelrQlbn = cin . nextInt ( ) ; long [ ] arr = new long [ DdxelrQlbn ] ; for ( int i = 0 ; i < DdxelrQlbn ; 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 HzrQkxr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hzrNt = sc . nextInt ( ) ; int [ ] arr = new int [ hzrNt ] ; for ( int i = 0 ; i < hzrNt ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int [ ] dp = new int [ hzrNt ] ; if ( hzrNt == 1 ) System . out . println ( arr [ 0 ] ) ; for ( int i = 1 ; i < hzrNt ; 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 [ hzrNt - 1 ] ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class McfImb { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int mcfDkf = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int ans = 1 ; int D = 0 ; for ( int i = 0 ; i < mcfDkf ; i ++ ) { D += sc . nextInt ( ) ; if ( D <= X ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class QdwwQoph { public static void main ( String [ ] args ) throws Exception { String [ ] lines = getStdin ( ) ; String str1 = lines [ 0 ] ; int QdwwS = 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 = QdwwS * i ; if ( multiple >= from && multiple <= till ) { System . out . println ( " OK " ) ; return ; } else { multiple = QdwwS ; } } 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 JvjRfgx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jvjQeat = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int result = 0 ; for ( int i = jvjQeat ; 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 UofecdWs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UofecdIz = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double ans = 0 ; int times = 0 ; for ( int i = UofecdIz ; i > 0 ; -- i ) { while ( i * Math . pow ( 2 , times ) < k ) ++ times ; ans = ans + ( 1 / ( double ) UofecdIz ) * Math . pow ( 0.5 , times ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class KvqjnhZooia { public static void main ( String [ ] arg ) { Scanner scan = new Scanner ( System . in ) ; int KvqjnhRjl = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int K = 0 ; int check = 0 ; if ( ( KvqjnhRjl + B ) % 2 == 0 ) { K = ( Math . abs ( KvqjnhRjl ) + Math . abs ( B ) ) / 2 ; check ++ ; } if ( check == 0 ) { System . out . println ( " IMPOSSIBLE " ) ; } else { System . out . println ( K ) ; } } } import java . io . * ; public class gorlwBvd { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; int GorlwOtf = Integer . parseInt ( line ) ; int sec = 0 , min = 0 , hour = 0 ; if ( GorlwOtf >= 3600 ) { hour = GorlwOtf / 3600 ; GorlwOtf = GorlwOtf % 3600 ; min = GorlwOtf / 60 ; sec = GorlwOtf % 60 ; System . out . println ( hour + " : " + min + " : " + sec ) ; } else if ( GorlwOtf >= 60 ) { min = GorlwOtf / 60 ; sec = GorlwOtf % 60 ; System . out . println ( hour + " : " + min + " : " + sec ) ; } else { System . out . println ( hour + " : " + min + " : " + sec ) ; } } } import java . util . Scanner ; public class MrleeZmji { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mrleeRhnl = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; for ( int turtle = 0 ; turtle <= mrleeRhnl ; ++ turtle ) { int crane = mrleeRhnl - 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 klvY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KlvHnqfb = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; String [ ] s = new String [ KlvHnqfb ] ; for ( int i = 0 ; i < KlvHnqfb ; i ++ ) { s [ i ] = sc . next ( ) ; set . add ( s [ i ] ) ; map . put ( s [ i ] , 0 ) ; } for ( int i = 0 ; i < KlvHnqfb ; 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 redjNxi { int RedjGch , 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 ) ; RedjGch = sc . nextInt ( ) ; B = sc . nextInt ( ) ; S = sc . next ( ) ; cS = S . toCharArray ( ) ; len = cS . length ; } public void solve ( ) { if ( len == RedjGch + B + 1 ) { if ( cS [ RedjGch ] == '-' ) { for ( int i = 0 ; i < RedjGch ; i ++ ) { if ( cS [ i ] >= '0' && cS [ i ] <= '9' ) { flg = true ; } else { flg = false ; break ; } } if ( flg == true ) { for ( int i = RedjGch + 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 ezzqU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EzzqDcfh = 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 <= EzzqDcfh ) { if ( EzzqDcfh - a >= EzzqDcfh - b ) { a = ( int ) b ; } } else { break ; } } } if ( EzzqDcfh < 4 ) { System . out . println ( EzzqDcfh ) ; } else { System . out . println ( a ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class hpmfS { 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 HpmfBmqqm = 0 ; HpmfBmqqm < string . length ( ) ; HpmfBmqqm ++ ) { lig [ HpmfBmqqm ] = string . substring ( HpmfBmqqm , HpmfBmqqm + 1 ) ; } int sum = 0 ; int [ ] v = new int [ lig . length ] ; for ( int HpmfBmqqm = 0 ; HpmfBmqqm < lig . length ; HpmfBmqqm ++ ) { v [ HpmfBmqqm ] = Integer . parseInt ( lig [ HpmfBmqqm ] ) ; sum += v [ HpmfBmqqm ] ; } 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 WyfsUp { 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 WyfsBou = Integer . parseInt ( st . nextToken ( ) ) ; int K = Integer . parseInt ( st . nextToken ( ) ) ; int [ ] prices = new int [ WyfsBou ] ; 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 lbbxGbm { public static void main ( String [ ] args ) { Set < Integer > set = new HashSet ( ) ; int LbbxFnsa = getInput ( ) ; do { set . add ( LbbxFnsa ) ; LbbxFnsa = f ( LbbxFnsa ) ; } while ( ! set . contains ( LbbxFnsa ) ) ; 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 XtntJrqx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xtntB = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int point = 0 ; int res = 1 ; for ( int i = 0 ; i < xtntB ; i ++ ) { point += Integer . parseInt ( sc . next ( ) ) ; if ( x < point ) break ; res ++ ; } System . out . println ( res ) ; } } import java . io . * ; public class PxveYk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int PxveVal = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 1 ] ) ; int d = PxveVal / b ; int e = PxveVal % b ; double f = ( double ) PxveVal / b ; System . out . printf ( " %d %d %.5f \n " , d , e , f ) ; } } import java . util . Scanner ; import java . lang . * ; public class LtezsfYlgr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String input = scanner . nextLine ( ) ; String [ ] inputs = input . split ( " " ) ; int ltezsfWs = Integer . parseInt ( inputs [ 0 ] ) ; int Q = Integer . parseInt ( inputs [ 1 ] ) ; int R = Integer . parseInt ( inputs [ 2 ] ) ; int min1 = Math . min ( ltezsfWs , Q ) ; int max1 = Math . max ( ltezsfWs , 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 MbvpYnd { 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 mbvpBx = str . mbvpBx ( ) ; String firstHalf = str . substring ( 0 , ( mbvpBx - 1 ) / 2 ) ; if ( ! isPalindrone ( firstHalf ) ) { return Result . No ; } String lastHalf = str . substring ( ( mbvpBx + 1 ) / 2 ) ; if ( ! isPalindrone ( lastHalf ) ) { return Result . No ; } return Result . Yes ; } private static boolean isPalindrone ( String str ) { int mbvpBx = str . mbvpBx ( ) ; if ( mbvpBx == 1 ) { return true ; } for ( int i = 0 ; i < ( mbvpBx + 1 ) / 2 ; i ++ ) { if ( str . charAt ( i ) != str . charAt ( mbvpBx - i - 1 ) ) { return false ; } } return true ; } public static enum Result { Yes , No } } import java . util . Scanner ; public class ZrcyvlWy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZrcyvlZt = sc . nextInt ( ) ; int [ ] A = new int [ ZrcyvlZt + 1 ] ; int [ ] B = new int [ ZrcyvlZt ] ; long jizenSum = 0 ; for ( int i = 0 ; i < ZrcyvlZt + 1 ; i ++ ) { A [ i ] = sc . nextInt ( ) ; jizenSum += A [ i ] ; } for ( int i = 0 ; i < ZrcyvlZt ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } int tmp = 0 ; for ( int i = 0 ; i < ZrcyvlZt ; 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 < ZrcyvlZt + 1 ; i ++ ) { sum += A [ i ] ; } System . out . println ( jizenSum - sum ) ; } } import java . util . Scanner ; public class hdaOd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int HdaRdppx = scanner . nextInt ( ) ; int hissatsuwazashurui = scanner . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < hissatsuwazashurui ; i ++ ) { sum += scanner . nextInt ( ) ; } if ( HdaRdppx > sum ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; class EebVhus { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String strs = sc . next ( ) ; String strp = sc . next ( ) ; int EebO = strs . length ( ) ; int psum = strp . length ( ) ; for ( int p = 0 ; p < EebO ; p ++ ) { String str1 = " " ; String str2 = " " ; String str3 = " " ; for ( int q = p ; q < EebO ; 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 == EebO - 1 ) { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class RnzjnYm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String rnzjnNtm = sc . nextLine ( ) ; rnzjnNtm = rnzjnNtm . replace ( " eraser " , " " ) . replace ( " erase " , " " ) . replace ( " dreamer " , " " ) . replace ( " dream " , " " ) ; if ( rnzjnNtm . equals ( " " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; class cdkeqcWud { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CdkeqcTma = sc . nextInt ( ) ; int [ ] [ ] [ ] bill = new int [ 4 ] [ 3 ] [ 10 ] ; int b ; int f ; int r ; int v = 0 ; for ( int i = 0 ; i < CdkeqcTma ; 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 QzfjFck { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long QzfjT = sc . nextLong ( ) ; long ans = Long . MAX_VALUE ; long j = 0 ; for ( long i = 1 ; i * i <= QzfjT ; i ++ ) { if ( QzfjT % i != 0 ) { continue ; } j = QzfjT / 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 avubVhz { 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 AvubGwe = ( int ) Math . ceil ( ( Double . parseDouble ( fight [ 0 ] ) / Double . parseDouble ( fight [ 1 ] ) ) ) ; System . out . println ( AvubGwe ) ; } } import java . util . Scanner ; public class NlcrdWql { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nlcrdH = sc . nextInt ( ) ; sc . nextLine ( ) ; String str = sc . nextLine ( ) ; if ( str . length ( ) <= nlcrdH ) { System . out . println ( str ) ; return ; } String str2 = str . substring ( 0 , nlcrdH ) + " ... " ; System . out . println ( str2 ) ; } } import java . util . * ; import java . util . Arrays ; public class QgdJsea { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; int qgdQbvy = scanner . nextInt ( ) ; int S = scanner . nextInt ( ) ; int sub = 0 ; int count = 0 ; for ( int i = 0 ; i <= qgdQbvy ; i ++ ) { if ( i != S ) { for ( int j = 0 ; j <= qgdQbvy ; j ++ ) { if ( i + j != S ) { sub = S - ( i + j ) ; if ( sub >= 0 && sub <= qgdQbvy ) { count ++ ; } } else if ( i + j == S ) { count ++ ; break ; } } } else if ( i == S ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class EppEkpku { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EppPyb = 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 ] ) ) { EppPyb ++ ; } } System . out . println ( EppPyb ) ; } } import java . util . * ; class CxhutYggg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CxhutUa = sc . nextInt ( ) ; Integer [ ] num = new Integer [ CxhutUa ] ; int alice = 0 ; int bob = 0 ; for ( int i = 0 ; i < CxhutUa ; i ++ ) { num [ i ] = sc . nextInt ( ) ; } Arrays . sort ( num ) ; for ( int i = CxhutUa - 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 XxdzpSkjxjl { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int XxdzpR = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] [ ] h = new int [ XxdzpR + 1 ] [ c + 1 ] ; StringBuilder sb1 = new StringBuilder ( ) ; StringBuilder sb2 = new StringBuilder ( ) ; String b = " " , n = " \n " ; for ( int i = 0 ; i < XxdzpR ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { h [ i ] [ j ] = sc . nextInt ( ) ; h [ i ] [ c ] += h [ i ] [ j ] ; h [ XxdzpR ] [ j ] += h [ i ] [ j ] ; h [ XxdzpR ] [ c ] += h [ i ] [ j ] ; sb1 . append ( h [ i ] [ j ] + b ) ; if ( i == XxdzpR - 1 ) sb2 . append ( h [ XxdzpR ] [ j ] + b ) ; } sb1 . append ( h [ i ] [ c ] + n ) ; } sb2 . append ( h [ XxdzpR ] [ c ] ) ; System . out . print ( sb1 ) ; System . out . println ( sb2 ) ; } } import static java . lang . Integer . parseInt ; public class blgoA { public static void main ( String [ ] args ) { String BlgoSsrmv = new java . util . Scanner ( System . in ) . nextLine ( ) ; String [ ] number = BlgoSsrmv . 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 EoduYz { 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 OstrvwKmg { 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 ostrvwM = m . searchA ( ) ; int end = m . searchZ ( ) ; System . out . println ( end - ostrvwM ) ; } } import java . util . Scanner ; public class DplqquUwr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . nextLine ( ) ; String [ ] strAry = str . split ( " " ) ; int DplqquTe = Integer . parseInt ( strAry [ 0 ] ) ; int int2 = Integer . valueOf ( strAry [ 1 ] ) . intValue ( ) ; int i = 0 ; boolean b = true ; while ( b ) { if ( DplqquTe < Math . pow ( int2 , i ) ) { System . out . println ( i ) ; b = false ; } i ++ ; scan . close ( ) ; } } } import java . util . * ; public class WsydvRknd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WsydvR = getInputInteger ( sc ) ; int b = getInputInteger ( sc ) ; if ( WsydvR % 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 HnhCmkkln { 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 HnhCmkkln { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int HnhTpz = in . nextInt ( ) ; int D = in . nextInt ( ) ; int mans = ( int ) Math . ceil ( HnhTpz / ( ( D * 2 ) + 1 ) ) ; if ( HnhTpz % ( ( D * 2 ) + 1 ) != 0 ) { mans ++ ; } out . println ( mans ) ; } } } import java . util . * ; public class YcjfrKzy { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int YcjfrMym = sc . nextInt ( ) ; String po = sc . next ( ) ; String po2 = po . substring ( 0 , YcjfrMym / 2 ) ; String po3 = po . substring ( YcjfrMym / 2 ) ; System . out . println ( ( po2 . equals ( po3 ) ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class gyjpzMa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GyjpzRy = sc . nextInt ( ) ; int [ ] array = new int [ GyjpzRy ] ; 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 PuegdXgf { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] str = new String [ 2 ] ; int puegdGja = 0 ; while ( in . hasNext ( ) ) { String buf = in . nextLine ( ) ; str [ puegdGja ] = 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 CsqdOnnd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CsqdKk = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { CsqdKk += sc . nextInt ( ) ; } if ( CsqdKk >= 22 ) { System . out . println ( " bust " ) ; return ; } System . out . println ( " win " ) ; } } import java . util . * ; class XhuPdfu { 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 xhuSk ; do { xhuSk = 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 ( ) ) ; xhuSk = true ; break ; } } } while ( xhuSk ) ; System . out . println ( ( str . toString ( ) . equals ( " " ) ) ? " YES " : " NO " ) ; } } import java . util . * ; public class WgoqIv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wgoqC = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] A = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { A [ i ] = sc . nextInt ( ) ; wgoqC -= A [ i ] ; } if ( wgoqC <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class AextojOiokju { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int AextojNj = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int empty = AextojNj - b ; if ( c - empty < 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( c - empty ) ; } } } import java . util . Scanner ; public class rmcnG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RmcnEqjo = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String result = ( RmcnEqjo == b ) ? " a == b " : ( RmcnEqjo > b ) ? " a > b " : " a < b " ; System . out . println ( result ) ; } } import java . util . Scanner ; public class bitqQk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; Boolean bool = true ; for ( int BitqYxd = 0 ; BitqYxd < S . length ( ) ; BitqYxd ++ ) { if ( BitqYxd % 2 == 0 ) { if ( ! ( ( S . charAt ( BitqYxd ) == 'R' ) || ( S . charAt ( BitqYxd ) == 'U' ) || ( S . charAt ( BitqYxd ) == 'D' ) ) ) { bool = false ; } } if ( BitqYxd % 2 == 1 ) { if ( ! ( ( S . charAt ( BitqYxd ) == 'L' ) || ( S . charAt ( BitqYxd ) == 'U' ) || ( S . charAt ( BitqYxd ) == 'D' ) ) ) { bool = false ; } } } if ( bool == true ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } sc . close ( ) ; } } import java . util . * ; public class WowfByb { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String WowfHh = in . next ( ) ; if ( WowfHh . compareTo ( " ABC " ) == 0 ) { System . out . println ( " ARC " ) ; } else { System . out . println ( " ABC " ) ; } } } import java . util . * ; public class WtrLegxa { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int WtrIkg = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int z ; int count = 0 ; for ( int x = 0 ; x <= WtrIkg ; x ++ ) { for ( int y = 0 ; y <= WtrIkg ; y ++ ) { z = s - x - y ; if ( 0 <= z && z <= WtrIkg ) { count += 1 ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class PiauJc { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scanner = new Scanner ( System . in ) ; int piauM = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; System . out . println ( piauM * b ) ; } } import java . util . Scanner ; public class KinvoPgq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int KinvoT = scan . nextInt ( ) , b = scan . nextInt ( ) , c = scan . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= c ; i ++ ) { if ( KinvoT <= 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 AhjaXfng { 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 AhjaXfng { public void solve ( int testNumber , FastReader in , PrintWriter out ) { out . println ( in . nextInt ( ) > in . nextInt ( ) ? " safe " : " unsafe " ) ; } } static class AhjaXfng { 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 EbswfJw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EbswfX = sc . nextInt ( ) ; int [ ] H = new int [ EbswfX ] ; int [ ] Hmax = new int [ EbswfX ] ; for ( int i = 0 ; i < EbswfX ; 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 < EbswfX ; i ++ ) { if ( H [ i ] >= Hmax [ i ] ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; class MhkbdSqp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mhkbdUi = scan . nextInt ( ) ; int [ ] r = new int [ mhkbdUi ] ; int ans ; for ( int i = 0 ; i < mhkbdUi ; i ++ ) { r [ i ] = scan . nextInt ( ) ; } int maxv = r [ 1 ] - r [ 0 ] ; int minv = r [ 0 ] ; for ( int i = 1 ; i < mhkbdUi ; i ++ ) { maxv = Math . max ( maxv , r [ i ] - minv ) ; minv = Math . min ( minv , r [ i ] ) ; } System . out . println ( maxv ) ; } } import java . util . Scanner ; public class tvdiayTv { public static void main ( String [ ] args ) { int TvdiayFnlo , y , z , a , b , c ; Scanner sc = new Scanner ( System . in ) ; a = 0 ; TvdiayFnlo = sc . nextInt ( ) ; y = sc . nextInt ( ) ; y = y / 1000 ; if ( y < TvdiayFnlo ) { System . out . println ( " -1 -1 -1 " ) ; } else if ( y == TvdiayFnlo ) { System . out . println ( " 0 0 " + y ) ; } else { z = y - TvdiayFnlo ; while ( z % 9 != 0 ) { z = z - 4 ; a ++ ; } b = z / 9 ; c = TvdiayFnlo - 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 SddzkSlgb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int sddzkOumn = scanner . nextInt ( ) ; int [ ] b = new int [ sddzkOumn ] ; int c = Integer . MAX_VALUE ; int d = Integer . MIN_VALUE ; long e = 0 ; for ( int i = 0 ; i < sddzkOumn ; 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 SimraUdcs { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; double SimraE = sc . nextDouble ( ) ; double a = 3.14159265358979323846 * SimraE * SimraE ; double l = 3.14159265358979323846 * SimraE * 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 UlhNpzj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Double > list = new ArrayList < > ( ) ; Double n = sc . nextDouble ( ) ; for ( int UlhP = 0 ; UlhP < n ; UlhP ++ ) { 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 NtjhRtg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NtjhB = sc . nextInt ( ) ; int [ ] d = new int [ NtjhB ] ; int ans = 0 ; for ( int i = 0 ; i < NtjhB ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < NtjhB ; i ++ ) { for ( int j = i + 1 ; j < NtjhB ; 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 VjpSljstd { static class VjpSljstd { 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 VjpBip = s . nextInt ( ) ; int v = ( int ) ( VjpBip + Math . pow ( VjpBip , 2 ) + Math . pow ( VjpBip , 3 ) ) ; System . out . println ( v ) ; } } import java . util . * ; public class GxdzDtaesg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GxdzThj = sc . nextInt ( ) ; int a2 = GxdzThj * GxdzThj ; int a3 = GxdzThj * GxdzThj * GxdzThj ; int ans = GxdzThj + a2 + a3 ; System . out . println ( ans ) ; } } import java . util . Scanner ; class IyppFcip { int iyppAyjq , m , x , y ; public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; sc . useDelimiter ( " \\ s " ) ; iyppAyjq = sc . nextInt ( ) ; m = sc . nextInt ( ) ; int [ ] [ ] A = new int [ iyppAyjq ] [ m ] ; int [ ] b = new int [ m ] ; int [ ] c = new int [ iyppAyjq ] ; for ( x = 0 ; x < iyppAyjq ; 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 < iyppAyjq ; x ++ ) { for ( y = 0 ; y < m ; y ++ ) { c [ x ] = c [ x ] + A [ x ] [ y ] * b [ y ] ; } } for ( x = 0 ; x < iyppAyjq ; x ++ ) { System . out . println ( c [ x ] ) ; } } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . * ; public class ewtoAq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EwtoNknmm = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; long at = 0 ; for ( int i = 0 ; i < n ; i ++ ) at += sc . nextInt ( ) ; if ( EwtoNknmm <= at ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; class plzYvg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PlzZtfk = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] x = new int [ b ] ; for ( int i = 0 ; i < PlzZtfk ; 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 ( PlzZtfk == x [ k ] ) ret = ret + 1 ; } System . out . println ( ret ) ; } } import java . util . Scanner ; public class EznmwyNev { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eznmwyOf = sc . nextInt ( ) ; int [ ] monsters = new int [ eznmwyOf + 1 ] ; int [ ] heroes = new int [ eznmwyOf ] ; for ( int i = 0 ; i < eznmwyOf + 1 ; i ++ ) monsters [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < eznmwyOf ; i ++ ) heroes [ i ] = sc . nextInt ( ) ; int rem = 0 ; long totalKilled = 0 ; for ( int i = 0 ; i < eznmwyOf ; 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 [ eznmwyOf ] ) ; System . out . println ( totalKilled ) ; } } import java . util . * ; public class ufkbeyZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] s = S . toCharArray ( ) ; int UfkbeyNzfsm = S . length ( ) ; boolean OK = true ; int i = 0 ; int j = ( UfkbeyNzfsm - 1 ) / 2 - 1 ; while ( j - i >= 1 ) { if ( s [ i ] == s [ j ] && s [ UfkbeyNzfsm - 1 - i ] == s [ UfkbeyNzfsm - 1 - j ] ) { i ++ ; j -- ; } else { OK = false ; break ; } } for ( int k = 0 ; k < UfkbeyNzfsm / 2 ; k ++ ) { if ( s [ k ] != s [ UfkbeyNzfsm - 1 - k ] ) { OK = false ; break ; } } System . out . println ( OK ? " Yes " : " No " ) ; } } import java . util . * ; class upqsmHb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long UpqsmIqnp = sc . nextLong ( ) ; long r = sc . nextLong ( ) ; long min = Long . MAX_VALUE ; int cnt = 0 ; if ( r - UpqsmIqnp >= 2018 ) { System . out . println ( 0 ) ; return ; } for ( long i = UpqsmIqnp ; 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 wzrQor { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WzrNz = 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 ljsbEp { 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 ljsbEp { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int LjsbIkbis = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; out . println ( LjsbIkbis + b + c >= 22 ? " bust " : " win " ) ; } } } import java . math . * ; import java . util . * ; public class ItzoTk { 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 kzhmnH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int KzhmnBm = 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 ++ ; } KzhmnBm = Math . min ( count , KzhmnBm ) ; } System . out . println ( KzhmnBm ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class PekiuFsoaf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PekiuIpi = getInt ( sc ) ; int [ ] d = getIntArray ( sc ) ; Arrays . sort ( d ) ; int ARCMax = d [ PekiuIpi / 2 - 1 ] ; int ABCMin = d [ PekiuIpi / 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 gbjulY { 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 GbjulDpr = sc . nextInt ( ) ; GbjulDpr > 0 ; GbjulDpr -- ) { 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 PwgyIo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pwgyPrf = sc . nextInt ( ) ; int [ ] value = new int [ pwgyPrf ] ; for ( int i = 0 ; i < pwgyPrf ; 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 CemoUzpv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cemoJuv = sc . nextInt ( ) ; int a = cemoJuv / 100 ; int b = ( cemoJuv - a * 100 ) / 10 ; int c = ( cemoJuv - a * 100 - b * 10 ) / 1 ; System . out . println ( a + b + c ) ; } } import java . util . * ; public class BvrByd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bvrDg = sc . nextInt ( ) ; double b = sc . nextDouble ( ) ; long ans = ( long ) ( bvrDg * ( b * 100 ) ) / 100 ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . Scanner ; public class RxtvpOmwofp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RxtvpN = sc . nextInt ( ) ; int [ ] w = new int [ RxtvpN ] ; for ( int i = 0 ; i < RxtvpN ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } int ans = 100000000 ; for ( int i = 0 ; i < RxtvpN ; i ++ ) { int sum1 = 0 ; int sum2 = 0 ; for ( int j = 0 ; j < i ; j ++ ) { sum1 += w [ j ] ; } for ( int k = i ; k < RxtvpN ; k ++ ) { sum2 += w [ k ] ; } ans = Math . min ( ans , ( int ) Math . abs ( sum1 - sum2 ) ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class rrtOs { void run ( ) { Scanner s = new Scanner ( System . in ) ; while ( true ) { int RrtNmvti = s . nextInt ( ) ; int x = s . nextInt ( ) ; if ( RrtNmvti == 0 && x == 0 ) break ; int sum = 0 ; int count = 0 ; int a = 0 ; int [ ] num = new int [ RrtNmvti ] ; for ( int i = 0 ; i < RrtNmvti ; i ++ ) num [ i ] = i + 1 ; for ( int i = a ; i < RrtNmvti ; i ++ ) { for ( int j = i + 1 ; j < RrtNmvti ; j ++ ) { for ( int k = j + 1 ; k < RrtNmvti ; 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 spgjchLgk { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int SpgjchXybev , m , ans ; SpgjchXybev = sc . nextInt ( ) ; m = sc . nextInt ( ) ; ans = ( ( SpgjchXybev + m ) * ( SpgjchXybev + m - 1 ) ) / 2 - ( SpgjchXybev * m ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class MwvzipQlyo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long MwvzipMw = sc . nextLong ( ) , K = sc . nextLong ( ) ; double ch = Math . log ( MwvzipMw ) / 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 bvjJn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BvjTrymv = sc . nextInt ( ) ; int sum = sc . nextInt ( ) ; int ct = 0 ; for ( int i = 0 ; i <= BvjTrymv ; i ++ ) { for ( int j = 0 ; j <= BvjTrymv ; j ++ ) { int tmp = sum - i - j ; if ( tmp <= BvjTrymv && tmp >= 0 ) ct ++ ; } } System . out . println ( ct ) ; } } import java . util . Scanner ; public class ouxeeC { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int OuxeeKjgb = in . nextInt ( ) ; int T = in . nextInt ( ) ; int A = in . nextInt ( ) ; int [ ] h = new int [ OuxeeKjgb ] ; double [ ] t = new double [ OuxeeKjgb ] ; for ( int i = 0 ; i < OuxeeKjgb ; 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 < OuxeeKjgb ; i ++ ) { if ( min > t [ i ] ) { min = t [ i ] ; minn = i ; } } System . out . println ( minn + 1 ) ; } } import java . util . Scanner ; public class MmylSjhh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mmylDra = sc . nextInt ( ) ; boolean ok = false ; LOOP : for ( int i = 0 ; i <= mmylDra ; i += 4 ) { for ( int j = 0 ; i + j <= mmylDra ; j += 7 ) { if ( i + j == mmylDra ) { ok = true ; break LOOP ; } } } if ( ok ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class XbuovkIa { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] pizza = new int [ 5 ] ; int xbuovkLrs = 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 ; xbuovkLrs = Math . min ( xbuovkLrs , pizza [ 0 ] * a + pizza [ 1 ] * b + pizza [ 2 ] * c ) ; } System . out . println ( xbuovkLrs ) ; } } import java . util . * ; public class wzoueOwk { private final static int WzoueMgcdc = 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 eulloY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EulloWhie = sc . nextInt ( ) ; int [ ] c = new int [ 9 ] ; for ( int i = 0 ; i < EulloWhie ; 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 pskzfNp { final static long PskzfJxnc = 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 / PskzfJxnc != R / PskzfJxnc ) { 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 ) % PskzfJxnc ; min = Math . min ( min , r ) ; } } System . out . println ( min ) ; } } import java . util . Scanner ; public class VpxcxAdeo { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; String vpxcxU = scanner . next ( ) ; String b = scanner . next ( ) ; if ( ( vpxcxU . length ( ) + 1 == b . length ( ) ) && b . startsWith ( vpxcxU ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class JjjyUus { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JjjyLr = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; if ( JjjyLr <= 5 ) System . out . println ( " 0 " ) ; else if ( JjjyLr <= 12 ) System . out . println ( b / 2 ) ; else System . out . println ( b ) ; } } import java . io . * ; class hirsewQud { int [ ] s ; int HirsewBooj ; Sta ( ) { s = new int [ 1000 ] ; HirsewBooj = 0 ; } void push ( int x ) { HirsewBooj ++ ; s [ HirsewBooj ] = x ; } int pop ( ) { HirsewBooj -- ; return s [ HirsewBooj + 1 ] ; } } public class hirsewQud { 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 ecolBz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EcolKozcz = sc . nextInt ( ) ; int lowPos = sc . nextInt ( ) ; String str = sc . next ( ) ; String [ ] ary = str . split ( " " , 0 ) ; for ( int i = 0 ; i < EcolKozcz ; i ++ ) { if ( i == lowPos - 1 ) ary [ i ] = ary [ i ] . toLowerCase ( ) ; System . out . print ( ary [ i ] ) ; } } } import java . util . Scanner ; class harxciBjv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HarxciYatg = sc . nextInt ( ) ; int [ ] sequence = new int [ HarxciYatg ] ; double denominator = 0 ; for ( int i = 0 ; i < HarxciYatg ; i ++ ) { sequence [ i ] = sc . nextInt ( ) ; denominator += 1.0 / sequence [ i ] ; } System . out . println ( 1 / denominator ) ; } } import java . util . * ; public class HzmoCe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; String T = sc . nextLine ( ) ; sc . close ( ) ; boolean hzmoL = true ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { char sVal = S . charAt ( i ) ; char tVal = T . charAt ( i ) ; if ( sVal != tVal ) { hzmoL = false ; break ; } } if ( hzmoL ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class qctsgTu { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int QctsgNtb = in . nextInt ( ) ; int [ ] hills = new int [ QctsgNtb ] ; for ( int i = 0 ; i < QctsgNtb ; i ++ ) { hills [ i ] = in . nextInt ( ) ; } int counter = 1 ; int cur = hills [ 0 ] ; for ( int i = 1 ; i < QctsgNtb ; i ++ ) { if ( hills [ i ] >= cur ) { counter ++ ; cur = hills [ i ] ; } } System . out . println ( counter ) ; } } import java . util . * ; public class JzmxyMu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JzmxyUiv = sc . nextInt ( ) , d = sc . nextInt ( ) ; sc . close ( ) ; int tmp = 2 * d + 1 ; int r = JzmxyUiv % tmp ; int ans = JzmxyUiv / tmp ; if ( r != 0 ) ans ++ ; System . out . println ( ans ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class IlvmvHgy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Set < Integer > arrays = new HashSet < > ( ) ; int ilvmvOdd = 1 ; int s = sc . nextInt ( ) ; arrays . add ( s ) ; while ( true ) { ilvmvOdd ++ ; s = result ( s ) ; if ( arrays . contains ( s ) ) { System . out . println ( ilvmvOdd ) ; 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 hqiqtN { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; char HqiqtZar = scan . next ( ) . charAt ( 0 ) ; System . out . println ( ++ HqiqtZar ) ; } } import java . util . * ; public class odwribNx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OdwribIpwqo = sc . nextInt ( ) ; int a = OdwribIpwqo % 500 ; int b = ( a - ( a % 5 ) ) ; int c = ( OdwribIpwqo - a ) * 2 ; System . out . println ( b + c ) ; } } import java . util . * ; public class zjdrqF { public static void main ( String [ ] args ) { Scanner sc = null ; sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; String before = " " ; int ZjdrqSrw = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( i == 0 ) { if ( s . substring ( 0 , 1 ) . equals ( " R " ) ) { ZjdrqSrw = 1 ; } before = s . substring ( 0 , 1 ) ; } else { if ( s . substring ( i , i + 1 ) . equals ( " R " ) && before . equals ( " R " ) ) { ZjdrqSrw += 1 ; } else if ( s . substring ( i , i + 1 ) . equals ( " R " ) && before . equals ( " S " ) ) { ZjdrqSrw = 1 ; } before = s . substring ( i , i + 1 ) ; } } System . out . println ( ZjdrqSrw ) ; } } import java . util . Arrays ; import java . util . Collection ; import java . util . Collections ; import java . util . Scanner ; public class oruuVw { public static void main ( String [ ] args ) { int OruuIl = 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 == '+' ) { OruuIl ++ ; } else { OruuIl -- ; } if ( b == '+' ) { OruuIl ++ ; } else { OruuIl -- ; } if ( c == '+' ) { OruuIl ++ ; } else { OruuIl -- ; } if ( d == '+' ) { OruuIl ++ ; } else { OruuIl -- ; } System . out . println ( OruuIl ) ; } } import java . util . * ; public class alngiqF { public static void main ( String [ ] args ) { boolean AlngiqWgdoz = 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 ) AlngiqWgdoz = 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 ) AlngiqWgdoz = false ; } else AlngiqWgdoz = false ; } } } else AlngiqWgdoz = false ; if ( AlngiqWgdoz ) System . out . println ( " Yes " ) ; else if ( ! AlngiqWgdoz ) System . out . println ( " No " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class qpaB { static long QpaQf = 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 VrsvMxf { public static void main ( String [ ] args ) { Scanner inp = new Scanner ( System . in ) ; int vrsvQez = inp . nextInt ( ) ; int cols = inp . nextInt ( ) ; int [ ] [ ] aMatrix = new int [ vrsvQez ] [ cols ] ; int [ ] [ ] bMatrix = new int [ cols ] [ 1 ] ; for ( int k = 0 ; k < vrsvQez ; 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 , vrsvQez , cols ) ; for ( int [ ] item : total ) { for ( int secondItem : item ) { System . out . println ( secondItem ) ; } } } public static int [ ] [ ] matrixCalc ( int [ ] [ ] aMatrix , int [ ] [ ] bMatrix , int vrsvQez , int cols ) { int [ ] [ ] totals = new int [ vrsvQez ] [ 1 ] ; for ( int k = 0 ; k < vrsvQez ; 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 FvpfwfIzt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int FvpfwfFw = scan . nextInt ( ) ; long sum = 0 ; for ( int i = 1 ; i <= FvpfwfFw ; i ++ ) { for ( int j = 1 ; j <= FvpfwfFw ; j ++ ) { for ( int l = 1 ; l <= FvpfwfFw ; 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 dzoB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DzoIl = sc . nextInt ( ) ; int a , b , c ; a = DzoIl / 100 ; b = ( DzoIl - a * 100 ) / 10 ; c = DzoIl - 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 IvdmbAedrn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; sc . close ( ) ; int IvdmbFqe = S . IvdmbFqe ( ) ; boolean flag = true ; for ( int i = 1 ; i <= IvdmbFqe ; 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 NipvmDf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nipvmI = sc . nextInt ( ) ; int [ ] b = new int [ nipvmI - 1 ] ; int sum = 0 ; for ( int i = 0 ; i < nipvmI - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } sum += b [ 0 ] ; for ( int j = 0 ; j < nipvmI - 2 ; j ++ ) { if ( b [ j ] >= b [ j + 1 ] ) { sum += b [ j + 1 ] ; } else { sum += b [ j ] ; } } sum += b [ nipvmI - 2 ] ; System . out . println ( sum ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class ZyuPyln { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String zyuIfo = sc . next ( ) ; if ( zyuIfo . charAt ( 0 ) == zyuIfo . charAt ( 1 ) && ( zyuIfo . charAt ( 2 ) == zyuIfo . charAt ( 3 ) ) && ( zyuIfo . charAt ( 0 ) != zyuIfo . charAt ( 2 ) ) ) System . out . println ( " Yes " ) ; else if ( zyuIfo . charAt ( 0 ) == zyuIfo . charAt ( 2 ) && ( zyuIfo . charAt ( 1 ) == zyuIfo . charAt ( 3 ) ) && ( zyuIfo . charAt ( 0 ) != zyuIfo . charAt ( 1 ) ) ) System . out . println ( " Yes " ) ; else if ( zyuIfo . charAt ( 0 ) == zyuIfo . charAt ( 3 ) && ( zyuIfo . charAt ( 1 ) == zyuIfo . charAt ( 2 ) ) && ( zyuIfo . charAt ( 0 ) != zyuIfo . charAt ( 1 ) ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class SlmkmbYt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int slmkmbSt = 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' ; slmkmbSt = slmkmbSt + b ; } if ( n % slmkmbSt == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class GhlpavLcsy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String GhlpavH = sc . next ( ) ; if ( GhlpavH . 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 fhqXb { 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 fhqXb { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { int FhqFyexv = in . Int ( ) ; out . println ( ( 1000 - ( FhqFyexv % 1000 ) ) % 1000 ) ; } } static class fhqXb { 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 VjbieNem { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { while ( true ) { int vjbieSqn = sc . nextInt ( ) , f = sc . nextInt ( ) , r = sc . nextInt ( ) ; if ( vjbieSqn == - 1 && f == - 1 && r == - 1 ) { break ; } if ( vjbieSqn == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } else if ( vjbieSqn + f >= 80 ) { System . out . println ( " A " ) ; } else if ( vjbieSqn + f >= 65 ) { System . out . println ( " B " ) ; } else if ( vjbieSqn + f >= 50 ) { System . out . println ( " C " ) ; } else if ( vjbieSqn + 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 zgozwQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZgozwSo = sc . nextInt ( ) ; String [ ] vote = new String [ ZgozwSo ] ; int i = 0 ; while ( i < ZgozwSo ) { vote [ i ] = sc . next ( ) ; i ++ ; } Arrays . sort ( vote ) ; int maxCounter = 0 ; int [ ] a = new int [ ZgozwSo ] ; String [ ] b = new String [ ZgozwSo ] ; int j = 0 ; a [ 0 ] = 1 ; b [ 0 ] = vote [ 0 ] ; for ( i = 1 ; i < ZgozwSo ; 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 < ZgozwSo ; i ++ ) { if ( a [ i ] == maxCounter ) { System . out . println ( b [ i ] ) ; } } } } import java . util . * ; class OmcnmaXk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int omcnmaExhj = Integer . parseInt ( sc . next ( ) ) ; String s = Integer . toString ( omcnmaExhj ) ; 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 SmmRjxh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String word = sc . nextLine ( ) ; int smmAwg = 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 ) ) { smmAwg ++ ; } } } System . out . println ( smmAwg ) ; } } import java . util . Scanner ; import java . util . Arrays ; import java . lang . Math ; public class CucpbLcsr { 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 BjtnpNh { 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 bjtnpRku = 0 ; bjtnpRku < in . length ; bjtnpRku ++ ) { char b01 = in [ bjtnpRku ] ; 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 bjtnpRku = 0 ; bjtnpRku < out . size ( ) ; bjtnpRku ++ ) { String s = out . get ( bjtnpRku ) ; kotae = kotae + s ; } System . out . println ( kotae ) ; } } import java . io . * ; import java . util . * ; public class AivnkEs { public static void main ( final String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; int AivnkSc = sc . nextInt ( ) ; String S = sc . next ( ) ; final Solver solver = new Solver ( ) ; solver . solve ( AivnkSc , S ) ; } } class AivnkEs { public void solve ( int AivnkSc , String S ) { int ans = 0 ; int cur = 'A' ; for ( int i = 0 ; i < AivnkSc ; 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 AvutgiJbuo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int AvutgiJg = Integer . parseInt ( a + b ) ; for ( int i = 2 ; i * i <= AvutgiJg ; i ++ ) { if ( i * i == AvutgiJg ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class ccxynDd { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String CcxynKmv = sc . nextLine ( ) ; String p = sc . nextLine ( ) ; CcxynKmv += CcxynKmv ; if ( CcxynKmv . contains ( p ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class wqpbX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WqpbWgdz = sc . nextInt ( ) ; int [ ] t = new int [ WqpbWgdz ] ; int [ ] x = new int [ WqpbWgdz ] ; int [ ] y = new int [ WqpbWgdz ] ; for ( int i = 0 ; i < WqpbWgdz ; 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 < WqpbWgdz ; 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 IpcmoGsn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; sc . next ( ) ; int IpcmoQhb = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; if ( c [ IpcmoQhb - 1 ] == 'A' ) { c [ IpcmoQhb - 1 ] = 'a' ; } else if ( c [ IpcmoQhb - 1 ] == 'B' ) { c [ IpcmoQhb - 1 ] = 'b' ; } else { c [ IpcmoQhb - 1 ] = 'c' ; } System . out . println ( c ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class YjgpKz { 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 YjgpGh = 0 ; int lastW = 0 ; do { YjgpGh = stdIn . nextInt ( ) ; lastW = stdIn . nextInt ( ) ; H . add ( YjgpGh ) ; W . add ( lastW ) ; } while ( YjgpGh != 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 QzsMgvpr { public static void main ( String [ ] args ) { Scanner key = new Scanner ( System . in ) ; double QzsG = key . nextInt ( ) ; key . close ( ) ; System . out . println ( ( QzsG / 3 ) * ( QzsG / 3 ) * ( QzsG / 3 ) ) ; } } import java . util . Scanner ; public class EhakAof { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String S = stdIn . next ( ) ; String [ ] s = S . split ( " S " ) ; int EhakE = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { EhakE = Math . max ( EhakE , s [ i ] . length ( ) ) ; } System . out . println ( EhakE ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class MevgttUxo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mevgttEs = 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 < mevgttEs ; 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 ] == mevgttEs ) ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; class DpqhUujf { private static Scanner sc ; public static void main ( final String [ ] args ) { sc = new Scanner ( System . in ) ; String dpqhFhv = sc . next ( ) ; if ( dpqhFhv . equals ( " ABC " ) ) System . out . println ( " ARC " ) ; else { System . out . println ( " ABC " ) ; } } } import java . util . * ; public class KdefYfec { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int kdefOp = s . length ( ) ; int sum1 = 0 ; int sum2 = 0 ; sum1 = 0 ; for ( int i = 0 ; i < kdefOp ; 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 < kdefOp ; 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 TwnmUqpn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int twnmM = sc . nextInt ( ) ; double a = twnmM / 3.0 ; double b = twnmM / 3.0 ; double v = a * b * ( twnmM - a - b ) ; System . out . println ( v ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class jhrxFx { 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 HyalOe { public static void main ( String [ ] args ) { int hyalQqn , b ; Scanner sc = new Scanner ( System . in ) ; do { hyalQqn = sc . nextInt ( ) ; } while ( ! ( ( hyalQqn >= 1 ) && ( hyalQqn <= 20 ) ) ) ; do { b = sc . nextInt ( ) ; } while ( ! ( ( b >= 1 ) && ( b <= 20 ) ) ) ; if ( ( hyalQqn >= 1 && hyalQqn <= 9 ) && ( b >= 1 && b <= 9 ) ) { System . out . println ( hyalQqn * b ) ; } else { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; public class VuewgYdy { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int vuewgGs = Integer . parseInt ( scanner . nextLine ( ) ) ; String s = scanner . nextLine ( ) ; if ( vuewgGs % 2 == 1 || vuewgGs == 0 ) { System . out . println ( " No " ) ; return ; } String s1 = s . substring ( 0 , vuewgGs / 2 ) ; String s2 = s . substring ( vuewgGs / 2 , vuewgGs ) ; if ( s1 . startsWith ( s2 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scanner . close ( ) ; } } import java . util . Scanner ; public class DdbolpRt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ddbolpFyq = scan . nextInt ( ) ; for ( int i = 1 ; i <= ddbolpFyq ; 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 StnKtb { private static long stnMxf = 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 ] % stnMxf ; } if ( steps [ i + 1 ] != - 1 ) { steps [ i + 1 ] += steps [ i ] % stnMxf ; } } System . out . println ( steps [ count ] % stnMxf ) ; } } import java . util . Scanner ; public class jtqlZku { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JtqlHigig = sc . nextInt ( ) ; int maxCount = 0 ; int maxNum = 0 ; for ( int i = 0 ; i < JtqlHigig ; 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 ZvcnRye { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long zvcnOoki = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( zvcnOoki > k ) { zvcnOoki -= k * ( zvcnOoki / k ) ; if ( k - zvcnOoki < zvcnOoki ) { System . out . println ( k - zvcnOoki ) ; } else { System . out . println ( zvcnOoki ) ; } } else { if ( k - zvcnOoki < zvcnOoki ) { System . out . println ( k - zvcnOoki ) ; } else { System . out . println ( zvcnOoki ) ; } } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class BhjsqvSy { public static void main ( String [ ] args ) throws Exception { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] natural = stdReader . readLine ( ) . split ( " " , 0 ) ; int BhjsqvSv = Integer . parseInt ( natural [ 0 ] ) ; int y = Integer . parseInt ( natural [ 1 ] ) ; if ( BhjsqvSv < y ) { BhjsqvSv = BhjsqvSv ^ y ; y = BhjsqvSv ^ y ; BhjsqvSv = BhjsqvSv ^ y ; } while ( y > 0 ) { int r = BhjsqvSv % y ; BhjsqvSv = y ; y = r ; } System . out . println ( BhjsqvSv ) ; } } import java . util . * ; public class QuaxTv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int QuaxUot = 0 ; int z = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'A' ) { QuaxUot = i ; break ; } } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'Z' ) { z = i + 1 ; } } System . out . println ( z - QuaxUot ) ; } } import java . util . Scanner ; public class FbgBd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int fbgZ = 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 != fbgZ ; 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 YjkPhg { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; String re = " " ; for ( int yjkNid = line . length ( ) ; yjkNid > 0 ; yjkNid -- ) { re += line . charAt ( yjkNid - 1 ) ; } System . out . println ( re ) ; } } import java . util . * ; import java . text . * ; class CqgpnyZmqt { 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 cqgpnyH = s1 . length ( ) ; int l2 = s2 . length ( ) ; int l = Math . min ( cqgpnyH , l2 ) ; for ( int i = 0 ; i < l ; i ++ ) { int d = s1 . charAt ( i ) - s2 . charAt ( i ) ; if ( d != 0 ) return d ; } return cqgpnyH - 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 TxuksGu { public static void main ( String [ ] args ) throws IOException { long txuksWc = 0 ; int i = 0 ; long n = 100 ; double k = 0 ; BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) ) ; txuksWc = Long . parseLong ( r . readLine ( ) ) ; do { i ++ ; k = Math . ceil ( ( double ) ( n / 100 ) ) ; n += ( long ) k ; } while ( n < txuksWc ) ; System . out . println ( i ) ; } } import java . util . Scanner ; public class rhoEn { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; double RhoCwd , d , s ; d = sc . nextDouble ( ) ; RhoCwd = sc . nextDouble ( ) ; s = sc . nextDouble ( ) ; if ( ( d / s ) <= RhoCwd ) 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 kxniwvJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KxniwvTcjca = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; Queue < Process > Q = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < KxniwvTcjca ; 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 kxniwvJ { 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 YeezsLjroja { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int YeezsAe = Integer . parseInt ( br . readLine ( ) ) ; int [ ] arr = new int [ YeezsAe - 1 ] ; String [ ] s = br . readLine ( ) . split ( " " ) ; int prev = 987654321 ; long sum = 0 ; for ( int i = 0 ; i < YeezsAe - 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 fanefrIm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int FanefrExh = scan . nextInt ( ) ; int [ ] a = new int [ FanefrExh ] ; int i = 0 ; int Alice = 0 ; int Bob = 0 ; for ( i = 0 ; i < FanefrExh ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } Arrays . sort ( a ) ; for ( i = 1 ; i <= FanefrExh ; i ++ ) { if ( i % 2 == 1 ) { Alice = Alice + a [ FanefrExh - i ] ; } else { Bob = Bob + a [ FanefrExh - i ] ; } } System . out . println ( Alice - Bob ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class InddzuBn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int InddzuS = sc . nextInt ( ) ; List < Long > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < InddzuS ; 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 JlgwvlUu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jlgwvlB = 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 ) { jlgwvlB += i ; } } System . out . println ( jlgwvlB ) ; } private static int sum ( int i ) { int sumDigits = 0 ; while ( i != 0 ) { sumDigits += i % 10 ; i /= 10 ; } return sumDigits ; } } import java . util . * ; public class TnxqffVi { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int tnxqffGj = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; System . out . println ( scanner . next ( ) . matches ( String . format ( " \\ d { %d } - \\ d { %d } " , tnxqffGj , b ) ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; class ryvckrLl { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int RyvckrVdc = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int [ ] [ ] array ; array = new int [ RyvckrVdc ] [ b ] ; int [ ] Vec = new int [ b ] ; int [ ] sum = new int [ RyvckrVdc ] ; int x = 0 ; for ( int i = 0 ; i < RyvckrVdc ; 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 < RyvckrVdc ; 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 < RyvckrVdc ; i ++ ) { System . out . println ( sum [ i ] ) ; } scanner . close ( ) ; } } import java . util . Scanner ; public class EvkhNz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String buff = " " ; int evkhWnf = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double count = 1 , flag = 0 ; double count1 = 0 , count2 = 0 ; int count3 = 9999999 ; int [ ] [ ] array1 = new int [ evkhWnf ] [ k ] ; for ( int i = 0 ; i < evkhWnf ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { array1 [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < evkhWnf - 1 ; i ++ ) { for ( int j = i + 1 ; j < evkhWnf ; 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 gwtkaHu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GwtkaWt = 0 ; int five = 0 ; while ( sc . hasNext ( ) ) { int num = sc . nextInt ( ) ; if ( num == 7 ) { GwtkaWt ++ ; } else if ( num == 5 ) { five ++ ; } } if ( GwtkaWt == 1 && five == 2 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; import java . lang . * ; import java . math . * ; public class ZtrzSpl { Scanner sc = new Scanner ( System . in ) ; void run ( ) { int ztrzM = sc . nextInt ( ) ; int b = 100 ; for ( int i = 0 ; i < ztrzM ; 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 UljrdmQzczui { 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 UljrdmUyi = 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 ) ) ) { UljrdmUyi ++ ; } } } } if ( UljrdmUyi > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class GlcqgPn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int glcqgN = 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 ++ ) { glcqgN = 0 ; S2 = 0 ; S3 = 0 ; for ( int k = 0 ; k <= j ; k ++ ) { glcqgN = glcqgN + arys [ k ] ; } for ( int k = j + 1 ; k <= N - 1 ; k ++ ) { S2 = S2 + arys [ k ] ; } S3 = Math . abs ( glcqgN - 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 SkcbkvLjl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SkcbkvPd = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] m = new int [ SkcbkvPd ] ; int sumG = 0 ; int minDonut = 1001 ; for ( int i = 0 ; i < SkcbkvPd ; i ++ ) { m [ i ] = sc . nextInt ( ) ; sumG += m [ i ] ; minDonut = Math . min ( minDonut , m [ i ] ) ; } int sumDonut = SkcbkvPd + ( x - sumG ) / minDonut ; System . out . println ( sumDonut ) ; } } import java . util . * ; public class BktqcdTww { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bktqcdCaj = sc . nextInt ( ) ; double min = Math . pow ( 10 , 10 ) ; double max = 0 ; for ( int i = 0 ; i < bktqcdCaj ; 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 lnagMxk { 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 LnagAyvi = 0 ; LnagAyvi < s1 . length ( ) ; LnagAyvi ++ ) { if ( c [ LnagAyvi ] != 'B' ) list . add ( ( int ) c [ LnagAyvi ] - '0' ) ; else { if ( list . size ( ) > 0 ) list . remove ( list . size ( ) - 1 ) ; } } for ( int LnagAyvi = 0 ; LnagAyvi < list . size ( ) ; LnagAyvi ++ ) System . out . print ( list . get ( LnagAyvi ) ) ; } } import java . util . Scanner ; public class PmoExiwka { public static void main ( String [ ] av ) { Scanner s = new Scanner ( System . in ) ; int PmoQbb = s . nextInt ( ) ; int [ ] a = new int [ PmoQbb + 1 ] ; for ( int i = 0 ; i < PmoQbb ; i ++ ) { a [ i ] = s . nextInt ( ) ; } for ( int i = 1 ; i < PmoQbb ; i ++ ) { for ( int k = 0 ; k < PmoQbb ; k ++ ) { System . out . print ( a [ k ] ) ; if ( k != PmoQbb - 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 < PmoQbb ; k ++ ) { System . out . print ( a [ k ] ) ; if ( k != PmoQbb - 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 uxsFc { 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 uxsFc { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int UxsFwpgm = Integer . parseInt ( in . next ( ) ) ; int d = Integer . parseInt ( in . next ( ) ) ; int ans = 0 ; if ( UxsFwpgm % ( 2 * d + 1 ) == 0 ) { ans = UxsFwpgm / ( 2 * d + 1 ) ; } else { ans = UxsFwpgm / ( 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 wddFjh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long WddDf = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; System . out . println ( solve ( b , c , d ) - solve ( WddDf - 1 , c , d ) ) ; } static long gcd ( long WddDf , long b ) { if ( b == 0 ) { return WddDf ; } return gcd ( b , WddDf % 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 OetcrRm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oetcrYqn = sc . nextInt ( ) ; oetcrYqn = oetcrYqn % 10 ; if ( oetcrYqn == 2 || oetcrYqn == 4 || oetcrYqn == 5 || oetcrYqn == 7 || oetcrYqn == 9 ) { System . out . println ( " hon " ) ; } else if ( oetcrYqn == 0 || oetcrYqn == 1 || oetcrYqn == 6 || oetcrYqn == 8 ) { System . out . println ( " pon " ) ; } else { System . out . println ( " bon " ) ; } } } import java . util . * ; public class wnorU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WnorEqqp = sc . nextInt ( ) ; String ans = " APPROVED " ; for ( int i = 0 ; i < WnorEqqp ; 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 MdzveeHn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; for ( int mdzveeLbk = 0 ; mdzveeLbk < s . length ( ) - 1 ; mdzveeLbk ++ ) { if ( s . charAt ( mdzveeLbk ) != s . charAt ( mdzveeLbk + 1 ) ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class LgldIm { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int LgldN = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int ans = ( LgldN + a - 1 ) / a ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class jcrRa { 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 jcrRa { public void solve ( InputReader in , PrintWriter out ) { int JcrDobh = in . nextInt ( ) ; int [ ] a = new int [ JcrDobh ] ; for ( int i = 0 ; i < JcrDobh ; i ++ ) a [ i ] = in . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < JcrDobh - 1 ; i ++ ) { for ( int j = i + 1 ; j < JcrDobh ; j ++ ) { int mul = a [ i ] * a [ j ] ; sum += mul ; } } out . println ( sum ) ; } } static class jcrRa { 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 wifkOu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String p = sc . nextLine ( ) ; int WifkZehhd = s . length ( ) ; int pLen = p . length ( ) ; boolean ok = false ; for ( int i = 0 ; i < WifkZehhd ; i ++ ) { for ( int j = 0 ; j < pLen ; j ++ ) { if ( s . charAt ( ( i + j ) % WifkZehhd ) != 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 xvtEs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long XvtUme = sc . nextLong ( ) ; long r = sc . nextLong ( ) ; long min = 9999 ; for ( long i = XvtUme ; 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 lgjtWhs { static public void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int LgjtBbhay = s . nextInt ( ) ; String c = s . next ( ) ; if ( LgjtBbhay % 2 == 1 ) { System . out . println ( " No " ) ; } else { boolean yes = true ; for ( int i = 0 ; i < LgjtBbhay / 2 && yes ; i ++ ) { if ( c . charAt ( i ) != c . charAt ( i + LgjtBbhay / 2 ) ) yes = false ; } if ( yes ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } } import java . util . * ; import java . io . * ; public class VxdiBab { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int VxdiM , x , t = 0 ; String [ ] brr = br . readLine ( ) . split ( " " ) ; VxdiM = Integer . parseInt ( brr [ 0 ] ) ; x = Integer . parseInt ( brr [ 1 ] ) ; t = Integer . parseInt ( brr [ 2 ] ) ; long ans = 0 ; while ( VxdiM > 0 ) { ans += t ; VxdiM -= x ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class ezvQfx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long EzvUk = sc . nextLong ( ) , min = 11 ; String a = " " , b = " " ; for ( int i = 1 ; i <= Math . sqrt ( EzvUk ) ; i ++ ) { if ( EzvUk % i == 0 ) { a = String . valueOf ( i ) ; b = String . valueOf ( EzvUk / i ) ; min = Math . min ( min , Math . max ( a . length ( ) , b . length ( ) ) ) ; } } System . out . println ( min ) ; } public static List < Long > divisorEnum ( long EzvUk ) { List < Long > l = new ArrayList < > ( ) ; for ( long i = 1 ; i <= Math . sqrt ( EzvUk ) ; i ++ ) { if ( EzvUk % i == 0 ) { l . add ( i ) ; if ( i != Math . sqrt ( EzvUk ) ) l . add ( EzvUk / i ) ; } } l . sort ( null ) ; return l ; } } import java . util . Scanner ; public class aduoHah { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AduoVf = Integer . parseInt ( ( sc . next ( ) ) ) ; long [ ] aArr = new long [ AduoVf + 1 ] ; for ( int i = 0 ; i <= AduoVf ; i ++ ) { aArr [ i ] = Long . parseLong ( sc . next ( ) ) ; } long [ ] bArr = new long [ AduoVf ] ; for ( int i = 0 ; i < AduoVf ; i ++ ) { bArr [ i ] = Long . parseLong ( sc . next ( ) ) ; } sc . close ( ) ; long ans = 0 ; for ( int i = AduoVf - 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 PxbfdaFgat { 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 PxbfdaIh = S . length - T . length + 1 ; int [ ] cnt = new int [ PxbfdaIh ] ; int max = 0 ; for ( int i = 0 ; i < PxbfdaIh ; 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 YxtsTuo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yxtsHbcg = sc . nextInt ( ) ; int num2 = sc . nextInt ( ) ; int num3 = sc . nextInt ( ) ; System . out . println ( num3 ) ; System . out . println ( yxtsHbcg ) ; System . out . println ( num2 ) ; } } import java . util . * ; public class NkrngCqy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nkrngYc = sc . nextInt ( ) ; int [ ] A = new int [ nkrngYc + 1 ] ; int [ ] B = new int [ nkrngYc ] ; for ( int i = 0 ; i < nkrngYc + 1 ; i ++ ) A [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < nkrngYc ; i ++ ) B [ i ] = sc . nextInt ( ) ; int [ ] AC = A . clone ( ) ; long cnt = 0 ; for ( int i = 0 ; i < nkrngYc ; 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 < nkrngYc + 1 ; i ++ ) { cnt += AC [ i ] - A [ i ] ; } System . out . println ( cnt ) ; } } import java . util . * ; public class audZg { 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 AudXisls = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { sChar [ i ] = s . charAt ( i ) ; cChar [ i ] = c . charAt ( i ) ; if ( sChar [ i ] == cChar [ i ] ) { AudXisls ++ ; } } System . out . println ( AudXisls ) ; } } import java . util . * ; public class CldurrUxg { static boolean [ ] targetNumbers ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long CldurrGfb = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long gcd = calcGcd ( CldurrGfb , B ) ; System . out . println ( CldurrGfb * 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 NjfJu { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String njfPm = br . readLine ( ) ; Integer witdh = Integer . parseInt ( njfPm . split ( " " ) [ 0 ] ) ; Integer height = Integer . parseInt ( njfPm . split ( " " ) [ 1 ] ) ; Integer x = Integer . parseInt ( njfPm . split ( " " ) [ 2 ] ) ; Integer y = Integer . parseInt ( njfPm . split ( " " ) [ 3 ] ) ; Integer r = Integer . parseInt ( njfPm . 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 qplxrjM { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int QplxrjYgb = scanner . nextInt ( ) ; int [ ] p = new int [ QplxrjYgb ] ; for ( int i = 0 ; i < QplxrjYgb ; i ++ ) { p [ i ] = scanner . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < QplxrjYgb - 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 posQko { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PosNyzd = sc . nextInt ( ) ; int [ ] B = new int [ PosNyzd - 1 ] ; for ( int i = 0 ; i < PosNyzd - 1 ; i ++ ) B [ i ] = sc . nextInt ( ) ; int count = B [ 0 ] ; for ( int i = 0 ; i < PosNyzd - 2 ; i ++ ) { if ( B [ i ] < B [ i + 1 ] ) count += B [ i ] ; else count += B [ i + 1 ] ; } count += B [ PosNyzd - 2 ] ; System . out . println ( count ) ; } } import java . util . Scanner ; public class pasH { public static void main ( String [ ] s ) { Scanner sc = new Scanner ( System . in ) ; int PasVcev = 0 ; if ( sc . hasNextInt ( ) ) PasVcev = sc . nextInt ( ) ; int cnt = 0 ; boolean res = false ; while ( PasVcev -- != 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 yqkrjlDvw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YqkrjlCtzzq = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] a = new int [ YqkrjlCtzzq ] ; 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 PwaYy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pwaY = 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 plnxjiUph { 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 PlnxjiAotcr = 0 ; PlnxjiAotcr < v . length ; PlnxjiAotcr ++ ) { v [ PlnxjiAotcr ] = Integer . parseInt ( k [ PlnxjiAotcr ] ) ; } int count = 0 ; for ( int PlnxjiAotcr = v [ 0 ] ; PlnxjiAotcr <= v [ 1 ] ; PlnxjiAotcr ++ ) { if ( v [ 2 ] % PlnxjiAotcr == 0 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class VezOgaof { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VezXna = 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 ( ) != VezXna ) 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 JgujWry { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int jgujY = Integer . parseInt ( S . substring ( 0 , 2 ) ) ; int last2 = Integer . parseInt ( S . substring ( 2 , 4 ) ) ; String result = " " ; if ( 1 <= jgujY && jgujY <= 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 tqlwgA { 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 TqlwgCgob = Integer . parseInt ( tmpArray [ 0 ] ) ; int b = Integer . parseInt ( tmpArray [ 1 ] ) ; if ( TqlwgCgob == 0 && b == 0 ) { break ; } for ( int i = 0 ; i < TqlwgCgob ; 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 YjqfMwho { 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 YjqfMwho { 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 hjxX { 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 HjxQbtf = 0 ; HjxQbtf < line . length ( ) ; HjxQbtf ++ ) { String str = Character . toString ( line . charAt ( HjxQbtf ) ) . 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 SiephOm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int siephUfv = 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 IcnmtvSdr { 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 icnmtvQff = 0 ; icnmtvQff < in . length ( ) ; icnmtvQff ++ ) x [ icnmtvQff ] = in . charAt ( icnmtvQff ) - '0' ; System . out . println ( Arrays . stream ( x ) . parallel ( ) . sum ( ) ) ; } } import java . util . * ; public class nhwbpmZzh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String N = sc . next ( ) ; sc . close ( ) ; String [ ] arr = N . split ( " " ) ; int NhwbpmFrqjb = Integer . valueOf ( N ) ; int sn = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { sn += Integer . valueOf ( arr [ i ] ) ; } if ( NhwbpmFrqjb % sn == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class aloxV { private static int digitSum ( int input ) { int AloxJjw = 0 ; int tmp = 1 ; while ( tmp <= input ) { AloxJjw += ( input / tmp ) % 10 ; tmp *= 10 ; } return AloxJjw ; } 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 VlygcOyyroe { public static void main ( String [ ] args ) { int [ ] a ; int VlygcUq = 0 , count = 1 ; a = new int [ 100000 ] ; a [ 0 ] = 1 ; Scanner n = new Scanner ( System . in ) ; while ( a [ VlygcUq ] != 0 ) { VlygcUq ++ ; a [ VlygcUq ] = n . nextInt ( ) ; if ( a [ VlygcUq ] != 0 ) { count += 1 ; } } VlygcUq = 1 ; while ( count > VlygcUq ) { System . out . println ( " Case " + VlygcUq + " : " + a [ VlygcUq ] ) ; VlygcUq ++ ; } } } import java . util . * ; public class ugtD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UgtKk = sc . nextInt ( ) ; int num = 1 ; for ( int i = 0 ; i < 9 ; i ++ ) { if ( UgtKk - 111 > 0 ) { UgtKk -= 111 ; } else { num += i ; break ; } } System . out . println ( num * 111 ) ; } } import java . io . * ; import java . util . * ; public class IzpXrpe { public static void main ( String [ ] args ) { int izpFkk , q , time = 0 ; Queue < String > queueName = new ArrayDeque < String > ( ) ; Queue < Integer > queueTime = new ArrayDeque < Integer > ( ) ; Scanner sc = new Scanner ( System . in ) ; izpFkk = sc . nextInt ( ) ; q = sc . nextInt ( ) ; sc . nextLine ( ) ; for ( int i = 0 ; i < izpFkk ; 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 izuuqrBa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IzuuqrHkdof ; String str ; while ( true ) { str = sc . next ( ) ; if ( str . equals ( " - " ) ) { break ; } String str1 ; String str2 ; int m ; m = sc . nextInt ( ) ; int h ; for ( IzuuqrHkdof = 0 ; IzuuqrHkdof < m ; IzuuqrHkdof ++ ) { 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 ZvtbnrPrhn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] S = sc . next ( ) . toCharArray ( ) ; String output = " Good " ; for ( int ZvtbnrDsx = 0 ; ZvtbnrDsx < S . length - 1 ; ZvtbnrDsx ++ ) { if ( S [ ZvtbnrDsx ] == S [ ZvtbnrDsx + 1 ] ) { output = " Bad " ; break ; } } System . out . println ( output ) ; } } import java . util . Scanner ; public class KoqamcTcr { 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 KoqamcUor = 0 ; int idxb = 0 ; int idxc = 0 ; char temp = 'A' ; while ( true ) { if ( temp == 'A' ) { if ( KoqamcUor >= a . length ( ) ) { break ; } temp = a . charAt ( KoqamcUor ) ; KoqamcUor ++ ; } 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 ptnV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long PtnRasd = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; long ansA , ansB ; if ( PtnRasd - k >= 0 ) { ansA = PtnRasd - k ; } else { ansA = 0 ; } k -= PtnRasd ; 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 LfixBbj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lfixCz = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( lfixCz == B ) { System . out . println ( " IMPOSSIBLE " ) ; } else if ( ( lfixCz + B ) % 2 == 0 ) { System . out . println ( ( lfixCz + B ) / 2 ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } sc . close ( ) ; } } import java . io . * ; public class jdaSnf { 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 JdaIpav = line . indexOf ( " " ) ; final int x = Integer . parseInt ( line . substring ( 0 , JdaIpav ) ) ; final int y = Integer . parseInt ( line . substring ( JdaIpav + 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 tiucdZwg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TiucdWbo = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i <= TiucdWbo ; 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 NhpUnyh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int NhpCjc = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int q = scan . nextInt ( ) ; int [ ] a = new int [ NhpCjc + 1 ] ; int i ; for ( i = 0 ; i < q ; i ++ ) a [ scan . nextInt ( ) ] ++ ; int border = q - k ; for ( i = 1 ; i <= NhpCjc ; i ++ ) { if ( a [ i ] > border ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class LohowaQpx { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int lohowaT = in . nextInt ( ) ; int [ ] value = new int [ lohowaT ] ; int a = 0 ; int b = 0 ; for ( int i = 0 ; i < lohowaT ; 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 < lohowaT ; 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 tdaMqq { static Scanner sc = new Scanner ( ) ; public static void main ( final String [ ] args ) throws IOException { int TdaFfy = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; char temp = c [ 0 ] ; int ans = 1 ; for ( int i = 1 ; i < TdaFfy ; i ++ ) { if ( c [ i ] != temp ) { temp = c [ i ] ; ans ++ ; } } System . out . println ( ans ) ; } static class tdaMqq { 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 ZpatzeWaq { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String s = input . nextLine ( ) ; for ( int zpatzeIiyp = 0 ; zpatzeIiyp < s . length ( ) ; zpatzeIiyp ++ ) { System . out . print ( " x " ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class dkezlS { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int DkezlKmma = 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 < DkezlKmma ; 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 ulijNna { char UlijLkhy ; 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 ++ ) { UlijLkhy = str . charAt ( i ) ; if ( '0' > UlijLkhy || UlijLkhy > '9' ) { System . out . println ( " No " ) ; return ; } } if ( str . charAt ( a ) != '-' ) { System . out . println ( " No " ) ; return ; } for ( int i = a + 1 ; i <= a + b ; i ++ ) { UlijLkhy = str . charAt ( i ) ; if ( '0' > UlijLkhy || UlijLkhy > '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 bhmB { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Queue < Character > [ ] queues = new Queue [ 3 ] ; for ( int BhmCb = 0 ; BhmCb < 3 ; BhmCb ++ ) { queues [ BhmCb ] = new LinkedList < > ( ) ; for ( char ch : scanner . next ( ) . toCharArray ( ) ) queues [ BhmCb ] . 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 YhlbYyi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YhlbF = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < YhlbF ; 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 rybhilBsx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int RybhilCkk = scanner . nextInt ( ) ; int [ ] flowersHeight = new int [ RybhilCkk ] ; int maxFlowerHeight = 0 ; for ( int i = 0 ; i < RybhilCkk ; ++ 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 < RybhilCkk ; ++ 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 == RybhilCkk ) break loop ; } } ++ wateringTimes ; } System . out . print ( wateringTimes ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class CvwbhjPxkm { 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 CvwbhjA = s . nextLine ( ) ; System . out . println ( 8 - map . get ( CvwbhjA ) ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class qcfIbq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long QcfRjquk = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; long c = ( b * b ) - ( QcfRjquk * QcfRjquk ) ; long d = 2 * b - 2 * QcfRjquk ; if ( c % d == 0 ) System . out . println ( c / d ) ; else System . out . println ( " IMPOSSIBLE " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class GrydWh { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int grydDlw = s . nextInt ( ) ; ArrayList < Long > list = new ArrayList < > ( ) ; long num = 1 ; while ( num != grydDlw + 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 HlfqrScl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hlfqrO = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( lcm ( hlfqrO , B ) ) ; } public static long lcm ( int hlfqrO , int B ) { int temp ; long C = hlfqrO ; C *= B ; while ( ( temp = hlfqrO % B ) != 0 ) { hlfqrO = B ; B = temp ; } return ( C / B ) ; } } import java . util . Scanner ; public class KbbKg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( ( System . in ) ) ; int KbbNot = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) , ans = " Yes " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i == ( KbbNot ) ) { 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 DnezMnc { 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 BltyclTdsp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long BltyclS = sc . nextLong ( ) ; int k = 1 ; long z = 26L ; long d = 0L ; while ( z < BltyclS ) { d = z ; k ++ ; z += ( long ) Math . pow ( 26 , k ) ; } long y = BltyclS - 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 OfpRbidzr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int OfpMk = sc . nextInt ( ) ; int [ ] h = new int [ OfpMk ] ; for ( int i = 0 ; i < OfpMk ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int max = h [ 0 ] ; boolean b = true ; for ( int i = 0 ; i < OfpMk ; 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 QmoMej { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QmoOy = sc . nextInt ( ) ; int Sum = 0 ; List < String > listA = new ArrayList < String > ( ) ; for ( int i = 0 ; i < QmoOy ; 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 XdzydCl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String xdzydYfgd = scan . next ( ) ; String b = scan . next ( ) ; String c = scan . next ( ) ; String next = " a " ; while ( true ) { if ( next . equals ( " a " ) && xdzydYfgd . length ( ) > 0 ) { next = xdzydYfgd . substring ( 0 , 1 ) ; xdzydYfgd = xdzydYfgd . 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 QciiynKapbwx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QciiynYe = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int ans = 2000 ; for ( int i = 0 ; i < QciiynYe ; 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 SqbLk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int sqbA = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; if ( sqbA == 0 && w == 0 ) break ; for ( int i = 0 ; i < sqbA ; 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 EwckpUh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = " " ; while ( sc . hasNext ( ) ) { int ewckpVjo = 0 ; s = sc . nextLine ( ) ; if ( s . equalsIgnoreCase ( " ssr " ) || s . equalsIgnoreCase ( " srs " ) || s . equalsIgnoreCase ( " rss " ) || s . equalsIgnoreCase ( " rsr " ) ) { ewckpVjo = 1 ; } else if ( s . equalsIgnoreCase ( " rrs " ) || s . equalsIgnoreCase ( " srr " ) ) { ewckpVjo = 2 ; } else if ( s . equalsIgnoreCase ( " rrr " ) ) { ewckpVjo = 3 ; } else ewckpVjo = 0 ; System . out . println ( ewckpVjo ) ; } } } import java . util . Scanner ; public class PelybCaj { public static void main ( String [ ] args ) { int pelybS , B , C , D ; Scanner scan = new Scanner ( System . in ) ; pelybS = scan . nextInt ( ) ; B = scan . nextInt ( ) ; C = scan . nextInt ( ) ; D = scan . nextInt ( ) ; while ( true ) { if ( pelybS <= 0 || C <= 0 ) break ; C -= B ; if ( pelybS <= 0 || C <= 0 ) break ; pelybS -= D ; } if ( C <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class kgctrMi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KgctrPzwd = sc . nextInt ( ) ; int [ ] h = new int [ KgctrPzwd ] ; for ( int i = 0 ; i < KgctrPzwd ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; while ( true ) { int l = KgctrPzwd ; int r = KgctrPzwd - 1 ; for ( int i = 0 ; i < KgctrPzwd ; i ++ ) { if ( h [ i ] > 0 ) { l = Math . min ( l , i ) ; } else if ( l < i ) { r = i - 1 ; break ; } } if ( l == KgctrPzwd ) 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 KqxnQcq { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String str = s . next ( ) ; char [ ] alphabet = new char [ 26 ] ; char kqxnSpaf = 'a' ; for ( int i = 0 ; i < 26 ; i ++ ) { alphabet [ i ] = kqxnSpaf ++ ; 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 ZylisqEalo { public static void main ( String [ ] arg ) { Scanner ob = new Scanner ( System . in ) ; int zylisqAqeb = 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 yzmrB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YzmrTvw = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] arr = new int [ YzmrTvw ] ; Arrays . fill ( arr , 0 ) ; for ( int i = 0 ; i < 2 * M ; i ++ ) { int a = sc . nextInt ( ) ; for ( int j = 1 ; j <= YzmrTvw ; j ++ ) { if ( a == j ) { arr [ j - 1 ] ++ ; } } } for ( int i = 0 ; i < YzmrTvw ; i ++ ) { System . out . println ( arr [ i ] ) ; } } } import java . util . Scanner ; public class MmxNfv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mmxUqr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int y = 0 ; for ( int x = mmxUqr ; x <= b ; x ++ ) { if ( c % x == 0 ) { y ++ ; } } System . out . println ( y ) ; } } import java . util . Scanner ; class uudiavNzi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int UudiavUyxac = 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 " ) ) { UudiavUyxac ++ ; } else { UudiavUyxac = 0 ; } if ( maxCount < UudiavUyxac ) { maxCount = UudiavUyxac ; } } System . out . println ( maxCount ) ; } } import java . io . * ; import java . util . * ; public class PyggsaNfycu { public static void main ( final String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; long PyggsaBt ; PyggsaBt = sc . nextLong ( ) ; long B ; B = sc . nextLong ( ) ; final Solver solver = new Solver ( ) ; solver . solve ( PyggsaBt , B ) ; } } class PyggsaNfycu { public void solve ( long PyggsaBt , long B ) { System . out . println ( PyggsaBt * B / lcd ( PyggsaBt , B ) ) ; } private long lcd ( long PyggsaBt , long B ) { if ( B == 0 ) { return PyggsaBt ; } return lcd ( B , PyggsaBt % B ) ; } } import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; import java . util . TreeMap ; public class MrbyosNoa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MrbyosHb = sc . nextInt ( ) ; Map < String , Integer > m = new TreeMap < String , Integer > ( ) ; int max = 0 ; for ( int i = 0 ; i < MrbyosHb ; 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 tjuH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int TjuFq = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] lots = new int [ TjuFq ] ; for ( int i = 1 ; i <= TjuFq ; ++ 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 < TjuFq ; ++ 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 UindeFrg { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int UindeSvb = in . nextInt ( ) ; for ( int n = UindeSvb ; n < 1000 ; n ++ ) { if ( n % 111 == 0 ) { System . out . println ( n ) ; return ; } } } } } import java . util . Scanner ; public class KuivZmj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int KuivIhu = scan . nextInt ( ) ; for ( int h = 0 ; h < 241 ; h ++ ) { if ( KuivIhu >= 3600 ) { KuivIhu = KuivIhu - 3600 ; } else { System . out . print ( h + " : " ) ; break ; } } for ( int m = 0 ; m < 60 ; m ++ ) { if ( KuivIhu >= 60 ) { KuivIhu = KuivIhu - 60 ; } else { System . out . println ( m + " : " + KuivIhu ) ; break ; } } } } import java . io . * ; import java . util . StringTokenizer ; public class JcwJmrxfu { public static void main ( String [ ] args ) { final FastScanner fs = new FastScanner ( ) ; final int [ ] arr = fs . nextIntArray ( ) ; int JcwXgh = 0 ; for ( int i : arr ) { JcwXgh += countDiv ( i ) ; } System . out . println ( JcwXgh ) ; } static int countDiv ( int n ) { int i = 0 ; while ( n != 0 && n % 2 == 0 ) { n /= 2 ; i ++ ; } return i ; } public static class JcwJmrxfu { 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 MvdpofTzrfkr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MvdpofL = sc . nextInt ( ) ; long co = 0 ; HashMap < String , Long > l = new HashMap < String , Long > ( ) ; for ( int i = 0 ; i < MvdpofL ; 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 gxfrbqWe { 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 GxfrbqKhidx ; for ( GxfrbqKhidx = 0 ; GxfrbqKhidx < 25 ; GxfrbqKhidx ++ ) { if ( alp [ GxfrbqKhidx ] . equals ( str ) ) { break ; } } System . out . println ( alp [ GxfrbqKhidx + 1 ] ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; class pbtZ { public static void main ( String [ ] args ) throws IOException { int PbtVrhx , 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 ] ) ; PbtVrhx = getD ( a , b ) ; r = getR ( a , b ) ; f = getF ( a , b ) ; System . out . printf ( " %d %d %.5f " , PbtVrhx , 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 ttenPt { 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 TtenObo = parseInt ( scan . nextLine ( ) ) ; for ( int i = 0 ; i < TtenObo ; 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 SxzeYzg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sxzeUe = Integer . parseInt ( sc . next ( ) ) ; int L = Integer . parseInt ( sc . next ( ) ) ; int [ ] data = new int [ sxzeUe ] ; int sum = 0 ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < sxzeUe ; 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 CnoKkbbqv { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long CnoBi = scanner . nextLong ( ) ; long a = scanner . nextLong ( ) ; long b = scanner . nextLong ( ) ; if ( a == 0 ) { System . out . println ( " 0 " ) ; return ; } long d = a + b ; long q = CnoBi / d ; long r = CnoBi % d ; long blue = ( q * a ) + ( a < r ? a : r ) ; System . out . println ( blue ) ; } } import java . util . Scanner ; public class MjyImvmi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MjyUsm = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x <= MjyUsm ; x ++ ) { for ( int y = 0 ; y <= MjyUsm ; y ++ ) { int z = S - ( x + y ) ; if ( 0 <= z && z <= MjyUsm ) { count ++ ; } } } System . out . print ( count ) ; } } import java . util . Scanner ; class TerdvQq { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int TerdvYu = in . nextInt ( ) ; if ( TerdvYu == 0 ) break ; int [ ] numbers = new int [ TerdvYu ] ; long double_sum = 0 ; long sum_double = 0 ; for ( int i = 0 ; i < TerdvYu ; i ++ ) { numbers [ i ] = in . nextInt ( ) ; double_sum += numbers [ i ] ; } double_sum = double_sum * double_sum ; for ( int i = 0 ; i < TerdvYu ; i ++ ) sum_double += ( numbers [ i ] * numbers [ i ] ) ; double sd = Math . sqrt ( ( sum_double - double_sum / ( double ) TerdvYu ) / ( double ) TerdvYu ) ; System . out . printf ( " %5.8f " , sd ) ; System . out . println ( ) ; } } } import java . util . Scanner ; public class YciLdt { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int yciVxr = sc . nextInt ( ) ; int tt = 0 ; int tx = 0 ; int ty = 0 ; for ( int i = 0 ; i < yciVxr ; 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 pucptuV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PucptuNmq = sc . nextInt ( ) ; long [ ] h = new long [ PucptuNmq ] ; for ( int i = 0 ; i < PucptuNmq ; i ++ ) { h [ i ] = sc . nextLong ( ) ; } long max = 0 , count = 0 ; for ( int i = 0 ; i < PucptuNmq - 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 ziszwmUm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ZiszwmCqsej = sc . nextLong ( ) ; String alphabet = " abcdefghijklmnopqrstuvwxyz " ; String name = " " ; while ( ZiszwmCqsej > 0 ) { ZiszwmCqsej -- ; long remain = ZiszwmCqsej % 26l ; name = alphabet . charAt ( ( int ) remain ) + name ; ZiszwmCqsej = ZiszwmCqsej / 26l ; } System . out . println ( name ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class swudwqJg { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int SwudwqUocw = Integer . parseInt ( br . readLine ( ) ) ; int sum = ( int ) ( SwudwqUocw + Math . pow ( ( double ) SwudwqUocw , 2.0 ) + Math . pow ( ( double ) SwudwqUocw , 3.0 ) ) ; System . out . println ( sum ) ; } } import java . io . * ; import java . util . * ; public class WcznQaec { 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 wcznA = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '+' ) wcznA ++ ; else wcznA -- ; } out . println ( wcznA ) ; out . flush ( ) ; out . close ( ) ; } static class WcznQaec { 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 QuiyunBoow { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long quiyunFsk = sc . nextLong ( ) ; double b = sc . nextDouble ( ) ; int c = ( int ) Math . round ( 100 * b ) ; System . out . println ( ( long ) ( quiyunFsk * c ) / 100 ) ; } } public class JoyzqLo { public static void main ( String [ ] args ) { int joyzqMi = new java . util . Scanner ( System . in ) . nextInt ( ) ; int pay = 0 ; while ( pay < joyzqMi ) { pay += 1000 ; } System . out . println ( pay - joyzqMi ) ; } } import java . util . * ; class HmfmeDbzfo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HmfmeR = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int count = 0 ; for ( int ca = 0 ; ca < HmfmeR + 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 RegvoWgo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = " " ; String [ ] data = a . split ( " " ) ; for ( int regvoIp = 0 ; data . length > regvoIp ; regvoIp ++ ) { if ( regvoIp == 3 ) { data [ regvoIp ] = " 8 " ; b = b + data [ regvoIp ] ; } else { b = b + data [ regvoIp ] ; } } 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 DwsMdppip { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DwsI = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; int count = 0 ; if ( b + c - DwsI <= 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( b + c - DwsI ) ; } } } import java . util . Scanner ; public class KvayOj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kvayIr = Integer . parseInt ( sc . next ( ) ) ; int N = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; if ( N != 100 ) { int answer = ( int ) ( N * Math . pow ( 100 , kvayIr ) ) ; System . out . println ( answer ) ; return ; } else { int answer = ( int ) ( 101 * Math . pow ( 100 , kvayIr ) ) ; System . out . println ( answer ) ; return ; } } } import java . util . Scanner ; class knfrtvSgh { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int KnfrtvPq = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = ( int ) Math . log10 ( KnfrtvPq + b ) + 1 ; System . out . println ( c ) ; } } } import java . util . Scanner ; public class WbwlVq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wbwlXeod = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; for ( int i = 1 ; i <= wbwlXeod ; i ++ ) { if ( y == ( i * 2 ) + ( ( wbwlXeod - i ) * 4 ) ) { System . out . println ( " Yes " ) ; return ; } } for ( int i = 1 ; i <= wbwlXeod ; i ++ ) { if ( y == ( i * 4 ) + ( ( wbwlXeod - i ) * 2 ) ) { System . out . println ( " Yes " ) ; return ; } } for ( int i = 1 ; i <= wbwlXeod / 2 ; i ++ ) { if ( y == i * 2 ) { System . out . println ( " Yes " ) ; return ; } } for ( int i = 1 ; i <= wbwlXeod / 4 ; i ++ ) { if ( y == i * 4 ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class avszhaQow { int AvszhaGkhx ; int ans ; public void shori ( ) { Scanner sc = new Scanner ( System . in ) ; AvszhaGkhx = sc . nextInt ( ) ; ans = AvszhaGkhx * AvszhaGkhx * AvszhaGkhx ; System . out . println ( ans ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { Main obj = new Main ( ) ; obj . shori ( ) ; } } import java . util . * ; public class hrhdxJ { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int HrhdxPh = 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 = HrhdxPh - j ; int max = HrhdxPh + j ; String mi = String . valueOf ( min ) ; String ma = String . valueOf ( max ) ; if ( ! Arrays . asList ( p ) . contains ( mi ) ) { System . out . println ( HrhdxPh - j ) ; return ; } if ( ! Arrays . asList ( p ) . contains ( ma ) ) { System . out . println ( HrhdxPh + j ) ; return ; } } scn . close ( ) ; } } import java . util . Scanner ; public class JyinotZntb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jyinotMmpo = scan . nextInt ( ) ; int alpha = 0 ; int sum = 0 ; for ( int i = 1 ; i <= jyinotMmpo ; i ++ ) { for ( int j = 1 ; j <= jyinotMmpo ; j ++ ) { for ( int k = 1 ; k <= jyinotMmpo ; k ++ ) { alpha = gcd ( i , j ) ; sum += gcd ( alpha , k ) ; } } } System . out . println ( sum ) ; } public static int fac ( int jyinotMmpo ) { if ( jyinotMmpo == 1 ) { return 1 ; } else { return fac ( jyinotMmpo - 1 ) * jyinotMmpo ; } } public static int pow ( int jyinotMmpo ) { return jyinotMmpo * jyinotMmpo * jyinotMmpo ; } 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 wnwmtCxl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WnwmtXyk = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; int max = 0 ; for ( int i = 0 ; i < WnwmtXyk ; 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 pqhfbqD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PqhfbqFmtc = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int ninzuu = 0 ; D = D * 2 + 1 ; do { PqhfbqFmtc = PqhfbqFmtc - D ; ninzuu ++ ; } while ( PqhfbqFmtc > 0 ) ; System . out . println ( ninzuu ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; public class CxaBuym { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int CxaN = sc . nextInt ( ) ; int [ ] s = new int [ CxaN ] ; for ( int i = 0 ; i < CxaN ; 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 , CxaN , t ) >= 0 ) ans ++ ; } System . out . println ( ans ) ; } static int binarySearch ( int [ ] a , int CxaN , int key ) { int left = 0 ; int right = CxaN ; 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 CxaBuym { 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 othrkRss { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long OthrkQj = sc . nextLong ( ) ; List < Long > divisor = divisor ( OthrkQj ) ; long min = 1000000000001L ; for ( Long elm : divisor ) { min = Math . min ( min , elm + ( OthrkQj / elm ) ) ; } long ans = min - 2 ; System . out . println ( ans ) ; } static List < Long > divisor ( long OthrkQj ) { Set < Long > ret = new HashSet < > ( ) ; for ( long i = 1 ; i * i <= OthrkQj ; i ++ ) { if ( OthrkQj % i == 0 ) { ret . add ( i ) ; if ( i != OthrkQj / i ) ret . add ( OthrkQj / i ) ; } } return ret . stream ( ) . sorted ( Comparator . naturalOrder ( ) ) . collect ( Collectors . toList ( ) ) ; } } import java . util . * ; import java . math . * ; import java . io . * ; public class KcwchBb { 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 KcwchBb { public long kcwchNug ; public long second ; public Pair ( ) { this ( 0 , 0 ) ; } public Pair ( final long kcwchNug , final long second ) { this . kcwchNug = kcwchNug ; this . second = second ; } } } import java . util . Arrays ; import java . util . Scanner ; public class KruSdug { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int kruQ = scanner . nextInt ( ) ; int A2 = scanner . nextInt ( ) ; int A3 = scanner . nextInt ( ) ; scanner . close ( ) ; int [ ] A = { kruQ , A2 , A3 } ; Arrays . sort ( A ) ; System . out . println ( A [ 2 ] - A [ 0 ] ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class BathfdNbz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String bathfdWwh = sc . next ( ) ; String tmpS = " " ; while ( ! bathfdWwh . equals ( tmpS ) ) { if ( bathfdWwh . endsWith ( " dreamer " + tmpS ) ) { tmpS = " dreamer " + tmpS ; } else if ( bathfdWwh . endsWith ( " dream " + tmpS ) ) { tmpS = " dream " + tmpS ; } else if ( bathfdWwh . endsWith ( " eraser " + tmpS ) ) { tmpS = " eraser " + tmpS ; } else if ( bathfdWwh . 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 BfoeOskngg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int BfoeI = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int ans = 0 ; for ( ; 0 < k ; k -- ) { if ( BfoeI > 0 ) { BfoeI -- ; ans ++ ; } else if ( b > 0 ) { b -- ; } else { ans -- ; } } System . out . println ( ans ) ; } } import java . util . * ; class AlxdEkq { 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 alxdGnzn = 0 ; for ( int i = 1 ; i < str . length ( ) ; i ++ ) { if ( tmp . equals ( str . substring ( i , i + 1 ) ) ) { alxdGnzn ++ ; tmp = tmp . equals ( " 0 " ) ? " 1 " : " 0 " ; } else { tmp = str . substring ( i , i + 1 ) ; } } return alxdGnzn ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class YkzpnHqfzuz { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strAry = br . readLine ( ) . split ( " " ) ; int YkzpnY = Integer . parseInt ( strAry [ 0 ] ) ; int y = Integer . parseInt ( strAry [ 1 ] ) ; int z = Integer . parseInt ( strAry [ 2 ] ) ; String result ; result = YkzpnY >= y ? " No " : y < z ? " Yes " : " No " ; System . out . println ( result ) ; } } import java . util . Scanner ; public class HytfzXy { public static void main ( String [ ] args ) { int HytfzVsn , M , ans = 0 ; int [ ] [ ] Food ; Scanner scan = new Scanner ( System . in ) ; HytfzVsn = scan . nextInt ( ) ; M = scan . nextInt ( ) ; Food = new int [ HytfzVsn + 1 ] [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { Food [ HytfzVsn ] [ i ] = 1 ; } int A , K ; for ( int i = 0 ; i < HytfzVsn ; 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 < HytfzVsn ; j ++ ) { Food [ HytfzVsn ] [ i ] *= Food [ j ] [ i ] ; } } for ( int i = 0 ; i < M ; i ++ ) { ans += Food [ HytfzVsn ] [ i ] ; } System . out . print ( ans ) ; } } import java . util . * ; public class WoyiFanic { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WoyiHid = sc . nextInt ( ) ; int [ ] card = new int [ WoyiHid ] ; int alice = 0 ; int bob = 0 ; for ( int i = 0 ; i < WoyiHid ; i ++ ) { card [ i ] = sc . nextInt ( ) ; } Arrays . sort ( card ) ; for ( int i = ( WoyiHid - 1 ) ; i >= 0 ; i -= 2 ) { alice += card [ i ] ; } for ( int j = ( WoyiHid - 2 ) ; j >= 0 ; j -= 2 ) { bob += card [ j ] ; } int division = alice - bob ; System . out . println ( division ) ; } } import java . util . * ; class IryuszYyw { Scanner sc ; int iryuszK ; private void calc ( ) { sc = new Scanner ( System . in ) ; iryuszK = sc . nextInt ( ) ; double l = iryuszK / 3d ; System . out . println ( l * l * l ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . * ; public class JixWhkauw { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; int JixXz = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; if ( b + c <= JixXz ) { System . out . println ( " 0 " ) ; } else { System . out . println ( b + c - JixXz ) ; } } } import java . util . Scanner ; import java . util . List ; import java . util . ArrayList ; import java . util . Objects ; import java . lang . StringBuilder ; public class QmotNmph { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int QmotR = 0 ; QmotR < 5 ; QmotR ++ ) { int a = sc . nextInt ( ) ; list . add ( a ) ; } int k = sc . nextInt ( ) ; boolean cantConnect = false ; for ( int QmotR = 0 ; QmotR < list . size ( ) ; QmotR ++ ) { for ( int j = QmotR + 1 ; j < list . size ( ) ; j ++ ) { if ( list . get ( j ) - list . get ( QmotR ) > k ) cantConnect = true ; } } System . out . println ( cantConnect ? " :( " : " Yay! " ) ; } } import java . io . BufferedInputStream ; import java . io . IOException ; import java . util . Scanner ; public class KeheAd { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( new BufferedInputStream ( System . in ) ) ; int keheCojv = scanner . nextInt ( ) ; int t = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; double need = ( double ) keheCojv / s ; System . out . println ( need <= t ? " Yes " : " No " ) ; } } import java . util . * ; import java . io . * ; public class JzkWs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JzkS = sc . nextInt ( ) ; int max = 0 ; int total = 0 ; for ( int i = 0 ; i < JzkS ; 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 QywrtlXbrh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qywrtlVk = sc . nextInt ( ) ; int point = sc . nextInt ( ) ; int seikai = sc . nextInt ( ) ; int [ ] array = new int [ qywrtlVk ] ; for ( int i = 0 ; i < qywrtlVk ; i ++ ) { array [ i ] = point - seikai ; } for ( int i = 0 ; i < seikai ; i ++ ) { array [ sc . nextInt ( ) - 1 ] ++ ; } for ( int i = 0 ; i < qywrtlVk ; i ++ ) { if ( array [ i ] <= 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } } import java . util . * ; import java . io . * ; public class hhtCs { 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 HhtJepo = Integer . parseInt ( br . readLine ( ) ) ; int a = 0 ; int b = 0 ; String [ ] input = br . readLine ( ) . split ( " " ) ; Integer [ ] numbers = new Integer [ HhtJepo ] ; for ( int i = 0 ; i < HhtJepo ; i ++ ) { numbers [ i ] = Integer . valueOf ( input [ i ] ) ; } Arrays . sort ( numbers , Collections . reverseOrder ( ) ) ; for ( int i = 0 ; i < HhtJepo ; i ++ ) { if ( i % 2 == 0 ) { a += numbers [ i ] ; } else { b += numbers [ i ] ; } } out . println ( a - b ) ; out . close ( ) ; } } import java . util . Scanner ; public class OibOzb { 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 oibXkp = 0 ; oibXkp < s . length ; oibXkp ++ ) { if ( s [ oibXkp ] != t [ oibXkp ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class JkoBx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jkoAwzv = sc . nextInt ( ) ; int [ ] a = new int [ jkoAwzv ] ; for ( int i = 0 ; i < jkoAwzv ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; int x = 0 ; int y = 0 ; for ( int i = 0 ; i < jkoAwzv ; i ++ ) { if ( i % 2 == 0 ) { x += a [ i ] ; } else { y += a [ i ] ; } } System . out . println ( Math . abs ( x - y ) ) ; } } import java . util . * ; public class LlvktbEcrk { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } long llvktbBfkg ; long b ; long c ; long k ; long ans ; public void run ( ) { Scanner sc = new Scanner ( System . in ) ; llvktbBfkg = sc . nextLong ( ) ; b = sc . nextLong ( ) ; c = sc . nextLong ( ) ; k = sc . nextLong ( ) ; sc . close ( ) ; solve ( ) ; } private void solve ( ) { if ( llvktbBfkg < k ) { ans = llvktbBfkg ; k -= llvktbBfkg ; } 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 ymuNs { public static void main ( String [ ] args ) { int YmuMdjwj = 0 ; Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . nextLine ( ) . toCharArray ( ) ; for ( int cnt = 0 ; cnt < s . length ; cnt ++ ) { if ( s [ cnt ] == '1' ) { YmuMdjwj ++ ; } } System . out . println ( YmuMdjwj ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class YzmgwkBb { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int yzmgwkLit = sc . nextInt ( ) ; double [ ] v = new double [ yzmgwkLit ] ; for ( int i = 0 ; i < yzmgwkLit ; i ++ ) { v [ i ] = sc . nextDouble ( ) ; } sc . close ( ) ; Arrays . sort ( v ) ; double s = ( v [ 0 ] + v [ 1 ] ) / 2 ; if ( yzmgwkLit >= 3 ) { for ( int i = 2 ; i < yzmgwkLit ; i ++ ) { s = ( s + v [ i ] ) / 2 ; } } System . out . println ( s ) ; } } import java . util . * ; public class BdxSagnu { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int BdxKz = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int res = 0 ; if ( ( BdxKz >= 10 ) || ( B >= 10 ) ) { res = - 1 ; } else { res = BdxKz * B ; } System . out . println ( res ) ; } } import java . util . Scanner ; class ZfgNik { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; boolean zfgHgh = false ; for ( int i = 0 ; i < 3 ; i ++ ) { zfgHgh |= ( str . charAt ( i ) == str . charAt ( i + 1 ) ) ; } if ( zfgHgh ) { System . out . println ( " Bad " ) ; } else { System . out . println ( " Good " ) ; } } } import java . util . * ; public class DdwffFkrwxz { 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 DdwffDm = 0 ; for ( int i = 0 ; i < S1 . length ; i ++ ) { if ( S1 [ i ] == S2 [ i ] ) { DdwffDm ++ ; } } if ( DdwffDm == S1 . length ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class VbyybjThx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] lines = line . split ( " " ) ; boolean vbyybjYr = true ; int before = Integer . parseInt ( lines [ 0 ] ) ; for ( int i = 1 ; i < lines . length ; i ++ ) { int after = Integer . parseInt ( lines [ i ] ) ; if ( before == after ) { vbyybjYr = false ; break ; } before = after ; } if ( vbyybjYr ) { System . out . println ( " Good " ) ; } else { System . out . println ( " Bad " ) ; } } } import java . util . * ; public class zyisnR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZyisnDlxtt = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( 0 <= ZyisnDlxtt && ZyisnDlxtt <= 5 ) { B = 0 ; System . out . print ( B ) ; } else if ( 6 <= ZyisnDlxtt && ZyisnDlxtt <= 12 ) { B = B / 2 ; System . out . print ( B ) ; } else if ( 13 <= ZyisnDlxtt && ZyisnDlxtt <= 100 ) { System . out . print ( B ) ; } } } import java . io . * ; public class VfziPuf { 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 vfziRu = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; int [ ] [ ] matrix = new int [ vfziRu ] [ m ] ; int [ ] vector = new int [ m ] ; int [ ] result = new int [ vfziRu ] ; for ( int i = 0 ; i < vfziRu ; 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 < vfziRu ; i ++ ) { for ( int k = 0 ; k < m ; k ++ ) { result [ i ] += matrix [ i ] [ k ] * vector [ k ] ; } } for ( int i = 0 ; i < vfziRu ; i ++ ) { System . out . println ( result [ i ] ) ; } } } public class YmrkenTvtw { 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 ymrkenOdsb = 0 ; while ( ymrkenOdsb != s . length ( ) ) { if ( s . contains ( p ) ) { System . out . println ( " Yes " ) ; return ; } s = s . substring ( 1 ) + s . charAt ( 0 ) ; ymrkenOdsb ++ ; } System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class cyfwsK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int CyfwsYupm = s . length ( ) ; String str1 = s . substring ( 0 , ( CyfwsYupm - 1 ) / 2 ) ; String str2 = s . substring ( ( ( CyfwsYupm + 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 hpybAxw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] data = new int [ 10 ] ; for ( int HpybHmnd = 0 ; HpybHmnd < 10 ; HpybHmnd ++ ) { data [ HpybHmnd ] = scan . nextInt ( ) ; } int afterData , beforeIndex ; for ( int HpybHmnd = 1 ; HpybHmnd < 10 ; HpybHmnd ++ ) { afterData = data [ HpybHmnd ] ; beforeIndex = HpybHmnd - 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 LfxLfvhne { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double LfxIu = sc . nextDouble ( ) ; sc . close ( ) ; long ret = ( long ) ( LfxIu + Math . pow ( LfxIu , 2 ) + Math . pow ( LfxIu , 3 ) ) ; System . out . println ( ret ) ; } } import java . util . * ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; class XrwpIk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long xrwpFzr = sc . nextLong ( ) ; long R = sc . nextLong ( ) ; long ans = Long . MAX_VALUE ; loop : for ( long i = xrwpFzr ; 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 OhekjVgry { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int ohekjObx = 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' ) { ohekjObx ++ ; } else { ohekjObx = 0 ; } if ( max < ohekjObx ) { max = ohekjObx ; } } System . out . println ( max ) ; } } import java . util . Scanner ; public class fksgG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double FksgJkbe = scan . nextDouble ( ) ; scan . close ( ) ; System . out . println ( 2 * FksgJkbe * Math . PI ) ; } } import java . util . Scanner ; public class CzsyBrsy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int czsyHtst = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int cap1 = czsyHtst - B ; int use = 0 ; if ( cap1 < C ) { use = cap1 ; } else { use = C ; } System . out . println ( C - use ) ; } } import java . util . * ; public class wjxhoxN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WjxhoxSv = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; aLoop : for ( int a = 0 ; a <= WjxhoxSv ; a ++ ) { bLoop : for ( int b = 0 ; b <= WjxhoxSv ; b ++ ) { int abSum = a + b ; if ( abSum > s ) { continue aLoop ; } else if ( s - abSum <= WjxhoxSv ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . io . * ; public class ZjypoMbwto { 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 ZjypoUj = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { ZjypoUj = 0 ; for ( int j = 0 ; j < p . length ( ) ; j ++ ) { if ( s . charAt ( ( i + j ) % s . length ( ) ) == p . charAt ( j ) ) { ZjypoUj ++ ; } else { break ; } } if ( ZjypoUj == p . length ( ) ) { break ; } } if ( ZjypoUj == p . length ( ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class UztSdew { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int uztLjgu = scan . nextInt ( ) ; long b = uztLjgu * uztLjgu * uztLjgu ; System . out . println ( ( double ) b / 27 ) ; } } import java . util . Scanner ; class fyuEyf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FyuZn = sc . nextInt ( ) ; double x = ( double ) FyuZn / 3 ; double V = x * x * x ; System . out . println ( V ) ; } } import java . util . Scanner ; public class OuqnyRnxj { public static void main ( String [ ] args ) throws Exception { try ( Scanner sc = new Scanner ( System . in ) ) { String S = sc . next ( ) ; for ( int ouqnyUnbn = 1 ; ouqnyUnbn <= S . length ( ) ; ouqnyUnbn ++ ) { char c = S . charAt ( ouqnyUnbn - 1 ) ; if ( ouqnyUnbn % 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 wozcdDlc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WozcdYfid = sc . nextInt ( ) ; boolean flg = true ; for ( int i = 0 ; i < WozcdYfid ; 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 UgzngZiqao { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UgzngS = sc . nextInt ( ) ; int [ ] h = new int [ UgzngS ] ; for ( int i = 0 ; i < UgzngS ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int cnt = 1 ; int max = h [ 0 ] ; for ( int i = 0 ; i < UgzngS - 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 KxetxbNp { public static void main ( String [ ] args ) throws NumberFormatException , IOException { int KxetxbAdr , task2 , task3 ; int [ ] cost = new int [ 6 ] ; int ans = 1000 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; KxetxbAdr = Integer . parseInt ( str [ 0 ] ) ; task2 = Integer . parseInt ( str [ 1 ] ) ; task3 = Integer . parseInt ( str [ 2 ] ) ; cost [ 0 ] = Math . abs ( KxetxbAdr - task2 ) + Math . abs ( task2 - task3 ) ; cost [ 1 ] = Math . abs ( KxetxbAdr - task3 ) + Math . abs ( task3 - task2 ) ; cost [ 2 ] = Math . abs ( task2 - KxetxbAdr ) + Math . abs ( KxetxbAdr - task3 ) ; cost [ 3 ] = Math . abs ( task2 - task3 ) + Math . abs ( task3 - KxetxbAdr ) ; cost [ 4 ] = Math . abs ( task3 - KxetxbAdr ) + Math . abs ( KxetxbAdr - task2 ) ; cost [ 5 ] = Math . abs ( task3 - task2 ) + Math . abs ( task2 - KxetxbAdr ) ; for ( int i = 0 ; i < 6 ; i ++ ) { if ( ans > cost [ i ] ) { ans = cost [ i ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class QdaqzKaio { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QdaqzCi = sc . nextInt ( ) ; int Ri = sc . nextInt ( ) ; int Rj = 1 ; int minv = Ri ; int maxv = Integer . MIN_VALUE ; for ( int i = 1 ; i < QdaqzCi ; 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 PmjuxfWlwz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . nextLine ( ) ; long pmjuxfDiz = 0 ; int l = s . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { int num = Character . getNumericValue ( s . charAt ( i ) ) ; pmjuxfDiz += num ; } if ( pmjuxfDiz % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; } } import java . util . * ; class hgqleRu { 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 HgqleEn = 1 ; a += b ; while ( a >= 10 ) { HgqleEn ++ ; a /= 10 ; } return HgqleEn ; } } import java . util . Scanner ; public class hqnoTgh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HqnoCavq = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = 0 ; for ( int i = 0 ; i < HqnoCavq - 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 njpjcEc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] C = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; int NjpjcPrpv = 0 ; int oneCnt = 0 ; for ( int i = 0 ; i < C . length ; i ++ ) { if ( C [ i ] == '0' ) { NjpjcPrpv ++ ; } else { oneCnt ++ ; } } System . out . println ( Math . min ( NjpjcPrpv , oneCnt ) * 2 ) ; } } import java . util . Scanner ; public class dcaevV { public static void main ( String [ ] args ) { long DcaevEaoqi = 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 ) { DcaevEaoqi = DcaevEaoqi + tmp ; array [ i ] = array [ i ] - ( int ) tmp ; } else { DcaevEaoqi = DcaevEaoqi + array [ i ] ; array [ i ] = 0 ; } tmp = 0 ; } if ( i == n ) { continue ; } if ( array [ i ] >= array2 [ i ] ) { DcaevEaoqi = DcaevEaoqi + array2 [ i ] ; tmp = 0 ; } else { DcaevEaoqi = DcaevEaoqi + array [ i ] ; tmp = ( array2 [ i ] - array [ i ] ) ; } } System . out . println ( DcaevEaoqi ) ; sc . close ( ) ; } } import java . util . * ; public class TvfreBe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long TvfreQlk = sc . nextInt ( ) ; long r = sc . nextInt ( ) ; long min = TvfreQlk * ( TvfreQlk + 1 ) % 2019 ; if ( ( TvfreQlk % 2019 == 0 ) || ( r % 2019 == 0 ) ) { System . out . println ( 0 ) ; } else if ( ( TvfreQlk / 2019 ) != ( r / 2019 ) ) { System . out . println ( 0 ) ; } else if ( ( TvfreQlk / 2019 ) == ( r / 2019 ) ) { for ( long i = TvfreQlk ; 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 JqohWmfa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jqohD = sc . nextInt ( ) ; boolean f = true ; for ( int i = 0 ; i < jqohD ; 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 NzqxaIfmw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int nzqxaYavt = 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 ++ ; } nzqxaYavt = Math . min ( nzqxaYavt , diff ) ; } System . nzqxaYavt . println ( nzqxaYavt ) ; } } import java . util . Scanner ; public class LuhaxcCnqbqx { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int LuhaxcLr = 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 > LuhaxcLr + b ) { t = 1 ; } else { t = 2 ; } if ( t == 2 ) { sum += Math . min ( x , y ) * a_b ; if ( x > y ) { sum += ( x - y ) * LuhaxcLr ; } else { sum += ( y - x ) * b ; } sum = Math . min ( sum , a_b * ( Math . max ( x , y ) ) ) ; } else { sum += ( x * LuhaxcLr ) + ( y * b ) ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class ZjvEbuj { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int zjvUoj = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i <= zjvUoj ; 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 vburznKb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VburznZl = sc . nextInt ( ) ; int y = VburznZl ; if ( VburznZl == 2 ) { System . out . println ( 2 ) ; System . exit ( 0 ) ; } else if ( VburznZl == 3 ) { System . out . println ( 3 ) ; System . exit ( 0 ) ; } if ( y % 2 == 0 ) { y ++ ; } int n = 3 ; while ( n <= VburznZl ) { 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 WujTjff { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WujJ = sc . nextInt ( ) ; int [ ] nlist = new int [ WujJ ] ; for ( int i = 1 ; i <= WujJ ; i ++ ) { int a = sc . nextInt ( ) ; nlist [ a - 1 ] = i ; } for ( int i = 0 ; i < WujJ ; i ++ ) { System . out . print ( nlist [ i ] + " " ) ; } sc . close ( ) ; } } import java . util . Scanner ; class cykEem { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int CykGmfp = scan . nextInt ( ) ; int [ ] [ ] [ ] OffHouse = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int i = 0 ; i < CykGmfp ; 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 AddmKvds { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int AddmVtf = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; System . out . println ( ans ( AddmVtf , b , c , x ) ) ; } static int ans ( int AddmVtf , int b , int c , int x ) { int ans = 0 ; for ( int i = 0 ; i <= AddmVtf ; 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 AwkwnNbaocr { public static void main ( String [ ] args ) { Scanner a = new Scanner ( System . in ) ; int AwkwnH = a . nextInt ( ) ; int [ ] A = new int [ AwkwnH ] ; for ( int i = 0 ; i < AwkwnH ; i ++ ) { A [ i ] = a . nextInt ( ) ; } int flag = 1 ; int count = 0 ; while ( flag == 1 ) { flag = 0 ; for ( int i = AwkwnH - 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 < AwkwnH ; i ++ ) { System . out . print ( A [ i ] ) ; if ( i < AwkwnH - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; System . out . println ( count ) ; } } import java . util . * ; class HmjXvar { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] values = new int [ 3 ] [ 3 ] ; for ( int hmjL = 0 ; hmjL < 3 ; hmjL ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { values [ hmjL ] [ j ] = sc . nextInt ( ) ; } } boolean ok = false ; for ( int hmjL = 0 ; hmjL < 101 ; hmjL ++ ) { for ( int j = 0 ; j < 101 ; j ++ ) { for ( int k = 0 ; k < 101 ; k ++ ) { int b1 = values [ 0 ] [ 0 ] - hmjL ; int b2 = values [ 0 ] [ 1 ] - hmjL ; int b3 = values [ 0 ] [ 2 ] - hmjL ; 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 aofidNa { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . nextLine ( ) ; long AofidEh = scanner . nextLong ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < AofidEh ; i ++ ) { if ( S . charAt ( i ) == '1' ) { continue ; } System . out . println ( S . charAt ( i ) ) ; return ; } System . out . println ( 1 ) ; scanner . close ( ) ; } } import java . util . * ; class KxnIzkq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int KxnO = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; String j = sc . next ( ) ; if ( a . equals ( j ) ) { KxnO = KxnO - 1 ; } else if ( b . equals ( j ) ) { d = d - 1 ; } System . out . println ( KxnO ) ; 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 ZmepMvqss { static long ZmepRw = 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 AqpnFp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String strn = sc . next ( ) ; sc . close ( ) ; String [ ] str = strn . split ( " " ) ; int AqpnQvp = 0 ; for ( int i = 0 ; i < strn . length ( ) ; i ++ ) { AqpnQvp += Integer . parseInt ( str [ i ] ) ; } String ans = " No " ; if ( AqpnQvp % 9 == 0 ) { ans = " Yes " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class GyglqWweu { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int GyglqPb = scanner . nextInt ( ) ; int divValue , modValue , totalHp ; divValue = GyglqPb / 500 ; totalHp = divValue * 1000 ; modValue = GyglqPb % 500 ; if ( modValue != 0 ) { divValue = modValue / 5 ; totalHp = totalHp + divValue * 5 ; } System . out . println ( totalHp ) ; } } import java . util . * ; public class MsucjuPgak { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int msucjuCir = sc . nextInt ( ) ; int [ ] ai = new int [ msucjuCir ] ; for ( int i = 0 ; i < msucjuCir ; i ++ ) ai [ i ] = sc . nextInt ( ) ; int [ ] ans = new int [ msucjuCir ] ; for ( int i = 0 ; i < msucjuCir ; i ++ ) ans [ ai [ i ] - 1 ] = i + 1 ; for ( int i = 0 ; i < msucjuCir ; i ++ ) System . out . print ( ans [ i ] + " " ) ; } } import java . util . * ; public class GfbfBkn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gfbfY = sc . nextInt ( ) ; int l = 1 ; int r = 1_000_000_007 ; for ( int i = gfbfY ; 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 MhkRa { 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 MhkYge = Integer . parseInt ( str2 [ 0 ] ) ; int b = Integer . parseInt ( str2 [ 1 ] ) ; int digits = Integer . toString ( MhkYge + b ) . length ( ) ; System . out . println ( digits ) ; } } } import java . util . Scanner ; public class WnijpEfcg { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int wnijpQwa = scn . nextInt ( ) ; int [ ] A1 = new int [ wnijpQwa + 1 ] , A2 = new int [ wnijpQwa + 1 ] ; for ( int i = 1 ; i < wnijpQwa + 1 ; i ++ ) { A1 [ i ] = A1 [ i - 1 ] + scn . nextInt ( ) ; } for ( int i = 1 ; i < wnijpQwa + 1 ; i ++ ) { A2 [ i ] = A2 [ i - 1 ] + scn . nextInt ( ) ; } int ans = 0 ; for ( int i = 0 ; i < wnijpQwa ; i ++ ) { ans = Math . max ( ans , A1 [ i + 1 ] - A1 [ 0 ] + A2 [ wnijpQwa ] - A2 [ i ] ) ; } System . out . println ( ans ) ; } } import java . util . * ; class ipoehAok { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int [ ] rec = new int [ 26 ] ; for ( int IpoehKzag = 0 ; IpoehKzag < s . length ( ) ; IpoehKzag ++ ) { rec [ s . charAt ( IpoehKzag ) - 'a' ] ++ ; } String ans = " Yes " ; for ( int IpoehKzag = 0 ; IpoehKzag < 26 ; IpoehKzag ++ ) { if ( rec [ IpoehKzag ] % 2 == 1 ) ans = " No " ; } System . out . println ( ans ) ; } } import java . util . * ; public class dgyVxu { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int DgyUg = scn . nextInt ( ) ; int m = scn . nextInt ( ) ; int [ ] [ ] a = new int [ DgyUg ] [ m ] ; int [ ] b = new int [ m ] ; int [ ] c = new int [ DgyUg ] ; Arrays . fill ( c , 0 ) ; for ( int i = 0 ; i < DgyUg ; 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 < DgyUg ; 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 UaleiXd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int UaleiM = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) { sum += scan . nextInt ( ) ; } if ( UaleiM - sum < 0 ) { System . out . println ( - 1 ) ; } else { System . out . println ( UaleiM - sum ) ; } } } import java . util . Scanner ; public class GegvwZcbo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GegvwKzj = Integer . parseInt ( sc . nextLine ( ) ) ; String strings = sc . nextLine ( ) ; if ( strings . length ( ) <= GegvwKzj ) { System . out . println ( strings ) ; } else { System . out . println ( strings . substring ( 0 , GegvwKzj ) + " ... " ) ; } } } import java . util . * ; public class MqxranHx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mqxranWylt = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( mqxranWylt % 2 == 0 ) { int h = mqxranWylt / 2 - 1 ; String bs = S . substring ( 0 , h + 1 ) ; String as = S . substring ( h + 1 , mqxranWylt ) ; 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 MzsGkns { 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 mzsG = Integer . parseInt ( reader . readLine ( ) ) ; int cnt = 0 ; while ( true ) { inputData = reader . readLine ( ) ; cardMap . put ( String . valueOf ( cnt ) , inputData ) ; cnt ++ ; if ( cnt == mzsG ) { 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 xkevlEt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String XkevlVm = sc . next ( ) ; String ans = " " ; if ( XkevlVm . equals ( " ABC " ) ) { ans = " ARC " ; } else { ans = " ABC " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; class FdxmmoCp { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; boolean FdxmmoSmy = true ; int a = 0 , b = 0 ; while ( FdxmmoSmy ) { 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 nnqwosKtv { 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 NnqwosXtxvf = 0 ; NnqwosXtxvf < c . length ; NnqwosXtxvf ++ ) { for ( int m = 0 ; m < c . length ; m ++ ) { if ( c [ NnqwosXtxvf ] == c [ m ] ) { count [ NnqwosXtxvf ] ++ ; } } } for ( int NnqwosXtxvf = 0 ; NnqwosXtxvf < c . length ; NnqwosXtxvf ++ ) { if ( count [ NnqwosXtxvf ] % 2 != 0 ) { show = " No " ; break ; } else { show = " Yes " ; } } System . out . println ( show ) ; } } import java . util . * ; public class huscxScf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HuscxXxo = sc . nextInt ( ) ; int digitNum = ( int ) Math . log10 ( HuscxXxo ) + 1 ; int ans = 0 ; if ( digitNum == 6 ) { ans = 9 + 900 + 90000 ; } else if ( digitNum == 5 ) { ans = 9 + 900 + HuscxXxo - 10000 + 1 ; } else if ( digitNum == 4 ) { ans = 9 + 900 ; } else if ( digitNum == 3 ) { ans = 9 + HuscxXxo - 100 + 1 ; } else if ( digitNum == 2 ) { ans = 9 ; } else if ( digitNum == 1 ) { ans = HuscxXxo ; } System . out . println ( " " + ans ) ; } } import java . io . * ; import java . util . * ; import java . math . * ; import java . lang . * ; class gqwXlr { public static void PrintIntArray ( int [ ] Arr ) { for ( int GqwTz = 0 ; GqwTz < Arr . length ; GqwTz ++ ) { System . out . print ( Arr [ GqwTz ] + " " ) ; } 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 gqwXlr { 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 xrpSz { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; int XrpWt = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; for ( int i = 1 ; i < 2 * Math . abs ( XrpWt ) ; i ++ ) { System . out . print ( x - XrpWt + i + " " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class VamHgy { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int vamGpa = sc . nextInt ( ) ; int [ ] d = new int [ vamGpa ] ; for ( int i = 0 ; i < vamGpa ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; System . out . print ( d [ vamGpa / 2 ] - d [ vamGpa / 2 - 1 ] ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class CyvYl { 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 CyvWkg = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == t [ i ] ) { CyvWkg ++ ; } } System . out . println ( CyvWkg ) ; } } import java . util . * ; import java . lang . * ; public class undsnAx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; String s1 = str . substring ( 0 ) ; char UndsnNai = str . charAt ( 0 ) ; char c2 = str . charAt ( 1 ) ; char c3 = str . charAt ( 2 ) ; if ( UndsnNai == c2 && c2 == c3 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . Scanner ; class sbkYxh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int result [ ] = new int [ 1000000 ] , SbkMqsa = 0 ; while ( true ) { result [ SbkMqsa ] = sc . nextInt ( ) ; if ( result [ SbkMqsa ] == 0 ) break ; SbkMqsa ++ ; } for ( int j = 0 ; j < SbkMqsa ; j ++ ) { System . out . println ( " Case " + ( j + 1 ) + " : " + result [ j ] ) ; } } } import java . util . * ; public class vucyvHg { public static void main ( String [ ] args ) { int VucyvUxk = 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 ndfiDc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NdfiZgjo = sc . nextInt ( ) ; int [ ] a = new int [ 1000000 ] ; int Answer = 0 ; a [ 0 ] = NdfiZgjo ; 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 XttBpk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] array = new int [ 100 ] ; int XttT = sc . nextInt ( ) ; for ( int i = 0 ; i < XttT ; i ++ ) array [ i ] = sc . nextInt ( ) ; doInsertionSort ( array , XttT ) ; printArray ( array , XttT ) ; } public static void doInsertionSort ( int [ ] array , int XttT ) { for ( int i = 1 ; i < XttT ; i ++ ) { printArray ( array , XttT ) ; 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 XttT ) { for ( int i = 0 ; i < XttT ; i ++ ) { if ( i != 0 ) System . out . print ( " " ) ; System . out . print ( array [ i ] ) ; } System . out . print ( " \n " ) ; } } import java . util . * ; public class EecrNozo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eecrT = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < eecrT ; 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 xtiFef { 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 XtiVnyk = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( XtiVnyk == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < XtiVnyk ; i ++ ) { char p ; if ( i == 0 || i == XtiVnyk - 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 WbxoYpgn { public static void main ( String [ ] args ) { new Main ( ) . exec ( ) ; } void exec ( ) { Scanner sc = new Scanner ( System . in ) ; int wbxoMm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = Math . min ( wbxoMm , b ) ; i >= 1 ; -- i ) { if ( wbxoMm % i == 0 && b % i == 0 ) { -- k ; if ( k == 0 ) { System . out . println ( i ) ; sc . close ( ) ; return ; } } } sc . close ( ) ; } } import java . util . Scanner ; public class GexrvePxjg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gexrveSu = 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 ) gexrveSu ++ ; } System . out . println ( gexrveSu ) ; } } import java . util . * ; public class vzwnOnt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VzwnBsw , b , c ; VzwnBsw = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; int n = VzwnBsw - 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 ijpbxdFq { Scanner sc = new Scanner ( System . in ) ; void solve ( ) { String [ ] rawInputs = sc . nextLine ( ) . split ( " " ) ; Stack < String > stack = new Stack < > ( ) ; for ( String IjpbxdCbnt : rawInputs ) { switch ( IjpbxdCbnt ) { 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 ( IjpbxdCbnt ) ; } } } String result = stack . pop ( ) ; System . out . println ( result ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class OqhnNr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int OqhnXw = scan . nextInt ( ) ; for ( int i = 1 ; i <= OqhnXw ; i ++ ) { if ( OqhnXw >= 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 ImmCmg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " Yes " ; int immM = s . length ( ) ; for ( int i = 0 ; i < ( immM - 1 ) / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( immM - 1 - i ) ) ans = " No " ; } immM = immM / 2 ; if ( ! ans . equals ( " No " ) ) { for ( int i = 0 ; i < immM / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( immM - 1 - i ) ) ans = " No " ; } } System . out . print ( ans ) ; } } import java . util . Scanner ; public class UojdEc { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int uojdAwof = sc . nextInt ( ) ; String op = sc . next ( ) ; int b = sc . nextInt ( ) ; for ( ; ! op . equals ( " ? " ) ; ) { int ans = 0 ; switch ( op ) { case " + " : ans = uojdAwof + b ; break ; case " - " : ans = uojdAwof - b ; break ; case " * " : ans = uojdAwof * b ; break ; case " / " : if ( uojdAwof == 0 ) { break ; } ans = uojdAwof / b ; } System . out . println ( ans ) ; uojdAwof = sc . nextInt ( ) ; op = sc . next ( ) ; b = sc . nextInt ( ) ; } } } import java . util . HashMap ; import java . util . Scanner ; class VipUy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vipMy = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] k = new int [ vipMy ] ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < vipMy ; 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 == vipMy ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class dycpgIq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String DycpgDnwk = sc . next ( ) ; String t = sc . next ( ) ; String S = DycpgDnwk + DycpgDnwk ; if ( S . contains ( t ) == true ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class bhykZiz { 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 BhykVfej = 0 ; BhykVfej < s . length ( ) ; BhykVfej ++ ) { if ( s . charAt ( BhykVfej ) >= 'a' && s . charAt ( BhykVfej ) <= 'z' ) { a [ s . charAt ( BhykVfej ) - 'a' ] ++ ; } } } for ( char BhykVfej = 'a' ; BhykVfej <= 'z' ; BhykVfej ++ ) { System . out . println ( BhykVfej + " : " + a [ BhykVfej - 'a' ] ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class yuztU { public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = in . readLine ( ) ; int YuztUorl = Integer . parseInt ( W ) ; W = in . readLine ( ) ; String [ ] Ws = W . split ( " " ) ; int [ ] P = new int [ YuztUorl ] ; for ( int i = 0 ; i < YuztUorl ; i ++ ) { P [ i ] = Integer . parseInt ( Ws [ i ] ) ; } int ans = 0 ; int Pj = Integer . MAX_VALUE ; for ( int i = 0 ; i < YuztUorl ; i ++ ) { if ( P [ i ] <= Pj ) { ans ++ ; Pj = P [ i ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class vucnjcNd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . next ( ) ; String t = scanner . next ( ) ; int VucnjcMxc = 0 ; for ( int i = 0 ; i < s . length ( ) && i < t . length ( ) ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) VucnjcMxc ++ ; } System . out . println ( VucnjcMxc ) ; } } import java . util . * ; public class DnrmlMukz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dnrmlV = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int a3 = sc . nextInt ( ) ; if ( dnrmlV + 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 DnrmlMukz { int a , b ; Pair ( int a , int b ) { this . a = a ; this . b = b ; } } import java . util . Scanner ; public class GkaomNmn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; int gkaomLwr = 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 ++ ; } gkaomLwr = Math . min ( gkaomLwr , cnt ) ; } System . out . println ( gkaomLwr ) ; } } import java . util . Scanner ; public class rvbrIc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int RvbrWw = scan . nextInt ( ) ; String s = Integer . toString ( RvbrWw ) ; 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 pdxsWzt { public static void main ( String [ ] args ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; try { String [ ] list = br . readLine ( ) . split ( " " ) ; int PdxsGap = Integer . parseInt ( list [ 0 ] ) ; int b = Integer . parseInt ( list [ 1 ] ) ; int d = PdxsGap / b ; int r = PdxsGap % b ; double f = ( double ) PdxsGap / b ; System . out . println ( d + " " + r + " " + String . format ( " %.5f " , f ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class VkcrxsWlug { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vkcrxsYdem = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int a = 0 ; for ( int i = 0 ; i < N ; i ++ ) a += sc . nextInt ( ) ; if ( a >= vkcrxsYdem ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . * ; import java . util . * ; public class pnyfSvv { 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 PnyfCn = 0 ; for ( char c : cs ) { PnyfCn += c ; } PnyfCn -= cs . length * '0' ; System . out . println ( PnyfCn % 9 == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class vxberZqv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VxberIoits = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( ( VxberIoits + 1 ) / 2 * 1.0 / VxberIoits ) ; } } import java . util . Arrays ; import java . util . Scanner ; import java . util . stream . Stream ; public class UubjqRsa { public static void main ( final String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; final String UubjqNmc = sc . next ( ) ; StringBuffer sb = new StringBuffer ( UubjqNmc ) ; sb . setCharAt ( 3 , '8' ) ; System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; public class ZqzsFzxgia { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; int ZqzsB = scan . nextInt ( ) ; int [ ] p = new int [ ZqzsB ] ; int a = 0 ; for ( int i = 0 ; i < ZqzsB ; i ++ ) { p [ i ] = scan . nextInt ( ) ; } for ( int i = 1 ; i < ZqzsB - 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 IuwkZpoi { public static void main ( String [ ] args ) { int [ ] n ; n = new int [ 3 ] ; int iuwkUqvs , 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 ] ; iuwkUqvs = ( n [ 1 ] < n [ 2 ] ) ? n [ 1 ] : n [ 2 ] ; iuwkUqvs = ( n [ 0 ] < iuwkUqvs ) ? n [ 0 ] : iuwkUqvs ; max = ( n [ 1 ] < n [ 2 ] ) ? n [ 2 ] : n [ 1 ] ; max = ( n [ 0 ] < max ) ? max : n [ 0 ] ; mid = mid - ( iuwkUqvs + max ) ; System . out . println ( iuwkUqvs + " " + mid + " " + max ) ; scan . close ( ) ; } } import java . util . * ; import java . io . * ; import java . math . BigInteger ; public class wsafukEtq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; int WsafukYxaet = Integer . parseInt ( br . readLine ( ) ) ; int [ ] arr = new int [ WsafukYxaet ] ; StringTokenizer st1 = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < WsafukYxaet ; i ++ ) { arr [ i ] = Integer . parseInt ( st1 . nextToken ( ) ) ; } int [ ] cnt = new int [ WsafukYxaet ] ; int max = 0 ; for ( int i = WsafukYxaet - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] >= arr [ i + 1 ] ) { cnt [ i ] = cnt [ i + 1 ] + 1 ; } } for ( int i = 0 ; i < WsafukYxaet ; 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 PhtbChhjis { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int PhtbM = Integer . parseInt ( br . readLine ( ) ) ; int [ ] num = new int [ PhtbM ] ; 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 NoatyRea { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; char [ ] c = str . toCharArray ( ) ; for ( int NoatyRyz = 0 ; NoatyRyz < c . length ; NoatyRyz ++ ) { int count = 0 ; for ( int j = 0 ; j < c . length ; j ++ ) { if ( c [ NoatyRyz ] == c [ j ] ) { count ++ ; } } if ( count % 2 != 0 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class geqywnD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GeqywnKz = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = 0 ; for ( int i = GeqywnKz ; 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 WmpoiRbymmr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WmpoiEi = sc . nextInt ( ) ; int [ ] x = new int [ WmpoiEi ] ; int l = Integer . MAX_VALUE / 2 , r = - 1 ; for ( int i = 0 ; i < WmpoiEi ; 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 < WmpoiEi ; j ++ ) { d += Math . pow ( i - x [ j ] , 2 ) ; } min = Math . min ( min , d ) ; } System . out . println ( min ) ; } } import java . util . * ; public class LhecHn { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int lhecUt = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; long z = lhecUt + y ; System . out . println ( ( lhecUt + y ) % 2 == 0 ? ( lhecUt + y ) / 2 : " IMPOSSIBLE " ) ; } } import java . io . * ; public class EzydguCk { public static void main ( String [ ] args ) { try { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int ezydguFz = Integer . parseInt ( in . readLine ( ) ) ; int [ ] iArr = new int [ ezydguFz ] ; 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 BgisskHceg { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int bgisskMsx = sc . nextInt ( ) ; ArrayList < String > result = new ArrayList < > ( ) ; result . add ( sc . next ( ) ) ; for ( int i = 1 ; i < bgisskMsx ; i ++ ) { result . add ( sc . next ( ) ) ; } ArrayList < String > ans = new ArrayList < String > ( new HashSet < > ( result ) ) ; System . out . println ( ans . size ( ) ) ; } } import java . util . * ; public class ZoecRymkha { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZoecUo = 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 <= ZoecUo ; 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 TeqNsx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long teqIix = sc . nextLong ( ) ; long h = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; double ans = 0.5 * teqIix * h ; StringBuilder builder = new StringBuilder ( String . valueOf ( ans ) ) ; int flag = 0.5 * teqIix == x && 0.5 * h == y ? 1 : 0 ; builder . append ( " " + flag ) ; System . out . println ( builder ) ; } } import java . util . Scanner ; public class IwcnvfNq { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; int iwcnvfZz = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; scanner . close ( ) ; int c = iwcnvfZz * b ; if ( c % 2 == 1 ) { System . out . println ( " Odd " ) ; } else if ( c % 2 == 0 ) { System . out . println ( " Even " ) ; } } } import java . util . * ; public class MceugBtm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MceugSxh = 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 [ MceugSxh ] ; int [ ] wa = new int [ MceugSxh ] ; 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 < MceugSxh ; 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 UovlhfTqun { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int uovlhfBt = scanner . nextInt ( ) ; final Set < Integer > appeared = new HashSet < > ( ) ; int m = 1 ; do { appeared . add ( uovlhfBt ) ; if ( uovlhfBt % 2 == 0 ) { uovlhfBt = uovlhfBt / 2 ; } else { uovlhfBt = 3 * uovlhfBt + 1 ; } m ++ ; } while ( ! appeared . contains ( uovlhfBt ) ) ; System . out . println ( m ) ; } } import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class CjqqZprz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; String Sa = sc . next ( ) ; String Sb = sc . next ( ) ; String Sc = sc . next ( ) ; int cjqqJw = Sa . length ( ) , b = Sb . length ( ) , c = Sc . length ( ) ; char p = Sa . charAt ( Sa . length ( ) - cjqqJw ) ; cjqqJw -- ; while ( true ) { switch ( p ) { case 'a' : if ( cjqqJw == 0 ) { out . println ( " A " ) ; exit ( 0 ) ; } p = Sa . charAt ( Sa . length ( ) - cjqqJw ) ; cjqqJw -- ; 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 bpopZ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long BpopOcdmu = scan . nextLong ( ) ; long syou = 0 ; long a = 0 , b = 0 ; long re = Long . MAX_VALUE ; for ( int i = 1 ; i <= Math . sqrt ( BpopOcdmu ) ; i ++ ) { if ( BpopOcdmu % i == 0 ) { a = i ; b = BpopOcdmu / 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 hqbYfr { 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 HqbVpan = Integer . parseInt ( reader . readLine ( ) ) ; int n = Integer . parseInt ( reader . readLine ( ) ) ; int [ ] numbers = new int [ HqbVpan ] ; for ( int i = 0 ; i < HqbVpan ; 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 < HqbVpan ; i ++ ) { out . println ( numbers [ i ] ) ; } } } import java . util . Scanner ; public class ldcviD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; long LdcviBenzl = sc . nextLong ( ) ; int ans = 0 ; int n = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { n = s . charAt ( i ) - '0' ; LdcviBenzl -- ; if ( LdcviBenzl == 0 || n > 1 ) break ; } System . out . println ( n ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class BoihRvcj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int boihV = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean [ ] broken = new boolean [ boihV + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { broken [ sc . nextInt ( ) ] = true ; } int [ ] dp = new int [ boihV + 1 ] ; Arrays . fill ( dp , 0 ) ; dp [ 0 ] = 1 ; dp [ 1 ] = broken [ 1 ] ? 0 : 1 ; for ( int i = 2 ; i <= boihV ; 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 AwmqCjreee { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AwmqD = sc . nextInt ( ) ; int num2 = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( AwmqD < num2 ) { sum += num2 ; num2 -- ; } else { sum += AwmqD ; AwmqD -- ; } } 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 efmostFom { 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 efmostFom { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int EfmostQbz = 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 efmostFom { 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 EdnuzLyu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ednuzEwoz = Integer . parseInt ( scan . next ( ) ) ; if ( ednuzEwoz <= 111 ) { System . out . println ( 111 ) ; } else if ( ednuzEwoz <= 222 ) { System . out . println ( 222 ) ; } else if ( ednuzEwoz <= 333 ) { System . out . println ( 333 ) ; } else if ( ednuzEwoz <= 444 ) { System . out . println ( 444 ) ; } else if ( ednuzEwoz <= 555 ) { System . out . println ( 555 ) ; } else if ( ednuzEwoz <= 666 ) { System . out . println ( 666 ) ; } else if ( ednuzEwoz <= 777 ) { System . out . println ( 777 ) ; } else if ( ednuzEwoz <= 888 ) { System . out . println ( 888 ) ; } else if ( ednuzEwoz <= 999 ) { System . out . println ( 999 ) ; } } } import java . util . * ; public class tnbjikA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TnbjikPjtqc = sc . nextInt ( ) ; int result = 100000 ; for ( int i = 0 ; i < TnbjikPjtqc ; i ++ ) { result += result * 0.05 ; result = ( int ) Math . ceil ( ( double ) result / 1000 ) * 1000 ; } System . out . println ( result ) ; } } import java . util . * ; public class bntmzI { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String BntmzNlra = sc . next ( ) ; BntmzNlra = " 2018 " + BntmzNlra . substring ( 4 , BntmzNlra . length ( ) ) ; System . out . println ( BntmzNlra ) ; } public static void main ( String [ ] args ) { solve ( ) ; } } import java . util . * ; public class ZzmhedEybx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zzmhedLxo = Integer . parseInt ( sc . nextLine ( ) ) ; String sTaro ; String sHanako ; int iTaro = 0 ; int iHanako = 0 ; for ( int i = 0 ; i < zzmhedLxo ; 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 rkoIt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RkoDktpo = sc . nextInt ( ) ; System . out . println ( ( ( RkoDktpo + 1 ) / 2 ) ) ; } } import java . util . * ; public class BrinkbLsm { static String Rort ( String s , String t ) { String brinkbAk = s + s ; brinkbAk = brinkbAk . replaceFirst ( t , " " ) ; if ( brinkbAk . 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 rpmO { public static void main ( String [ ] args ) throws IOException { int RpmRvxd = 0 , f = 0 , r = 0 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String str = br . readLine ( ) ; String [ ] i = str . split ( " " ) ; RpmRvxd = Integer . parseInt ( i [ 0 ] ) ; f = Integer . parseInt ( i [ 1 ] ) ; r = Integer . parseInt ( i [ 2 ] ) ; if ( RpmRvxd == ( - 1 ) && f == ( - 1 ) && r == ( - 1 ) ) { break ; } if ( RpmRvxd == ( - 1 ) || f == ( - 1 ) ) { System . out . println ( " F " ) ; } else if ( RpmRvxd + f >= 80 ) { System . out . println ( " A " ) ; } else if ( RpmRvxd + f >= 65 ) { System . out . println ( " B " ) ; } else if ( RpmRvxd + f >= 50 ) { System . out . println ( " C " ) ; } else if ( RpmRvxd + 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 FcxyOn { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int fcxyAki = 0 ; int n ; while ( true ) { fcxyAki ++ ; n = Integer . parseInt ( br . readLine ( ) ) ; if ( n == 0 ) break ; System . out . println ( " Case " + fcxyAki + " : " + n ) ; } } } import java . util . Scanner ; public class GdrwpzXuknq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GdrwpzYv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; boolean ok = true ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i == GdrwpzYv && s . charAt ( GdrwpzYv ) != '-' ) { ok = false ; } if ( i != GdrwpzYv && s . charAt ( i ) == '-' ) { ok = false ; } } if ( ok ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class ZfxkymIg { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( true ) { String s = in . nextLine ( ) ; if ( s . equals ( " 0 " ) ) return ; long ZfxkymRx = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { ZfxkymRx += Integer . parseInt ( " " + s . charAt ( i ) ) ; } System . out . println ( ZfxkymRx ) ; } } } import java . util . * ; public class NrtlkEjvsux { 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 NrtlkYzy = 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 + NrtlkYzy ) % 26 ) ) ; } } } System . out . print ( " \n " ) ; } } import java . util . * ; public class WhtbrrBtrqz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int WhtbrrSn = str . length ( ) ; String leftStr = str . substring ( 0 , ( WhtbrrSn - 1 ) / 2 ) ; String rightStr = str . substring ( ( WhtbrrSn + 1 ) / 2 , WhtbrrSn ) ; 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 LulksvPsav { 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 LulksvIc = Long . MIN_VALUE ; for ( int i = 0 ; i < 2 ; ++ i ) { for ( int j = 0 ; j < 2 ; ++ j ) { long tmp = a [ i ] * b [ j ] ; LulksvIc = Math . LulksvIc ( tmp , LulksvIc ) ; } } System . out . println ( LulksvIc ) ; sc . close ( ) ; } } import java . util . Scanner ; public class CahgegNdxkip { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CahgegHew = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; long p = 1 ; int r = 0 ; while ( p <= CahgegHew ) { p *= k ; r ++ ; } System . out . println ( r ) ; } } import java . util . Scanner ; public class MatVfv { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int MatNog = stdIn . nextInt ( ) ; int [ ] A = new int [ MatNog ] ; int count = 0 ; int ans = 0 ; for ( int i = 0 ; i < MatNog ; 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 NuuqmIwxdc { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int NuuqmG = gi ( ) ; int [ ] A = new int [ NuuqmG ] ; for ( int i = 0 ; i < NuuqmG ; i ++ ) { A [ i ] = gi ( ) ; } int max = 0 ; int t = 0 ; for ( int i = 0 ; i < NuuqmG ; 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 cnhrqqAz { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CnhrqqVxbrp = 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 = ( CnhrqqVxbrp * CnhrqqVxbrp ) + ( B * B ) - ( 2 * CnhrqqVxbrp * B * Math . cos ( rad ) ) ; System . out . println ( Math . sqrt ( rsq ) ) ; } } import java . util . * ; public class qqvyN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QqvyMmb = sc . nextInt ( ) ; int check = 0 ; String [ ] W = new String [ QqvyMmb ] ; for ( int i = 0 ; i < QqvyMmb ; i ++ ) { W [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < QqvyMmb - 1 ; i ++ ) { if ( W [ i ] . charAt ( W [ i ] . length ( ) - 1 ) != W [ i + 1 ] . charAt ( 0 ) ) { check ++ ; break ; } for ( int j = i + 1 ; j < QqvyMmb ; 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 dcpM { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double DcpPnmvm = 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 = DcpPnmvm * DcpPnmvm + B * B - 2 * DcpPnmvm * B * co ; System . out . println ( Math . sqrt ( ans ) ) ; } } import java . util . * ; public class EnfqvOxiat { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EnfqvXi = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int a = x - ( EnfqvXi - 1 ) ; for ( int i = 0 ; i < EnfqvXi * 2 - 1 ; i ++ ) { if ( a < - 1000000 || a > 1000000 ) continue ; System . out . print ( a + " " ) ; a ++ ; } } } import java . util . * ; public class NvsfPjtk { public static void main ( String [ ] args ) { Scanner yomi = new Scanner ( System . in ) ; int NvsfYpu = yomi . nextInt ( ) ; boolean tf = true ; int [ ] n = new int [ NvsfYpu ] ; for ( int i = 0 ; i < NvsfYpu ; i ++ ) { n [ i ] = yomi . nextInt ( ) ; } for ( int i = 0 ; i < NvsfYpu ; 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 WvuprPwvp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wvuprHv = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] ar = new int [ wvuprHv ] ; int sum = 0 ; int res = 114514 ; for ( int i = 0 ; i < wvuprHv ; 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 WvuprPwvp { 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 WvuprPwvp { public static boolean isOdd ( int wvuprHv ) { return wvuprHv % 2 == 1 ; } public static boolean isEven ( int wvuprHv ) { return wvuprHv % 2 == 0 ; } } import java . util . Scanner ; public class TkhZgi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tkhX = scan . nextInt ( ) ; int sum = scan . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x <= tkhX ; ++ x ) { for ( int y = 0 ; y <= tkhX ; ++ y ) { int z = sum - x - y ; if ( 0 <= z && z <= tkhX ) { ans = ans + 1 ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; class IvcUvnl { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int ivcOw = cin . nextInt ( ) ; int res = sol ( ivcOw ) ; System . out . println ( res ) ; } private static int sol ( int ivcOw ) { return ( ivcOw * ivcOw * ivcOw ) ; } } import java . util . Scanner ; public class qgwEif { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int QgwGyas = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c ; int k = scanner . nextInt ( ) ; if ( QgwGyas > b ) c = QgwGyas ; else c = b ; for ( int i = c ; i >= 1 ; i -- ) { if ( QgwGyas % i == 0 && b % i == 0 ) { -- k ; if ( k == 0 ) { System . out . println ( i ) ; } } } } } import java . util . * ; import java . io . * ; public class SegtvAod { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int SegtvD = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( ( SegtvD * b ) % 2 == 0 ) System . out . println ( " Even " ) ; else System . out . println ( " Odd " ) ; } } import java . util . * ; public class JmwiRxeuit { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int JmwiSdd = sc . nextInt ( ) ; int [ ] [ ] nums = new int [ 4 ] [ 13 ] ; for ( int i = 0 ; i < JmwiSdd ; 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 YdlkLbrb { 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 FhqeEe { public static void main ( String [ ] a ) throws IOException { java . io . BufferedReader r = new java . io . BufferedReader ( new java . io . InputStreamReader ( System . in ) ) ; try { int fhqeSqo = Integer . parseInt ( r . readLine ( ) ) ; String [ ] ans = new String [ fhqeSqo ] ; for ( int i = 0 ; i < fhqeSqo ; 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 < fhqeSqo ; i ++ ) { System . out . println ( ans [ i ] ) ; } } catch ( Exception ex ) { System . exit ( 0 ) ; } } } import java . util . * ; public class DjqdewDfl { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int djqdewNzqo = Integer . parseInt ( sc . next ( ) ) ; String str = sc . next ( ) ; if ( djqdewNzqo % 2 == 1 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } String m = str . substring ( djqdewNzqo / 2 ) ; if ( str . substring ( 0 , djqdewNzqo / 2 ) . equals ( m ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class VdyVr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int vdyY = Integer . parseInt ( sc . next ( ) ) ; if ( vdyY % 2 == 0 ) { System . out . println ( vdyY / 2 ) ; } else { System . out . println ( ( vdyY + 1 ) / 2 ) ; } } } import java . util . Scanner ; class FxcXp { 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 fxcN = 0 ; for ( int i = 0 ; i < input . length ( ) ; ++ i ) { char ch = input . charAt ( i ) ; fxcN += Character . getNumericValue ( ch ) ; } System . out . println ( fxcN ) ; } } } import java . util . * ; public class SsjdbWc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] nt = line . split ( " " ) ; int SsjdbLk = Integer . parseInt ( nt [ 0 ] ) ; int t = Integer . parseInt ( nt [ 1 ] ) ; String rel = " TLE " ; for ( int i = 0 ; i < SsjdbLk ; 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 NmdkuAw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nmdkuZ = 0 ; String s = sc . nextLine ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '+' ) { nmdkuZ ++ ; } else if ( s . charAt ( i ) == '-' ) { nmdkuZ -- ; } } System . out . println ( nmdkuZ ) ; } } import java . util . * ; public class QjeenLi { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String qjeenU = sc . next ( ) ; if ( qjeenU . toUpperCase ( ) . equals ( qjeenU ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . Scanner ; public class DyfiPsm { public static void main ( String [ ] args ) { Diagram diagram = new Diagram ( ) ; try ( Scanner stdin = new Scanner ( System . in ) ) { int dyfiQ , w ; while ( stdin . hasNext ( ) ) { dyfiQ = Integer . parseInt ( stdin . next ( ) ) ; w = Integer . parseInt ( stdin . next ( ) ) ; if ( dyfiQ < 0 || dyfiQ > 300 || w < 0 || w > 300 ) { throw new RuntimeException ( " Input Error:Range 0 to 300 " ) ; } if ( dyfiQ == 0 && w == 0 ) { break ; } diagram . draw ( dyfiQ , w ) ; System . out . println ( " " ) ; } } catch ( RuntimeException e ) { e . printStackTrace ( ) ; } } } abstract class DyfiPsm { abstract void draw ( int height , int width ) ; } class DyfiPsm extends AbstractDiagram { @ Override void draw ( int dyfiQ , int w ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i <= dyfiQ ; i ++ ) { for ( int j = 1 ; j <= w ; j ++ ) { if ( ( i == 1 || i == dyfiQ ) || ( j == 1 || j == w ) ) { sb . append ( '#' ) ; } else { sb . append ( '.' ) ; } } System . out . println ( sb ) ; sb . setLength ( 0 ) ; } } } import java . util . Scanner ; public class KhwAe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int khwHdhj = sc . nextInt ( ) ; int point = sc . nextInt ( ) ; int min = point - khwHdhj + 1 ; int max = point + khwHdhj - 1 ; for ( int i = min ; i <= max ; i ++ ) { System . out . print ( i + " " ) ; } } } import java . util . * ; import java . io . * ; import java . math . * ; public class lnqoiZqw { public static void main ( String [ ] omkar ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; String LnqoiTtze = st . nextToken ( ) ; if ( LnqoiTtze . charAt ( 2 ) == LnqoiTtze . charAt ( 3 ) && LnqoiTtze . charAt ( 4 ) == LnqoiTtze . charAt ( 5 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class HqmjvDfm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hqmjvK = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int LMax = 0 ; int RMin = hqmjvK ; 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 YrpgFngwi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YrpgCxm = sc . nextInt ( ) ; int cnt = 0 ; while ( YrpgCxm -- > 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 FdquysNqo { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int FdquysPg = 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 <= FdquysPg ; 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 ( FdquysPg ) % 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 sgtwRa { static class sgtwRa { 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 SgtwHqhn = ( int ) n . charAt ( 0 ) ; SgtwHqhn ++ ; System . out . println ( ( char ) SgtwHqhn ) ; } } import java . util . Scanner ; public class MbvgzcCvcx { public static void main ( String ... nui ) { Scanner sc = new Scanner ( System . in ) ; int mbvgzcJmw = sc . nextInt ( ) ; int min = ( int ) 1e9 ; for ( int i = 0 ; i < mbvgzcJmw ; 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 IbxwpaOrfqt { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int IbxwpaTou = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] ints = new int [ IbxwpaTou ] [ m ] ; int [ ] line = new int [ IbxwpaTou ] ; int [ ] row = new int [ m ] ; int sum = 0 ; for ( int i = 0 ; i < IbxwpaTou ; 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 < IbxwpaTou + 1 ; i ++ ) { for ( int j = 0 ; j < m + 1 ; j ++ ) { if ( i == IbxwpaTou && j == m ) { System . out . print ( sum ) ; } else if ( j == m ) { System . out . print ( line [ i ] ) ; } else if ( i == IbxwpaTou ) { 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 IobrjvPulrja { 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 IobrjvT = Integer . parseInt ( tok [ 0 ] ) ; int B = Integer . parseInt ( tok [ 1 ] ) ; System . out . println ( IobrjvT * B ) ; } void calc ( ) { } void showResult ( ) { } } import java . util . Scanner ; public class XxbjtUxjv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xxbjtX = Integer . parseInt ( sc . next ( ) ) ; int b = xxbjtX + ( xxbjtX * xxbjtX ) + ( xxbjtX * xxbjtX * xxbjtX ) ; System . out . println ( b ) ; } } import java . util . Scanner ; public class yvjFt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YvjQxlhq = sc . nextInt ( ) ; long [ ] a = new long [ YvjQxlhq ] ; for ( int i = 0 ; i < YvjQxlhq ; i ++ ) { a [ i ] = sc . nextLong ( ) ; if ( a [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } long prod = 1 ; for ( int i = 0 ; i < YvjQxlhq ; 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 QrwrbqZjy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QrwrbqRnw = scan . nextInt ( ) ; int [ ] a = new int [ QrwrbqRnw + 1 ] ; for ( int i = 1 ; i < QrwrbqRnw ; i ++ ) { int j = scan . nextInt ( ) ; a [ j ] ++ ; } for ( int i = 1 ; i < QrwrbqRnw + 1 ; i ++ ) { System . out . println ( a [ i ] ) ; } } } import java . io . * ; class KauqXe { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String input = br . readLine ( ) ; double kauqJkuj = Double . parseDouble ( input ) ; double s = kauqJkuj * kauqJkuj * Math . PI ; double l = kauqJkuj * 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 WtstiZq { public static void main ( String [ ] Args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int WtstiR = 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 ) { WtstiR = 1 ; } } if ( WtstiR == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class DfoIxd { public static void main ( String [ ] args ) { try { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line ; while ( ( line = stdReader . readLine ( ) ) != null ) { int DfoVb = Integer . parseInt ( line ) ; System . out . println ( DfoVb * DfoVb * DfoVb ) ; } stdReader . close ( ) ; } catch ( Exception e ) { e . getStackTrace ( ) ; System . exit ( 0 ) ; } } } import java . util . * ; import java . text . * ; public class rkyIci { 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 RkyUutyo = formatDate2 . after ( formatDate ) ; if ( ! RkyUutyo ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } } } import java . util . * ; public class NpgvOkipef { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NpgvJj = 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 [ NpgvJj ] [ 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 mqhnpaDh { 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 MqhnpaVh = scan . nextInt ( ) ; int A = scan . nextInt ( ) ; int ans = ( int ) Math . ceil ( ( double ) MqhnpaVh / A ) ; os . println ( ans ) ; } } import java . util . Scanner ; public class eiyneVpw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EiyneUtbw = 0 ; int ans = 0 ; for ( int i = 1 ; i < 6 ; i ++ ) { EiyneUtbw = scan . nextInt ( ) ; if ( EiyneUtbw == 0 ) { ans = i ; } } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class PayrzdXr { public static void main ( String ... args ) { Scanner scanner = new Scanner ( System . in ) ; int PayrzdWy = scanner . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; int cnt = 1 ; for ( int i = 0 ; i < PayrzdWy ; i ++ ) { int sc = scanner . nextInt ( ) ; if ( sc == cnt ) { list . add ( cnt ++ ) ; } } int rst = PayrzdWy - list . size ( ) ; System . out . println ( rst == PayrzdWy ? - 1 : rst ) ; } } import java . util . * ; public class SzhvyPv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int szhvyHg = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] b = new int [ szhvyHg ] [ 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 < szhvyHg ; i ++ ) { if ( b [ i ] [ 0 ] > 0 ) { ok ++ ; ng += b [ i ] [ 1 ] ; } } System . out . println ( ok + " " + ng ) ; } } import java . util . Scanner ; public class vlnaY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VlnaVhez = 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 calahLd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CalahLlqoo = 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 >= CalahLlqoo ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class GrvcwEg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] n = new int [ 3 ] ; for ( int grvcwEnjn = 0 ; grvcwEnjn < 3 ; grvcwEnjn ++ ) { n [ grvcwEnjn ] = scan . nextInt ( ) ; } int k = scan . nextInt ( ) ; Arrays . sort ( n ) ; for ( int grvcwEnjn = 0 ; grvcwEnjn < k ; grvcwEnjn ++ ) { n [ 2 ] *= 2 ; } int a = 0 ; for ( int grvcwEnjn = 0 ; grvcwEnjn < 3 ; grvcwEnjn ++ ) { a += n [ grvcwEnjn ] ; } System . out . println ( a ) ; } } import java . util . Scanner ; public class zojNn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int ZojZzu = 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 { ZojZzu ++ ; } } } System . out . println ( ZojZzu ) ; } } } import java . util . * ; public class sfwjVc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SfwjMufa = sc . nextInt ( ) ; int [ ] a = new int [ SfwjMufa + 1 ] ; for ( int i = 1 ; i <= SfwjMufa ; 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 BmqymnQr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bmqymnU = sc . nextInt ( ) ; int [ ] k = new int [ bmqymnU ] ; Boolean allZero = false ; int count = 0 ; for ( int i = 0 ; i < bmqymnU ; i ++ ) { k [ i ] = sc . nextInt ( ) ; } while ( ! allZero ) { allZero = true ; int now = 0 ; Boolean isZero = true ; while ( now < bmqymnU ) { 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 QihToe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long qihMz = Long . parseLong ( sc . next ( ) ) ; long r = Long . parseLong ( sc . next ( ) ) ; long ans = Long . MAX_VALUE ; long num = 0 ; for ( long i = qihMz ; 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 NnitpzLmgm { 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 NnitpzLmgm { int NnitpzXlv = - 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 - NnitpzXlv + 1 < K ) { start = NnitpzXlv ; 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 EvmbgUa { 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 evmbgIk = sc . nextInt ( ) ; Arrays . parallelSort ( A ) ; System . out . println ( A [ 0 ] + A [ 1 ] + ( int ) ( A [ 2 ] * Math . pow ( 2 , evmbgIk ) ) ) ; } } import java . util . Scanner ; class wtqbDoa { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int WtqbGtu = 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 ) == WtqbGtu && ( int ) ( pc * 0.1 ) == b ) { while ( ( int ) ( pc * 0.08 ) == WtqbGtu && ( int ) ( pc * 0.1 ) == b ) { pc -- ; } pc ++ ; System . out . println ( pc ) ; return ; } else if ( ( int ) ( pc * 0.08 ) < WtqbGtu || ( int ) ( pc * 0.1 ) < b ) { pl = pc + 1 ; } else if ( ( int ) ( pc * 0.08 ) > WtqbGtu || ( int ) ( pc * 0.1 ) > b ) { pr = pc - 1 ; } } while ( pl <= pr ) ; System . out . println ( - 1 ) ; } } import java . util . * ; class xlcmIu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XlcmVgb = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; String tmp = sc . nextLine ( ) ; for ( int i = 0 ; i < XlcmVgb ; ++ 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 RqmKsom { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rqmA = sc . nextInt ( ) ; int [ ] n = new int [ rqmA ] ; for ( int i = 0 ; i < rqmA ; i ++ ) { n [ i ] = sc . nextInt ( ) ; } Arrays . sort ( n ) ; int sum = 0 ; for ( int i = 0 ; i < rqmA - 1 ; i ++ ) { sum += n [ i ] ; } if ( n [ rqmA - 1 ] < sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class XtnzqQysuop { public static void main ( String [ ] args ) { solve_149_B ( ) ; return ; } private static void solve_149_B ( ) { Scanner sc = new Scanner ( System . in ) ; long XtnzqN = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; if ( XtnzqN >= K ) { XtnzqN = XtnzqN - K ; } else { if ( B >= ( K - XtnzqN ) ) { B = B - ( K - XtnzqN ) ; } else { B = 0 ; } XtnzqN = 0 ; } System . out . println ( XtnzqN + " " + B ) ; } } import java . util . Scanner ; public class NjynpOhb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int njynpG = scanner . nextInt ( ) ; int i = 0 ; int m = 0 ; i = njynpG / 500 ; njynpG = njynpG - 500 * i ; m = njynpG / 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 AyawlmOuga { 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 ayawlmY = date . compareTo ( today ) ; if ( ayawlmY <= 0 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } catch ( DateTimeParseException e ) { System . out . println ( " 堥力値がyyyy/mm/dd形式ではありません"); } } } import java . util . * ; public class AlmzddCu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int almzddG = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; String s = sc . next ( ) ; StringBuffer buf = new StringBuffer ( ) ; for ( int i = 0 ; i < almzddG ; 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 WqzrhuRjnge { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int WqzrhuF = scn . nextInt ( ) ; float temp = ( float ) WqzrhuF / 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 UymlKiqn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uymlElg = sc . nextInt ( ) ; sc . close ( ) ; int c = uymlElg / 4 ; int d = uymlElg / 7 ; for ( int i = 0 ; i <= c ; i ++ ) { for ( int j = 0 ; j <= d ; j ++ ) { if ( 4 * i + 7 * j == uymlElg ) { System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } } import java . util . * ; public class yluikLir { 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 YluikJid = sortedString . length ( ) ; int cnt = 0 ; char tmpVal = sortedString . charAt ( 0 ) ; if ( YluikJid <= 1 ) { System . out . println ( " No " ) ; return ; } for ( int i = 0 ; i < YluikJid ; 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 KuitqxPyv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kuitqxWuz = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; int m = kuitqxWuz * y ; int n = 2 * kuitqxWuz + 2 * y ; System . out . println ( m + " " + n ) ; } } import java . util . * ; public class bjhLf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BjhUmzc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = BjhUmzc * 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 EqaXp { public static int prime ( int x ) { int eqaJoo = 0 ; if ( x == 1 ) { eqaJoo = 1 ; } else if ( x % 2 == 0 ) { eqaJoo = 1 ; } for ( int i = 3 ; i <= Math . sqrt ( x ) ; i += 2 ) { if ( x % i == 0 ) { eqaJoo = 1 ; break ; } } if ( x == 2 ) { eqaJoo = 0 ; } return eqaJoo ; } 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 utmpufY { 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 UtmpufAy = Integer . parseInt ( st . nextToken ( ) ) ; int y = Integer . parseInt ( st . nextToken ( ) ) ; System . out . print ( UtmpufAy * y ) ; System . out . print ( " " ) ; System . out . println ( 2 * UtmpufAy + 2 * y ) ; } } import java . io . * ; import java . util . * ; class MbyqWpq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int mbyqKsc = Integer . parseInt ( st . nextToken ( ) ) ; int T = Integer . parseInt ( st . nextToken ( ) ) ; int S = Integer . parseInt ( st . nextToken ( ) ) ; float tmp = ( float ) mbyqKsc / T ; if ( S >= tmp ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class OyfPd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oyfHhp = 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 ( oyfHhp - sum >= 0 ) { System . out . print ( ( oyfHhp - sum ) ) ; } else { System . out . print ( - 1 ) ; } } } import java . util . * ; public class CbtadhSxdm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cbtadhTj = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; double sum = 0 ; int cnt = 0 ; Integer [ ] items = new Integer [ cbtadhTj ] ; for ( int i = 0 ; i < cbtadhTj ; 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 HqwdvRc { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int HqwdvMm = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; int K = in . nextInt ( ) ; int sum = HqwdvMm + B + C ; int max = Math . max ( HqwdvMm , Math . max ( B , C ) ) ; sum += - max + ( max << K ) ; System . out . println ( sum ) ; } } } import java . util . Scanner ; public class XnaTmu { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int XnaN = input . nextInt ( ) ; int [ ] level = new int [ XnaN ] ; int count = 1 ; int min = 0 ; for ( int i = 0 ; i < XnaN ; 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 XjegbHv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XjegbQ = sc . nextInt ( ) ; int strength1 = sc . nextInt ( ) ; int health2 = sc . nextInt ( ) ; int strength2 = sc . nextInt ( ) ; while ( true ) { health2 -= strength1 ; if ( health2 <= 0 ) break ; XjegbQ -= strength2 ; if ( XjegbQ <= 0 ) break ; } if ( XjegbQ > health2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class bsftB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int BsftNbwp = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; if ( BsftNbwp == - 1 && f == - 1 && r == - 1 ) { break ; } else { int x ; x = BsftNbwp + f ; if ( BsftNbwp == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } if ( x >= 80 && BsftNbwp != - 1 && f != - 1 ) { System . out . println ( " A " ) ; } if ( x < 80 && x >= 65 && BsftNbwp != - 1 && f != - 1 ) { System . out . println ( " B " ) ; } if ( x < 65 && x >= 50 && BsftNbwp != - 1 && f != - 1 ) { System . out . println ( " C " ) ; } if ( x < 50 && x >= 30 && BsftNbwp != - 1 && f != - 1 && r >= 50 ) { System . out . println ( " C " ) ; } if ( x >= 30 && x < 50 && BsftNbwp != - 1 && f != - 1 && r < 50 ) { System . out . println ( " D " ) ; } if ( x < 30 && BsftNbwp != - 1 && f != - 1 ) { System . out . println ( " F " ) ; } } } } } import java . util . Scanner ; public class MpwrMncg { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int MpwrCn = gi ( ) ; int M = gi ( ) ; int a = ( int ) Math . ceil ( ( double ) ( M - 1 ) / ( double ) ( MpwrCn - 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 dojtaDcz { static final Scanner stdin = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { while ( stdin . hasNext ( ) ) { int DojtaMmr = stdin . nextInt ( ) ; int b = stdin . nextInt ( ) ; int comp_val = DojtaMmr - b ; int num , aval , m , n , ans1 ; if ( comp_val > 0 ) { for ( int i = 0 ; i <= DojtaMmr ; i ++ ) { aval = DojtaMmr - i ; if ( DojtaMmr % aval == 0 && b % aval == 0 ) { m = DojtaMmr / 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 ( DojtaMmr % aval == 0 && b % aval == 0 ) { m = DojtaMmr / aval ; n = b / aval ; ans1 = m * n * aval ; System . out . println ( aval + " " + ans1 ) ; break ; } } } } } } import java . util . Scanner ; public class OfhknpXzik { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String S = input . next ( ) ; long OfhknpI = 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 ) ; OfhknpI -= ( long ) Math . pow ( n , days ) ; if ( OfhknpI <= 0 ) { System . out . println ( c ) ; return ; } } } } import java . util . Scanner ; public class XgtufWpk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xgtufL = sc . nextInt ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) for ( int a = 1 ; a <= 9 ; a ++ ) { if ( i * a == xgtufL ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class MjneYdh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String mjneMtt = sc . next ( ) ; char [ ] wordStr = mjneMtt . 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 YoqNdk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int yoqN = 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 ( yoqN - studyDay >= 0 ) { playable = yoqN - studyDay ; System . out . println ( playable ) ; } else { System . out . println ( " -1 " ) ; } scanner . close ( ) ; } } import java . util . * ; public class JqyamKe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JqyamIl = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] c = new int [ JqyamIl ] ; int [ ] t = new int [ JqyamIl ] ; int cmin = 1001 ; int twithin = 1001 ; for ( int i = 0 ; i < JqyamIl ; 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 wbnhtuFe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WbnhtuWn = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; String ss = s ; ss = ss . substring ( WbnhtuWn , WbnhtuWn + 1 ) ; if ( ss . equals ( " - " ) ) { s = s . replace ( " - " , " " ) ; int slen = s . length ( ) ; if ( slen == WbnhtuWn + b ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class gdlzvSo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GdlzvXxxc = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; if ( C - ( GdlzvXxxc - B ) < 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( C - ( GdlzvXxxc - B ) ) ; } } } import java . util . * ; public class ugflUrv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UgflXl = sc . nextInt ( ) ; int [ ] arr = new int [ UgflXl ] ; for ( int i = 0 ; i < UgflXl ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int [ ] leftSum = new int [ UgflXl ] ; leftSum [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < UgflXl ; i ++ ) leftSum [ i ] = leftSum [ i - 1 ] + arr [ i ] ; int [ ] rightSum = new int [ UgflXl ] ; rightSum [ UgflXl - 1 ] = arr [ UgflXl - 1 ] ; for ( int i = UgflXl - 2 ; i >= 0 ; i -- ) { rightSum [ i ] += rightSum [ i + 1 ] + arr [ i ] ; } int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < UgflXl - 1 ; i ++ ) min = Math . min ( min , Math . abs ( leftSum [ i ] - rightSum [ i + 1 ] ) ) ; System . out . println ( min ) ; } } import java . util . * ; public class PnsnbStz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PnsnbG = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] [ ] a = new int [ PnsnbG ] [ m ] ; int [ ] [ ] b = new int [ m ] [ l ] ; for ( int i = 0 ; i < PnsnbG ; 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 < PnsnbG ; 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 PwjsMuy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int PwjsLh = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == '1' ) { PwjsLh += 1 ; } } System . out . println ( PwjsLh ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class PmtBws { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] parts = br . readLine ( ) . split ( " " ) ; long pmtAmrs = 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 VjkpzCcj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VjkpzNee = sc . nextInt ( ) ; int [ ] x = new int [ VjkpzNee ] ; for ( int i = 0 ; i < VjkpzNee ; i ++ ) x [ i ] = sc . nextInt ( ) ; Arrays . sort ( x ) ; int alice = 0 ; int bob = 0 ; if ( VjkpzNee % 2 == 0 ) { for ( int i = VjkpzNee - 1 ; i >= 0 ; i -= 2 ) { alice += x [ i ] ; bob += x [ i - 1 ] ; } } if ( VjkpzNee % 2 != 0 ) { if ( VjkpzNee == 1 ) alice += x [ 0 ] ; else { for ( int i = 0 ; i < VjkpzNee ; i += 2 ) alice += x [ i ] ; for ( int i = 1 ; i < VjkpzNee ; i += 2 ) bob += x [ i ] ; } } System . out . println ( alice - bob ) ; } } import java . util . * ; public class LvibdHnr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LvibdZdq = 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 <= LvibdZdq ; ++ i ) { if ( LvibdZdq % 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 NmyyjtThra { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int nmyyjtYpn = s . nextInt ( ) ; int [ ] arr = new int [ nmyyjtYpn ] ; for ( int i = 0 ; i < nmyyjtYpn ; i ++ ) { arr [ i ] = s . nextInt ( ) ; } long [ ] dp = new long [ nmyyjtYpn ] ; dp [ 0 ] = 0 ; for ( int i = 1 ; i < nmyyjtYpn ; 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 [ nmyyjtYpn - 1 ] ) ; } } import java . util . * ; class equOt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long EquCusz = sc . nextLong ( ) ; double B = sc . nextDouble ( ) ; long ans = 0 ; ans = EquCusz * ( Math . round ( B * 100 ) ) / 100 ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class qlomlDo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QlomlKra = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int count = 0 ; while ( QlomlKra != 0 || x != 0 ) { for ( int i = 1 ; i <= QlomlKra ; i ++ ) { for ( int j = i + 1 ; j <= QlomlKra ; j ++ ) { for ( int k = j + 1 ; k <= QlomlKra ; k ++ ) { if ( i + j + k == x ) { count ++ ; } } } } System . out . println ( count ) ; QlomlKra = scan . nextInt ( ) ; x = scan . nextInt ( ) ; count = 0 ; } } } import java . util . * ; public class TtsZsv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] a = s . toCharArray ( ) ; for ( int TtsVmo = a . length - 1 ; TtsVmo >= 0 ; TtsVmo -- ) System . out . print ( a [ TtsVmo ] ) ; System . out . println ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; class swemcbKk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String name ; int SwemcbMxsq ; 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 YbblEy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] n = sc . nextLine ( ) . toCharArray ( ) ; int ybblX = 0 ; for ( char c : n ) { ybblX += Character . getNumericValue ( c ) ; } if ( ybblX % 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 yudegeGnm { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int YudegeNne = 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 BglAxpl { public static void main ( String [ ] args ) throws IOException { int BglK = 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 ) BglK = Integer . parseInt ( current ) ; if ( i == 1 ) b = Integer . parseInt ( current ) ; if ( i == 2 ) c = Integer . parseInt ( current ) ; i ++ ; } if ( BglK < 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 JnslMd { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int jnslKfsx = s . nextInt ( ) ; int numn = s . nextInt ( ) ; if ( numn == 0 ) { System . out . println ( jnslKfsx ) ; 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 ( jnslKfsx ) ) { ans = jnslKfsx ; flg_con = false ; } int count = 0 ; while ( flg_con ) { count ++ ; int mnx = jnslKfsx - count ; int plx = jnslKfsx + 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 mzvXmf { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MzvKkkqg = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = 0 ; if ( MzvKkkqg % 2 == 1 ) { count ++ ; } char [ ] work = new char [ s . length ( ) ] ; for ( int i = 0 ; i < MzvKkkqg ; i ++ ) { work [ i ] = s . charAt ( i ) ; } for ( int i = 0 ; i < MzvKkkqg / 2 ; i ++ ) { if ( work [ i ] == work [ i + MzvKkkqg / 2 ] ) { } else { count ++ ; } } if ( count == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class WxiVln { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wxiL = 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 < wxiL + 1 ; k ++ ) { int W = Z - 500 * k ; if ( W == 0 ) { cnt ++ ; continue ; } } } } System . out . println ( cnt ) ; } } import java . util . * ; public class QnojFign { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qnojVbvi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ 101 ] ; for ( int i = 1 ; i <= 100 ; i ++ ) { if ( ( qnojVbvi % 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 OeegPmsth { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int OeegS = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { OeegS += str . charAt ( i ) - '0' ; } System . out . println ( Integer . parseInt ( str ) % OeegS == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class mfmTsk { 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 MfmKaq = 0 ; MfmKaq < str . length ; MfmKaq ++ ) a [ MfmKaq ] = Integer . parseInt ( str [ MfmKaq ] ) ; 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 kbyeMf { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] nums = br . readLine ( ) . split ( " " ) ; br . close ( ) ; int KbyeSjv = Integer . parseInt ( nums [ 0 ] ) ; int b = Integer . parseInt ( nums [ 1 ] ) ; if ( KbyeSjv > 9 || b > 9 ) System . out . println ( - 1 ) ; else System . out . println ( KbyeSjv * b ) ; } } import java . util . * ; class vydcK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VydcSi = sc . nextInt ( ) ; int [ ] T = new int [ VydcSi + 1 ] ; int [ ] X = new int [ VydcSi + 1 ] ; int [ ] Y = new int [ VydcSi + 1 ] ; T [ 0 ] = X [ 0 ] = Y [ 0 ] = 0 ; boolean yes = true ; for ( int i = 1 ; i <= VydcSi ; 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 QsyhPjr { 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 QsyhS = true ; int size = sc . nextInt ( ) ; if ( size > 100 ) { QsyhS = 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 ) { QsyhS = true ; } else { QsyhS = false ; break ; } } if ( ! slist . contains ( word ) ) { if ( QsyhS ) { slist . add ( word ) ; beforeWord = word ; } } else { QsyhS = false ; break ; } } if ( QsyhS ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class HfnVupa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int hfnSdvt = Integer . parseInt ( sc . next ( ) ) ; int W = Integer . parseInt ( sc . next ( ) ) ; if ( hfnSdvt == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < hfnSdvt ; i ++ ) { if ( i == 0 || i == hfnSdvt - 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 GdcmgAwfq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gdcmgSxrd = sc . nextInt ( ) ; int ans = gdcmgSxrd + gdcmgSxrd * gdcmgSxrd + ( int ) Math . pow ( gdcmgSxrd , 3 ) ; System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; import java . math . BigInteger ; class DuklKcnz { 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 MigHgk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MigTxw = Integer . parseInt ( sc . nextLine ( ) ) ; int result = 0 ; for ( int i = 0 ; i < MigTxw ; 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 SzmtEbin { 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 szmtPswl = 0 ; int b = 0 ; for ( int i = 0 ; i < inputArray . length ; i ++ ) { if ( inputArray [ i ] . equals ( " + " ) ) { szmtPswl = stack . pop ( ) ; b = stack . pop ( ) ; stack . add ( b + szmtPswl ) ; continue ; } if ( inputArray [ i ] . equals ( " - " ) ) { szmtPswl = stack . pop ( ) ; b = stack . pop ( ) ; stack . add ( b - szmtPswl ) ; continue ; } if ( inputArray [ i ] . equals ( " * " ) ) { szmtPswl = stack . pop ( ) ; b = stack . pop ( ) ; stack . add ( b * szmtPswl ) ; continue ; } stack . push ( Integer . parseInt ( inputArray [ i ] ) ) ; } System . out . println ( stack . pop ( ) ) ; } } import java . util . Arrays ; import java . util . Scanner ; class AcxWlt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int acxDvq = sc . nextInt ( ) ; long [ ] A = new long [ acxDvq ] ; for ( long i = 0L ; i < acxDvq ; i ++ ) { long t = sc . nextLong ( ) * 100000000L + ( i + 1L ) ; A [ ( int ) i ] = t ; } Arrays . sort ( A ) ; for ( int i = 0 ; i < acxDvq - 1 ; i ++ ) { System . out . print ( A [ i ] % 100000000 + " " ) ; } System . out . println ( A [ acxDvq - 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 YpmztAzeasx { public static int [ ] sorted ( int [ ] inputs ) { int [ ] res = Arrays . copyOf ( inputs , inputs . length ) ; for ( int YpmztT = 0 ; YpmztT < res . length ; YpmztT ++ ) { for ( int j = 1 ; j < res . length - YpmztT ; j ++ ) { if ( res [ j - 1 ] > res [ j ] ) { int tmp = res [ j - 1 ] ; res [ j - 1 ] = res [ j ] ; res [ j ] = tmp ; } } } return res ; } } public class YpmztAzeasx { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] inputs = new int [ 3 ] ; int YpmztT = 0 ; while ( scan . hasNext ( ) ) { inputs [ YpmztT ] = scan . nextInt ( ) ; YpmztT ++ ; } 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 IzifoqNqh { public static void main ( String [ ] args ) throws IOException { int izifoqXd = 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 ) izifoqXd = Integer . parseInt ( current ) ; if ( i == 1 ) b = Integer . parseInt ( current ) ; if ( i == 2 ) c = Integer . parseInt ( current ) ; i ++ ; } if ( izifoqXd > c ) { tmp = izifoqXd ; izifoqXd = c ; c = tmp ; } if ( izifoqXd > b ) { tmp = izifoqXd ; izifoqXd = b ; b = tmp ; } if ( b > c ) { tmp = b ; b = c ; c = tmp ; } System . out . println ( izifoqXd + " " + b + " " + c ) ; } } import java . util . * ; public class OeqyqmWizp { 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 oeqyqmWl = a . charAt ( 0 ) ; a . deleteCharAt ( 0 ) ; Main . nextTurn ( oeqyqmWl ) ; } public static void nextTurn ( char card ) { if ( card == 'a' ) { if ( a . length ( ) == 0 ) { System . out . println ( " A " ) ; return ; } char oeqyqmWl = a . charAt ( 0 ) ; a . deleteCharAt ( 0 ) ; Main . nextTurn ( oeqyqmWl ) ; } else if ( card == 'b' ) { if ( b . length ( ) == 0 ) { System . out . println ( " B " ) ; return ; } char oeqyqmWl = b . charAt ( 0 ) ; b . deleteCharAt ( 0 ) ; Main . nextTurn ( oeqyqmWl ) ; } else if ( card == 'c' ) { if ( c . length ( ) == 0 ) { System . out . println ( " C " ) ; return ; } char oeqyqmWl = c . charAt ( 0 ) ; c . deleteCharAt ( 0 ) ; Main . nextTurn ( oeqyqmWl ) ; } } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class bkedeXh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BkedeIlvnc = Integer . parseInt ( sc . nextLine ( ) ) ; Map < String , Long > m = new HashMap < > ( ) ; for ( int i = 0 ; i < BkedeIlvnc ; 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 FylWh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fylAhk = sc . nextInt ( ) ; System . out . println ( ( 10000 - fylAhk ) % 1000 ) ; sc . close ( ) ; } } import java . util . * ; public class CtahVirbi { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int CtahYg = sc . nextInt ( ) ; long A = ( long ) ( Math . pow ( 10 , 18 ) ) ; long [ ] B = new long [ CtahYg ] ; boolean chk_0 = false ; for ( int i = 0 ; i < CtahYg ; 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 PywWsjv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pywQaxm = sc . nextInt ( ) ; int [ ] [ ] t = new int [ pywQaxm ] [ 3 ] ; for ( int i = 0 ; i < pywQaxm ; 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 OaouTy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oaouYwoy = Integer . parseInt ( sc . next ( ) ) ; Integer [ ] d1 = new Integer [ oaouYwoy ] ; Integer [ ] d2 = new Integer [ oaouYwoy ] ; for ( int i = 0 ; i < oaouYwoy ; 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 < oaouYwoy ; 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 TsvLkyjh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int TsvNx = scanner . nextInt ( ) ; String s = scanner . next ( ) ; System . out . println ( ( TsvNx - s . replaceAll ( " ABC " , " " ) . length ( ) ) / 3 ) ; } } import java . util . * ; import java . util . Map . Entry ; import java . util . stream . Collectors ; public class dgzeqPjr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DgzeqEanio = sc . nextInt ( ) ; String [ ] S = new String [ DgzeqEanio ] ; for ( int i = 0 ; i < DgzeqEanio ; 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 TqximYnfd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TqximN = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = 0 ; int [ ] d = new int [ TqximN ] ; for ( int i = 0 ; i < TqximN ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < TqximN ; i ++ ) { if ( d [ i ] >= b ) { c ++ ; } } System . out . println ( c ) ; } } import java . util . * ; import java . io . * ; public class molpkTh { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; long MolpkOyqzs = sc . nextLong ( ) ; long m = sc . nextLong ( ) ; if ( MolpkOyqzs > m ) System . out . println ( MolpkOyqzs * m / gcd ( MolpkOyqzs , m ) ) ; else System . out . println ( MolpkOyqzs * m / gcd ( m , MolpkOyqzs ) ) ; } 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 IeuntGbt { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { long ieuntZth = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; long c = gcd ( ieuntZth , b ) ; long d = ieuntZth * b / c ; System . out . println ( c + " " + d ) ; } sc . close ( ) ; } public long gcd ( long ieuntZth , long b ) { if ( b == 0 ) { return ieuntZth ; } else { return gcd ( b , ieuntZth % b ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class ZamzkLzlb { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int zamzkCpc ; int result ; String readLine = br . readLine ( ) ; zamzkCpc = Integer . parseInt ( readLine ) ; result = zamzkCpc * zamzkCpc * zamzkCpc ; System . out . println ( result ) ; } } import java . util . Scanner ; public class JbhvjYg { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int JbhvjEr = in . nextInt ( ) ; int [ ] order = new int [ JbhvjEr + 1 ] ; for ( int i = 1 ; i <= JbhvjEr ; i ++ ) { order [ in . nextInt ( ) ] = i ; } for ( int i = 1 ; i <= JbhvjEr ; i ++ ) { System . out . print ( order [ i ] + " " ) ; } in . close ( ) ; } } import java . util . * ; class CydtpdVi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cydtpdUiz = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] a = new int [ cydtpdUiz ] ; for ( int i = 0 ; i < cydtpdUiz ; 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 YnxsLiv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s , t ; int YnxsOm , b ; String u ; s = scan . next ( ) ; t = scan . next ( ) ; YnxsOm = scan . nextInt ( ) ; b = scan . nextInt ( ) ; u = scan . next ( ) ; if ( u . equals ( s ) ) YnxsOm -= 1 ; else b -= 1 ; System . out . printf ( YnxsOm + " " + b ) ; } } import java . util . * ; class sohxedUbe { public static void main ( String [ ] g ) { Scanner S = new Scanner ( System . in ) ; for ( int SohxedRse = S . nextInt ( ) , j , x , y , z , a [ ] = new int [ 3 ] ; SohxedRse -- > 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 DsqkKliq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dsqkMx = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; ArrayList < Integer > aList = new ArrayList < Integer > ( dsqkMx ) ; ArrayList < Integer > bList = new ArrayList < Integer > ( B ) ; for ( int i = 1 ; i <= dsqkMx ; i ++ ) { if ( dsqkMx % 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 VfukIlf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long vfukC = sc . nextInt ( ) ; long h = sc . nextInt ( ) ; long x = sc . nextInt ( ) ; long y = sc . nextInt ( ) ; long area = vfukC * h ; int multi ; if ( vfukC / 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 MznmkbAl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; String ans = " " ; String x = " 1 " ; for ( int mznmkbFxd = 0 ; mznmkbFxd < 3 ; mznmkbFxd ++ ) { if ( n . charAt ( mznmkbFxd ) == x . charAt ( 0 ) ) { ans += " 9 " ; } else { ans += " 1 " ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class FvbFon { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String x = sc . next ( ) ; int fvbAitk = 0 ; for ( int i = 0 ; i < x . length ( ) ; i ++ ) { fvbAitk += Character . getNumericValue ( x . charAt ( i ) ) ; } if ( fvbAitk % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . * ; class FnzviNz { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int FnzviIn = Integer . parseInt ( buf . readLine ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; int num = 0 ; for ( int j = 3 ; j <= FnzviIn ; 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 LtncvWw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ltncvMenx = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int max = ltncvMenx + b ; if ( max < ltncvMenx - b ) { max = ltncvMenx - b ; } if ( max < ltncvMenx * b ) { max = ltncvMenx * b ; } System . out . println ( max ) ; } } import java . io . * ; class swvdDxf { public static void main ( String [ ] arg ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String keyword = br . readLine ( ) ; int SwvdHb = 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 ) ) { SwvdHb ++ ; } } } System . out . println ( SwvdHb ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; public class NfoxfIdaq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NfoxfRq = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ NfoxfRq + 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 <= NfoxfRq ; i ++ ) { if ( arr [ i ] == 0 ) count ++ ; } count -- ; System . out . println ( count ) ; } } import java . util . Scanner ; public class osqqrXp { private static final Scanner SC = new Scanner ( System . in ) ; private static final int OsqqrPc = SC . nextInt ( ) ; private static final int [ ] VALUE = load ( SC ) ; private static int [ ] load ( Scanner sc ) { int [ ] value = new int [ OsqqrPc ] ; for ( int i = 0 ; i < OsqqrPc ; 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 prykfuY { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String a = scanner . next ( ) ; String b = scanner . next ( ) ; int PrykfuKw = Math . min ( a . PrykfuKw ( ) , b . PrykfuKw ( ) ) ; int pos = 0 ; while ( pos < PrykfuKw ) { if ( 0 != ( a . charAt ( pos ) ^ b . charAt ( pos ) ) ) { break ; } pos ++ ; } if ( a . substring ( pos ) . PrykfuKw ( ) == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class TbcrqTlvm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tbcrqLs = scan . nextInt ( ) ; int sum = tbcrqLs / 1000 ; if ( tbcrqLs % 1000 == 0 ) { System . out . println ( 0 ) ; } else { sum += 1 ; int goukei = ( 1000 * sum ) - tbcrqLs ; System . out . println ( goukei ) ; } } } import java . util . Scanner ; public class IppUo { 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 IppHh = 0 ; int cIndex = 0 ; for ( int i = 2 ; i < s . length ( ) - 1 ; i ++ ) { char c = s . charAt ( i ) ; if ( c == 'C' ) { IppHh ++ ; cIndex = i ; } } if ( IppHh != 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 YocgGy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yocgJz = sc . nextInt ( ) ; int [ ] arrayOishi = new int [ yocgJz ] ; for ( int i = 0 ; i < arrayOishi . length ; i ++ ) { arrayOishi [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int j = 0 ; j < yocgJz ; j ++ ) { for ( int k = j + 1 ; k < yocgJz ; k ++ ) { result += arrayOishi [ j ] * arrayOishi [ k ] ; } } System . out . println ( result ) ; sc . close ( ) ; } } import java . io . IOException ; import java . util . Scanner ; public class SuaYe { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int suaZo = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int [ ] [ ] a = new int [ suaZo ] [ y ] ; int [ ] [ ] b = new int [ y ] [ z ] ; for ( int i = 0 ; i < suaZo ; 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 < suaZo ; 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 EcsBzss { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int [ ] cnt = new int [ 26 ] ; int ecsJq = 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 fadUs { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int FadYdel = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] a = new int [ FadYdel ] ; for ( int i = 0 ; i < FadYdel ; 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 AfqwJfc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AfqwVul = sc . nextInt ( ) ; int d = AfqwVul % 10 ; int c = AfqwVul / 10 % 10 ; int b = AfqwVul / 10 / 10 % 10 ; int a = AfqwVul / 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 PnwvRkqd { public static void main ( String [ ] args ) { Scanner scan ; int pnwvEpeh ; int B ; int C ; int K ; int Aa ; int Bb ; int Cc ; scan = new Scanner ( System . in ) ; pnwvEpeh = scan . nextInt ( ) ; B = scan . nextInt ( ) ; C = scan . nextInt ( ) ; K = scan . nextInt ( ) ; if ( K >= pnwvEpeh ) { Aa = pnwvEpeh ; 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 JxlvddQo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( scan . hasNext ( ) ) { int JxlvddAdo = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; while ( JxlvddAdo != 0 && y != 0 ) { int t = y ; y = JxlvddAdo ; JxlvddAdo = t % JxlvddAdo ; } System . out . println ( ( JxlvddAdo == 0 ) ? y : JxlvddAdo ) ; } } } import java . util . Scanner ; public class FobqtIe { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int fobqtBbt = sc . nextInt ( ) ; int min = 1000000000 ; int max = - 1000000000 ; for ( int i = 0 ; i < fobqtBbt ; 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 QvuHlqf { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int qvuT = Integer . parseInt ( br . readLine ( ) ) ; int i ; String [ ] su = br . readLine ( ) . split ( " " ) ; StringBuilder outArray = new StringBuilder ( ) ; for ( i = qvuT - 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 SqjyeyDntz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int sqjyeyV = in . nextInt ( ) ; long [ ] a = new long [ sqjyeyV ] ; for ( int i = 0 ; i < sqjyeyV ; i ++ ) a [ i ] = in . nextLong ( ) ; long curr = a [ 0 ] ; long total = 0 ; for ( int i = 1 ; i < sqjyeyV ; i ++ ) { if ( a [ i ] >= curr ) curr = a [ i ] ; else { total += ( curr - a [ i ] ) ; } } System . out . println ( total ) ; } } class BtjfnIcd { public static void main ( String [ ] g ) throws Exception { double btjfnIol = 1e5 ; int n = 0 , i ; for ( ; ( i = System . in . read ( ) ) > 32 ; n = n * 10 + i - 48 ) ; for ( i = 1000 ; n -- > 0 ; btjfnIol += btjfnIol % i > 0 ? i - btjfnIol % i : 0 ) btjfnIol *= 1.05 ; System . out . println ( ( int ) btjfnIol ) ; } } import java . util . * ; public class GwquiJkrsc { static final String ascii = " ABCDEFGHIJKLMNOPQRSTUVWXYZ " ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GwquiF = sc . nextInt ( ) ; String str = sc . next ( ) ; if ( GwquiF == 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 + GwquiF ; if ( ri >= ascii . length ( ) ) { ri = ri - ascii . length ( ) ; } replaced = replaced + String . valueOf ( ascii . charAt ( ri ) ) ; } System . out . println ( replaced ) ; } } } import java . util . * ; public class rkngQxj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RkngXbm = sc . nextInt ( ) ; int [ ] a = new int [ RkngXbm + 1 ] ; int [ ] b = new int [ RkngXbm + 1 ] ; int [ ] c = new int [ RkngXbm ] ; String dm = " " ; for ( int i = 1 ; i <= RkngXbm ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= RkngXbm ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < RkngXbm ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int i = 1 ; i <= RkngXbm ; i ++ ) { ans += b [ a [ i ] ] ; if ( i < RkngXbm && a [ i + 1 ] == a [ i ] + 1 ) ans += c [ a [ i ] ] ; } System . out . println ( ans ) ; } } import java . io . * ; class UtrBr { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = br . readLine ( ) ; String [ ] T ; int utrNwhy = 0 ; while ( true ) { T = br . readLine ( ) . split ( " " ) ; if ( T [ 0 ] . equals ( " END_OF_TEXT " ) ) break ; for ( String str : T ) { if ( str . equalsIgnoreCase ( W ) ) utrNwhy ++ ; } } System . out . println ( utrNwhy ) ; } } import java . util . * ; class cnfjkiVwr { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int CnfjkiOhn = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ CnfjkiOhn ] [ m ] ; for ( int i = 0 ; i < CnfjkiOhn ; 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 < CnfjkiOhn ; 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 tugeDet { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long TugeOk = 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 ( TugeOk * c , TugeOk * 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 NifhEz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nifhG = Integer . parseInt ( sc . next ( ) ) ; int [ ] ary = new int [ nifhG ] ; for ( int i = 0 ; i < nifhG ; i ++ ) { ary [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int ans = 0 ; for ( int i = 0 ; i < nifhG ; i ++ ) { for ( int j = i + 1 ; j < nifhG ; j ++ ) { ans += ary [ i ] * ary [ j ] ; } } System . out . println ( ans ) ; } } import java . util . * ; public class UasntLb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uasntYl = sc . nextInt ( ) ; int sum = 0 ; sum = uasntYl / 2 ; if ( uasntYl % 2 == 0 ) { System . out . print ( uasntYl / 2 ) ; } else { sum = uasntYl / 2 ; System . out . print ( sum + 1 ) ; } } } import java . util . * ; public class OuajkwCae { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ouajkwYedp = sc . nextInt ( ) ; int count = 0 ; int tens = ( ( ouajkwYedp / 10 ) - ( ( int ) ( ouajkwYedp / 100 ) ) * 10 ) * 10 ; int ones = ouajkwYedp % 10 ; if ( ( ouajkwYedp / 100 ) <= 12 && ( ouajkwYedp / 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 QwzwdMh { public static void main ( String [ ] args ) throws NumberFormatException , IOException { Scanner scan = new Scanner ( System . in ) ; int qwzwdAvh = 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 < qwzwdAvh ; 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 < qwzwdAvh ; 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 ohpX { static final long OhpRvdw = 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 ] ) % OhpRvdw ; } System . out . println ( dp [ n ] ) ; sc . close ( ) ; } } import java . util . Scanner ; import java . util . InputMismatchException ; class JwtsAy { public static void main ( String [ ] args ) { int JwtsB = 0 , y = 0 , z = 0 ; int sum = 0 ; try { Scanner scanner = new Scanner ( System . in ) ; JwtsB = scanner . nextInt ( ) ; y = scanner . nextInt ( ) ; z = scanner . nextInt ( ) ; scanner . close ( ) ; } catch ( InputMismatchException e ) { System . out . println ( " error " ) ; } for ( int i = JwtsB ; i < z + 1 ; i = i + JwtsB ) { sum = sum + y ; } System . out . println ( sum ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class KaqjcPvxbcd { public static void main ( String [ ] args ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; try { String input = br . readLine ( ) ; int KaqjcOj = Integer . parseInt ( input ) ; int i , x ; String ret = " " ; for ( i = 2 ; i <= KaqjcOj ; 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 gcioaVyy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long GcioaTcymz = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long t1 = ( GcioaTcymz / ( a + b ) ) * a ; long t2 = GcioaTcymz % ( a + b ) > a ? a : GcioaTcymz % ( a + b ) ; sc . close ( ) ; System . out . println ( t1 + t2 ) ; } } import java . util . Scanner ; public class RfkvfyMoru { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RfkvfyW = sc . nextInt ( ) ; int min = sc . nextInt ( ) ; int max = sc . nextInt ( ) ; int [ ] a = new int [ RfkvfyW ] ; int sum = 0 ; for ( int i = 0 ; i < RfkvfyW ; 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 DiznrGz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long diznrOis = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( diznrOis >= k ) { System . out . println ( ( diznrOis - k ) + " " + b ) ; } else if ( b >= k - diznrOis ) { System . out . println ( " 0 " + " " + ( b - ( k - diznrOis ) ) ) ; } else { System . out . println ( " 0 0 " ) ; } } } import java . util . * ; public class ekktrW { static boolean [ ] targetNumbers ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EkktrFlguh = sc . nextInt ( ) ; printPrimeNumbers2 ( 1000000 ) ; for ( int i = EkktrFlguh ; 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 JzzflmAmzx { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int JzzflmIwx = s . nextInt ( ) , B = s . nextInt ( ) , C = s . nextInt ( ) ; int temp = JzzflmIwx ; JzzflmIwx = B ; B = temp ; temp = JzzflmIwx ; JzzflmIwx = C ; C = temp ; System . out . println ( JzzflmIwx + " " + B + " " + C ) ; } } import java . util . Scanner ; public class PhekIpa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int phekGpx = sc . nextInt ( ) ; int [ ] p = new int [ phekGpx ] ; for ( int i = 0 ; i < phekGpx ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } if ( isAsc ( p ) ) { System . out . println ( " YES " ) ; return ; } for ( int i = 0 ; i < phekGpx - 1 ; i ++ ) { for ( int j = i + 1 ; j < phekGpx ; 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 ggltzTj { 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 GgltzMmy = 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 < ( GgltzMmy - 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 WkiyCvx { private void solve ( ) { Scanner in = new Scanner ( System . in ) ; int WkiyPif = in . nextInt ( ) ; int B = in . nextInt ( ) ; System . out . println ( Math . max ( WkiyPif + B , Math . max ( WkiyPif - B , WkiyPif * B ) ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class ZmxUri { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int zmxCdbv = sc . nextInt ( ) ; int [ ] S = new int [ zmxCdbv ] ; for ( int i = 0 ; i < zmxCdbv ; 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 gpkimJ { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int GpkimDliwm = fs . nextInt ( ) ; if ( GpkimDliwm == 0 ) { System . out . println ( 1 ) ; } else if ( GpkimDliwm == 1 ) { System . out . println ( 0 ) ; } else { } } static class gpkimJ { 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 GpkimDliwm ) { int [ ] a = new int [ GpkimDliwm ] ; for ( int i = 0 ; i < GpkimDliwm ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . util . * ; public class wbcbwfEa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WbcbwfYtfd = sc . nextInt ( ) ; int m = 0 ; int t = 1 ; while ( WbcbwfYtfd > 0 ) { if ( WbcbwfYtfd % 10 == 1 ) { m += 9 * t ; } else if ( WbcbwfYtfd % 10 == 9 ) { m += t ; } else { m += WbcbwfYtfd % 10 * t ; } WbcbwfYtfd /= 10 ; t *= 10 ; } System . out . println ( m ) ; } } import java . util . Scanner ; public class OirtOo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oirtW = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; int count = 0 ; for ( int i = oirtW ; 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 EwqUsfv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EwqAp = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int a , b , c ; a = EwqAp + y ; b = EwqAp - y ; c = EwqAp * 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 lnswuC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LnswuXedm = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < LnswuXedm ; i ++ ) { long l = Long . parseLong ( sc . next ( ) ) ; while ( l % 2 == 0 ) { l /= 2 ; count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class tynE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TynJh = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ TynJh ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < TynJh ; 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 < TynJh ; 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 BapimTbhg { 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 bapimV = Integer . parseInt ( st . nextToken ( ) ) + Integer . parseInt ( st . nextToken ( ) ) ; System . out . println ( ( int ) Math . log10 ( bapimV ) + 1 ) ; s = in . readLine ( ) ; } } catch ( Exception ex ) { System . exit ( 0 ) ; } } } } import java . util . Scanner ; public class MlobaKe { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int mlobaKht = scanner . nextInt ( ) ; int N = scanner . nextInt ( ) ; System . out . print ( ( mlobaKht * ( mlobaKht - 1 ) + N * ( N - 1 ) ) / 2 ) ; } } import java . util . Scanner ; public class DqvbnhEe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String passS = scan . nextLine ( ) ; String passT = scan . nextLine ( ) ; int DqvbnhCxv = passS . length ( ) ; String passTa = passT . substring ( 0 , DqvbnhCxv ) ; if ( passS . equals ( passTa ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class TeinzvQqc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int TeinzvL = 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 HzqGfg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String hzqDgvc = sc . next ( ) ; Map < String , String > map = new HashMap < String , String > ( ) ; map . put ( " ABC " , " ARC " ) ; map . put ( " ARC " , " ABC " ) ; if ( map . containsKey ( hzqDgvc ) ) { System . out . println ( map . get ( hzqDgvc ) ) ; } else { System . out . println ( " もう一度やり直して下さい"); } } } import java . util . Scanner ; class UmrdSt { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String S = scan . next ( ) ; String T = scan . next ( ) ; int UmrdGcw = 0 ; int j = 0 ; int count = 0 ; while ( UmrdGcw < S . length ( ) && j < T . length ( ) ) { if ( S . charAt ( UmrdGcw ) != T . charAt ( j ) ) { count ++ ; } UmrdGcw ++ ; j ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class MdhjfWrmhut { public static int MdhjfOb ; public static int [ ] arr ; public static int [ ] dp ; public static int minCost ( int pos ) { if ( pos >= MdhjfOb - 1 ) return 0 ; if ( dp [ pos ] != - 1 ) return dp [ pos ] ; int onestep = Integer . MAX_VALUE ; int twostep = Integer . MAX_VALUE ; if ( pos + 1 < MdhjfOb ) { onestep = Math . abs ( arr [ pos ] - arr [ pos + 1 ] ) + minCost ( pos + 1 ) ; } if ( pos + 2 < MdhjfOb ) { 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 ) ; MdhjfOb = in . nextInt ( ) ; arr = new int [ MdhjfOb ] ; dp = new int [ MdhjfOb ] ; for ( int i = 0 ; i < MdhjfOb ; i ++ ) arr [ i ] = in . nextInt ( ) ; Arrays . fill ( dp , - 1 ) ; System . out . println ( minCost ( 0 ) ) ; } } import java . util . Scanner ; public class MujtOst { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int mujtLlid = Integer . parseInt ( scanner . nextLine ( ) ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; int [ ] z = new int [ mujtLlid ] ; 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 < mujtLlid ; 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 < mujtLlid ; i ++ ) { System . out . println ( z [ i ] ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class tyixMfa { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int TyixSwd = Integer . parseInt ( br . readLine ( ) ) ; String [ ] line = br . readLine ( ) . split ( " " ) ; int [ ] a = new int [ TyixSwd ] ; for ( int i = 0 ; i < TyixSwd ; i ++ ) { a [ i ] = Integer . parseInt ( line [ i ] ) ; } insertionSort ( a , TyixSwd ) ; } } 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 WnzzouCv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] str = s . split ( " " ) ; int wnzzouBh = str . wnzzouBh ; boolean easiness = true ; for ( int i = 0 ; i < wnzzouBh ; i += 2 ) { if ( str [ i ] . equals ( " L " ) ) { easiness = false ; break ; } } for ( int i = 1 ; i < wnzzouBh ; 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 VvstVa { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int vvstD = scan . nextInt ( ) ; int [ ] x = new int [ vvstD ] ; for ( int i = 0 ; i < vvstD ; 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 < vvstD ; i ++ ) { System . out . println ( x [ i ] ) ; } } } import java . util . * ; public class ImtzSpuavx { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int ImtzH = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; sc . close ( ) ; int ans = 0 ; if ( B <= C || D <= ImtzH ) { } else if ( ( B > C ) && ( ImtzH < C ) ) { ans = B <= D ? B - C : D - C ; } else { ans = D <= B ? D - ImtzH : B - ImtzH ; } System . out . println ( ans ) ; } } import java . util . * ; public class PjkxmgPdpbgl { public static void main ( String [ ] args ) { exec ( ) ; } static void exec ( ) { Scanner sc = new Scanner ( System . in ) ; long PjkxmgG = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; int ans = 0 ; for ( int i = 0 ; i < PjkxmgG ; 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 GqoEb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GqoN = sc . nextInt ( ) ; int [ ] d = new int [ GqoN ] ; for ( int i = 0 ; i < GqoN ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( d ) ; int [ ] a = new int [ GqoN / 2 ] ; int [ ] b = new int [ GqoN / 2 ] ; for ( int i = 0 ; i < GqoN / 2 ; i ++ ) { a [ i ] = d [ i ] ; } int j = 0 ; for ( int i = GqoN / 2 ; i < GqoN ; i ++ ) { b [ j ] = d [ i ] ; j ++ ; } int count = 0 ; if ( a [ GqoN / 2 - 1 ] < b [ 0 ] ) { count = b [ 0 ] - a [ GqoN / 2 - 1 ] ; } System . out . println ( count ) ; } } import java . util . * ; class OdaNr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int odaGj = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= odaGj ; i ++ ) { for ( int j = 1 ; j <= odaGj ; 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 <= odaGj ; 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 BooUggtz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int BooH = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int [ ] [ ] root = new int [ BooH ] [ BooH ] ; 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 < BooH ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < BooH ; j ++ ) { sum += root [ i ] [ j ] ; } System . out . println ( sum ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class UyntClrk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] abc = { sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) } ; int UyntZl = sc . nextInt ( ) ; Arrays . sort ( abc ) ; for ( int i = 0 ; i < UyntZl ; 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 OsquTeo { 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 osquXgeg = 0 ; osquXgeg < 4 ; osquXgeg ++ ) { String keyword = keywords [ osquXgeg ] ; String ts = s . replaceAll ( keyword , " " ) ; if ( s . length ( ) > ts . length ( ) ) queue . add ( ts ) ; } } System . out . println ( " NO " ) ; } } import java . util . Scanner ; public class SnwrjuSqfj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int snwrjuF = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int j = 0 ; while ( snwrjuF <= y ) { if ( z % snwrjuF == 0 ) { j ++ ; } snwrjuF ++ ; } System . out . println ( j ) ; sc . close ( ) ; } } import java . util . Scanner ; class TbrrkdVyg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tbrrkdOp = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int d = tbrrkdOp / b ; int r = tbrrkdOp % b ; double f = ( ( double ) tbrrkdOp / ( double ) b ) ; System . out . print ( d + " " + r + " " ) ; System . out . printf ( " %.5f " , f ) ; } } import java . util . * ; import java . lang . * ; public class UseaTbge { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int UseaRqx = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int [ ] ans = new int [ UseaRqx ] ; for ( int i = 0 ; i < UseaRqx ; 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 IjyplhHhfnqe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IjyplhR = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= IjyplhR ; i ++ ) { double p = 1 ; int tmp = i ; while ( tmp < k ) { p *= 0.5 ; tmp *= 2 ; } ans += p / IjyplhR ; } System . out . println ( ans ) ; } } import java . util . * ; public class MrfDd { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String mrfWl = stdIn . next ( ) ; if ( mrfWl . equals ( " Sunny " ) ) { System . out . println ( " Cloudy " ) ; } if ( mrfWl . equals ( " Cloudy " ) ) { System . out . println ( " Rainy " ) ; } if ( mrfWl . equals ( " Rainy " ) ) { System . out . println ( " Sunny " ) ; } } } import java . util . * ; public class liqtD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LiqtYrny = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( LiqtYrny % 2 == 0 ) { for ( int i = 0 ; i < LiqtYrny / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( LiqtYrny / 2 + i ) ) { System . out . println ( " No " ) ; break ; } else if ( i < LiqtYrny / 2 - 1 ) { continue ; } System . out . println ( " Yes " ) ; } } else if ( LiqtYrny % 2 != 0 ) { System . out . println ( " No " ) ; } } } import java . util . * ; public class AldjgnHhuhvj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AldjgnL = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int res = 0 ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < AldjgnL ; 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 wrfmuzTu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String WrfmuzShdfv = scan . nextLine ( ) ; String weather = " Sunny " ; if ( " Sunny " . equals ( WrfmuzShdfv ) ) { weather = " Cloudy " ; } else if ( " Cloudy " . equals ( WrfmuzShdfv ) ) { weather = " Rainy " ; } System . out . println ( weather ) ; } } import java . util . Scanner ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Iterator ; public class ooemmaS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < String > list = new ArrayList < > ( ) ; ArrayList < String > anslist = new ArrayList < > ( ) ; int OoemmaZa = sc . nextInt ( ) ; String [ ] a = new String [ OoemmaZa ] ; int max = 1 ; int count = 1 ; for ( int i = 0 ; i < OoemmaZa ; i ++ ) { a [ i ] = sc . next ( ) ; list . add ( a [ i ] ) ; } Collections . sort ( list ) ; for ( int j = 1 ; j < OoemmaZa ; j ++ ) { if ( list . get ( j - 1 ) . equals ( list . get ( j ) ) ) { count ++ ; if ( j == OoemmaZa - 1 ) max = Math . max ( max , count ) ; } else { max = Math . max ( max , count ) ; count = 1 ; } } for ( int x = 0 ; x < OoemmaZa - 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 kaxqtKz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KaxqtLnx = sc . nextInt ( ) ; int [ ] sum1 = new int [ KaxqtLnx + 1 ] ; int [ ] sum2 = new int [ KaxqtLnx + 1 ] ; for ( int i = 1 ; i <= KaxqtLnx ; i ++ ) { sum1 [ i ] = sum1 [ i - 1 ] + sc . nextInt ( ) ; } for ( int i = 1 ; i <= KaxqtLnx ; i ++ ) { sum2 [ i ] = sum2 [ i - 1 ] + sc . nextInt ( ) ; } int max = 0 ; for ( int i = 1 ; i <= KaxqtLnx ; i ++ ) { max = Math . max ( max , sum1 [ i ] + sum2 [ KaxqtLnx ] - sum2 [ i - 1 ] ) ; } System . out . println ( max ) ; } } import java . util . Scanner ; public class QwliOvi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QwliReb = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( ( QwliReb <= 9 ) && ( b <= 9 ) ? QwliReb * b : " -1 " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class ujqF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UjqJhmzu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . printf ( " %d %d %.10f " , UjqJhmzu / b , UjqJhmzu % b , ( double ) UjqJhmzu / b ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class MzdqImmkj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] [ ] arr = new int [ 3 ] [ ] ; for ( int MzdqJhq = 0 ; MzdqJhq < 3 ; MzdqJhq ++ ) arr [ MzdqJhq ] = new int [ 3 ] ; for ( int MzdqJhq = 0 ; MzdqJhq < 3 ; MzdqJhq ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) arr [ MzdqJhq ] [ j ] = scan . nextInt ( ) ; } int [ ] diff = new int [ 9 ] ; for ( int MzdqJhq = 0 ; MzdqJhq < 3 ; MzdqJhq ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) diff [ MzdqJhq * 3 + j ] = arr [ MzdqJhq ] [ j ] - arr [ MzdqJhq ] [ ( j + 1 ) % 3 ] ; } for ( int MzdqJhq = 0 ; MzdqJhq < 3 ; MzdqJhq ++ ) { if ( diff [ MzdqJhq ] != diff [ MzdqJhq + 3 ] || diff [ MzdqJhq + 3 ] != diff [ MzdqJhq + 6 ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . HashMap ; import java . util . Scanner ; public class VgrgNa { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int VgrgJhx = sc . nextInt ( ) ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < VgrgJhx ; i ++ ) { map . put ( sc . nextInt ( ) , i + 1 ) ; } for ( int i = 1 ; i <= VgrgJhx ; i ++ ) { if ( i != 1 ) { System . out . print ( " " ) ; } System . out . print ( map . get ( i ) ) ; } sc . close ( ) ; } } import java . util . * ; class BzfwmOtjaq { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int BzfwmIsb = in . nextInt ( ) ; int k = in . nextInt ( ) ; in . nextLine ( ) ; int [ ] N = new int [ BzfwmIsb ] ; 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 < BzfwmIsb ; i ++ ) { if ( N [ i ] == 0 ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class kfcoTxo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KfcoYixyh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; Long [ ] in = new Long [ KfcoYixyh ] ; for ( int i = 0 ; i < KfcoYixyh ; i ++ ) { in [ i ] = sc . nextLong ( ) ; } Arrays . sort ( in ) ; Long c = in [ 0 ] - in [ 0 ] ; for ( int i = 0 ; i < KfcoYixyh - b ; i ++ ) { c += in [ i ] ; } System . out . println ( c ) ; } } import java . util . * ; public class VoitcvYny { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] sp ; int voitcvMd = 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 ( voitcvMd < num ) voitcvMd = num ; num = 0 ; } } if ( voitcvMd < num ) voitcvMd = num ; System . out . println ( voitcvMd ) ; } } import java . util . Scanner ; public class UxvfmwSx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int UxvfmwJ = Integer . parseInt ( scanner . next ( ) ) ; int B = Integer . parseInt ( scanner . next ( ) ) ; scanner . close ( ) ; if ( UxvfmwJ == 1 && B == 2 ) { System . out . println ( " 3 " ) ; } else if ( UxvfmwJ == 1 && B == 3 ) { System . out . println ( " 2 " ) ; } else if ( UxvfmwJ == 2 && B == 1 ) { System . out . println ( " 3 " ) ; } else if ( UxvfmwJ == 2 && B == 3 ) { System . out . println ( " 1 " ) ; } else if ( UxvfmwJ == 3 && B == 1 ) { System . out . println ( " 2 " ) ; } else if ( UxvfmwJ == 3 && B == 2 ) { System . out . println ( " 1 " ) ; } } } import java . util . Scanner ; class AbhawjFgv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int abhawjIom = scan . nextInt ( ) ; int [ ] data = new int [ abhawjIom ] ; int sum = 0 ; for ( int i = 0 ; i < abhawjIom ; i ++ ) { data [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < abhawjIom ; 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 HrybhcGykj { 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 hrybhcOyge = nextInt ( ) ; int [ ] K = new int [ hrybhcOyge ] ; for ( int i = 0 ; i < hrybhcOyge ; i ++ ) { K [ nextInt ( ) - 1 ] = i ; } for ( int i = 0 ; i < hrybhcOyge ; 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 dzglqvRxb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] list = sc . nextLine ( ) . split ( " " , 0 ) ; int DzglqvComn = Integer . parseInt ( list [ 0 ] ) ; int B = Integer . parseInt ( list [ 1 ] ) ; int T = Integer . parseInt ( list [ 2 ] ) ; System . out . println ( B * ( T / DzglqvComn ) ) ; sc . close ( ) ; } } import java . util . * ; public class xtvpdU { 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 DkmuJprm { public static void main ( String [ ] args ) throws Exception { BufferedReader breader = getReader ( ) ; int [ ] ary = getAry ( breader ) ; while ( ary [ 0 ] != 0 || ary [ 1 ] != 0 ) { for ( int dkmuLq = 0 ; dkmuLq < ary [ 0 ] ; dkmuLq ++ ) { 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 dkmuLq = 0 ; dkmuLq < nstr . length ; dkmuLq ++ ) { n [ dkmuLq ] = Integer . valueOf ( nstr [ dkmuLq ] ) ; } return n ; } } import java . util . Scanner ; public class UsqQi { 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 usqUgxj = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int [ ] h = new int [ usqUgxj ] ; for ( int i = 0 ; i < usqUgxj ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } double minDiff = Math . abs ( a - temp ( t , h [ 0 ] ) ) ; int num = 0 ; for ( int i = 1 ; i < usqUgxj ; 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 QpuhqxKio { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int QpuhqxWur = Integer . parseInt ( s . next ( ) ) ; int k = Integer . parseInt ( s . next ( ) ) ; int count = 1 ; for ( int i = 1 ; i < QpuhqxWur ; ) { i = i * k ; if ( QpuhqxWur / i >= 1 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class KqaobSd { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int kqaobOq = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int ans ; if ( K <= kqaobOq ) { ans = K ; } else if ( K <= kqaobOq + B ) { ans = kqaobOq ; } else { ans = kqaobOq - ( K - ( kqaobOq + B ) ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class QruHrkt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qruHudk = sc . nextInt ( ) ; int ac = 0 ; int wa = 0 ; int tle = 0 ; int re = 0 ; for ( int i = 0 ; i < qruHudk + 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 TjpjaBzg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tjpjaXso = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int count = 1 ; while ( true ) { if ( tjpjaXso / ( int ) ( Math . pow ( k , count ) ) == 0 ) break ; count ++ ; } System . out . println ( " " + count ) ; } } import java . util . Scanner ; public class JjpkhkFq { 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 jjpkhkOueq ; int [ ] [ ] D ; Main ( Scanner sc ) { this . sc = sc ; this . jjpkhkOueq = sc . nextInt ( ) ; this . D = new int [ jjpkhkOueq ] [ 2 ] ; for ( int i = 0 ; i < jjpkhkOueq ; 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 < jjpkhkOueq - 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 GqaxMdy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long GqaxTr = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; boolean flag = true ; long d = 0 ; GqaxTr = GqaxTr % k ; d = Math . min ( GqaxTr , Math . abs ( GqaxTr - k ) ) ; System . out . println ( d ) ; } } import java . util . Scanner ; class KziaqpMlt { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int kziaqpDh = scanner . nextInt ( ) ; int numB = scanner . nextInt ( ) ; int numC = scanner . nextInt ( ) ; int ans = 0 ; for ( int val = kziaqpDh ; val <= numB ; val ++ ) { if ( numC % val == 0 ) ans ++ ; } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class XwgMwe { static class XwgMwe { 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 xwgH = scanner . nextInt ( ) ; int [ ] A = new int [ xwgH ] ; for ( int i = 0 ; i < xwgH ; i ++ ) { A [ i ] = scanner . nextInt ( ) ; } int [ ] DP = new int [ xwgH ] ; DP [ 1 ] = Math . abs ( A [ 1 ] - A [ 0 ] ) ; for ( int i = 2 ; i < xwgH ; 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 [ xwgH - 1 ] ) ; } } import java . util . Scanner ; public class NutJzwhky { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long [ ] dd = new long [ 10000 ] ; int NutOo = 9 ; long r = 0 ; long su ; for ( int i = 0 ; NutOo == 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 BppGtn { 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 BppGtn { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int BppS = in . nextInt ( ) ; boolean ret = true ; for ( int i = 0 ; i < BppS ; 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 FtakxNu { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int FtakxA = sc . nextInt ( ) , t = 0 ; while ( FtakxA -- > 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 BnlwfbUh { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int bnlwfbTgqm = scn . nextInt ( ) ; HashSet < Integer > arr = new HashSet < Integer > ( ) ; boolean yes = true ; for ( int i = 0 ; i < bnlwfbTgqm ; 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 YgzocOzjl { 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 ygzocVjgk = 0 ; ygzocVjgk < list . size ( ) - 1 ; ygzocVjgk ++ ) { String s = list . get ( ygzocVjgk ) ; String [ ] ary = s . split ( " " ) ; data [ ygzocVjgk ] [ 0 ] = Integer . parseInt ( ary [ 0 ] ) ; data [ ygzocVjgk ] [ 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 pzfnWpu { public static void main ( String [ ] argv ) { Scanner scan = new Scanner ( System . in ) ; int PzfnUp = scan . nextInt ( ) ; int h = 0 , m = 0 , s = 0 ; while ( true ) { if ( PzfnUp - 3600 >= 0 ) { PzfnUp = PzfnUp - 3600 ; h ++ ; } else if ( PzfnUp - 60 >= 0 ) { PzfnUp = PzfnUp - 60 ; m ++ ; } else { if ( PzfnUp == 0 ) break ; s ++ ; PzfnUp -- ; } } System . out . println ( h + " : " + m + " : " + s ) ; } } import java . util . * ; public class YkuivyBre { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ykuivyZ = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < String > ( ) ; char last = 'X' ; boolean flag = true ; for ( int i = 0 ; i < ykuivyZ ; 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 RalkIrwu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ralkKwk = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int ANS = 0 ; if ( ralkKwk == 0 ) { if ( N != 100 ) { ANS = N ; } else { ANS = N + 1 ; } } else if ( ralkKwk == 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 fvzsWj { 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 FvzsNt = 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 ( FvzsNt > b && FvzsNt > c ) { FvzsNt *= 2 ; } else if ( b > c ) { b *= 2 ; } else { c *= 2 ; } } System . out . println ( FvzsNt + b + c ) ; } } } import java . util . Scanner ; public class EosjyqVuvt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eosjyqXhn = sc . nextInt ( ) ; int [ ] h = new int [ eosjyqXhn ] ; for ( int i = 0 ; i < eosjyqXhn ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < ( eosjyqXhn - 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 eyjlzM { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int EyjlzLrfrx = Integer . parseInt ( br . readLine ( ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int [ ] array = new int [ EyjlzLrfrx ] ; for ( int i = 0 ; i < EyjlzLrfrx ; 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 ZqreveCuq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int ZqreveSyo = Integer . parseInt ( str ) ; int h_point = 0 , t_point = 0 ; for ( int i = 0 ; i < ZqreveSyo ; 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 IicjmkEdcgjk { 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 IicjmkBx = Integer . parseInt ( num [ 0 ] ) ; int w = Integer . parseInt ( num [ 1 ] ) ; if ( IicjmkBx == 0 && w == 0 ) { break ; } for ( int i = 0 ; i < IicjmkBx ; i ++ ) { if ( i == 0 || i == IicjmkBx - 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 ffkvInp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FfkvQcar = 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 ( FfkvQcar > b && FfkvQcar > c ) { answer = FfkvQcar * powk + b + c ; } else if ( b > FfkvQcar && b > c ) { answer = b * powk + FfkvQcar + c ; } else { answer = c * powk + FfkvQcar + b ; } System . out . println ( answer ) ; } } import java . util . Scanner ; class CmaLooy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cmaOvye = scan . nextInt ( ) ; int str2 = scan . nextInt ( ) ; System . out . println ( cmaOvye * str2 + " " + ( cmaOvye * 2 + str2 * 2 ) ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class PlmffOkxw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int plmffInj = sc . nextInt ( ) ; int [ ] s = new int [ plmffInj ] ; for ( int i = 0 ; i < plmffInj ; 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 < plmffInj && 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 SmpQn { public static void main ( String ... args ) { final Scanner sc = new Scanner ( System . in ) ; final int smpKf = sc . nextInt ( ) ; System . out . println ( smpKf * smpKf * smpKf ) ; } } public class SmpQn { 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 LpqwTd { 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 lpqwYsh = 0 ; for ( int si = 0 ; si < s . length ; si ++ ) { if ( c . equals ( s [ si ] ) ) { lpqwYsh = si ; break ; } } System . out . println ( s [ lpqwYsh + 1 ] ) ; sc . close ( ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; class qtyId { static class qtyId { 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 QtyWqxv = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = 0 ; for ( int i = a ; i <= b ; i ++ ) { if ( i % QtyWqxv == 0 ) { sum = 1 ; } } if ( sum == 1 ) { System . out . println ( " OK " ) ; } else { System . out . println ( " NG " ) ; } } } import java . util . Scanner ; public class CjpWhp { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long cjpP = s . nextLong ( ) ; long a = s . nextLong ( ) ; long b = s . nextLong ( ) ; long set = cjpP / ( a + b ) ; long rem = cjpP % ( 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 OshZoa { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int OshO = scan . nextInt ( ) ; BigDecimal [ ] an = new BigDecimal [ OshO ] ; for ( int i = 0 ; i < OshO ; 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 nkbDui { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int NkbJmjd = 0 ; NkbJmjd < 3 ; NkbJmjd ++ ) a [ NkbJmjd ] = sc . nextInt ( ) ; int [ ] b = new int [ 3 ] ; for ( int NkbJmjd = 0 ; NkbJmjd < 3 ; NkbJmjd ++ ) { b [ NkbJmjd ] = a [ ( NkbJmjd + 2 ) % 3 ] ; System . out . print ( b [ NkbJmjd ] + " " ) ; } } } import java . util . * ; public class ftyqgTz { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int FtyqgQas = sc . nextInt ( ) ; int answer = FtyqgQas + FtyqgQas * FtyqgQas + FtyqgQas * FtyqgQas * FtyqgQas ; System . out . println ( answer ) ; } } import java . util . Scanner ; class DfybRm { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String key = in . next ( ) . toLowerCase ( ) ; int DfybYuk = 0 ; while ( true ) { String input = in . next ( ) ; if ( input . equals ( " END_OF_TEXT " ) ) break ; if ( input . equalsIgnoreCase ( key ) ) DfybYuk ++ ; } System . out . println ( DfybYuk ) ; } } import java . util . * ; public class BkmnqmCkki { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bkmnqmJdck = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] S = sc . nextLine ( ) . split ( " " ) ; int ans = 0 ; for ( int i = 0 ; i < bkmnqmJdck ; i ++ ) { int n = Integer . parseInt ( S [ i ] ) ; while ( n % 2 == 0 ) { n /= 2 ; ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; class CgzxxGjwx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CgzxxYxy = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = s . length ( ) ; String add = " ... " ; if ( count <= CgzxxYxy ) { System . out . println ( s ) ; } else if ( count > CgzxxYxy ) { String result = s . substring ( 0 , CgzxxYxy ) + add ; System . out . println ( result ) ; } } } import java . util . * ; import static java . lang . Math . * ; import java . math . BigInteger ; public class ycynNgq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String result = " No " ; int YcynAex = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { YcynAex += s . charAt ( i ) - '0' ; } if ( Integer . valueOf ( s ) % YcynAex == 0 ) result = " Yes " ; System . out . println ( result ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class PlldbLq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int plldbJizt = sc . nextInt ( ) ; Integer [ ] d = new Integer [ plldbJizt ] ; for ( int i = 0 ; i < plldbJizt ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( d , Collections . reverseOrder ( ) ) ; int ans = 1 ; for ( int i = 0 ; i < plldbJizt - 1 ; i ++ ) { if ( d [ i ] > d [ i + 1 ] ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class UhobRdep { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int uhobBrn = Integer . parseInt ( scan . next ( ) ) ; int counter = 0 ; int min = Integer . MAX_VALUE ; ArrayList < Integer > pi = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < uhobBrn ; ++ 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 KertGi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String W = sc . next ( ) . toLowerCase ( ) ; String T ; int kertBqh = 0 ; while ( ! ( T = sc . next ( ) ) . equals ( " END_OF_TEXT " ) ) { if ( T . toLowerCase ( ) . equals ( W ) ) { kertBqh ++ ; } } sc . close ( ) ; System . out . println ( kertBqh ) ; } } import java . util . * ; public class NosmrpBjbyy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int NosmrpG = 0 ; boolean flag = false ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( str . charAt ( i ) == 'R' ) { NosmrpG ++ ; flag = true ; } else { if ( flag == true ) break ; } } System . out . println ( NosmrpG ) ; } } import java . util . Scanner ; public class sqjheAkg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char SqjheJpeph = ' ' ; for ( int i = 0 ; i < S . length ( ) ; i = i + 2 ) { SqjheJpeph = S . charAt ( i ) ; if ( SqjheJpeph != 'R' && SqjheJpeph != 'U' && SqjheJpeph != 'D' ) { System . out . println ( " No " ) ; return ; } } for ( int k = 1 ; k < S . length ( ) ; k = k + 2 ) { SqjheJpeph = S . charAt ( k ) ; if ( SqjheJpeph != 'L' && SqjheJpeph != 'U' && SqjheJpeph != 'D' ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class HlliiUqjmip { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HlliiM = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] L = new int [ M ] ; int [ ] R = new int [ M ] ; int max = HlliiM + 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 XrajnfOypkss { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long XrajnfJl = sc . nextLong ( ) ; if ( XrajnfJl == 1 || XrajnfJl == 2 || XrajnfJl == 3 ) { System . out . println ( XrajnfJl ) ; return ; } while ( true ) { boolean prime = true ; for ( int i = 2 ; i <= XrajnfJl / 2 ; i ++ ) { if ( XrajnfJl % i == 0 ) { prime = false ; break ; } } if ( prime ) { System . out . println ( XrajnfJl ) ; return ; } XrajnfJl ++ ; } } } import java . util . Scanner ; public class UtleIsy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int utleX = Integer . parseInt ( sc . next ( ) ) ; int [ ] d = new int [ utleX ] ; for ( int i = 0 ; i < utleX ; i ++ ) { d [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int ans = 0 ; for ( int a = 0 ; a < utleX - 1 ; a ++ ) { for ( int b = 0 ; b < utleX - 1 - a ; b ++ ) { ans += d [ a ] * d [ a + 1 + b ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; class VvtTwx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vvtShg = sc . nextInt ( ) ; int numCol = sc . nextInt ( ) ; int [ ] [ ] mat = new int [ vvtShg ] [ numCol ] ; int [ ] vecIn = new int [ numCol ] ; int [ ] vecOut = new int [ vvtShg ] ; int i , j ; for ( i = 0 ; i < vvtShg ; 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 < vvtShg ; 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 OktaUzb { static int OktaQ = 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 gzoqgA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GzoqgVgcw = sc . nextInt ( ) ; String [ ] s = new String [ GzoqgVgcw ] ; for ( int i = 0 ; i < GzoqgVgcw ; 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 < GzoqgVgcw ; i ++ ) { if ( ! map . containsKey ( s [ i ] ) ) { ans ++ ; map . put ( s [ i ] , 1 ) ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class KlusdPxs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String KlusdYop = scan . next ( ) ; if ( KlusdYop . length ( ) == 3 ) { if ( KlusdYop . contains ( " 7 " ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; class UlvuupVwy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UlvuupZoe = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int value ; int rowTotal ; int [ ] colTotal = new int [ c ] ; for ( int i = 0 ; i < UlvuupZoe ; 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 CyqeWmes { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String S = s . next ( ) ; String T = s . next ( ) ; int cyqeGqg = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) != T . charAt ( i ) ) cyqeGqg ++ ; } System . out . println ( cyqeGqg ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class QcbSuwh { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int QcbFgz = 1 ; while ( true ) { int n = Integer . parseInt ( br . readLine ( ) ) ; if ( n == 0 ) { break ; } sb . append ( " Case " ) . append ( QcbFgz ) . append ( " : " ) . append ( n ) . append ( " \n " ) ; QcbFgz ++ ; } System . out . print ( sb ) ; } } import java . util . * ; public class CrtRdwmtk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CrtVh = sc . nextInt ( ) ; int [ ] a = new int [ CrtVh ] ; for ( int i = 0 ; i < CrtVh ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int bigTall = a [ 0 ] ; long count = 0 ; for ( int i = 1 ; i < CrtVh ; 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 IgyelWjeup { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String IgyelH = scan . next ( ) ; String result = " No " ; if ( String . valueOf ( IgyelH . charAt ( 2 ) ) . equals ( String . valueOf ( IgyelH . charAt ( 3 ) ) ) && ( String . valueOf ( IgyelH . charAt ( 4 ) ) . equals ( String . valueOf ( IgyelH . charAt ( 5 ) ) ) ) ) { result = " Yes " ; } System . out . println ( result ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class NzxbrzJi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NzxbrzIpq = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] key = new int [ NzxbrzIpq ] ; 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 oqtpgL { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long [ ] line = new long [ 4 ] ; for ( int OqtpgJrsda = 0 ; OqtpgJrsda < 4 ; OqtpgJrsda ++ ) { line [ OqtpgJrsda ] = sc . nextLong ( ) ; } long max = Long . MIN_VALUE ; for ( int OqtpgJrsda = 0 ; OqtpgJrsda < 2 ; OqtpgJrsda ++ ) { for ( int j = 2 ; j < 4 ; j ++ ) { max = Math . max ( max , line [ OqtpgJrsda ] * line [ j ] ) ; } } System . out . println ( max ) ; sc . close ( ) ; } } import java . util . Scanner ; public class KlaSfkpb { int KlaQs , 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 LvbqxKhb { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; String lvbqxGxs = sc . next ( ) . replace ( " 2017 " , " 2018 " ) ; System . out . println ( lvbqxGxs ) ; sc . close ( ) ; } } import java . util . Scanner ; class DmqlxrGsyfcq { public static void main ( String [ ] argv ) { Scanner sc = new Scanner ( System . in ) ; boolean DmqlxrClk = false ; for ( int i = 0 ; i < 2 ; i ++ ) { int x = sc . nextInt ( ) ; if ( ( x % 2 ) == 0 ) { DmqlxrClk = true ; } } sc . close ( ) ; if ( DmqlxrClk == true ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Scanner ; public class UbjFkz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ubjN = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int result = 0 ; if ( ubjN == B ) { result = ubjN + B ; } else if ( ubjN > B ) { result = ubjN + ubjN - 1 ; } else if ( B > ubjN ) { result = B + B - 1 ; } System . out . println ( result ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class DyfCos { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long dyfUag = sc . nextLong ( ) ; ArrayList < Integer > numList = new ArrayList < Integer > ( ) ; while ( true ) { int digit = ( int ) ( dyfUag % 26L ) ; if ( digit == 0 ) { digit = 26 ; } numList . add ( digit + 96 ) ; dyfUag = ( dyfUag - digit ) / 26L ; if ( dyfUag == 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 zqtHg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long ZqtDpxi , b1 , r1 , r2 , temp , a2 , b2 ; while ( scan . hasNext ( ) ) { ZqtDpxi = scan . nextInt ( ) ; a2 = ZqtDpxi ; b1 = scan . nextInt ( ) ; b2 = b1 ; while ( a2 % b2 != 0 ) { if ( a2 < b2 ) { temp = a2 ; a2 = b2 ; b2 = temp ; } a2 = a2 % b2 ; } r1 = b2 ; r2 = ( ZqtDpxi * b1 ) / r1 ; System . out . println ( r1 + " " + r2 ) ; } } } import java . util . LinkedHashSet ; import java . util . Scanner ; import java . util . Set ; public class OyzocvQyzpkj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int OyzocvA = scan . nextInt ( ) ; String [ ] list = new String [ OyzocvA ] ; for ( int i = 0 ; i < OyzocvA ; 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 njdxyvTfw { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int NjdxyvTsfn = Integer . parseInt ( in . readLine ( ) ) ; long [ ] a = new long [ NjdxyvTsfn ] ; long sum = 1 ; long lastSum = 1 ; boolean over = false ; String [ ] str = in . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < NjdxyvTsfn ; 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 aqscmyJ { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int AqscmySuz = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; boolean flg = false ; for ( int i = 1 ; i < 1269 ; i ++ ) { if ( Math . floor ( i * 0.08 ) == AqscmySuz && 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 ZqfvchInqsuy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZqfvchYkw = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ ZqfvchYkw ] ; int [ ] B = new int [ ZqfvchYkw - 1 ] ; for ( int i = 0 ; i < ZqfvchYkw ; i ++ ) A [ i ] = 100_000 ; for ( int i = 0 ; i < ZqfvchYkw - 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 WkqpCjqvr { public static void main ( final String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int WkqpFpt = sc . nextInt ( ) ; int [ ] [ ] route = new int [ 2 ] [ WkqpFpt ] ; for ( int i = 0 ; i < 2 ; i ++ ) { route [ i ] = new int [ WkqpFpt ] ; for ( int j = 0 ; j < WkqpFpt ; j ++ ) { route [ i ] [ j ] = sc . nextInt ( ) ; } } int maxCandy = Integer . MIN_VALUE ; for ( int i = 0 ; i < WkqpFpt ; i ++ ) { int tmp = 0 ; int h = 0 ; for ( int j = 0 ; j < WkqpFpt ; 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 OahqNit { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OahqCsp = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < OahqCsp ; i ++ ) { int a = sc . nextInt ( ) ; while ( ( a % 2 ) == 0 ) { cnt ++ ; a /= 2 ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class CafbtJzn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cafbtK = sc . nextInt ( ) ; double ans1 = 0 ; for ( int i = 0 ; i < cafbtK ; 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 DvrnkrCq { static int getMorePrime ( int n ) { if ( n == 2 ) return n ; ArrayList < Integer > primes = new ArrayList < Integer > ( ) ; primes . add ( 2 ) ; int dvrnkrUum = 2 ; while ( true ) { for ( int j = 0 ; j < primes . size ( ) ; j ++ ) if ( dvrnkrUum % primes . get ( j ) == 0 ) { ++ dvrnkrUum ; j = 0 ; } if ( dvrnkrUum >= n ) return dvrnkrUum ; primes . add ( dvrnkrUum ) ; ++ dvrnkrUum ; } } 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 NehvqVxurqq { public static void main ( String [ ] args ) throws IOException { int NehvqEy = 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 ) { NehvqEy ++ ; } } System . out . println ( NehvqEy ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class MehhEied { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int mehhS = sc . nextInt ( ) ; int ans = 1 ; lavel : for ( int i = 2 ; i < mehhS ; i ++ ) { for ( int j = 2 ; ; j ++ ) { if ( ( int ) Math . pow ( i , j ) > mehhS ) { 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 CfgqfqPdk { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int CfgqfqXjt = 0 ; String n = sc . next ( ) ; for ( char ch : n . toCharArray ( ) ) { CfgqfqXjt += ch - '0' ; CfgqfqXjt %= 9 ; } if ( CfgqfqXjt == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class jhybcrWt { public static void main ( String [ ] argsp ) { Scanner sc = new Scanner ( System . in ) ; int JhybcrDw = 0 ; String s = sc . next ( ) , t = sc . next ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) { JhybcrDw ++ ; } } System . out . print ( JhybcrDw ) ; } } import java . util . * ; public class KcqMs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KcqD = sc . nextInt ( ) ; if ( KcqD % 2 == 1 ) { System . out . println ( ( double ) ( ( KcqD - 1 ) / 2 + 1 ) / KcqD ) ; } else { System . out . println ( 0.5 ) ; } } } import java . util . * ; import java . lang . Integer ; public class BokNsmwv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double BokLq = sc . nextInt ( ) ; double y = sc . nextInt ( ) ; double crane = - ( y / 2 ) + 2 * BokLq ; double turtle = BokLq - 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 TzufvcUrrb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tzufvcWht = sc . nextInt ( ) ; int result = 0 ; result += tzufvcWht / 100 ; result = result * 111 ; System . out . println ( tzufvcWht <= result ? result : result == 999 ? result + 112 : result + 111 ) ; } } import java . util . * ; public class NzuqskMzsz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int nzuqskCzof = str . length ( ) ; char [ ] c = new char [ nzuqskCzof ] ; 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 LskmHmda { public static void main ( String [ ] args ) { Scanner sn = new Scanner ( System . in ) ; ArrayList < Integer > a = new ArrayList < Integer > ( ) ; for ( int lskmUzy = 0 ; lskmUzy < 10 ; lskmUzy ++ ) { a . add ( sn . nextInt ( ) ) ; } Collections . sort ( a ) ; for ( int lskmUzy = 0 ; lskmUzy < 3 ; lskmUzy ++ ) { System . out . println ( a . get ( a . size ( ) - lskmUzy - 1 ) ) ; } } } import java . math . BigInteger ; import java . util . Scanner ; public class ozwzokApf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OzwzokGtmvq = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; BigInteger c = BigInteger . valueOf ( OzwzokGtmvq ) . multiply ( BigInteger . valueOf ( b ) ) ; int d = OzwzokGtmvq % b ; while ( d != 0 ) { OzwzokGtmvq = b ; b = d ; d = OzwzokGtmvq % b ; } System . out . println ( c . divide ( BigInteger . valueOf ( b ) ) ) ; } } import java . util . Scanner ; public class PlvjTdy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String plvjVdl = sc . next ( ) ; char [ ] c = plvjVdl . toCharArray ( ) ; c [ 3 ] = '8' ; String st = new String ( c ) ; System . out . println ( st ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class VqqevvYztr { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] values = new int [ 5 ] ; for ( int VqqevvGgz = 0 ; VqqevvGgz < 5 ; VqqevvGgz ++ ) { values [ VqqevvGgz ] = Integer . parseInt ( input . readLine ( ) ) ; } int k = Integer . parseInt ( input . readLine ( ) ) ; for ( int VqqevvGgz = 0 ; VqqevvGgz < 5 ; VqqevvGgz ++ ) { for ( int j = VqqevvGgz + 1 ; j < 5 ; j ++ ) { if ( Math . abs ( values [ VqqevvGgz ] - values [ j ] ) > k ) { System . out . println ( " :( " ) ; return ; } } } System . out . println ( " Yay! " ) ; } } import java . util . * ; public class QeqFcd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qeqE = sc . nextInt ( ) ; String f = sc . next ( ) ; if ( qeqE % 2 == 0 ) { if ( f . substring ( 0 , qeqE / 2 ) . equals ( f . substring ( qeqE / 2 , qeqE ) ) ) { 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 lbdehtKc { 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 LbdehtCgkbm = Integer . parseInt ( input ) - 1 ; LbdehtCgkbm >= 0 ; LbdehtCgkbm -- ) { System . out . print ( inputan [ LbdehtCgkbm ] ) ; if ( LbdehtCgkbm > 0 ) System . out . print ( " " ) ; if ( LbdehtCgkbm == 0 ) System . out . println ( ) ; } } } import java . util . Scanner ; public class ObjUlwz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int ObjV = S . length ( ) ; String ans = " " ; for ( int i = 0 ; i < ObjV ; i ++ ) { ans = ans . concat ( " x " ) ; } System . out . println ( ans ) ; } } import java . util . * ; import java . lang . * ; public class IcjfRz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long icjfTrjd = 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 ( icjfTrjd >= 1 ) { long a = icjfTrjd % 26 ; int b = ( int ) a ; if ( b != 0 ) { ans . add ( alpha [ b - 1 ] ) ; } else if ( b == 0 ) { ans . add ( alpha [ 25 ] ) ; } if ( icjfTrjd % 26 != 0 ) { icjfTrjd = icjfTrjd / 26 ; } else { icjfTrjd = icjfTrjd / 26 - 1 ; } } for ( int i = ans . size ( ) - 1 ; i >= 0 ; i -- ) { System . out . print ( ans . get ( i ) ) ; } } } import java . util . Scanner ; public class InnrXrev { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int innrFq = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += Integer . parseInt ( sc . next ( ) ) ; System . out . println ( innrFq > sum ? " No " : " Yes " ) ; } } import java . util . Scanner ; class PaxxeUja { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int paxxeUnc = scan . nextInt ( ) ; int [ ] a = new int [ paxxeUnc ] ; for ( int i = 0 ; i < paxxeUnc ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } boolean flag = true ; int swap ; int count = 0 ; int min ; for ( int i = 0 ; i < paxxeUnc ; i ++ ) { min = i ; for ( int j = i ; j < paxxeUnc ; 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 < paxxeUnc ; i ++ ) { System . out . print ( a [ i ] ) ; if ( i != paxxeUnc - 1 ) System . out . print ( " " ) ; } System . out . println ( ) ; System . out . println ( count ) ; } } import java . util . Scanner ; public class PjnqtoEy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int PjnqtoVn = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s [ i ] - '0' == 1 ) PjnqtoVn ++ ; } System . out . println ( PjnqtoVn ) ; } } import java . util . * ; public class KytcKhr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kytcWwcl = sc . nextInt ( ) ; int [ ] result = new int [ 4 ] ; for ( int i = 0 ; i < kytcWwcl ; 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 iuemDoc { public static void main ( String [ ] args ) { long IuemZkbgp = 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 gkujwOn { 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 RopkuYuh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ropkuHea = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String [ ] s = sc . next ( ) . split ( " " ) ; String ans = " Yes " ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( i == ropkuHea ) { if ( ! s [ ropkuHea ] . equals ( " - " ) ) { ans = " No " ; break ; } } else { if ( s [ i ] . equals ( " - " ) ) { ans = " No " ; break ; } } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; class mfufhQk { void solve ( ) { int MfufhLkg = in . nextInt ( ) ; if ( MfufhLkg % 2 == 0 ) System . out . println ( 0.5 ) ; else { double b = MfufhLkg / 2 + 1 ; double c = MfufhLkg ; 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 BexvlIy { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; while ( true ) { int BexvlLqd = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; if ( BexvlLqd == - 1 && b == - 1 && c == - 1 ) break ; if ( BexvlLqd == - 1 || b == - 1 ) System . out . println ( " F " ) ; else if ( BexvlLqd + b >= 80 ) System . out . println ( " A " ) ; else if ( BexvlLqd + b >= 65 ) System . out . println ( " B " ) ; else if ( BexvlLqd + b >= 50 ) System . out . println ( " C " ) ; else if ( BexvlLqd + 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 opqeGs { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int OpqeIeu , b ; Scanner sc = new Scanner ( System . in ) ; while ( true ) { String [ ] input = sc . nextLine ( ) . split ( " " ) ; OpqeIeu = Integer . parseInt ( input [ 0 ] ) ; b = Integer . parseInt ( input [ 1 ] ) ; if ( OpqeIeu == 0 && b == 0 ) { break ; } System . out . println ( Math . min ( OpqeIeu , b ) + " " + Math . max ( OpqeIeu , b ) ) ; } } } import java . util . Scanner ; public class dkhH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DkhBi = sc . nextInt ( ) ; int [ ] a = new int [ DkhBi ] ; for ( int i = 0 ; i < DkhBi ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int t ; int j = 1 ; for ( int i = 0 ; i < DkhBi ; i ++ ) { for ( int k = 0 ; k < DkhBi ; 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 < DkhBi ; i ++ ) { if ( max > a [ i ] ) { j ++ ; max = a [ i ] ; } } System . out . println ( j ) ; } } import java . util . Scanner ; public class IkctglLal { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ikctglEv = sc . nextInt ( ) ; int [ ] a = new int [ ikctglEv ] ; int [ ] b = new int [ ikctglEv - 1 ] ; for ( int i = 0 ; i < ikctglEv - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } a [ 0 ] = b [ 0 ] ; int score = a [ 0 ] ; for ( int i = 1 ; i < ikctglEv - 1 ; i ++ ) { a [ i ] = Math . min ( b [ i - 1 ] , b [ i ] ) ; score += a [ i ] ; } if ( ikctglEv != 1 ) { a [ ikctglEv - 1 ] = b [ ikctglEv - 2 ] ; score += a [ ikctglEv - 1 ] ; } System . out . println ( score ) ; } } import java . util . Scanner ; public class CffatTz { 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 cffatVc = 0 , l = c . length ; cffatVc < l ; ++ cffatVc ) { char _c = c [ cffatVc ] ; if ( 97 <= _c && _c <= 122 ) ++ a [ _c - 'a' ] ; else if ( 65 <= _c && _c <= 90 ) ++ a [ _c - 'A' ] ; } } for ( int cffatVc = 0 ; cffatVc < 26 ; ++ cffatVc ) System . out . printf ( " %c : %d \n " , 'a' + cffatVc , a [ cffatVc ] ) ; } } import java . util . Scanner ; public class ytoB { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int YtoShis = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; if ( YtoShis * B > C ) { System . out . println ( C ) ; } else { System . out . println ( YtoShis * B ) ; } } } import java . io . * ; import java . util . * ; public class OopiRnwrfc { public static void main ( String [ ] args ) { new Main ( ) ; } Scanner in = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int OopiFnc , b ; Main ( ) { OopiFnc = in . nextInt ( ) ; b = in . nextInt ( ) ; if ( ( OopiFnc % 2 ) != ( b % 2 ) ) out . println ( " IMPOSSIBLE " ) ; else out . println ( ( OopiFnc + b ) / 2 ) ; out . close ( ) ; } } import java . util . * ; import java . lang . * ; public class wdhmK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WdhmKzcnj = sc . nextInt ( ) ; if ( WdhmKzcnj < 105 ) { System . out . println ( 0 ) ; } else if ( WdhmKzcnj >= 105 && WdhmKzcnj < 135 ) { System . out . println ( 1 ) ; } else if ( WdhmKzcnj >= 135 && WdhmKzcnj < 165 ) { System . out . println ( 2 ) ; } else if ( WdhmKzcnj >= 165 && WdhmKzcnj < 189 ) { System . out . println ( 3 ) ; } else if ( WdhmKzcnj >= 189 && WdhmKzcnj < 195 ) { System . out . println ( 4 ) ; } else if ( WdhmKzcnj >= 195 ) { System . out . println ( 5 ) ; } } } import java . util . Scanner ; public class XtlKkq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XtlI = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int s = XtlI / a ; if ( XtlI % 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 ijybsRjf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int IjybsPk = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < IjybsPk ; 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 AteMpxj { 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 AtePo = m . length ; for ( int i = 0 ; i < AtePo / 2 ; i ++ ) { int tmp = m [ i ] ; m [ i ] = m [ AtePo - i - 1 ] ; m [ AtePo - i - 1 ] = tmp ; } } private static final void output ( int [ ] m , int AtePo ) { for ( int i = 0 ; i < AtePo ; i ++ ) { System . out . println ( m [ i ] ) ; } } private static final void input ( int [ ] m , int AtePo ) { Scanner cin = new Scanner ( System . in ) ; for ( int i = 0 ; i < AtePo ; i ++ ) { m [ i ] = cin . nextInt ( ) ; } } } import java . util . * ; public class IcroewUmc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int icroewTzoc = 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 ++ ) { icroewTzoc -= attack . remove ( 0 ) ; if ( icroewTzoc <= 0 ) { flag = true ; break ; } } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class vmibaP { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long VmibaOnjx = scan . nextLong ( ) ; long ans = 0 ; for ( int i = 1 ; i < VmibaOnjx + 1 ; i ++ ) { if ( ( i % 3 ) == 0 || ( i % 5 ) == 0 ) { ans += 0 ; } else { ans += i ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class YhyqrgZh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YhyqrgVz = 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 = YhyqrgVz ; for ( int i = 0 ; i <= 101 ; i ++ ) { if ( q [ i ] == 0 ) { if ( Math . abs ( YhyqrgVz - i ) < minDif ) { ans = i ; minDif = Math . abs ( YhyqrgVz - i ) ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class ogxF { Scanner sc ; int OgxAi , D ; public Main ( ) { sc = new Scanner ( System . in ) ; } void out ( Object o ) { System . out . println ( o ) ; System . out . flush ( ) ; } public void exec ( ) throws Exception { OgxAi = sc . nextInt ( ) ; D = sc . nextInt ( ) ; int n = ( OgxAi + 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 RpnkksJz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int RpnkksD = scanner . nextInt ( ) ; int w = scanner . nextInt ( ) ; while ( RpnkksD + w > 0 ) { for ( int i = 0 ; i < RpnkksD ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( j == 0 || j == w - 1 || i == 0 || i == RpnkksD - 1 ) System . out . print ( " # " ) ; else System . out . print ( " . " ) ; } System . out . println ( ) ; } System . out . println ( ) ; RpnkksD = scanner . nextInt ( ) ; w = scanner . nextInt ( ) ; } } } import java . util . * ; public class zvytkS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZvytkWbsqo = sc . nextInt ( ) ; int [ ] l = new int [ ZvytkWbsqo ] ; int max = 0 ; int pnt = - 1 ; for ( int i = 0 ; i < ZvytkWbsqo ; i ++ ) { l [ i ] = sc . nextInt ( ) ; if ( max < l [ i ] ) { max = l [ i ] ; pnt = i ; } } int total = 0 ; for ( int i = 0 ; i < ZvytkWbsqo ; 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 mjgXc { public static void main ( String [ ] arge ) { Scanner sc = new Scanner ( System . in ) ; int MjgDv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int men = MjgDv * b ; int syu = ( MjgDv + 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 xophQpe { public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( System . in ) ; long XophMcdp = sc . nextLong ( ) ; long D = sc . nextLong ( ) ; long ans = 0 ; for ( long i = 0 ; i < XophMcdp ; 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 xophQpe { 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 QhlXjj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qhlLhk = sc . nextInt ( ) ; int numX = sc . nextInt ( ) ; int initNum = numX - qhlLhk + 1 ; String retStr = " " + initNum ; for ( int i = initNum + 1 ; i < numX + qhlLhk ; i ++ ) { retStr = retStr + " " + i ; } System . out . println ( retStr ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class JntdpgVjdqsm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JntdpgLrd = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; int res = 0 ; for ( int i = 0 ; i < JntdpgLrd ; 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 nxqvEg { static final Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] __ ) { D [ ] deques = new D [ 3 ] ; for ( int NxqvJimum = 0 ; NxqvJimum < 3 ; NxqvJimum ++ ) { deques [ NxqvJimum ] = new D ( ) ; for ( char c : s . next ( ) . toCharArray ( ) ) deques [ NxqvJimum ] . add ( c ) ; } char next = 'a' ; while ( ! deques [ next - 'a' ] . isEmpty ( ) ) { next = deques [ next - 'a' ] . poll ( ) ; } System . out . println ( Character . toUpperCase ( next ) ) ; } static class nxqvEg extends ArrayDeque < Character > { } } import java . util . Scanner ; public class OubmiNxtg { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String oubmiKuwo = s . nextLine ( ) ; if ( oubmiKuwo . charAt ( 0 ) == oubmiKuwo . charAt ( 1 ) && oubmiKuwo . charAt ( 0 ) == oubmiKuwo . charAt ( 2 ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } s . close ( ) ; } } import java . util . Scanner ; public class VizlDpic { private int VizlA ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int VizlA = 0 ; if ( N % 2 == 1 ) { VizlA = ( N / 2 ) + 1 ; } else { VizlA = ( N / 2 ) ; } System . out . print ( VizlA ) ; } } import java . util . * ; public class IscJppc { public static void main ( String [ ] args ) { int IscO ; Scanner sc = new Scanner ( System . in ) ; for ( ; ; ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( x == 0 && y == 0 ) break ; if ( x > y ) { IscO = x ; x = y ; y = IscO ; } System . out . println ( x + " " + y ) ; } } } import java . math . BigDecimal ; import java . util . Scanner ; class NjlwuFvxq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NjlwuQb = sc . nextInt ( ) ; long ans = 1 ; long [ ] A = new long [ NjlwuQb ] ; for ( int i = 0 ; i < NjlwuQb ; i ++ ) { A [ i ] = sc . nextLong ( ) ; if ( A [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } for ( int i = 0 ; i < NjlwuQb ; 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 YuxkdNs { private static final int yuxkdK = 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 xmuQyp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long XmuHlmii = sc . nextLong ( ) ; sc . close ( ) ; long ret = XmuHlmii ; while ( true ) { if ( isPrime ( ret ) ) { break ; } ret ++ ; } System . out . println ( ret ) ; } public static boolean isPrime ( long XmuHlmii ) { if ( XmuHlmii == 1 || XmuHlmii == 2 ) { return true ; } if ( XmuHlmii % 2 == 0 ) { return false ; } boolean ret = false ; for ( long i = 2 ; i <= Math . sqrt ( XmuHlmii ) ; i ++ ) { if ( XmuHlmii % i == 0 ) { ret = false ; break ; } ret = true ; } return ret ; } } import java . io . FileNotFoundException ; import java . util . Arrays ; import java . util . Scanner ; public class WotfHy { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int wotfRqlb = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] p = new int [ wotfRqlb + 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 <= wotfRqlb ; i ++ ) { if ( p [ i ] > border ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class HcggdIzaq { static Scanner scan ; static int hcggdQ = 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 ( hcggdQ ) ; } 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 ) { hcggdQ ++ ; 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 qfhoJi { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; int QfhoPmbs = 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 [ QfhoPmbs ] ; for ( int i = 0 ; i < q ; i ++ ) { int c = as [ i ] ; cp [ c ] ++ ; } int [ ] dp = new int [ QfhoPmbs ] ; Arrays . fill ( dp , k ) ; long [ ] sum = new long [ QfhoPmbs ] ; long all = Arrays . stream ( cp ) . sum ( ) ; for ( int i = 0 ; i < QfhoPmbs ; i ++ ) { sum [ i ] = all - cp [ i ] ; } for ( int i = 0 ; i < QfhoPmbs ; i ++ ) { if ( k > sum [ i ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class reycprOkx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ReycprBnpa = sc . nextInt ( ) ; String S = sc . next ( ) ; int count = 1 ; char [ ] slime = S . toCharArray ( ) ; for ( int i = 1 ; i < ReycprBnpa ; i ++ ) { if ( slime [ i ] != slime [ i - 1 ] ) { count += 1 ; } } System . out . println ( count ) ; } } import java . util . * ; import java . text . DecimalFormat ; public class EeaUmkras { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String EeaP = sc . nextLine ( ) ; if ( EeaP . equals ( " SUN " ) ) System . out . println ( 7 ) ; else if ( EeaP . equals ( " MON " ) ) System . out . println ( 6 ) ; else if ( EeaP . equals ( " TUE " ) ) System . out . println ( 5 ) ; else if ( EeaP . equals ( " WED " ) ) System . out . println ( 4 ) ; else if ( EeaP . equals ( " THU " ) ) System . out . println ( 3 ) ; else if ( EeaP . equals ( " FRI " ) ) System . out . println ( 2 ) ; else System . out . println ( 1 ) ; } } import java . util . Scanner ; public class CillGm { public static void main ( String [ ] args ) { long cillYg = 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 ) { cillYg = 0 ; ans2 = 0 ; } else { if ( k <= n ) { cillYg = n - k ; ans2 = m ; } else { cillYg = 0 ; ans2 = m - ( k - n ) ; } } System . out . println ( cillYg ) ; System . out . println ( ans2 ) ; sc . close ( ) ; } } import java . util . * ; public class SlxosdAz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int slxosdQ = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; String dummy = sc . nextLine ( ) ; int [ ] [ ] x = new int [ slxosdQ ] [ d ] ; for ( int i = 0 ; i < slxosdQ ; 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 < slxosdQ - 1 ; i ++ ) { for ( int j = i + 1 ; j < slxosdQ ; 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 FojlqYfag { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int fojlqB = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( S . length ( ) <= fojlqB ) { System . out . println ( S ) ; } else { System . out . println ( S . substring ( 0 , fojlqB ) + " ... " ) ; } } 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 bslsrdW { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) throws Exception { new Main ( ) . run ( ) ; } void run ( ) { int BslsrdMw = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; Pattern ptn = Pattern . compile ( " \\ d { " + BslsrdMw + " } - \\ d { " + b + " } " ) ; String s = sc . next ( ) ; System . out . println ( ptn . matcher ( s ) . matches ( ) ? " Yes " : " No " ) ; } } import java . io . * ; import java . util . * ; public class InsFb { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int InsW = in . nextInt ( ) ; boolean [ ] rate = new boolean [ 8 ] ; int free = 0 ; int a ; for ( int i = 0 ; i < InsW ; 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 tmkyoeThc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TmkyoeNvj = sc . nextInt ( ) ; int [ ] button = new int [ TmkyoeNvj + 1 ] ; for ( int i = 1 ; i <= TmkyoeNvj ; i ++ ) { button [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int count = 0 ; int nextButton = 1 ; boolean success = false ; for ( int j = 0 ; j < TmkyoeNvj ; 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 dbrmGy { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int DbrmOjjmg = 124 ; int max = - 1 ; for ( int i = 0 ; i < 5 ; i ++ ) { int n = in . nextInt ( ) ; if ( n < DbrmOjjmg ) DbrmOjjmg = n ; if ( n > max ) max = n ; } int k = in . nextInt ( ) ; System . out . println ( ( max - DbrmOjjmg <= k ) ? " Yay! " : " :( " ) ; in . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class lccusTji { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LccusDyivs = sc . nextInt ( ) ; int [ ] array = new int [ LccusDyivs ] ; boolean b = true ; int i ; for ( i = 0 ; i < LccusDyivs ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } Arrays . sort ( array ) ; for ( i = 0 ; i < LccusDyivs ; 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 pwszzsFib { public static void main ( String [ ] args ) { TreeSet < Integer > numerosUtiles = new TreeSet < > ( ) ; Scanner in = new Scanner ( System . in ) ; int PwszzsVubxf = in . nextInt ( ) ; int [ ] numbers = new int [ PwszzsVubxf ] ; for ( int i = 0 ; i < PwszzsVubxf ; i ++ ) { numbers [ i ] = in . nextInt ( ) ; } for ( int i = 1 ; i < ( PwszzsVubxf - 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 YlwnVuxx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ylwnD = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] variation = new int [ ylwnD ] ; int count = 0 ; int i , j , k = 0 ; int [ ] max = new int [ ylwnD ] ; for ( i = 0 ; i < ylwnD ; i ++ ) { variation [ i ] = sc . nextInt ( ) ; } for ( j = 0 ; j < ylwnD ; j ++ ) { X = X - variation [ j ] ; count ++ ; } for ( k = 0 ; k < ylwnD ; k ++ ) { max [ k ] = X / variation [ k ] ; } for ( j = 0 ; j < ylwnD ; j ++ ) { for ( k = j + 1 ; k < ylwnD ; 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 TwkAi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TwkFgg = sc . nextInt ( ) ; int happy500 = 0 ; int happy5 = 0 ; happy500 = TwkFgg / 500 * 1000 ; happy5 = ( TwkFgg % 500 ) / 5 * 5 ; System . out . println ( happy500 + happy5 ) ; } } import java . util . Scanner ; class YfjtQtlya { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YfjtGxf = sc . nextInt ( ) ; int [ ] a = new int [ YfjtGxf ] ; int [ ] b = new int [ YfjtGxf - 1 ] ; for ( int i = 0 ; i < YfjtGxf ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int j = 0 ; j < YfjtGxf - 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 < YfjtGxf - 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 QjnzYz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long qjnzY = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; long A = qjnzY % K ; long ans = 0 ; if ( qjnzY % K == 0 ) { ans = 0 ; } else { ans = Math . min ( A , K - A ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class CgkpOx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int CgkpGve = scanner . nextInt ( ) ; if ( CgkpGve == 0 ) { System . out . println ( " 1 " ) ; } else if ( CgkpGve == 1 ) { System . out . println ( " 0 " ) ; } } } import java . util . Scanner ; public class EpslmwTgwsdj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String EpslmwWio = sc . next ( ) ; String s1 = EpslmwWio . substring ( 2 , 3 ) ; String s2 = EpslmwWio . substring ( 3 , 4 ) ; String s3 = EpslmwWio . substring ( 4 , 5 ) ; String s4 = EpslmwWio . 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 MprvxbVsfu { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int mprvxbVg = sc . nextInt ( ) ; int min = 1_000_000_000 ; int max = 1 ; for ( int i = 0 ; i < mprvxbVg ; 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 GrntedZcn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GrntedK = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( ( b - 1 + GrntedK - 2 ) / ( GrntedK - 1 ) ) ; } } import java . util . Scanner ; public class HjiwTylk { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; String hjiwVi = std . next ( ) ; String first = hjiwVi . substring ( 0 , 2 ) ; String last = hjiwVi . 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 QjkoYmfa { public static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int qjkoVwnq = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int max = qjkoVwnq ; 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 : qjkoVwnq *= 2 ; break ; case 1 : b *= 2 ; break ; case 2 : c *= 2 ; break ; } } System . out . println ( qjkoVwnq + b + c ) ; } } import java . util . * ; class uprsoP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String UprsoOqav = sc . next ( ) ; switch ( UprsoOqav ) { case " ABC " : System . out . println ( " ARC " ) ; break ; case " ARC " : System . out . println ( " ABC " ) ; break ; } sc . close ( ) ; } } import java . util . Scanner ; public class evoFxu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EvoUfhm , n , j , S = 0 ; double avr , O = 0 , s ; for ( EvoUfhm = 0 ; ; EvoUfhm ++ ) { 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 HuhOn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String x = sc . next ( ) ; if ( x . equals ( " 0 " ) ) break ; int huhBhbj = 0 , i ; for ( i = 0 ; i < x . length ( ) ; i ++ ) { huhBhbj = huhBhbj + x . charAt ( i ) - 48 ; } System . out . printf ( " %d \n " , huhBhbj ) ; } } } import java . util . Scanner ; public class UcdgZdml { public static void main ( String [ ] args ) { int UcdgL , b ; Scanner scanner = new Scanner ( System . in ) ; while ( scanner . hasNext ( ) ) { UcdgL = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; System . out . println ( ( String . valueOf ( UcdgL + b ) . length ( ) ) ) ; } scanner . close ( ) ; } } import java . util . Scanner ; public class qxkT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QxkBwb = sc . nextInt ( ) ; int [ ] value = new int [ QxkBwb ] ; int [ ] cost = new int [ QxkBwb ] ; int [ ] trueValue = new int [ QxkBwb ] ; int max = 0 ; for ( int i = 0 ; i < QxkBwb ; i ++ ) { value [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < QxkBwb ; i ++ ) { cost [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < QxkBwb ; 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 JclUtyb { public static void main ( String [ ] args ) { int jclVulz = 0 ; int i = 0 ; String outputNum = " " ; String [ ] NumList ; try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; jclVulz = Integer . parseInt ( line ) ; line = br . readLine ( ) ; if ( line != null ) { NumList = line . split ( " " , 0 ) ; int Count = jclVulz - 1 ; for ( i = 0 ; i < NumList . length ; i ++ ) { if ( Count != jclVulz - 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 GjcDayzx { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int [ ] arr = new int [ 101010 ] ; int GjcVol ; int n ; int cnt = 0 ; n = reader . nextInt ( ) ; GjcVol = reader . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= GjcVol ) { cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; class lvnGb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LvnGlygn = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; if ( LvnGlygn == b || b == c || LvnGlygn == c ) { System . out . println ( " No " ) ; } else if ( LvnGlygn > b || LvnGlygn > 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 JmjdoNpd { public static void main ( String [ ] args ) { Scanner as = new Scanner ( System . in ) ; double JmjdoJkn , t , s ; JmjdoJkn = as . nextDouble ( ) ; s = 3.141592653589 * JmjdoJkn * JmjdoJkn ; t = 2.0 * 3.141592653589 * JmjdoJkn ; 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 jpdThd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JpdHz = Integer . parseInt ( sc . next ( ) ) ; int taro = 0 ; int hanako = 0 ; for ( int i = 0 ; i < JpdHz ; 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 YvogshNp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YvogshUy = sc . nextInt ( ) ; int result = 0 ; int ahead ; int current = 100000 ; for ( int i = 0 ; i < YvogshUy - 1 ; i ++ ) { ahead = current ; current = sc . nextInt ( ) ; result += Math . min ( ahead , current ) ; } result += current ; System . out . println ( result ) ; } } import java . util . Scanner ; public class nsipeoCow { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NsipeoOyc = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i <= NsipeoOyc ; 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 CfhwfWq { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; int cfhwfRe = scanner . nextInt ( ) ; int i = 0 ; int X ; int hantei = 0 ; int ans = 0 ; while ( hantei == 0 ) { X = cfhwfRe + 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 VfvrqTlc { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int vfvrqLeq = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; sc . close ( ) ; int sum = 0 ; for ( int i = 1 ; i < vfvrqLeq ; i ++ ) { sum += i ; } for ( int i = 1 ; i < M ; i ++ ) { sum += i ; } System . out . println ( sum ) ; } } import java . util . * ; public class YqltbQnpac { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YqltbIz = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int gugu = YqltbIz * ( YqltbIz - 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 LlzHmbw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int llzNuo = 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 [ llzNuo ] ; for ( int i = 0 ; i < q ; i ++ ) { int ans = a [ i ] - 1 ; point [ ans ] ++ ; } for ( int i = 0 ; i < llzNuo ; i ++ ) { if ( k - q + point [ i ] > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; public class FjndlCwiedo { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int FjndlMpt = scanner . nextInt ( ) ; int max = 1 ; for ( int i = 2 ; i <= FjndlMpt ; i ++ ) { int j = i ; while ( true ) { j *= i ; if ( j > FjndlMpt ) { break ; } max = Math . max ( max , j ) ; } } System . out . println ( max ) ; } } import java . util . * ; class lglhwK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LglhwRvu = sc . nextInt ( ) ; int res = 0 ; for ( int a = 1 ; a <= LglhwRvu ; ++ a ) { for ( int b = 1 ; b <= LglhwRvu ; ++ b ) { for ( int c = 1 ; c <= LglhwRvu ; ++ 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 LjjOqiyz { 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 LjjZif ; double rad = Math . PI * 2 * ( ( double ) h / 12 + ( ( double ) m / 60 ) / 12 - ( double ) m / 60 ) ; LjjZif = Math . sqrt ( Math . pow ( a , 2 ) + Math . pow ( b , 2 ) - 2 * a * b * Math . cos ( rad ) ) ; System . out . printf ( " %.20f " , LjjZif ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class CgghnJvek { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cgghnIzop = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; Integer [ ] a = new Integer [ cgghnIzop ] ; for ( int i = 0 ; i < cgghnIzop ; 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 adwlbkPki { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] nyu = sc . nextLine ( ) . split ( " " ) ; int AdwlbkIga = Integer . parseInt ( nyu [ 0 ] ) ; int numnext = Integer . parseInt ( nyu [ 1 ] ) ; int numend = Integer . parseInt ( nyu [ 2 ] ) ; int count = 0 ; if ( numend - ( AdwlbkIga - numnext ) < 0 ) { count = 0 ; } else { count = numend - ( AdwlbkIga - numnext ) ; } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; import java . nio . charset . StandardCharsets ; public class mtsgK { 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 MtsgTtei = 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 , MtsgTtei ) ; String str = valid ? " Yes " : " No " ; System . out . println ( str ) ; } static boolean isValid ( String S , Set < Character > numbers , int MtsgTtei ) { for ( int i = 0 ; i < S . length ( ) ; ++ i ) { if ( i == MtsgTtei ) { 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 xicitiK { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String XicitiSmfn = br . readLine ( ) ; Integer num = Integer . parseInt ( XicitiSmfn ) ; System . out . println ( num * num * num ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class ewihzI { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int EwihzZmxb = Integer . parseInt ( br . readLine ( ) ) ; String [ ] sNumbers = br . readLine ( ) . split ( " " ) ; int [ ] numbers = new int [ EwihzZmxb ] ; for ( int i = 0 ; i < EwihzZmxb ; 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 SlffKg { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int slffAmeo = Integer . parseInt ( in . readLine ( ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int [ ] a = new int [ slffAmeo ] ; int hantei = 1 ; int cntContinuous = 0 ; for ( int i = 0 ; i < slffAmeo ; i ++ ) { a [ i ] = Integer . parseInt ( str [ i ] ) ; if ( hantei == a [ i ] ) { cntContinuous ++ ; hantei ++ ; } } System . out . println ( cntContinuous == 0 ? - 1 : slffAmeo - cntContinuous ) ; } } import java . util . Scanner ; public class XofmkPa { public static void main ( String [ ] args ) { final int xofmkGdko = 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 ] [ xofmkGdko ] - 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 ] [ xofmkGdko ] ; } 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 ZgqRudn { static BigInteger limit = new BigInteger ( " 1000000000000000000 " ) ; public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int zgqDrnd = sc . nextInt ( ) ; List < BigInteger > values = new ArrayList < BigInteger > ( ) ; for ( int i = 0 ; i < zgqDrnd ; 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 LtdinUiidsz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int LtdinW = scanner . nextInt ( ) , B = scanner . nextInt ( ) , C = scanner . nextInt ( ) ; System . out . println ( C / LtdinW * B ) ; } } import java . util . * ; public class ftekQf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FtekClh = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int res = 9999 ; for ( int i = 0 ; i < FtekClh ; 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 MrqmqoBdf { public static void main ( String [ ] args ) { StringBuilder sb = new StringBuilder ( ) ; Scanner as = new Scanner ( System . in ) ; int mrqmqoTaq = 0 ; int tre = 0 ; int count = 0 ; int [ ] A ; Boolean flag = true ; mrqmqoTaq = Integer . parseInt ( as . next ( ) ) ; A = new int [ mrqmqoTaq ] ; for ( int i = 0 ; i < mrqmqoTaq ; i ++ ) { A [ i ] = Integer . parseInt ( as . next ( ) ) ; } while ( flag ) { flag = false ; for ( int j = mrqmqoTaq - 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 < mrqmqoTaq ; i ++ ) { if ( i != mrqmqoTaq - 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 VvaYdb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vvaLny = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int time = t ; int x1 = x ; while ( x < vvaLny ) { t = t + time ; x = x + x1 ; } System . out . println ( t ) ; sc . close ( ) ; } } import java . util . * ; public class HyvfEk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HyvfVtb = sc . nextInt ( ) ; long min = sc . nextInt ( ) ; long ret = - 1000000001 ; for ( int i = 1 ; i < HyvfVtb ; 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 trhlvOcm { 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 TrhlvPkxh = sc . nextInt ( ) ; for ( int i = 0 ; TrhlvPkxh > 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 ; TrhlvPkxh > i ; i ++ ) { System . out . println ( list_in_max ) ; } System . exit ( 0 ) ; } else { for ( int i = 0 ; TrhlvPkxh > 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 IwutzeAr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iwutzeIzrt = 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 >= iwutzeIzrt ) { 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 XunugIo { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String xunugBbbg = reader . readLine ( ) ; String p = reader . readLine ( ) ; String ss = xunugBbbg + xunugBbbg ; 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 DoecrlWsf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String answer = " Good " ; for ( int doecrlTf = 0 ; doecrlTf < 3 ; doecrlTf ++ ) { if ( s . charAt ( doecrlTf ) == s . charAt ( doecrlTf + 1 ) ) { answer = " Bad " ; break ; } } System . out . println ( answer ) ; sc . close ( ) ; } } import java . util . Scanner ; public class FsnbvRi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int fsnbvPrm = scanner . nextInt ( ) ; System . out . println ( fsnbvPrm / 2 + fsnbvPrm % 2 ) ; } } import java . util . Scanner ; public class eytAzl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; final int EytOdkmy = scan . nextInt ( ) ; final int M = scan . nextInt ( ) ; int [ ] [ ] codes = new int [ EytOdkmy ] [ 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 < EytOdkmy ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { codes [ i ] [ j ] = scan . nextInt ( ) ; } } int count = 0 ; for ( int i = 0 ; i < EytOdkmy ; 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 ylgqfrFl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YlgqfrDzsju = sc . nextInt ( ) ; String ans = " No " ; for ( int i = 1 ; i < 10 ; i ++ ) { for ( int j = 1 ; j < 10 ; j ++ ) { if ( i * j == YlgqfrDzsju ) { ans = " Yes " ; break ; } } } System . out . println ( ans ) ; } } import identifier . identifier . * ; import identifier . identifier . * ; public class XmocvAhp { 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 IoqCb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ioqZ = sc . nextInt ( ) ; int [ ] a = new int [ ioqZ ] ; int sum = 0 ; for ( int i = 0 ; i < ioqZ ; i ++ ) { a [ i ] = sc . nextInt ( ) ; sum += a [ i ] ; } Arrays . parallelSort ( a ) ; sum -= a [ ioqZ - 1 ] ; if ( sum > a [ ioqZ - 1 ] ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class MfztmPimm { 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 mfztmXgoj = 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 xauvbUw { 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 XauvbKg = 0 ; for ( int i = 0 ; i <= 6 ; i ++ ) { if ( input . equals ( s [ i ] ) ) XauvbKg = 7 - i ; } System . out . println ( XauvbKg ) ; } } import java . util . * ; public class ynvtJzj { 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 YnvtRlgg = 0 ; for ( int i = 0 ; i < s1 . length ; i ++ ) { if ( s1 [ i ] != t1 [ i ] ) { YnvtRlgg ++ ; } } System . out . println ( YnvtRlgg ) ; sc . close ( ) ; } } import java . util . Scanner ; public class RwqzsdZvun { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rwqzsdZge = 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 ) * rwqzsdZge + Math . max ( 0 , y - i ) * b ) ; } System . out . println ( min ) ; } } import java . lang . Math ; import java . util . Scanner ; class DiwAb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long diwPr = sc . nextLong ( ) ; double interest = 100 ; int year = 0 ; while ( interest < diwPr ) { year += 1 ; interest *= 1.01 ; interest = Math . floor ( interest ) ; if ( interest >= diwPr ) { break ; } } System . out . println ( year ) ; } } import java . util . Scanner ; public class SyqoZkrw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; char [ ] c = S . toCharArray ( ) ; int SyqoD = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( c [ i ] == '+' ) { SyqoD ++ ; } else { SyqoD -- ; } } System . out . println ( SyqoD ) ; } } import java . util . * ; public class qsmtHob { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QsmtVvlhx = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int tasu = QsmtVvlhx + B ; int hiku = QsmtVvlhx - B ; int kakeru = QsmtVvlhx * B ; System . out . println ( Math . max ( kakeru , Math . max ( tasu , hiku ) ) ) ; } } import java . util . Scanner ; public class SdajtOyfi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SdajtUq = 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 <= SdajtUq ; 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 ezoImw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EzoXeco = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int divideAns = EzoXeco / b ; int modAns = EzoXeco % b ; double fewAns = ( double ) EzoXeco / b ; out . printf ( " %d %d %f%n " , divideAns , modAns , fewAns ) ; } } import java . util . * ; public class EaxbGdzb { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int eaxbG = s . nextInt ( ) ; String yvgubhij = s . nextLine ( ) ; HashSet < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < eaxbG ; i ++ ) { String b = s . nextLine ( ) ; set . add ( b ) ; } System . out . println ( set . size ( ) ) ; } } import java . util . Scanner ; public class ysjgW { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int YsjgFljg = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int d = scanner . nextInt ( ) ; int ans = 0 ; if ( c < YsjgFljg && d < YsjgFljg ) { ans = 0 ; } if ( c <= YsjgFljg && d >= YsjgFljg && d <= b ) { ans = d - YsjgFljg ; } if ( c >= YsjgFljg && d <= b ) { ans = d - c ; } if ( c >= YsjgFljg && d >= b && c <= b ) { ans = b - c ; } if ( b < c ) { ans = 0 ; } if ( c <= YsjgFljg && b <= d ) { ans = b - YsjgFljg ; } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; import static java . lang . Math . * ; public class bxmtM { static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( System . in ) ; int BxmtYs = sc . nextInt ( ) , q = sc . nextInt ( ) ; String s = sc . next ( ) ; int [ ] AC = new int [ BxmtYs + 1 ] ; for ( int i = 1 ; i < BxmtYs ; i ++ ) { if ( s . charAt ( i - 1 ) == 'A' && s . charAt ( i ) == 'C' ) { AC [ i ] = 1 ; } } for ( int i = 1 ; i < BxmtYs + 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 < BxmtYs && 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 brbBbl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BrbZjc = sc . nextInt ( ) ; int [ ] tako = new int [ BrbZjc ] ; for ( int i = 0 ; i < BrbZjc ; i ++ ) { tako [ i ] = sc . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < BrbZjc ; i ++ ) { for ( int k = i + 1 ; k < BrbZjc ; k ++ ) { sum += tako [ i ] * tako [ k ] ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; class EgfcYcms { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int EgfcKtm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String ans = sc . next ( ) ; int sum = 0 ; if ( ans . equals ( s ) ) { sum = EgfcKtm - 1 ; System . out . println ( sum + " " + b ) ; } if ( ans . equals ( t ) ) { sum = b - 1 ; System . out . println ( EgfcKtm + " " + sum ) ; } sc . close ( ) ; } } import java . util . * ; public class FqgnpLxc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " " ; int fqgnpTn = Integer . parseInt ( s . substring ( 0 , 2 ) ) ; int l = Integer . parseInt ( s . substring ( 2 , 4 ) ) ; if ( fqgnpTn < 1 || 12 < fqgnpTn ) { 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 qwieuwSq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QwieuwRa = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; List < Integer > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < QwieuwRa ; 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 XldbLdo { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strAry ; long xldbMq , max , min , sum ; xldbMq = 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 < xldbMq ; 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 IueBxoz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iueQm = sc . nextInt ( ) ; int [ ] r = new int [ iueQm ] ; for ( int i = 1 ; i <= iueQm ; i ++ ) r [ sc . nextInt ( ) - 1 ] = i ; for ( int rr : r ) System . out . print ( rr + " " ) ; } } import java . util . Scanner ; public class qtrteR { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; while ( true ) { String a = scanner . nextLine ( ) ; if ( a . equals ( " 0 " ) ) break ; int QtrteOgg = 0 ; for ( char b : a . toCharArray ( ) ) { QtrteOgg += Integer . parseInt ( String . valueOf ( b ) ) ; } System . out . println ( QtrteOgg ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class NgyvqQplxff { public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( System . in ) ; int NgyvqEay = sc . nextInt ( ) ; int ans = 0 ; ans = NgyvqEay + ( int ) Math . pow ( NgyvqEay , 2 ) + ( int ) Math . pow ( NgyvqEay , 3 ) ; System . out . println ( ans ) ; } private static class NgyvqQplxff { 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 IwkQeni { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; Map < String , Integer > tV = new TreeMap < > ( ) ; int iwkBaa = scn . nextInt ( ) ; int [ ] VList = new int [ iwkBaa ] ; for ( int i = 0 ; i < iwkBaa ; 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 [ iwkBaa - 1 ] == VList [ 0 ] ) { for ( Map . Entry < String , Integer > vote : tV . entrySet ( ) ) { System . out . println ( vote . getKey ( ) . toString ( ) ) ; } } else { if ( VList [ 0 ] != VList [ iwkBaa - 1 ] ) { for ( Map . Entry < String , Integer > vote : tV . entrySet ( ) ) { if ( vote . getValue ( ) == VList [ iwkBaa - 1 ] ) { System . out . println ( vote . getKey ( ) . toString ( ) ) ; } } } } scn . close ( ) ; } } import java . util . Scanner ; import java . util . Arrays ; class lvnvfA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long LvnvfVn = sc . nextLong ( ) ; int i = 0 ; for ( i = 1 ; LvnvfVn > 1 ; i ++ ) { LvnvfVn = LvnvfVn / 2 ; } System . out . println ( ( long ) ( Math . pow ( 2 , i - 1 ) + Math . pow ( 2 , i - 1 ) - 1 ) ) ; } } import java . util . Scanner ; public class ThffrMsd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ThffrK = sc . nextInt ( ) ; double pi = 3.141592653558209749448214808651 ; double l = 2 * pi * ThffrK ; System . out . println ( l ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class bnyndOf { @ SuppressWarnings ( " deprecation " ) public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int BnyndEakbl = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; System . out . println ( BnyndEakbl * ( BnyndEakbl - 1 ) / 2 + M * ( M - 1 ) / 2 ) ; } } import java . util . * ; public class GxkjSeg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GxkjEkv = sc . nextInt ( ) ; String s = sc . next ( ) ; int b = 0 ; for ( int i = 0 ; i < GxkjEkv - 2 ; i ++ ) { if ( s . substring ( i , i + 3 ) . equals ( " ABC " ) ) { b ++ ; } } System . out . println ( b ) ; } } import java . util . Scanner ; public class XtnPczrms { static public void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XtnHny = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] counts = new int [ XtnHny ] ; 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 OjqfQy { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ojqfIty = Integer . parseInt ( scanner . next ( ) ) ; double [ ] S = new double [ ojqfIty ] ; for ( int i = 0 ; i < ojqfIty ; i ++ ) { S [ i ] = Double . parseDouble ( scanner . next ( ) ) ; } Arrays . parallelSort ( S ) ; double m = ( S [ 0 ] + S [ 1 ] ) / 2 ; for ( int i = 2 ; i < ojqfIty ; i ++ ) { m = ( m + S [ i ] ) / 2 ; } System . out . print ( m ) ; } } import java . util . ArrayList ; import java . util . HashMap ; import java . util . Scanner ; public class RzsCmbi { public static void main ( String [ ] args ) { HashMap < Integer , Integer > num = new HashMap < > ( ) ; Scanner sc = new Scanner ( System . in ) ; int rzsHdu = sc . nextInt ( ) ; for ( int i = 1 ; i < rzsHdu ; 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 <= rzsHdu ; i ++ ) { if ( num . containsKey ( i ) ) { System . out . println ( num . get ( i ) ) ; } else { System . out . println ( 0 ) ; } } } } import java . util . Scanner ; public class JouskqPrsi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JouskqOqi = sc . nextInt ( ) ; sc . nextLine ( ) ; String [ ] array = new String [ JouskqOqi ] ; for ( int i = 0 ; i < JouskqOqi ; i ++ ) { array [ i ] = sc . nextLine ( ) ; if ( i == 0 ) { continue ; } if ( ! ( array [ i ] . substring ( 0 , 1 ) ) . equals ( array [ i - 1 ] . substring ( array [ i - 1 ] . JouskqOqi ( ) - 1 ) ) ) { System . out . println ( " No " ) ; return ; } } for ( int i = 0 ; i < JouskqOqi - 1 ; i ++ ) { for ( int j = i + 1 ; j < JouskqOqi ; j ++ ) { if ( array [ i ] . equals ( array [ j ] ) ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class VigzxvUv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vigzxvYu = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int min = x - vigzxvYu + 1 ; int max = x + vigzxvYu - 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 TvujRdf { 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 TvujOq = 0 ; TvujOq < 3 ; TvujOq ++ ) { ODD_STEP . add ( ODD_STEP_STR . charAt ( TvujOq ) ) ; EVEN_STEP . add ( EVEN_STEP_STR . charAt ( TvujOq ) ) ; } int current_step = 0 ; String steps = sc . next ( ) ; for ( int TvujOq = 0 ; TvujOq < steps . length ( ) ; TvujOq ++ ) { char step = steps . charAt ( TvujOq ) ; if ( ( TvujOq + 1 ) % 2 == 0 && ! EVEN_STEP . contains ( step ) ) { break ; } else if ( ( TvujOq + 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 UqfJy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UqfH = 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 < UqfH ; 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 joeLrn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int JoeEgp = 1 ; int count = 0 ; if ( S . length ( ) % 2 == 0 ) { JoeEgp = S . length ( ) ; } else { JoeEgp = S . length ( ) - 1 ; } for ( int i = 0 ; i < JoeEgp / 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 KdsxrWp { 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 kdsxrZvj = reader . readLine ( ) ; while ( kdsxrZvj != null ) { mylist . add ( kdsxrZvj ) ; kdsxrZvj = 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 XgjkxMca { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xgjkxHxd = 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 [ xgjkxHxd ] ; 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 < xgjkxHxd ; i ++ ) { rightResult = rightResult + flag [ i ] ; } if ( leftResult < rightResult ) { System . out . println ( leftResult ) ; } else { System . out . println ( rightResult ) ; } } } import java . util . * ; public class GjabmtUyvde { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GjabmtN = sc . nextInt ( ) ; int [ ] hights = new int [ GjabmtN ] ; boolean reach = false ; String answer = " Yes " ; for ( int i = 0 ; i < GjabmtN ; i ++ ) { hights [ i ] = sc . nextInt ( ) ; } for ( int i = GjabmtN - 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 XzxncQty { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XzxncTi = sc . nextInt ( ) ; int xx = XzxncTi / 2 ; int ans = 0 ; for ( int i = 1 ; i <= XzxncTi ; i ++ ) { for ( int j = 2 ; j <= XzxncTi + 1 ; j ++ ) { if ( Math . pow ( i , j ) > ans && Math . pow ( i , j ) <= XzxncTi ) { 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 eywhgfT { 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 EywhgfHgae = 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 > EywhgfHgae ) { System . out . println ( " -1 " ) ; } else { System . out . println ( ( EywhgfHgae - sum ) ) ; } } void calc ( ) { } void showResult ( ) { } } import java . io . * ; import java . util . * ; class viaxmUt { 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 ViaxmHv = Integer . parseInt ( st . nextToken ( ) ) ; int w = Integer . parseInt ( st . nextToken ( ) ) ; if ( w == 0 && ViaxmHv == 0 ) break ; for ( int i = 0 ; i < ViaxmHv ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . * ; class OudFpm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oudGy = sc . nextInt ( ) ; long [ ] a = new long [ oudGy ] ; for ( int i = 0 ; i < oudGy ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long num = lcm ( a , oudGy ) ; long deno = sum ( a , oudGy , 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 oudGy ) { long lc = 1 ; for ( int i = 0 ; i < oudGy ; i ++ ) { lc = ( lc * a [ i ] ) / gcd ( lc , a [ i ] ) ; } return lc ; } public static long sum ( long [ ] a , int oudGy , long num ) { long count = 0 ; for ( int i = 0 ; i < oudGy ; i ++ ) { count += ( num / a [ i ] ) ; } return count ; } } import java . util . * ; public class dcoVdh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DcoPjax = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int min = 0 ; int min2 = 0 ; if ( DcoPjax < b ) { min = DcoPjax ; if ( b < c ) { min2 = b ; } else { min2 = c ; } } else { min = b ; if ( DcoPjax < c ) { min2 = DcoPjax ; } else { min2 = c ; } } System . out . println ( min + min2 ) ; } } import java . io . * ; public class IyfVb { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long iyfDw = Long . parseLong ( reader . readLine ( ) ) ; System . out . println ( calc ( 1 , iyfDw ) - calc ( 3 , iyfDw ) - calc ( 5 , iyfDw ) + calc ( 15 , iyfDw ) ) ; return ; } static long calc ( long n , long iyfDw ) { return ( n + iyfDw / n * n ) * ( iyfDw / n ) / 2 ; } } import java . util . Scanner ; public class QzdxtFgs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; char [ ] chars = s . toCharArray ( ) ; int QzdxtQ = 0 ; for ( int i = 0 ; i < chars . length / 2 ; i ++ ) { if ( chars [ i ] != chars [ chars . length - 1 - i ] ) { QzdxtQ ++ ; } } System . out . println ( QzdxtQ ) ; } } import java . io . * ; public class BdsvehKayewb { public static void main ( String ... args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String [ ] line = br . readLine ( ) . split ( " " ) ; int BdsvehI = Integer . parseInt ( line [ 0 ] ) ; int k = Integer . parseInt ( line [ 1 ] ) ; int q = Integer . parseInt ( line [ 2 ] ) ; int [ ] point = new int [ BdsvehI ] ; for ( int i = 0 ; i < q ; i ++ ) { point [ Integer . parseInt ( br . readLine ( ) ) - 1 ] += 1 ; } for ( int i = 0 ; i < BdsvehI ; 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 WyspwxJoo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WyspwxYzx = sc . nextInt ( ) ; int kari = WyspwxYzx + 1 ; int keta = 1 ; while ( ( int ) ( kari / 10 ) != 0 ) { keta ++ ; kari = ( int ) ( kari / 10 ) ; } if ( keta == 1 ) { System . out . println ( WyspwxYzx ) ; } else if ( keta == 2 ) { System . out . println ( 9 ) ; } else if ( keta == 3 ) { System . out . println ( ( 10 + WyspwxYzx - 100 ) ) ; } else if ( keta == 4 ) { System . out . println ( 909 ) ; } else if ( keta == 5 ) { System . out . println ( ( 910 + WyspwxYzx - 10000 ) ) ; } else { System . out . println ( 90909 ) ; } sc . close ( ) ; } } import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class ApnjCvzi { 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 apnjPch : A ) { if ( maplst . containsKey ( apnjPch ) ) { maplst . put ( apnjPch , maplst . get ( apnjPch ) + 1 ) ; } else { maplst . put ( apnjPch , 1 ) ; } } boolean judge = true ; if ( maplst . keySet ( ) . size ( ) == 2 ) { for ( char apnjPch : maplst . keySet ( ) ) { if ( maplst . get ( apnjPch ) != 2 ) { judge = ! judge ; break ; } } } else { judge = ! judge ; } if ( judge ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class epyevZd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EpyevQn = sc . nextInt ( ) ; int break_count = 0 ; int next = 1 ; for ( int i = 0 ; i < EpyevQn ; 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 lmreB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LmreVimvo = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int sta = d * 2 + 1 ; for ( int i = 0 ; i < 20 ; i ++ ) { if ( sta * i >= LmreVimvo ) { System . out . println ( i ) ; break ; } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class yfqeweNwz { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int YfqeweFvxic , b , w ; String str ; String [ ] s ; str = br . readLine ( ) ; while ( str != null ) { StringBuilder out = new StringBuilder ( ) ; s = str . split ( " " ) ; YfqeweFvxic = Integer . parseInt ( s [ 0 ] ) ; b = Integer . parseInt ( s [ 1 ] ) ; w = YfqeweFvxic + b ; out . append ( w ) ; System . out . println ( out . length ( ) ) ; str = br . readLine ( ) ; } } } import java . util . Scanner ; public class TginyZc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tginyCbpn = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = ( tginyCbpn + b ) / 2 ; String ans = " " ; if ( ( tginyCbpn + b ) % 2 == 0 && Math . abs ( tginyCbpn - k ) == Math . abs ( b - k ) ) { ans = String . valueOf ( k ) ; } else { ans = " IMPOSSIBLE " ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class YfbXiiqbb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YfbYc = sc . nextInt ( ) ; int [ ] h = new int [ YfbYc ] ; for ( int i = 0 ; i < YfbYc ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int number = 0 ; int ans = 0 ; for ( int i = 0 ; i < YfbYc ; i ++ ) { if ( number > h [ i ] ) ans += number - h [ i ] ; number = h [ i ] ; } ans += number ; System . out . println ( ans ) ; } } import java . util . * ; public class WtrkDwm { 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 WtrkNao = Integer . MAX_VALUE ; for ( int i = 0 ; i <= s . length ( ) - t . length ( ) ; i ++ ) { if ( WtrkNao > helper ( s . substring ( i , i + t . length ( ) ) , t ) ) { WtrkNao = helper ( s . substring ( i , i + t . length ( ) ) , t ) ; } } System . out . println ( WtrkNao ) ; } } 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 LdcsAihpxe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LdcsUfx = sc . nextInt ( ) ; int [ ] B = new int [ LdcsUfx ] ; for ( int i = 1 ; i < LdcsUfx ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int [ ] A = new int [ LdcsUfx + 1 ] ; A [ 1 ] = B [ 1 ] ; for ( int i = 1 ; i < LdcsUfx ; i ++ ) { if ( B [ i ] < A [ i ] ) { A [ i ] = B [ i ] ; } A [ i + 1 ] = B [ i ] ; } int max = 0 ; for ( int i = 1 ; i <= LdcsUfx ; i ++ ) { max += A [ i ] ; } System . out . println ( max ) ; } } import java . io . * ; import java . util . * ; public class ZmrhLwr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Question question = new Question ( ) ; question . solve ( sc ) ; } static class ZmrhLwr { public void solve ( Scanner sc ) { int ZmrhVvd = 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 ) , ZmrhVvd - Math . abs ( dist ) ) ) ; } System . out . println ( ZmrhVvd - m ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class TcuBz { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] Alph = new int [ 26 ] ; for ( int tcuVzjh = 0 ; tcuVzjh < 26 ; tcuVzjh ++ ) { Alph [ tcuVzjh ] = 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 kjlplhJ { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int KjlplhCum = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int count = 0 ; for ( int i = KjlplhCum ; 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 zetR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double ZetZm = 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 ( ZetZm , 2 ) + Math . pow ( b , 2 ) - 2 * ZetZm * b * Math . cos ( Math . toRadians ( rad ) ) ) ; System . out . println ( len ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class tbkwvPl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TbkwvMvowd = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; HashSet < Integer > sunuke = new HashSet < > ( ) ; for ( int i = 0 ; i < TbkwvMvowd ; 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 RqikcHr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rqikcN = sc . nextInt ( ) ; int standard = 1 ; while ( true ) { int target = standard * 2 ; if ( target <= rqikcN ) { standard = target ; } else { break ; } } System . out . println ( standard ) ; } } import java . lang . * ; import java . util . * ; public class efwoauHoz { public static void main ( String [ ] args ) { Scanner stdId = new Scanner ( System . in ) ; int EfwoauHleup = stdId . nextInt ( ) ; EfwoauHleup = EfwoauHleup * EfwoauHleup * EfwoauHleup ; System . out . println ( String . valueOf ( EfwoauHleup ) ) ; } } import java . util . Scanner ; public class rgtayZwm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String RgtayOy = scan . nextLine ( ) ; String str2 = scan . nextLine ( ) ; String c = str2 . substring ( 0 , RgtayOy . length ( ) ) ; if ( RgtayOy . equals ( c ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; } } import java . util . Scanner ; public class WaixppOyeq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int waixppZnn = Integer . parseInt ( sc . next ( ) ) ; int d = Integer . parseInt ( sc . next ( ) ) ; int range = 2 * d + 1 ; System . out . println ( ( waixppZnn + range - 1 ) / range ) ; System . out . flush ( ) ; sc . close ( ) ; } } import java . util . * ; public class XueeqyBldjap { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int XueeqyT = s . lastIndexOf ( " Z " ) - s . indexOf ( " A " ) + 1 ; System . out . println ( XueeqyT ) ; } } import java . util . Scanner ; class WldoUt { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; char [ ] S ; int WldoF = 0 ; S = input . next ( ) . toCharArray ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( S [ i ] == S [ i + 1 ] ) { System . out . println ( " Bad " ) ; WldoF ++ ; break ; } } if ( WldoF == 0 ) { System . out . println ( " Good " ) ; } } } import java . util . Scanner ; public class DpkzkgPkgk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dpkzkgCsw = sc . nextInt ( ) ; int [ ] h = new int [ dpkzkgCsw ] ; int viewableCnt = 0 ; for ( int i = 0 ; i < dpkzkgCsw ; 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 nohwE { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String NohwMtevl = sc . next ( ) ; if ( Character . isUpperCase ( NohwMtevl . charAt ( 0 ) ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . Scanner ; public class HpsObfj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; boolean hpsMdr = S . contains ( " A " ) ; boolean containsB = S . contains ( " B " ) ; System . out . println ( ( hpsMdr && containsB ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class qvwRc { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; while ( true ) { int QvwKfnkc = Integer . parseInt ( std . next ( ) ) ; if ( QvwKfnkc == 0 ) { break ; } double [ ] score = new double [ QvwKfnkc ] ; double ave = 0 ; for ( int i = 0 ; i < QvwKfnkc ; i ++ ) { score [ i ] = Double . parseDouble ( std . next ( ) ) ; ave += score [ i ] ; } ave /= QvwKfnkc ; double sd = 0 ; for ( int i = 0 ; i < QvwKfnkc ; i ++ ) { sd += Math . pow ( ( score [ i ] - ave ) , 2 ) ; } sd /= QvwKfnkc ; sd = Math . pow ( sd , 0.5 ) ; System . out . println ( String . format ( " %.5f " , sd ) ) ; } } } import java . io . * ; import java . util . * ; public class LfhbhXrkq { private void solve ( ) { int lfhbhB = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; for ( int i = A ; i <= B ; ++ i ) { if ( i % lfhbhB == 0 ) { out . println ( " OK " ) ; return ; } } out . println ( " NG " ) ; } private static PrintWriter out ; private static MyScanner sc ; private static class LfhbhXrkq { 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 VkzSltw { public static void main ( String [ ] a ) { Scanner c = new Scanner ( System . in ) ; String s = c . next ( ) ; String t = c . next ( ) ; int vkzJw = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != t . charAt ( i ) ) vkzJw ++ ; } System . out . println ( vkzJw ) ; } } import java . util . Scanner ; public class BcuihrBw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bcuihrAc = sc . nextInt ( ) ; int [ ] result = new int [ bcuihrAc ] ; for ( int i = 1 ; sc . hasNextInt ( ) ; i ++ ) { result [ sc . nextInt ( ) - 1 ] = i ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < bcuihrAc ; i ++ ) { sb . append ( result [ i ] ) ; if ( i != bcuihrAc ) { sb . append ( " " ) ; } else { sb . append ( " \n " ) ; } } System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; public class arwiE { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ArwiYofo = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int l = scan . nextInt ( ) ; int [ ] [ ] vectorA = new int [ ArwiYofo ] [ m ] ; int [ ] [ ] vectorB = new int [ m ] [ l ] ; long [ ] [ ] vectorC = new long [ ArwiYofo ] [ l ] ; for ( int i = 0 ; i < ArwiYofo ; 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 < ArwiYofo ; 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 NdiJsx { public long getTotalHeightOfStools ( int n , int [ ] arr ) { long NdiUu = 0 ; int prevHeight = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( prevHeight > arr [ i ] ) { NdiUu += prevHeight - arr [ i ] ; arr [ i ] = prevHeight ; } prevHeight = arr [ i ] ; } return NdiUu ; } 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 ImnwenUqr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ImnwenBxg = sc . nextInt ( ) ; String [ ] a = new String [ ImnwenBxg ] ; for ( int i = 0 ; i < ImnwenBxg ; 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 MgajRk { private static Scanner sc ; private static Printer pr ; private static void solve ( ) { int MgajPh = 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 == MgajPh ) { 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 MgajRk extends PrintWriter { Printer ( OutputStream out ) { super ( out ) ; } } } import java . util . Scanner ; public class FaznkJb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int faznkH = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i < faznkH ; 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 FfqeXah { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ffqeMah = scan . nextInt ( ) ; int intH = scan . nextInt ( ) ; int intX = scan . nextInt ( ) ; int intY = scan . nextInt ( ) ; int intR = scan . nextInt ( ) ; if ( intX <= ffqeMah - 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 HffAlv { public static void main ( String [ ] args ) { int hffIpg ; double sum = 0.0 , m , v , t = 0.0 ; Scanner sc = new Scanner ( System . in ) ; while ( true ) { hffIpg = sc . nextInt ( ) ; if ( hffIpg == 0 ) break ; double [ ] A = new double [ hffIpg ] ; 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 TwbiamHpjk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > List = new ArrayList < > ( ) ; for ( int twbiamZ = 0 ; twbiamZ < 5 ; twbiamZ ++ ) { int j = sc . nextInt ( ) ; List . add ( j ) ; } int k = sc . nextInt ( ) ; int num = 0 ; for ( int twbiamZ = 0 ; twbiamZ < 4 ; twbiamZ ++ ) { for ( int j = twbiamZ + 1 ; j < 5 ; j ++ ) { if ( List . get ( j ) - List . get ( twbiamZ ) > k ) num ++ ; } } if ( num == 0 ) System . out . println ( " Yay! " ) ; else System . out . println ( " :( " ) ; } } import java . util . * ; public class EijMept { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Long > List = new ArrayList < > ( ) ; long EijD = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; for ( int i = 0 ; i < EijD ; 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 LqpboQms { 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 lqpboEnnw = Integer . parseInt ( st . nextToken ( ) ) + Integer . parseInt ( st . nextToken ( ) ) ; System . out . println ( ( int ) Math . log10 ( lqpboEnnw ) + 1 ) ; s = br . readLine ( ) ; } } catch ( Exception ex ) { System . exit ( 0 ) ; } } } import java . util . * ; public class vdatcNt { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int VdatcHkvpx = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; boolean [ ] bool = new boolean [ VdatcHkvpx + 1 ] ; for ( int i = 0 ; i <= VdatcHkvpx ; i ++ ) { bool [ i ] = true ; } for ( int i = 0 ; i < m ; i ++ ) { bool [ scanner . nextInt ( ) ] = false ; } int [ ] b = new int [ VdatcHkvpx + 1 ] ; b [ 0 ] = 1 ; b [ 1 ] = 1 ; int mod = 1000000007 ; for ( int i = 2 ; i <= VdatcHkvpx ; 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 [ VdatcHkvpx ] ) ; } } import java . util . Scanner ; public class YkicdtSi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String numbers = " 1 " ; int YkicdtXtp ; while ( true ) { numbers = scanner . nextLine ( ) ; if ( numbers . equals ( " 0 " ) ) break ; YkicdtXtp = 0 ; for ( int i = 0 ; i < numbers . length ( ) ; ++ i ) { YkicdtXtp += Character . getNumericValue ( numbers . charAt ( i ) ) ; } System . out . println ( YkicdtXtp ) ; } } } import java . util . * ; public class wmljkfDoh { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long WmljkfBmsxk = in . nextLong ( ) , c = 0 , s = 0 ; long k = in . nextLong ( ) ; long [ ] arr = new long [ ( int ) WmljkfBmsxk ] ; for ( int i = 0 ; i < WmljkfBmsxk ; i ++ ) { arr [ i ] = in . nextInt ( ) ; s = s + arr [ i ] ; } if ( k >= WmljkfBmsxk ) { System . out . println ( " 0 " ) ; System . exit ( 0 ) ; } Arrays . sort ( arr ) ; long mid = WmljkfBmsxk - 1 ; while ( c != k ) { s = s - arr [ ( int ) mid ] ; mid -- ; c ++ ; } System . out . println ( s ) ; } } import java . util . * ; public class OnszgOrqo { public static void main ( String [ ] args ) { PriorityQueue < String > caca = new PriorityQueue < String > ( ) ; Scanner scn = new Scanner ( System . in ) ; int onszgL = scn . nextInt ( ) ; int n2 = scn . nextInt ( ) ; for ( int i = 0 ; i < onszgL ; i ++ ) caca . add ( scn . next ( ) ) ; for ( int i = 0 ; i < onszgL ; 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 VedbZhdsl { public static void main ( String [ ] args ) throws Exception { Scanner fr = new Scanner ( System . in ) ; int VedbVdi = fr . nextInt ( ) ; int x = fr . nextInt ( ) ; int xx = x ; int t = fr . nextInt ( ) ; int tt = t ; if ( VedbVdi < x ) { System . out . println ( t ) ; } else { while ( x < VedbVdi ) { x += xx ; t += tt ; } System . out . println ( t ) ; } } } import java . util . Scanner ; public class juklwMhm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int JuklwTmhm = Integer . parseInt ( scanner . next ( ) ) ; int s = Integer . parseInt ( scanner . next ( ) ) ; if ( JuklwTmhm < 10 && s < 10 ) { System . out . println ( JuklwTmhm * s ) ; } else { System . out . println ( - 1 ) ; } scanner . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class SxkXsya { public static void main ( String [ ] args ) throws IOException { BufferedReader bis = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = bis . readLine ( ) ; int SxkOj = s . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < SxkOj ; 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 DzvqgCbij { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dzvqgOyv = sc . nextInt ( ) , a = sc . nextInt ( ) ; if ( dzvqgOyv % a == 0 ) System . out . println ( dzvqgOyv / a ) ; else System . out . println ( dzvqgOyv / a + 1 ) ; } } import java . util . * ; public class NnrVlt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nnrHr = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int ans = 0 ; int b = K - nnrHr ; int c = K - nnrHr - B ; if ( nnrHr == 0 && C == 0 ) { System . out . println ( " 0 " ) ; } else if ( K >= nnrHr && c < 1 ) { System . out . println ( nnrHr ) ; } else if ( K >= nnrHr && c >= 1 ) { System . out . println ( nnrHr + ( c * - 1 ) ) ; } else if ( K < nnrHr ) { System . out . println ( K ) ; } } } import java . util . Scanner ; public class DuytDxfw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int duytBhoj = sc . nextInt ( ) ; int [ ] a = new int [ duytBhoj ] ; 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 dfzGh { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int DfzZvd = sc . nextInt ( ) ; int [ ] d = new int [ 100001 ] ; for ( int i = 0 ; i < DfzZvd ; i ++ ) { d [ sc . nextInt ( ) ] ++ ; } int tmp = 0 ; int cnt = 0 ; for ( int i = 0 ; i < 100001 ; i ++ ) { tmp += d [ i ] ; if ( DfzZvd == tmp * 2 ) { cnt ++ ; } else if ( DfzZvd < tmp * 2 ) { break ; } } System . out . println ( cnt ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class MmtnnpRj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] best = { 0 , 0 , 0 } ; for ( int mmtnnpMel = 0 ; mmtnnpMel < 10 ; mmtnnpMel ++ ) { 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 DrgitQvy { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int DrgitP = in . nextInt ( ) ; String [ ] array = new String [ DrgitP ] ; for ( int i = 0 ; i < DrgitP ; 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 < DrgitP ; 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 ibjoeRe { private static int prime ( int a ) { if ( a == 2 || a == 3 ) return 1 ; for ( int IbjoeUxis = 2 ; IbjoeUxis < Math . sqrt ( a ) + 1 ; IbjoeUxis ++ ) { if ( a % IbjoeUxis == 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 OdueiVwhwu { public static long gcd ( long a , long b ) { while ( a % b != 0 ) { long OdueiAjb = a % b ; a = b ; b = OdueiAjb ; } 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 MhjeDr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mhjeR = sc . nextInt ( ) ; int result = 0 ; for ( int i = 1 ; i <= mhjeR ; 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 QpdRon { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QpdO = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = Integer . parseInt ( QpdO + " " + 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 SxixplYf { public static void main ( String [ ] args ) { Scanner Ent = new Scanner ( System . in ) ; int sxixplGbp = Ent . nextInt ( ) ; int Q = Ent . nextInt ( ) ; int R = Ent . nextInt ( ) ; int res1 = sxixplGbp + Q ; int res2 = R + Q ; int res3 = R + sxixplGbp ; System . out . println ( Math . min ( res1 , Math . min ( res2 , res3 ) ) ) ; } } import java . util . Scanner ; public class QmdnIg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QmdnZg = scan . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= QmdnZg ; i ++ ) { String mozi = String . valueOf ( i ) ; if ( mozi . length ( ) % 2 == 1 ) { count ++ ; } } System . out . println ( count ) ; scan . close ( ) ; } } import java . util . * ; public class RrsscWw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rrsscR = sc . nextInt ( ) ; Integer [ ] list = new Integer [ rrsscR ] ; for ( int i = 0 ; i < rrsscR ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } Integer [ ] sorted = Arrays . copyOf ( list , rrsscR ) ; Arrays . sort ( sorted ) ; String ans = " YES " ; int count = 0 ; for ( int i = 0 ; i < rrsscR ; 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 MfuLqncr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int MfuQnz = Integer . parseInt ( scan . next ( ) ) ; int m = Integer . parseInt ( scan . next ( ) ) ; Integer [ ] a = new Integer [ MfuQnz ] ; for ( int i = 0 ; i < MfuQnz ; 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 eajFbg { private static int gcd ( int EajRmavy , int b ) { if ( ( EajRmavy % b ) == 0 ) return b ; return gcd ( b , EajRmavy % b ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EajRmavy = sc . nextInt ( ) ; int tmp ; int count = 0 ; for ( int i = 1 ; i < EajRmavy + 1 ; i ++ ) { for ( int j = 1 ; j < EajRmavy + 1 ; j ++ ) { tmp = gcd ( i , j ) ; for ( int k = 1 ; k < EajRmavy + 1 ; k ++ ) { count += gcd ( k , tmp ) ; } } } System . out . println ( count ) ; } } import java . util . * ; public class JjloklZb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int jjloklUyz = scanner . nextInt ( ) ; String s = scanner . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { System . out . print ( ( char ) ( ( s . charAt ( i ) - 'A' + jjloklUyz ) % 26 + 'A' ) ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class gieKb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GieSjwfd = sc . nextInt ( ) ; int hp = 0 ; List < Integer > takoyaki = new ArrayList < Integer > ( ) ; takoyaki . add ( sc . nextInt ( ) ) ; for ( int i = 1 ; i < GieSjwfd ; 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 wrryjSxq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] ab = scanner . nextLine ( ) . split ( " " , 2 ) ; int WrryjUay = Integer . parseInt ( ab [ 0 ] ) ; int b = Integer . parseInt ( ab [ 1 ] ) ; String s = scanner . nextLine ( ) ; if ( WrryjUay + b + 1 != s . length ( ) ) { System . out . println ( " No " ) ; return ; } for ( int i = 0 ; i <= WrryjUay + b ; i ++ ) { char ch = s . charAt ( i ) ; if ( i == WrryjUay ) { 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 OylQvnw { static boolean OylRw = 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 HpdkHji { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HpdkJna = sc . nextInt ( ) ; int sp = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int [ ] point = new int [ HpdkJna ] ; 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 aalhG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int AalhUcil = s . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < AalhUcil ; i ++ ) { for ( int j = i + 1 ; j <= AalhUcil ; 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 AwrkauAtzqnn { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { int AwrkauCp = Integer . parseInt ( reader . readLine ( ) ) ; int n = Integer . parseInt ( reader . readLine ( ) ) ; int [ ] x = new int [ AwrkauCp ] ; for ( int i = 0 ; i < AwrkauCp ; 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 < AwrkauCp ; i ++ ) { System . out . println ( x [ i ] ) ; } } catch ( IOException e ) { } } } import java . util . * ; public class dvxxbUb { static long DvxxbPxqps = 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 MbtmJdgpwi { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; char [ ] s = in . next ( ) . toCharArray ( ) ; boolean MbtmFrw = false ; boolean B = false ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == 'A' ) MbtmFrw = true ; if ( s [ i ] == 'B' ) B = true ; } if ( MbtmFrw && B ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class eztlxLy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EztlxYg = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] tmp = s . toCharArray ( ) ; for ( int i = 0 ; i < tmp . length ; i ++ ) { int j = EztlxYg ; 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 OntxdjSh { long OntxdjM = 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 MeepKbuimx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MeepN = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( method ( MeepN , b , c ) ) ; } static int method ( int MeepN , int b , int c ) { int divisor = 0 ; for ( int i = MeepN ; i < b + 1 ; i ++ ) { if ( c % i == 0 ) { divisor ++ ; } } return divisor ; } } import java . util . Scanner ; public class IbitKl { public static void main ( String [ ] args ) { Main2 cc = new Main2 ( ) ; cc . yesNo ( ) ; } } class IbitKl { public void yesNo ( ) { Scanner scan = new Scanner ( System . in ) ; int [ ] abc = new int [ 3 ] ; for ( int IbitE = 0 ; IbitE < 3 ; IbitE ++ ) { abc [ IbitE ] = 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 CfjtnYldhm { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] arr = new int [ 3 ] ; for ( int CfjtnDre = 0 ; CfjtnDre < 3 ; CfjtnDre ++ ) { arr [ CfjtnDre ] = 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 tsywK { 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 TsywGhz = readInt ( ) ; long D = readInt ( ) ; long D_squared = D * D ; int count = 0 ; for ( int i = 0 ; i < TsywGhz ; i ++ ) { long dx = readInt ( ) ; long dy = readInt ( ) ; if ( dx * dx + dy * dy <= D_squared ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class cbzgvUhg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CbzgvXxtnd = sc . nextInt ( ) ; String [ ] a = new String [ CbzgvXxtnd ] ; for ( int i = 0 ; i < CbzgvXxtnd ; i ++ ) { a [ i ] = sc . next ( ) ; } sc . close ( ) ; Arrays . sort ( a ) ; int yono = 1 ; for ( int i = 1 ; i < CbzgvXxtnd ; i ++ ) { if ( ! a [ i - 1 ] . equals ( a [ i ] ) ) yono ++ ; } System . out . println ( yono ) ; } } import java . util . Scanner ; public class tsnkmgEs { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int TsnkmgUrc = 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 == TsnkmgUrc ? " " : s . substring ( k ) ) ; System . out . println ( pre + conv + next ) ; } } import java . util . * ; class SywomLei { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sywomYwlj = sc . nextInt ( ) ; int [ ] a = new int [ sywomYwlj + 1 ] ; int [ ] w = new int [ sywomYwlj + 1 ] ; int [ ] s = new int [ sywomYwlj + 1 ] ; int [ ] indice = new int [ sywomYwlj ] ; a [ 0 ] = 0 ; for ( int i = 1 ; i <= sywomYwlj ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int nr_breaks = 0 ; int cur = 1 ; for ( int i = 1 ; i <= sywomYwlj ; i ++ ) { if ( a [ i ] == cur ) { cur ++ ; } else { nr_breaks ++ ; } } if ( nr_breaks == sywomYwlj ) { System . out . println ( - 1 ) ; } else { System . out . println ( nr_breaks ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class JjgxhVj { 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 JjgxhUa , b , t , gdc ; long lcm ; StringBuilder result = new StringBuilder ( ) ; while ( true ) { if ( ( ( line = br . readLine ( ) ) == null ) || line . isEmpty ( ) ) break ; num = line . split ( " " ) ; JjgxhUa = Integer . parseInt ( num [ 0 ] ) ; b = Integer . parseInt ( num [ 1 ] ) ; if ( JjgxhUa < b ) { t = JjgxhUa ; JjgxhUa = b ; b = t ; } gdc = gdc ( JjgxhUa , b ) ; lcm = lcm ( JjgxhUa , 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 IdkuvBjllf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IdkuvJv = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= IdkuvJv ; 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 NttHyko { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; String ans = " " ; for ( int nttJxkl = 0 ; nttJxkl < line . length ( ) ; nttJxkl ++ ) { String str = line . substring ( nttJxkl , nttJxkl + 1 ) ; if ( str . equals ( str . toUpperCase ( ) ) ) { ans += str . toLowerCase ( ) ; } else { ans += str . toUpperCase ( ) ; } } System . out . println ( ans ) ; } } import java . util . * ; public class QxumadPb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String o = " " ; long qxumadU = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; k = k - qxumadU ; qxumadU = Math . max ( - k , 0 ) ; if ( k > 0 ) b = Math . max ( b - k , 0 ) ; o = Long . toString ( qxumadU , 10 ) + " " + Long . toString ( b , 10 ) ; System . out . println ( o ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class jvbpUsr { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int JvbpEv , b ; ArrayList < String > str = new ArrayList < String > ( ) ; String [ ] result ; while ( s . hasNext ( ) ) { JvbpEv = s . nextInt ( ) ; b = s . nextInt ( ) ; System . out . println ( String . valueOf ( JvbpEv + b ) . length ( ) ) ; } } } import java . util . ArrayList ; import java . util . Comparator ; import java . util . List ; import java . util . Scanner ; class hxjhiFgo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HxjhiKg = Integer . parseInt ( sc . next ( ) ) ; List < Integer > numList = new ArrayList < > ( ) ; for ( int i = 0 ; i < HxjhiKg ; 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 EjgfbNutonr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EjgfbK = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; int result = EjgfbK * b ; System . out . println ( result ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class RwvxJh { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int RwvxJ = stdIn . nextInt ( ) ; int [ ] a = new int [ RwvxJ ] ; int [ ] b = new int [ RwvxJ ] ; int high = 0 ; for ( int i = 0 ; i < RwvxJ ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; b [ i ] = a [ i ] ; high = Math . max ( high , a [ i ] ) ; } Arrays . sort ( b ) ; for ( int i = 0 ; i < RwvxJ ; i ++ ) { if ( a [ i ] != high ) { System . out . println ( high ) ; } else { System . out . println ( b [ RwvxJ - 2 ] ) ; } } } } import java . util . Scanner ; public class TrhgGcra { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int trhgQun = sc . nextInt ( ) ; for ( int i = trhgQun ; 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 AzelasDrygh { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int AzelasD = Integer . parseInt ( sc . nextLine ( ) ) ; int counter = 0 ; int [ ] [ ] result = new int [ AzelasD ] [ 2 ] ; for ( int i = 0 ; i < AzelasD ; i ++ ) { result [ i ] [ 0 ] = sc . nextInt ( ) ; result [ i ] [ 1 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < AzelasD ; 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 ldpoWex { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int LdpoYgu = scan . nextInt ( ) ; int S = scan . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i <= LdpoYgu ; i ++ ) { for ( int j = 0 ; j <= LdpoYgu ; j ++ ) { if ( S - i - j >= 0 && S - i - j <= LdpoYgu ) 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 CyrLrzd { static Scanner scn = new Scanner ( System . in ) ; static long cyrA = 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 ) { cyrA ++ ; 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 YiziLy { 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 yiziZb = Integer . parseInt ( tmpArray [ 0 ] ) ; int b = Integer . parseInt ( tmpArray [ 1 ] ) ; if ( yiziZb == 0 && b == 0 ) { break ; } for ( int i = 0 ; i < yiziZb ; i ++ ) { for ( int j = 0 ; j < b ; j ++ ) { if ( i != 0 && i != yiziZb - 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 JfaxPatm { 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 JfaxG = 0 ; boolean doContinue = true ; for ( int i = 0 ; doContinue ; i ++ ) { if ( s % 2 == 0 ) { if ( list . contains ( s / 2 ) ) { JfaxG = i + 2 ; doContinue = false ; } else { s = s / 2 ; list . add ( s ) ; } } else { if ( list . contains ( 3 * s + 1 ) ) { JfaxG = i + 2 ; doContinue = false ; } else { s = 3 * s + 1 ; list . add ( s ) ; } } } System . out . println ( JfaxG ) ; sc . close ( ) ; } } import java . util . Scanner ; public class ttcnjhIna { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TtcnjhYrdr = Integer . parseInt ( sc . next ( ) ) ; int D = Integer . parseInt ( sc . next ( ) ) ; int [ ] [ ] arrayTwoDimension = new int [ TtcnjhYrdr ] [ D ] ; for ( int i = 0 ; i < TtcnjhYrdr ; i ++ ) { for ( int j = 0 ; j < D ; j ++ ) { arrayTwoDimension [ i ] [ j ] = sc . nextInt ( ) ; } } sc . close ( ) ; int count = 0 ; for ( int i = 0 ; i < TtcnjhYrdr ; i ++ ) { for ( int j = i + 1 ; j < TtcnjhYrdr ; 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 NjvqhZl { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String input = stdIn . nextLine ( ) ; String [ ] a = input . split ( " " ) ; int njvqhOua = Integer . parseInt ( a [ 0 ] ) ; int y = Integer . parseInt ( a [ 1 ] ) ; if ( njvqhOua > 0 && njvqhOua < 101 && y > 0 && y < 101 ) { int ans = y - njvqhOua * 2 ; if ( ans == 0 ) { System . out . println ( " Yes " ) ; } else if ( ans > 0 && ( ans % 2 ) == 0 ) { for ( int i = 0 ; i < njvqhOua ; 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 CpcdNsdry { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CpcdS = 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 < CpcdS ; 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 EurcWsfoad { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int EurcNqs = scanner . nextInt ( ) ; String N = scanner . next ( ) ; if ( N . length ( ) <= EurcNqs ) { System . out . println ( N ) ; } else { System . out . println ( N . substring ( 0 , EurcNqs ) + " ... " ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class kyzRb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KyzInf = Integer . parseInt ( sc . next ( ) ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Math . min ( KyzInf * a , b ) ; System . out . println ( c ) ; } } import java . util . * ; public class AlukBslleg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int AlukEc = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = AlukEc * a ; if ( ans >= b ) { ans = b ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class PzkoeTjbn { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int PzkoeWp = reader . nextInt ( ) ; int [ ] arr = new int [ PzkoeWp ] ; int a = 0 ; int b = 0 ; for ( int i = 0 ; i < PzkoeWp ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; } Arrays . sort ( arr ) ; for ( int i = PzkoeWp - 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 EiqkblDbycb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EiqkblY = 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 ( EiqkblY + b , c * 2 ) ; x -= xymin ; y -= xymin ; if ( x == 0 ) { ans += y * Math . min ( b , c * 2 ) ; } else { ans += x * Math . min ( EiqkblY , c * 2 ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class LizfFz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LizfDh = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = LizfDh * ( LizfDh - 1 ) / 2 ; int d = b * ( b - 1 ) / 2 ; System . out . println ( c + d ) ; } } import java . util . Scanner ; class EtjPr { public static void main ( String [ ] arg ) { Scanner in = new Scanner ( System . in ) ; String input = in . nextLine ( ) ; while ( ! input . equals ( " - " ) ) { String tmp = in . nextLine ( ) ; int etjL = Integer . parseInt ( tmp ) ; StringBuffer sb = new StringBuffer ( input ) ; for ( int i = 0 ; i < etjL ; 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 VnivpjTji { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int VnivpjAi = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; int [ ] cnts = new int [ M ] ; for ( int i = 0 ; i < VnivpjAi ; 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 ] == VnivpjAi ) { cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class uvdgA { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int UvdgPc = scanner . nextInt ( ) ; if ( UvdgPc < 105 ) { UvdgPc = 0 ; } else if ( UvdgPc < 135 ) { UvdgPc = 1 ; } else if ( UvdgPc < 165 ) { UvdgPc = 2 ; } else if ( UvdgPc < 189 ) { UvdgPc = 3 ; } else if ( UvdgPc < 195 ) { UvdgPc = 4 ; } else { UvdgPc = 5 ; } System . out . println ( UvdgPc ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class JhlafKm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JhlafY = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int [ ] times = new int [ 3 ] ; times [ 0 ] = JhlafY + q ; times [ 1 ] = q + r ; times [ 2 ] = r + JhlafY ; 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 dmpbT { public static void main ( String [ ] args ) { Scanner s1 = new Scanner ( System . in ) ; int DmpbOb = s1 . nextInt ( ) ; int A = s1 . nextInt ( ) ; int B = s1 . nextInt ( ) ; for ( int i = A ; i <= B ; i ++ ) { if ( i % DmpbOb == 0 ) { System . out . println ( " OK " ) ; return ; } } System . out . println ( " NG " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class DqgbgUfhv { 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 dqgbgRha = 0 ; dqgbgRha < table . length ; dqgbgRha ++ ) { table [ dqgbgRha ] = key . length ( ) ; } for ( int dqgbgRha = 0 ; dqgbgRha < key . length ( ) ; dqgbgRha ++ ) { table [ key . charAt ( dqgbgRha ) ] = key . length ( ) - dqgbgRha - 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 DgwnKr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DgwnRl = sc . nextInt ( ) ; int [ ] a = new int [ DgwnRl ] ; for ( int i = 0 ; i < DgwnRl ; i ++ ) { a [ i ] = sc . nextInt ( ) - 1 ; } int x = 0 ; int c = 0 ; for ( int i = 0 ; i < DgwnRl ; i ++ ) { c ++ ; x = a [ x ] ; if ( x == 1 ) { System . out . println ( c ) ; return ; } } System . out . println ( " -1 " ) ; } } import java . util . Scanner ; class NmawIbbny { 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 ZlxnLat { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] num = new int [ 3000 ] ; int [ ] num2 = new int [ 3000 ] ; for ( int ZlxnZix = 0 ; ZlxnZix < 3000 ; ZlxnZix ++ ) { String line = sc . nextLine ( ) ; String [ ] ss = line . split ( " " ) ; num [ ZlxnZix ] = Integer . parseInt ( ss [ 0 ] ) ; num2 [ ZlxnZix ] = Integer . parseInt ( ss [ 1 ] ) ; if ( num [ ZlxnZix ] == 0 && num2 [ ZlxnZix ] == 0 ) { break ; } } for ( int ZlxnZix = 0 ; ZlxnZix < num . length ; ZlxnZix ++ ) { if ( num [ ZlxnZix ] == 0 && num2 [ ZlxnZix ] == 0 ) { break ; } if ( num [ ZlxnZix ] < num2 [ ZlxnZix ] ) { System . out . println ( num [ ZlxnZix ] + " " + num2 [ ZlxnZix ] ) ; } if ( num [ ZlxnZix ] > num2 [ ZlxnZix ] ) { System . out . println ( num2 [ ZlxnZix ] + " " + num [ ZlxnZix ] ) ; } if ( num [ ZlxnZix ] == num2 [ ZlxnZix ] ) { System . out . println ( num [ ZlxnZix ] + " " + num2 [ ZlxnZix ] ) ; } } } } import java . util . * ; public class LjduzIc { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " Yes " ; for ( int LjduzAtx = 0 ; LjduzAtx < s . length ( ) ; LjduzAtx ++ ) { if ( LjduzAtx % 2 == 0 && s . charAt ( LjduzAtx ) == 'L' ) { ans = " No " ; break ; } else if ( LjduzAtx % 2 == 1 && s . charAt ( LjduzAtx ) == 'R' ) { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; class hfvqtKr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int HfvqtOuh = scanner . nextInt ( ) ; int t = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; System . out . print ( t * s >= HfvqtOuh ? " Yes " : " No " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class OqzpxcDoh { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int oqzpxcJw = s . nextInt ( ) ; int b = s . nextInt ( ) ; int c = s . nextInt ( ) ; int d = s . nextInt ( ) ; int ans1 = 0 , ans2 = 0 ; if ( oqzpxcJw % d == 0 ) { ans1 = oqzpxcJw / d ; } else { ans1 = oqzpxcJw / 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 TcsJtj { public static void main ( String [ ] args ) { int TcsO = 0 ; int x = 0 ; Scanner scan = new Scanner ( System . in ) ; TcsO = scan . nextInt ( ) ; for ( int i = 1 ; i != TcsO + 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 TedwveSvacn { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int TedwveTv = s . nextInt ( ) ; String a = s . next ( ) , b = s . next ( ) ; char [ ] c = new char [ TedwveTv * 2 ] ; for ( int i = 0 ; i < TedwveTv ; ++ 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 HebuzgVioxh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long HebuzgGod = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = a * ( HebuzgGod / ( a + b ) ) ; HebuzgGod %= ( a + b ) ; if ( HebuzgGod >= a ) { System . out . println ( ans + a ) ; } else { System . out . println ( ans + HebuzgGod ) ; } } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class lksqumVay { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LksqumLn = sc . nextInt ( ) ; Integer [ ] arrays = new Integer [ LksqumLn ] ; 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 WkcsbhSgcaor { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WkcsbhSuj = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( solve ( WkcsbhSuj , B ) ) ; sc . close ( ) ; } static int solve ( int WkcsbhSuj , int B ) { if ( WkcsbhSuj >= 13 ) { return B ; } else if ( WkcsbhSuj >= 6 ) { return B / 2 ; } else { return 0 ; } } } import java . util . * ; public class VbqAn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vbqFpf = sc . nextInt ( ) ; int [ ] arr = new int [ vbqFpf ] ; for ( int i = 0 ; i < vbqFpf ; 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 bghehIwg { 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 BghehAqw = 0 ; for ( int i = 0 ; i < str_split . length ; i ++ ) { switch ( str_split [ i ] . charAt ( 0 ) ) { case '+' : BghehAqw -- ; nums [ BghehAqw - 1 ] = nums [ BghehAqw - 1 ] + nums [ BghehAqw ] ; break ; case '-' : BghehAqw -- ; nums [ BghehAqw - 1 ] = nums [ BghehAqw - 1 ] - nums [ BghehAqw ] ; break ; case '*' : BghehAqw -- ; nums [ BghehAqw - 1 ] = nums [ BghehAqw - 1 ] * nums [ BghehAqw ] ; break ; default : nums [ BghehAqw ] = Integer . parseInt ( str_split [ i ] ) ; BghehAqw ++ ; break ; } } System . out . println ( nums [ 0 ] ) ; } } import java . util . Scanner ; public class CelqdZzldj { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long CelqdK , 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 hmzkqP { 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 HmzkqOnbvu = Integer . parseInt ( input [ 0 ] ) ; int a = Integer . parseInt ( input [ 1 ] ) ; int b = Integer . parseInt ( input [ 2 ] ) ; int ans = 0 ; for ( int i = 1 ; i <= HmzkqOnbvu ; 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 CoxFr { 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 CoxEsl = 0 ; CoxEsl < s . length ; CoxEsl ++ ) { if ( n == s . length ) { System . out . println ( " No " ) ; break ; } else if ( s [ CoxEsl + n >= s . length ? CoxEsl + n - s . length : CoxEsl + n ] != p [ CoxEsl ] ) { n ++ ; func ( s , p , n ) ; break ; } else if ( CoxEsl == p . length - 1 ) { System . out . println ( " Yes " ) ; break ; } } } } import java . util . * ; public class LfalbRp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lfalbIfr = sc . nextInt ( ) ; long [ ] b = new long [ lfalbIfr ] ; long MAX = ( long ) Math . pow ( 10 , 18 ) ; long result = 1 ; for ( int i = 0 ; i < lfalbIfr ; i ++ ) { b [ i ] = sc . nextLong ( ) ; if ( b [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } for ( int i = 0 ; i < lfalbIfr ; 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 QtrEe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QtrPct = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; Integer [ ] button = { QtrPct , b , QtrPct - 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 mlqhPaz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( new BufferedInputStream ( System . in ) ) ; int MlqhGubyv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( MlqhGubyv + 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 NczCp { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int NczRb = in . nextInt ( ) ; int B = in . nextInt ( ) ; String S = in . next ( ) ; char [ ] s_chars = S . toCharArray ( ) ; int flag = 0 ; if ( s_chars [ NczRb ] == '-' ) { for ( int i = 0 ; i < NczRb + 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 AayUmwjw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double AayY = sc . nextDouble ( ) ; double H = sc . nextDouble ( ) ; double x = sc . nextDouble ( ) ; double y = sc . nextDouble ( ) ; System . out . printf ( " %.6f " , AayY * H / 2 ) ; if ( x == AayY / 2 && y == H / 2 ) { System . out . println ( 1 ) ; } else { System . out . println ( 0 ) ; } } } import java . util . * ; class RfvMg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String rfvStb = sc . next ( ) ; rfvStb = rfvStb . replace ( " 1 " , " * " ) . replace ( " 9 " , " 1 " ) . replace ( " * " , " 9 " ) ; System . out . println ( rfvStb ) ; } } import java . util . Scanner ; public class itasltQs { public static void main ( String ... args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int ItasltNpk = 0 ; String [ ] s = sc . next ( ) . split ( " " ) ; for ( String i : s ) { if ( i . equals ( " + " ) ) { ItasltNpk ++ ; } else { ItasltNpk -- ; } } System . out . println ( ItasltNpk ) ; } } } import java . math . BigDecimal ; import java . math . RoundingMode ; import java . util . HashMap ; import java . util . Scanner ; public class psaSn { 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 VyfkJbh { public static void main ( String [ ] args ) { solve ( ) ; } public static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int vyfkKox = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] ans = new int [ vyfkKox ] ; 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 < vyfkKox ; i ++ ) { out . println ( ans [ i ] ) ; } out . flush ( ) ; } static class VyfkJbh { 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 EhjbHoy { 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 EhjbHoy { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String x = in . next ( ) ; for ( int EhjbG = 0 ; EhjbG < 3 ; EhjbG ++ ) { if ( x . charAt ( EhjbG ) != x . charAt ( ( EhjbG + 1 ) % 3 ) ) { out . println ( " Yes " ) ; return ; } } out . println ( " No " ) ; } } static class EhjbHoy { 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 PxwIorqxs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String PxwCwx = sc . next ( ) ; if ( PxwCwx . equals ( " MON " ) ) { System . out . println ( 6 ) ; } else if ( PxwCwx . equals ( " TUE " ) ) { System . out . println ( 5 ) ; } else if ( PxwCwx . equals ( " WED " ) ) { System . out . println ( 4 ) ; } else if ( PxwCwx . equals ( " THU " ) ) { System . out . println ( 3 ) ; } else if ( PxwCwx . equals ( " FRI " ) ) { System . out . println ( 2 ) ; } else if ( PxwCwx . equals ( " SAT " ) ) { System . out . println ( 1 ) ; } else if ( PxwCwx . equals ( " SUN " ) ) { System . out . println ( 7 ) ; } } } import java . util . * ; public class WcjQpjpyd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WcjVeq = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; int min = 300 , total = 0 ; for ( int i = 1 ; i <= WcjVeq ; i ++ ) { total += L + i - 1 ; } if ( L >= 0 ) { System . out . println ( total - L ) ; } else if ( L < 0 ) { if ( L + WcjVeq > 0 ) { System . out . println ( total ) ; } else { System . out . println ( total - ( L + WcjVeq - 1 ) ) ; } } } } import java . io . * ; import java . util . * ; import java . lang . * ; class RwuzyyPe { 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 RwuzyyDi = 'a' ; RwuzyyDi <= 'z' ; RwuzyyDi ++ ) { int count = 0 ; for ( int j = 0 ; j < input . length ( ) ; j ++ ) { if ( input . toString ( ) . charAt ( j ) == RwuzyyDi || Character . toUpperCase ( input . toString ( ) . charAt ( j ) ) == Character . toUpperCase ( RwuzyyDi ) ) { count ++ ; } } System . out . println ( RwuzyyDi + " : " + count ) ; } } } import java . util . * ; public class OllTt { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ollBhiq = Integer . MAX_VALUE ; int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < 5 ; i ++ ) { int n = sc . nextInt ( ) ; ollBhiq = Math . ollBhiq ( ollBhiq , n ) ; max = Math . max ( max , n ) ; } int k = sc . nextInt ( ) ; if ( max - ollBhiq > k ) System . out . println ( " :( " ) ; else System . out . println ( " Yay! " ) ; } } import java . util . * ; class OcpcouNp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long OcpcouQs = sc . nextInt ( ) ; long quo = OcpcouQs / 15 ; long rem = OcpcouQs % 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 umdrpyJhc { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { while ( sc . hasNext ( ) ) { int UmdrpyYj = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( digit ( UmdrpyYj , b ) ) ; } } private static int digit ( int UmdrpyYj , int b ) { int dg = Integer . toString ( UmdrpyYj + b ) . length ( ) ; return dg ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class AdzPgnw { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = reader . readLine ( ) . split ( " " ) ; int AdzV = Integer . parseInt ( str [ 0 ] ) ; int B = Integer . parseInt ( str [ 1 ] ) ; if ( 1 <= AdzV && AdzV <= 9 && 1 <= B && B <= 9 ) { System . out . println ( AdzV * B ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . Scanner ; public class EirmdhAe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EirmdhH = sc . nextInt ( ) ; int [ ] a = new int [ EirmdhH ] ; for ( int i = 0 ; i < EirmdhH ; 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 VhxKi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int vhxZy = scan . nextInt ( ) ; int money = scan . nextInt ( ) ; if ( vhxZy >= 13 ) { System . out . print ( money ) ; } else if ( vhxZy >= 6 ) { System . out . print ( money / 2 ) ; } else if ( vhxZy >= 0 ) { System . out . print ( 0 ) ; } } } import java . util . Scanner ; public class bddtumIh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BddtumHanf = sc . nextInt ( ) ; int [ ] array = new int [ BddtumHanf ] ; for ( int i = 1 ; i < BddtumHanf ; i ++ ) array [ sc . nextInt ( ) - 1 ] ++ ; sc . close ( ) ; for ( int i = 0 ; i < BddtumHanf ; i ++ ) System . out . println ( array [ i ] ) ; } } import java . util . * ; public class TnxpiCfm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; int TnxpiO = 0 ; int count1 = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '1' ) count1 ++ ; if ( S . charAt ( i ) == '0' ) TnxpiO ++ ; } System . out . println ( 2 * Math . min ( count1 , TnxpiO ) ) ; } } import java . util . * ; public class KvaQne { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String [ ] line = sc . nextLine ( ) . split ( " " ) ; int kvaUb = Integer . parseInt ( line [ 0 ] ) ; int buttonB = Integer . parseInt ( line [ 1 ] ) ; int ans = 0 ; if ( kvaUb > buttonB ) { ans += kvaUb ; kvaUb -- ; } else { ans += buttonB ; buttonB -- ; } if ( kvaUb > buttonB ) { ans += kvaUb ; } else { ans += buttonB ; } System . out . println ( ans ) ; } } import java . math . BigInteger ; import java . util . * ; public class zizbpQab { 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 ArxhPemky { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ArxhVj = sc . nextInt ( ) ; double a = 2 * ArxhVj * 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 ddbC { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] tmp = br . readLine ( ) . split ( " " ) ; int DdbPo = 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 edhgpPk { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int EdhgpWy = sc . nextInt ( ) ; int debt = 100000 ; int roundUpNum = 1000 ; for ( int i = 0 ; i < EdhgpWy ; 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 qqqffbM { public static void main ( String [ ] args ) { execute16_4 ( ) ; } private static void execute16_4 ( ) { try ( Scanner sc = new Scanner ( System . in ) ) { int QqqffbGpg = sc . nextInt ( ) ; System . out . println ( QqqffbGpg + QqqffbGpg * QqqffbGpg + QqqffbGpg * QqqffbGpg * QqqffbGpg ) ; } } } import java . util . Scanner ; public class bqufinX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BqufinHin = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; if ( BqufinHin >= 10 || B >= 10 ) { System . out . println ( - 1 ) ; } else { System . out . println ( BqufinHin * B ) ; } } } import java . util . Scanner ; public class GwexfHc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GwexfVxv = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; if ( N <= 99 ) { System . out . print ( N * ( int ) Math . pow ( 100 , GwexfVxv ) ) ; } else if ( N == 100 ) { System . out . print ( 101 * ( int ) Math . pow ( 100 , GwexfVxv ) ) ; } } } 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 plgnwOvx { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; MyScanner in = new MyScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; PlgnwPrawk solver = new PlgnwPrawk ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class plgnwOvx { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { int PlgnwPrawk = in . Int ( ) ; int B = in . Int ( ) ; out . println ( PlgnwPrawk * B ) ; } } static class plgnwOvx { 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 JixWeupi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JixZh = sc . nextInt ( ) ; String s = sc . next ( ) ; sc . close ( ) ; boolean sa = false ; boolean sine = false ; if ( JixZh % 2 != 0 ) { System . out . println ( " No " ) ; sine = true ; } else { int [ ] a = new int [ JixZh / 2 ] ; int [ ] b = new int [ JixZh / 2 ] ; for ( int i = 0 ; i < JixZh / 2 ; i ++ ) { a [ i ] = s . charAt ( i ) ; b [ i ] = s . charAt ( i + JixZh / 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 OynEvfy { static int OynHw ; static int [ ] w ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; OynHw = scanner . nextInt ( ) ; w = new int [ OynHw ] ; for ( int i = 0 ; i < OynHw ; i ++ ) { w [ i ] = scanner . nextInt ( ) ; } scanner . close ( ) ; int ans = Integer . MAX_VALUE ; int s1 = 0 ; for ( int i = 0 ; i < OynHw - 1 ; i ++ ) { int s2 = 0 ; for ( int j = OynHw - 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 yzcraX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YzcraJtqkj = sc . nextInt ( ) ; long a = 0 ; for ( int i = 0 ; i <= YzcraJtqkj ; 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 WsiXv { public static void main ( String [ ] args ) { Scanner sca = new Scanner ( System . in ) ; String c = sca . next ( ) ; char WsiSy = c . charAt ( 0 ) ; System . out . println ( ( char ) ( WsiSy + 1 ) ) ; sca . close ( ) ; } } import java . util . Scanner ; public class JszyZzk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jszyZyja = sc . nextInt ( ) ; int strLen = sc . nextInt ( ) ; sc . nextLine ( ) ; String [ ] strs = new String [ jszyZyja ] ; for ( int i = 0 ; i < jszyZyja ; i ++ ) { strs [ i ] = sc . nextLine ( ) ; } for ( int i = 0 ; i < jszyZyja ; i ++ ) { for ( int j = i + 1 ; j < jszyZyja ; 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 UgzeKs { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ugzePkcl = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] m = new int [ ugzePkcl ] ; for ( int i = 0 ; i < ugzePkcl ; 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 WfvyrHjq { 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 visPoo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int VisAsl = 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 KwareJbch { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long kwareWnk = sc . nextLong ( ) ; long start = 100 ; int answer = 0 ; while ( kwareWnk > start ) { start += start / 100 ; answer ++ ; } System . out . println ( answer ) ; sc . close ( ) ; } } import java . util . Scanner ; class DzhRvci { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dzhPo = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int ans = ( ( dzhPo + ( 2 * K + 1 ) - 1 ) ) / ( 2 * K + 1 ) ; System . out . print ( ans ) ; } } import java . util . * ; class FyxVkf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fyxVgp = sc . nextInt ( ) ; int [ ] a = new int [ fyxVgp ] ; for ( int i = 0 ; i < fyxVgp ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; System . out . println ( a [ ( fyxVgp - 1 ) / 2 + 1 ] - a [ ( fyxVgp - 1 ) / 2 ] ) ; } } import java . util . Scanner ; public class AxbSikb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int AxbB = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; boolean [ ] judge = new boolean [ AxbB ] ; 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 qfqsNn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String number ; char [ ] ca ; int QfqsXfpl ; for ( ; ; ) { number = scan . next ( ) ; ca = number . toCharArray ( ) ; QfqsXfpl = 0 ; if ( ca [ 0 ] == '0' ) { break ; } for ( int i = 0 ; i < ca . length ; i ++ ) { QfqsXfpl += ca [ i ] - '0' ; } System . out . println ( QfqsXfpl ) ; } } } import java . util . * ; public class QxgyrvPu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qxgyrvBz = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int end = l + qxgyrvBz - 1 ; int sum ; if ( l >= 0 ) { sum = ( l + 1 + end ) * ( qxgyrvBz - 1 ) / 2 ; } else if ( end > 0 ) { sum = ( l + end ) * qxgyrvBz / 2 ; } else { sum = ( l + end - 1 ) * ( qxgyrvBz - 1 ) / 2 ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class xrlgsqEuh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XrlgsqBx = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; StringBuilder answer = new StringBuilder ( ) ; for ( int i = 0 ; i < XrlgsqBx ; 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 ZyimWdj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zyimGiy = sc . nextInt ( ) ; String ans = " APPROVED " ; int tmp ; for ( int i = 0 ; i < zyimGiy ; 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 SajkicNvws { Scanner sc = new Scanner ( System . in ) ; void doIt ( ) { sC ( ) ; } void sC ( ) { String s = sc . next ( ) ; int sajkicSbez = 0 , one = 0 ; char [ ] c = s . toCharArray ( ) ; for ( int i = 0 ; i < c . length ; i ++ ) { if ( c [ i ] == '0' ) sajkicSbez ++ ; else one ++ ; } if ( one > sajkicSbez ) { System . out . println ( sajkicSbez * 2 ) ; } else System . out . println ( one * 2 ) ; } public static void main ( String [ ] args ) { new Main ( ) . doIt ( ) ; } } import java . util . * ; public class RfpLy { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int rfpU = stdIn . nextInt ( ) ; int [ ] flag = new int [ 101 ] ; Arrays . fill ( flag , 0 ) ; for ( int i = 0 ; i < rfpU ; 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 MxovMddl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter ou = new PrintWriter ( System . out ) ; int MxovBe = Integer . parseInt ( sc . next ( ) ) ; int h = Integer . parseInt ( sc . next ( ) ) ; boolean ebishu = false ; if ( MxovBe == 2 * Integer . parseInt ( sc . next ( ) ) && h == 2 * Integer . parseInt ( sc . next ( ) ) ) ebishu = true ; ou . print ( MxovBe * ( long ) h / 2.0 + " " ) ; if ( ebishu ) ou . print ( 1 + " \n " ) ; else ou . print ( 0 + " \n " ) ; ou . flush ( ) ; } } import java . util . * ; public class kudocTa { 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 KudocTt = 0 ; KudocTt < x + 1 ; KudocTt ++ ) { Integer sum = 2 * KudocTt + 4 * ( x - KudocTt ) ; if ( sum == y ) ans = " Yes " ; } System . out . println ( ans ) ; } } import java . util . * ; public class JcssboIj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int JcssboBks = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; String postal = sc . next ( ) ; String [ ] decomp = new String [ 3 ] ; decomp [ 0 ] = postal . substring ( 0 , JcssboBks ) ; decomp [ 1 ] = postal . substring ( JcssboBks , JcssboBks + 1 ) ; decomp [ 2 ] = postal . substring ( JcssboBks + 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 RkoPac { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rkoZa , n ; rkoZa = sc . nextInt ( ) ; n = sc . nextInt ( ) ; int [ ] ans ; ans = new int [ rkoZa + 1 ] ; for ( int i = 0 ; i <= rkoZa ; 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 <= rkoZa ; i ++ ) { System . out . println ( ans [ i ] ) ; } } } import java . util . Scanner ; public class vqhTv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VqhBdms = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; boolean flag = false ; A : for ( int x = 0 ; x <= Math . min ( Y / 10000 , VqhBdms ) ; x ++ ) { for ( int y = 0 ; y <= Math . min ( ( Y - 10000 * x ) / 5000 , VqhBdms - x ) ; y ++ ) { int k = Y - 10000 * x - 5000 * y ; if ( k % 1000 == 0 ) { int z = k / 1000 ; if ( z == ( VqhBdms - 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 OhtTjyd { 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 OhtTjyd { public static PrintWriter out ; public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int OhtQy = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; if ( w >= OhtQy ) { out . println ( " unsafe " ) ; } else { out . println ( " safe " ) ; } out . close ( ) ; } } import java . util . Scanner ; public class hrsD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HrsToly = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] matrix = new int [ HrsToly ] [ m ] ; int [ ] vector = new int [ m ] ; for ( int i = 0 ; i < HrsToly ; 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 < HrsToly ; 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 CvvEydd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cvvRt ; double ave , d ; while ( ( cvvRt = scan . nextInt ( ) ) != 0 ) { int [ ] point = new int [ cvvRt ] ; ave = 0 ; for ( int i = 0 ; i < cvvRt ; i ++ ) { point [ i ] = scan . nextInt ( ) ; ave += point [ i ] ; } ave /= ( double ) cvvRt ; d = 0 ; for ( int i = 0 ; i < cvvRt ; i ++ ) { d += ( Math . pow ( ( ave - point [ i ] ) , 2 ) ) ; } d /= ( double ) cvvRt ; d = Math . sqrt ( d ) ; System . out . printf ( " %.8f \n " , d ) ; } scan . close ( ) ; } } import java . util . Scanner ; public class HubfqjWv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HubfqjVnt = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] [ ] nm = new int [ HubfqjVnt ] [ m ] ; int [ ] [ ] ml = new int [ m ] [ l ] ; for ( int i = 0 ; i < HubfqjVnt ; 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 < HubfqjVnt ; 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 onzCe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OnzGxka = sc . nextInt ( ) ; int s = OnzGxka % 60 ; int M = OnzGxka / 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 PleVy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pleEw = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ pleEw ] ; for ( int i = 0 ; i < pleEw ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; int sum = 0 ; for ( int i = 0 ; i < k && i < pleEw ; i ++ ) { sum += arr [ i ] ; } System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class XddusMa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] task = new int [ 3 ] ; int xddusS = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { task [ i ] = sc . nextInt ( ) ; } Arrays . sort ( task ) ; for ( int i = 0 ; i < 2 ; i ++ ) { xddusS += Math . abs ( task [ i ] - task [ i + 1 ] ) ; } System . out . println ( xddusS ) ; } } import java . io . * ; class GsstcXxkkdi { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = reader . readLine ( ) ; int GsstcYmi = Integer . parseInt ( line ) ; int answer = ( int ) Math . pow ( GsstcYmi , 3 ) ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class SijtOl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sijtK = sc . nextInt ( ) ; int kind = sc . nextInt ( ) ; int [ ] di = new int [ kind ] ; int [ ] count = new int [ sijtK ] ; for ( int i = 0 ; i < sijtK ; 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 < sijtK ; i ++ ) { if ( count [ i ] == 0 ) { trickCount ++ ; } } System . out . println ( trickCount ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class SfgxycJigq { 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 SfgxycK = charArray . length - 1 ; SfgxycK >= 0 ; SfgxycK -- ) { System . out . print ( charArray [ SfgxycK ] ) ; } System . out . println ( " " ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . Scanner ; public class BrxzrqVx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int brxzrqGsyx = sc . nextInt ( ) ; for ( int i = 1 ; i <= brxzrqGsyx ; 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 SrqvJngy { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int srqvJy = sc . nextInt ( ) ; int [ ] [ ] array = new int [ 2 ] [ srqvJy ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < srqvJy ; j ++ ) { array [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] ans = new int [ 2 ] [ srqvJy ] ; ans [ 0 ] [ 0 ] = array [ 0 ] [ 0 ] ; for ( int i = 0 ; i < srqvJy - 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 < srqvJy ; i ++ ) { ans [ 1 ] [ i ] = Math . max ( ans [ 0 ] [ i ] , ans [ 1 ] [ i - 1 ] ) + array [ 1 ] [ i ] ; } System . out . println ( ans [ 1 ] [ srqvJy - 1 ] ) ; } } import java . util . Scanner ; public class JfiVfw { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long JfiBww = scanner . nextLong ( ) ; long answer = JfiBww - 1 ; answer = getAnswer ( JfiBww , answer ) ; System . out . println ( answer ) ; } private static long getAnswer ( long JfiBww , long answer ) { int newStart = ( int ) Math . sqrt ( JfiBww ) ; for ( long i = newStart ; i > 1 ; i -- ) { if ( JfiBww % i == 0 ) { long divisible = JfiBww / i ; long possibleAnswer = ( i - 1 ) + ( divisible - 1 ) ; return possibleAnswer ; } } return answer ; } } import java . util . * ; public class LwrTxuqv { public static void main ( String [ ] args ) { int LwrL ; Scanner sc = new Scanner ( System . in ) ; String num = sc . next ( ) ; num = num . replaceAll ( " 0 " , " " ) ; LwrL = num . LwrL ( ) ; System . out . println ( LwrL ) ; } } import java . util . Scanner ; public class MukwFwcw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mukwY = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int res ; if ( mukwY <= 5 ) { res = 0 ; } else if ( mukwY <= 12 ) { res = b / 2 ; } else { res = b ; } System . out . println ( res ) ; } } import java . util . * ; public class ejmzW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EjmzJxdkx = sc . nextInt ( ) , D = sc . nextInt ( ) , c = 0 ; for ( int i = 0 ; i < EjmzJxdkx ; 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 BoeerRzltfb { public static void main ( String [ ] args ) { try ( BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int BoeerQp = 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 ) { BoeerQp += 3 ; } else if ( cmp == 0 ) { BoeerQp ++ ; hanako ++ ; } else { hanako += 3 ; } } System . out . println ( BoeerQp + " " + hanako ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class SkvkTmtqp { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; int SkvkGod = ob . nextInt ( ) ; boolean C = true ; String R = " " ; while ( C ) { SkvkGod %= 10 ; C = false ; } if ( ( SkvkGod == 2 ) || ( SkvkGod == 4 ) || ( SkvkGod == 5 ) || ( SkvkGod == 7 ) || ( SkvkGod == 9 ) ) { R += " hon " ; } else if ( ( SkvkGod == 0 ) || ( SkvkGod == 1 ) || ( SkvkGod == 6 ) || ( SkvkGod == 8 ) ) { R += " pon " ; } else if ( SkvkGod == 3 ) { R += " bon " ; } System . out . println ( R ) ; } } import java . util . * ; public class SigpaVyv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sigpaCg = sc . nextInt ( ) ; int yen = sc . nextInt ( ) ; int s = yen / 1000 - sigpaCg ; for ( int i = 0 ; i <= Math . min ( s / 9 , sigpaCg ) ; i ++ ) { for ( int j = 0 ; j <= Math . min ( sigpaCg - i , s / 4 ) ; j ++ ) { if ( i * 9 + j * 4 == s ) { System . out . println ( i + " " + j + " " + ( sigpaCg - 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 AnlokfFl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int AnlokfX = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = Math . max ( AnlokfX , b ) ; int d = Math . min ( AnlokfX , b ) ; int out = 0 ; out += c ; out += Math . max ( c - 1 , d ) ; System . out . println ( out ) ; scan . close ( ) ; } } import java . util . Scanner ; public class OunjpfNl { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int OunjpfY = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int result = 0 ; switch ( OunjpfY ) { 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 xykdtvS { public static void main ( String [ ] args ) { Solve s = new Solve ( ) ; s . solve ( ) ; } } class xykdtvS { public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; double XykdtvNcbr = sc . nextInt ( ) ; double K = sc . nextInt ( ) ; double n = 0d ; double res = 0d ; String message ; for ( double i = 1 ; i <= XykdtvNcbr ; i ++ ) { for ( int j = 0 ; j < 100000 ; j ++ ) { if ( i * Math . pow ( 2 , j ) >= K ) { n = j ; j = 100000 ; } } res += 1 / ( XykdtvNcbr * 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 KenZzm { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; int kenCpn = Integer . parseInt ( line ) ; int [ ] a = new int [ kenCpn ] ; int k = 0 ; int count = 1 ; boolean fin = false ; for ( int i = 0 ; i < kenCpn ; i ++ ) { a [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } for ( int i = 0 ; i < kenCpn ; 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 RfwhcbSapli { 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 RfwhcbSapli { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String RfwhcbB = in . next ( ) ; if ( RfwhcbB . compareTo ( " Sunny " ) == 0 ) { out . println ( " Cloudy " ) ; } else if ( RfwhcbB . compareTo ( " Cloudy " ) == 0 ) { out . println ( " Rainy " ) ; } else { out . println ( " Sunny " ) ; } } } static class RfwhcbSapli { 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 PzzsIx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long pzzsTn = sc . nextLong ( ) ; long hh = sc . nextLong ( ) ; long xx = sc . nextLong ( ) ; long yy = sc . nextLong ( ) ; System . out . print ( pzzsTn * hh / 2.0 ) ; System . out . print ( " " + ( xx * 2 == pzzsTn && yy * 2 == hh ? 1 : 0 ) ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class KyaqEpy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; char [ ] t = sc . next ( ) . toCharArray ( ) ; int kyaqQf = 0 ; int len = s . length ; for ( int i = 0 ; i < len ; i ++ ) { if ( s [ i ] != t [ i ] ) kyaqQf ++ ; } System . out . println ( kyaqQf ) ; } } import java . util . Scanner ; public class XfiFbcwj { 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 XfiQop = 0 ; XfiQop < 26 ; XfiQop ++ ) { if ( C . equals ( slist [ XfiQop ] ) ) { C = slist [ XfiQop + 1 ] ; System . out . println ( C ) ; break ; } } } } import java . util . * ; class TtfggUn { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int ttfggApxv = stdIn . nextInt ( ) ; int x = stdIn . nextInt ( ) ; int count = 1 ; int sum = 0 ; while ( ttfggApxv -- > 0 ) { sum += stdIn . nextInt ( ) ; if ( x < sum ) break ; count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class qpfM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double QpfSnmkc = sc . nextDouble ( ) ; System . out . println ( ( int ) Math . ceil ( QpfSnmkc / 2 ) ) ; } } import java . util . Scanner ; public class TkvwOd { private static int TkvwJtc , x ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; TkvwJtc = stdIn . nextInt ( ) ; for ( int i = 1 ; i <= TkvwJtc ; 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 GqjuofNlhx { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String nb = buf . readLine ( ) ; int GqjuofQup = Integer . parseInt ( nb ) ; System . out . println ( ( int ) Math . pow ( GqjuofQup , 3 ) ) ; } } import java . lang . reflect . Array ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class AncfrkDixa { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; List < String [ ] > list = new ArrayList < > ( ) ; int ancfrkVg = 0 ; int N = 0 ; int M = 0 ; while ( scan . hasNext ( ) ) { if ( ancfrkVg == 0 ) { N = scan . nextInt ( ) ; M = scan . nextInt ( ) ; ancfrkVg ++ ; continue ; } String str = scan . nextLine ( ) ; String [ ] sp = str . split ( " " ) ; list . add ( sp ) ; ancfrkVg ++ ; if ( ancfrkVg > 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 FoxeeEznlc { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; long FoxeeBb = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; sc . close ( ) ; long res1 = Math . max ( 0 , FoxeeBb - k ) ; long res2 = Math . max ( 0 , Math . min ( FoxeeBb + b - k , b ) ) ; System . out . println ( res1 + " " + res2 ) ; } public static void main ( String [ ] args ) { solve ( ) ; } } import java . util . Scanner ; public class ddbBq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] s = sc . next ( ) . split ( " " ) ; for ( int DdbCwt = 0 ; DdbCwt < s . length ; DdbCwt ++ ) { sb . append ( s [ DdbCwt ] . equals ( " 1 " ) ? " 9 " : " 1 " ) ; } System . out . println ( sb ) ; } } import java . util . Scanner ; public class FhnQfjar { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FhnX = sc . nextInt ( ) , b = sc . nextInt ( ) ; StringBuilder a_str = new StringBuilder ( ) ; StringBuilder b_str = new StringBuilder ( ) ; for ( int i = 0 ; i < FhnX ; i ++ ) { a_str . append ( b ) ; } for ( int i = 0 ; i < b ; i ++ ) { b_str . append ( FhnX ) ; } System . out . println ( a_str . toString ( ) . compareTo ( b_str . toString ( ) ) < 0 ? a_str . toString ( ) : b_str . toString ( ) ) ; } } import java . util . * ; public class CdyeuaTurllm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long CdyeuaYie = sc . nextInt ( ) ; long total = 0 ; for ( long i = 0 ; i <= CdyeuaYie ; i ++ ) { if ( i % 3 != 0 && i % 5 != 0 ) { total += i ; } } System . out . println ( total ) ; } } import java . util . * ; import java . util . Collections ; public class IrqzdElc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IrqzdZo = sc . nextInt ( ) ; String S = sc . next ( ) ; int cnt = 0 ; for ( int i = 0 ; i < IrqzdZo - 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 DjqeyDkk { public static void main ( String [ ] args ) { int DjqeyP ; int b ; try ( Scanner scanner = new Scanner ( System . in ) ) { DjqeyP = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; } if ( ( DjqeyP & b & 1 ) == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class YayuZaf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yayuVpd = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] monsters = new int [ yayuVpd ] ; for ( int i = 0 ; i < yayuVpd ; i ++ ) { monsters [ i ] = sc . nextInt ( ) ; } Arrays . sort ( monsters ) ; long hp = 0 ; if ( k >= yayuVpd ) { System . out . println ( hp ) ; } else { for ( int j = 0 ; j < yayuVpd - k ; j ++ ) { hp += monsters [ j ] ; } System . out . println ( hp ) ; } } } import java . util . Scanner ; public class OaqNar { public static void main ( String [ ] args ) { Scanner c = new Scanner ( System . in ) ; long OaqOph = c . nextInt ( ) ; System . out . println ( ( OaqOph + ( OaqOph * OaqOph ) + ( OaqOph * OaqOph * OaqOph ) ) ) ; } } import java . util . * ; public class sdfTq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SdfGpeq = Integer . parseInt ( sc . next ( ) ) ; int d = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < SdfGpeq ; 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 PphcwUspg { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int pphcwGbwk = 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' ) { pphcwGbwk ++ ; if ( max <= pphcwGbwk ) { max = pphcwGbwk ; } } else { pphcwGbwk = 0 ; } } System . out . println ( max ) ; } } import java . util . Scanner ; public class lbibjbN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] array = sc . nextLine ( ) . split ( " " ) ; int LbibjbNby = 0 ; for ( String s : array ) { if ( Integer . parseInt ( s ) == 1 ) { LbibjbNby ++ ; } } System . out . println ( LbibjbNby ) ; } } import java . util . Scanner ; public class MfyQtxqbn { public static void main ( String [ ] args ) { String MfyEb ; Scanner n = new Scanner ( System . in ) ; MfyEb = n . next ( ) ; if ( MfyEb . equals ( " Sunny " ) ) System . out . print ( " Cloudy " ) ; else if ( MfyEb . equals ( " Cloudy " ) ) System . out . print ( " Rainy " ) ; else if ( MfyEb . equals ( " Rainy " ) ) System . out . print ( " Sunny " ) ; } } import java . util . Scanner ; public class UcwofMyg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UcwofK = 0 , b = 0 , c = 0 ; int [ ] n = new int [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { n [ i ] = sc . nextInt ( ) ; if ( n [ i ] > UcwofK ) { c = b ; b = UcwofK ; UcwofK = n [ i ] ; } else if ( n [ i ] > b ) { c = b ; b = n [ i ] ; } else if ( n [ i ] > c ) { c = n [ i ] ; } } System . out . println ( UcwofK ) ; System . out . println ( b ) ; System . out . println ( c ) ; } } import java . io . * ; class UzgRsbwc { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; char UzgX ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { UzgX = str . charAt ( i ) ; if ( Character . isUpperCase ( UzgX ) ) UzgX = Character . toLowerCase ( UzgX ) ; else if ( Character . isLowerCase ( UzgX ) ) UzgX = Character . toUpperCase ( UzgX ) ; System . out . print ( UzgX ) ; } System . out . println ( ) ; } catch ( IOException e ) { System . out . println ( " Exception : " + e ) ; } } } import java . util . * ; class ietwFjy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IetwAqdc = sc . nextInt ( ) ; int waza = sc . nextInt ( ) ; long ret = 0 ; int [ ] hoge = new int [ IetwAqdc ] ; if ( IetwAqdc <= waza ) { System . out . println ( 0 ) ; return ; } for ( int i = 0 ; i < IetwAqdc ; i ++ ) { hoge [ i ] = sc . nextInt ( ) ; } Arrays . sort ( hoge ) ; for ( int i = 0 ; i < IetwAqdc - waza ; i ++ ) { ret += hoge [ i ] ; } System . out . print ( ret ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class JmfOfli { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int jmfDu = sc . nextInt ( ) ; int maxPotision = 0 ; int maxValue = 0 ; int secondValue = 0 ; boolean maxDup = false ; for ( int i = 0 ; i < jmfDu ; 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 < jmfDu ; i ++ ) { System . out . println ( maxValue ) ; } } else { for ( int i = 0 ; i < jmfDu ; i ++ ) { if ( i == maxPotision ) { System . out . println ( secondValue ) ; } else { System . out . println ( maxValue ) ; } } } } } import java . util . * ; public class EmhznCa { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String emhznIvu = scan . nextLine ( ) ; String strings = emhznIvu + emhznIvu ; 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 IxdDwagd { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int IxdTpi = sc . nextInt ( ) ; int H = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; boolean flg = false ; BigDecimal S = BigDecimal . valueOf ( IxdTpi ) ; S = S . multiply ( BigDecimal . valueOf ( H ) ) ; S = S . divide ( BigDecimal . valueOf ( 2 ) , 10 , RoundingMode . HALF_UP ) ; if ( 2 * x == IxdTpi && 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 GphhMylsev { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; loop : while ( true ) { long GphhBr = scanner . nextInt ( ) ; String op = scanner . next ( ) ; long b = scanner . nextInt ( ) ; switch ( op ) { case " + " : System . out . println ( GphhBr + b ) ; break ; case " - " : System . out . println ( GphhBr - b ) ; break ; case " * " : System . out . println ( GphhBr * b ) ; break ; case " / " : System . out . println ( GphhBr / 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 MbwuimCh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mbwuimDan = sc . nextInt ( ) ; boolean [ ] isZorome = new boolean [ mbwuimDan ] ; for ( int i = 0 ; i < mbwuimDan ; 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 < mbwuimDan - 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 vgjdQgj { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int VgjdGinhf = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int M = 2 * D + 1 ; System . out . println ( ( VgjdGinhf + 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 GfcyoeNxyq { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int GfcyoeK = Integer . parseInt ( str [ 0 ] ) ; int l = Integer . parseInt ( str [ 1 ] ) ; String [ ] s = new String [ GfcyoeK ] ; for ( int i = 0 ; i < GfcyoeK ; i ++ ) { s [ i ] = in . readLine ( ) ; } Arrays . sort ( s ) ; for ( int i = 0 ; i < GfcyoeK ; i ++ ) { System . out . print ( s [ i ] ) ; } System . out . println ( ) ; } } import java . util . * ; import java . io . * ; public class PnrzGn { 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 PnrzBo = Integer . parseInt ( br . readLine ( ) ) ; long ans = 0 ; for ( int i = 1 ; i <= PnrzBo ; 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 IbvosuXkkb { 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 IbvosuYms = 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 YvguRestxn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double YvguH = sc . nextDouble ( ) ; double ans = YvguH / 3 ; System . out . printf ( " %.12f \n " , ans * ans * ans ) ; } } import java . util . Scanner ; public class IftnmWg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long IftnmPez = sc . nextLong ( ) , a = sc . nextLong ( ) , b = sc . nextLong ( ) ; long sum = a * ( IftnmPez / ( a + b ) ) ; sum += a < IftnmPez % ( a + b ) ? a : IftnmPez % ( a + b ) ; System . out . println ( sum ) ; } } import java . util . Scanner ; public class vcfHr { public static void main ( String [ ] args ) { Scanner inputscan = new Scanner ( System . in ) ; int VcfGq = 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 <= VcfGq && Vertical1 >= 0 && Vertical2 <= H ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . math . * ; public class VtlShr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String VtlUfy = sc . next ( ) ; String b = sc . next ( ) ; BigDecimal a1 = new BigDecimal ( VtlUfy ) ; BigDecimal b1 = new BigDecimal ( b ) ; BigDecimal res = a1 . multiply ( b1 ) ; System . out . println ( res . setScale ( 0 , RoundingMode . DOWN ) ) ; } } import java . io . * ; class OderrTysvo { } class OderrTysvo { public static void main ( String [ ] args ) throws IOException { Program obj = new Program ( ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] ip ; int OderrNp , M , C ; int [ ] A , B ; ip = in . readLine ( ) . split ( " " ) ; OderrNp = 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 ( -- OderrNp >= 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 pnecenP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; boolean [ ] [ ] cardHasFlag = new boolean [ 4 ] [ 13 ] ; int PnecenDrls = sc . nextInt ( ) ; for ( int i = 0 ; i < PnecenDrls ; 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 LuhvKqg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int luhvMany = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int sum = 0 ; if ( d <= luhvMany ) { System . out . println ( d ) ; return ; } sum = luhvMany ; d -= luhvMany ; if ( d <= b ) { System . out . println ( sum ) ; return ; } d -= b ; sum -= d ; System . out . println ( sum ) ; } } import java . util . * ; public class JijryPpdmc { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int JijryU = s . nextInt ( ) ; long [ ] monsters = new long [ JijryU + 1 ] ; long [ ] strength = new long [ JijryU ] ; long count = 0 ; for ( int i = 0 ; i < JijryU + 1 ; i ++ ) { monsters [ i ] = s . nextInt ( ) ; } for ( int i = 0 ; i < JijryU ; i ++ ) { strength [ i ] = s . nextInt ( ) ; } for ( int i = 0 ; i < JijryU ; 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 pkmmdQ { public static void main ( final String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { String s = scanner . nextLine ( ) ; int PkmmdCmxxh = 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 ) ) { PkmmdCmxxh ++ ; } } if ( PkmmdCmxxh == 2 ) { PkmmdCmxxh = 0 ; } else { System . out . println ( " No " ) ; flag = false ; break ; } } if ( flag ) { System . out . println ( " Yes " ) ; } } } } import java . util . * ; class ehjNjj { 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 EhjVqvfg = sc . nextInt ( ) ; int [ ] triangle = new int [ 3 ] ; for ( int cnt = 0 ; cnt < EhjVqvfg ; 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 HimhKe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long himhJ = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long answer = himhJ * B / calcGcd ( himhJ , 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 LavEg { public static void main ( String [ ] args ) { int lavA ; 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 QyfjlHi { static long qyfjlG = ( 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 QyfjlHi { 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 ZbnasUqr { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int zbnasFn = in . nextInt ( ) , b = in . nextInt ( ) , c = in . nextInt ( ) , n = in . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i <= zbnasFn ; 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 ChwptsYbmcu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; for ( int ChwptsI = 1 ; ChwptsI <= 10000 ; ChwptsI ++ ) { 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 VfnjdMviq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vfnjdIga = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean [ ] clash = new boolean [ vfnjdIga + 1 ] ; Arrays . fill ( clash , true ) ; for ( int i = 0 ; i < m ; i ++ ) clash [ sc . nextInt ( ) ] = false ; int [ ] dp = new int [ vfnjdIga + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 0 ; i < vfnjdIga ; i ++ ) { for ( int j = i + 1 ; j <= Math . min ( i + 2 , vfnjdIga ) ; j ++ ) { if ( clash [ j ] ) { dp [ j ] += dp [ i ] ; dp [ j ] %= 1000000007 ; } } } System . out . println ( dp [ vfnjdIga ] ) ; sc . close ( ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class TnbDcx { 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 TnbDcx { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String str = in . next ( ) ; int tnbJtb = 0 ; for ( char c : str . toCharArray ( ) ) { if ( c == '1' ) { tnbJtb ++ ; } } out . print ( tnbJtb ) ; } } } import java . util . Scanner ; public class EwzhPdpt { public static int getGcd ( int a , int b ) { if ( a == b ) return b ; int ewzhVylc = Math . max ( a , b ) ; int smaller = Math . min ( a , b ) ; int modded = ewzhVylc % smaller ; if ( modded == 0 ) return smaller ; return getGcd ( smaller , ewzhVylc % 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 JkxtuPwta { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; int JkxtuL = s . nextInt ( ) ; int [ ] a = new int [ JkxtuL ] ; for ( int i = 0 ; i < JkxtuL ; i ++ ) a [ i ] = s . nextInt ( ) ; int count = 0 ; boolean flag = false ; int j = 1 ; for ( int i = 0 ; i < JkxtuL ; 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 VyliUkk { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int vyliX = sc . nextInt ( ) ; int [ ] s = new int [ vyliX ] ; for ( int i = 0 ; i < vyliX ; 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 = vyliX - 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 dlocpKn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String someString = sc . next ( ) ; char DlocpHbqc = 'R' ; int rCount = 0 ; for ( int i = 0 ; i < someString . length ( ) ; i ++ ) { if ( rCount == 0 && someString . charAt ( i ) == DlocpHbqc ) { rCount = 1 ; } if ( someString . charAt ( i ) == DlocpHbqc ) { if ( i > 0 && someString . charAt ( i - 1 ) == DlocpHbqc ) { rCount ++ ; } } } System . out . println ( rCount ) ; } } import java . util . * ; public class ZkagKfz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zkagHy = sc . nextInt ( ) ; int [ ] L = new int [ zkagHy ] ; for ( int i = 0 ; i < zkagHy ; i ++ ) { L [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( L ) ; int sum = 0 ; for ( int i = zkagHy - 2 ; 0 <= i ; i -- ) { sum += L [ i ] ; } if ( L [ zkagHy - 1 ] < sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class LkeGyk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LkeD = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( ! ( e - LkeD > k ) ) { System . out . print ( " Yay! " ) ; } else { System . out . print ( " :( " ) ; } } } import java . util . Scanner ; public class CeurpbQvyd { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ceurpbGcx = in . nextInt ( ) ; int n = in . nextInt ( ) ; int [ ] a = new int [ 200009 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; } a [ n ] = ceurpbGcx + a [ 0 ] ; int ans = 1000000009 ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . min ( ans , ceurpbGcx - ( a [ i + 1 ] - a [ i ] ) ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class grsE { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int GrsLneyp = Integer . parseInt ( s . next ( ) ) ; int b = Integer . parseInt ( s . next ( ) ) ; System . out . printf ( " %d %d %.5f " , GrsLneyp / b , GrsLneyp % b , ( double ) GrsLneyp / ( double ) b ) ; } } import java . io . BufferedInputStream ; import java . io . BufferedOutputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class SehvwpPb { 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 sehvwpW = s . charAt ( 0 ) ; dp [ 0 ] [ 0 ] = ( sehvwpW == '1' ? 1 : 0 ) ; dp [ 1 ] [ 0 ] = ( sehvwpW == '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 IenVcyn { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] s = br . readLine ( ) . split ( " " ) ; long ienB = 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 > ienB && flag == true ) { K -= ienB ; sum += ienB ; } else if ( K <= ienB && 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 BfsczWavn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BfsczTt = sc . nextInt ( ) ; int [ ] p = new int [ BfsczTt ] ; for ( int i = 0 ; i < BfsczTt ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int c = 0 ; for ( int i = 0 ; i < BfsczTt ; 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 EtwtwLbbmmb { 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 EtwtwM = Integer . parseInt ( str [ 0 ] ) ; int W = Integer . parseInt ( str [ 1 ] ) ; if ( EtwtwM == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < EtwtwM ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { if ( i == 0 || j == 0 || i == EtwtwM - 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 LdkJxl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ldkNup = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( ldkNup > 0 && ldkNup <= 9 && b > 0 && b <= 9 ) System . out . println ( ldkNup * b ) ; else System . out . println ( " -1 " ) ; } } import java . util . Scanner ; public class WpifgLmxz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wpifgZo = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; System . out . println ( solve ( wpifgZo , Q , R ) ) ; sc . close ( ) ; } static int solve ( int wpifgZo , int Q , int R ) { return wpifgZo + Q + R - Math . max ( Math . max ( wpifgZo , Q ) , R ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class AnhMfkr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > A = new ArrayList < Integer > ( ) ; for ( int anhRbt = 0 ; anhRbt < 3 ; anhRbt ++ ) { 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 zinhUyc { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int ZinhFgtqd = sc . nextInt ( ) ; ArrayList < Integer > a = new ArrayList < Integer > ( ZinhFgtqd ) ; for ( int i = 0 ; i < ZinhFgtqd ; 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 < ZinhFgtqd ; 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 JcrwtWuax { static long JcrwtFz = 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 OzlkcnXooz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] t = { " eraser " , " erase " , " dreamer " , " dream " } ; for ( int ozlkcnUmc = 0 ; ozlkcnUmc < 4 ; ozlkcnUmc ++ ) s = s . replace ( t [ ozlkcnUmc ] , " " ) ; System . out . println ( s . equals ( " " ) ? " YES " : " NO " ) ; } } import java . util . Scanner ; class KnbxkJyi { private final int knbxkTlgo ; Solver ( Scanner in ) { int N = in . nextInt ( ) ; knbxkTlgo = in . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( in . nextInt ( ) >= knbxkTlgo ) count ++ ; } System . out . println ( count ) ; } void solve ( ) { } } class KnbxkJyi { 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 XqnxxjSuevv { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int XqnxxjF = 100000 ; int n = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { XqnxxjF *= 1.05 ; if ( ( XqnxxjF - ( ( XqnxxjF / 1000 ) * 1000 ) ) != 0 ) { XqnxxjF = ( XqnxxjF / 1000 ) * 1000 + 1000 ; } else { XqnxxjF = ( XqnxxjF / 1000 ) * 1000 ; } } System . out . println ( XqnxxjF ) ; } } import java . util . Scanner ; class PmhcjvEcr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] chars = new int [ 256 ] ; for ( int pmhcjvWosw = 0 ; pmhcjvWosw < 256 ; pmhcjvWosw ++ ) chars [ pmhcjvWosw ] = 0 ; while ( scan . hasNextLine ( ) ) { String line = scan . nextLine ( ) ; for ( int pmhcjvWosw = 0 ; pmhcjvWosw < line . length ( ) ; pmhcjvWosw ++ ) { char ch = Character . toLowerCase ( line . charAt ( pmhcjvWosw ) ) ; 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 rrpmzcS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RrpmzcPtgcl = Integer . parseInt ( sc . next ( ) ) ; int X = Integer . parseInt ( sc . next ( ) ) ; int [ ] M = new int [ RrpmzcPtgcl ] ; for ( int i = 0 ; i < RrpmzcPtgcl ; i ++ ) { M [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; Arrays . sort ( M ) ; int sum = 0 ; int cnt = RrpmzcPtgcl ; for ( int i = 0 ; i < RrpmzcPtgcl ; 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 VumlCckvse { static Scanner sc = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { while ( sc . hasNext ( ) ) { long VumlLdq = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; long x = VumlLdq ; long y = b ; long max = y ; while ( x % y != 0 ) { max = x % y ; x = y ; y = max ; } long min = VumlLdq * b / max ; System . out . println ( max + " " + min ) ; } } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class gjqrkaGz { 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 GjqrkaMtt = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; os . println ( GjqrkaMtt * B ) ; } } import java . util . * ; public class ShhpduCqi { 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 shhpduLl = 7 - week . indexOf ( dow ) ; System . out . println ( shhpduLl ) ; } } import java . util . Scanner ; public class NmkzFnjnbm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int NmkzIiw = scan . nextInt ( ) ; System . out . println ( NmkzIiw / 500 * 1000 + NmkzIiw % 500 / 5 * 5 ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class YdpCcm { 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 YdpSub = 0 ; for ( int i = 0 ; i < s . length ( ) / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( s . length ( ) - i - 1 ) ) { YdpSub ++ ; } } p ( YdpSub ) ; } } import java . util . * ; class CdgrxZr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cdgrxEh = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; Integer [ ] h = new Integer [ cdgrxEh ] ; int c = 0 ; for ( int i = 0 ; i < cdgrxEh ; 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 kjhHho { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KjhJpn = sc . nextInt ( ) ; int [ ] a = new int [ KjhJpn ] ; for ( int i = 0 ; i < KjhJpn ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; int alice = 0 ; int bob = 0 ; int check = 0 ; for ( int i = KjhJpn - 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 fbhFm { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int FbhCkjf = sc . nextInt ( ) ; int [ ] [ ] dp = new int [ 201 ] [ 201 ] ; long res = 0 ; for ( int i = 1 ; i <= FbhCkjf ; i ++ ) { for ( int j = 1 ; j <= FbhCkjf ; 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 <= FbhCkjf ; 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 KmjaNpkftq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int KmjaFqk = Integer . parseInt ( S . substring ( 5 , 7 ) ) ; if ( KmjaFqk < 5 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class iompoOf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IompoAo = sc . nextInt ( ) ; ArrayList < Integer > deckList = new ArrayList < > ( ) ; for ( int i = 1 ; i <= IompoAo ; 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 IxdjiXq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; scanner . close ( ) ; int IxdjiV = 0 , minus = 0 ; for ( int n = 0 ; n < S . length ( ) ; n ++ ) { String s = S . substring ( n , n + 1 ) ; if ( s . equals ( " + " ) ) { IxdjiV ++ ; } else if ( s . equals ( " - " ) ) { minus ++ ; } } int A = IxdjiV - minus ; System . out . println ( A ) ; } } import java . util . Scanner ; public class noiumkJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int NoiumkAwqrt = 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 ] + ( NoiumkAwqrt - 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 ( NoiumkAwqrt - max ) ; scan . close ( ) ; } } import java . util . Scanner ; class XcrPab { public static void main ( String [ ] args ) { int xcrV = 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 ) { xcrV ++ ; } yaku = 0 ; } System . out . println ( xcrV ) ; } } import java . util . Scanner ; public class OftdeChjb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; int oftdeJf = S . oftdeJf ( ) ; int count = 0 ; for ( int i = 0 ; i < oftdeJf / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( oftdeJf - 1 - i ) ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class OlvbfgKax { public static void main ( String [ ] args ) { int olvbfgAj ; Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; for ( olvbfgAj = 0 ; olvbfgAj < n ; olvbfgAj ++ ) { a . add ( Integer . parseInt ( sc . next ( ) ) ) ; } sc . close ( ) ; Collections . sort ( a , Comparator . reverseOrder ( ) ) ; int ans = 0 ; for ( olvbfgAj = 0 ; olvbfgAj < n ; olvbfgAj ++ ) { if ( olvbfgAj % 2 == 0 ) ans += a . get ( olvbfgAj ) ; else ans -= a . get ( olvbfgAj ) ; } 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 YztoYcmg { public static void main ( String [ ] args ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String YztoO = null ; try { YztoO = br . readLine ( ) ; br . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } SimpleDateFormat sdf = new SimpleDateFormat ( " yyyy/MM/dd " ) ; Date formatDate = null ; try { formatDate = sdf . parse ( YztoO ) ; } 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 azsRs { public static void main ( String ... args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String a = sc . next ( ) ; String b = sc . next ( ) ; int AzsYx = Integer . parseInt ( a + b ) ; int tmp = ( int ) Math . sqrt ( AzsYx ) ; if ( Math . pow ( tmp , 2 ) == AzsYx ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class SevnThyzv { 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 SevnY = 0 ; SevnY < s . length ( ) ; SevnY ++ ) { if ( map . containsKey ( s . charAt ( SevnY ) ) ) { map . put ( s . charAt ( SevnY ) , map . get ( s . charAt ( SevnY ) ) + 1 ) ; } else { map . put ( s . charAt ( SevnY ) , 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 RadbrKj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RadbrSij = 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 + RadbrSij ) % 26 ] ; } } } System . out . println ( R [ s ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class AovgjKbeok { 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 AovgjZ = Integer . parseInt ( ss [ 0 ] ) ; int b = Integer . parseInt ( ss [ 1 ] ) ; System . out . print ( AovgjZ * b ) ; System . out . print ( " " ) ; System . out . println ( 2 * AovgjZ + 2 * b ) ; } } import java . util . * ; class LopwyZki { 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 LopwyYvw = 0 ; LopwyYvw < 3 ; LopwyYvw ++ ) { arr [ LopwyYvw ] = Integer . parseInt ( aaa [ LopwyYvw ] ) ; } Arrays . sort ( arr ) ; System . out . println ( arr [ 2 ] - arr [ 0 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class OaroxXlfou { public static void main ( String [ ] args ) throws IOException { final int OaroxQj = 10 ; int [ ] a = new int [ OaroxQj ] ; InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( is ) ; for ( int i = 0 ; i < OaroxQj ; i ++ ) { a [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } for ( int i = 0 ; i < OaroxQj ; i ++ ) { for ( int j = i + 1 ; j < OaroxQj ; 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 WswClw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long WswHzw = Long . parseLong ( sc . next ( ) ) ; long yokin = 100 ; int counter = 0 ; while ( ! ( yokin >= WswHzw ) ) { yokin *= 1.01 ; counter ++ ; } System . out . println ( counter ) ; } } import java . util . Scanner ; public class GlwccVdjqx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GlwccX = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int divisor = 0 ; for ( int i = 0 ; i <= ( b - GlwccX ) ; i ++ ) { if ( c % ( GlwccX + i ) == 0 ) { divisor += 1 ; } } System . out . println ( divisor ) ; sc . close ( ) ; } } import java . util . * ; public class gqbabHj { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int GqbabMiona = in . nextInt ( ) ; long [ ] mo = new long [ GqbabMiona + 1 ] ; for ( int i = 0 ; i < GqbabMiona + 1 ; i ++ ) { mo [ i ] = in . nextInt ( ) ; } long sum = 0 ; long yu = 0 ; for ( int i = 0 ; i < GqbabMiona ; 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 lmjxxQuo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String LmjxxMssvd = sc . next ( ) ; System . out . println ( " ABC " . equals ( LmjxxMssvd ) ? " ARC " : " ABC " ) ; } } import java . util . * ; public class IpjQhbb { private static void prin ( String ans ) { System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ipjRit = sc . nextInt ( ) ; int upp = ipjRit / 100 ; int downn = ipjRit % 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 gyyPn { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = br . readLine ( ) . toLowerCase ( ) ; int GyyXpvqh = 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 ) ) GyyXpvqh ++ ; } } System . out . println ( GyyXpvqh ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class XhbGk { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int XhbP = Integer . parseInt ( in . readLine ( ) ) ; if ( XhbP < 0 || Math . pow ( 10 , 4 ) < XhbP ) throw new RuntimeException ( " error:range " ) ; String [ ] nums = new String [ XhbP ] ; nums = in . readLine ( ) . split ( " " ) ; int min = Integer . parseInt ( nums [ 0 ] ) , max = Integer . parseInt ( nums [ 0 ] ) ; long sum = 0 ; for ( int i = 0 ; i < XhbP ; 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 athQya { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int AthAfuqd = input . nextInt ( ) ; int M = input . nextInt ( ) ; int cnt = 0 ; System . out . println ( AthAfuqd * ( AthAfuqd - 1 ) / 2 + M * ( M - 1 ) / 2 ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class NqgnRl { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; final String NqgnQr = sc . next ( ) ; sc . close ( ) ; String ans = null ; switch ( NqgnQr ) { 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 UmtpuMz { 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 UmtpuMz { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int umtpuGgd = Integer . parseInt ( in . next ( ) + in . next ( ) ) ; for ( int i = 1 ; i < 10000 ; i ++ ) { if ( umtpuGgd == i * i ) { out . println ( " Yes " ) ; return ; } } out . println ( " No " ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class vsoqpPq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > x = new ArrayList < > ( ) ; for ( int VsoqpQt = 0 ; VsoqpQt < 5 ; VsoqpQt ++ ) { x . add ( sc . nextInt ( ) ) ; } for ( Integer VsoqpQt : x ) { if ( VsoqpQt == 0 ) { System . out . println ( x . indexOf ( VsoqpQt ) + 1 ) ; } } sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class DrcqYhrydp { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int DrcqQr = 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 ( DrcqQr - ans ) > Math . abs ( DrcqQr - i ) ) { ans = i ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class UwnaRmuwd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int UwnaGsm = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int C = scan . nextInt ( ) ; boolean flag = false ; if ( UwnaGsm == B && B != C ) { flag = true ; } if ( B == C && C != UwnaGsm ) { flag = true ; } if ( UwnaGsm == C && B != UwnaGsm ) { flag = true ; } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . IOException ; import java . util . Scanner ; public class BcyylBaoabt { 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 BcyylHe = Integer . parseInt ( data [ 0 ] ) ; final int x = Integer . parseInt ( data [ 1 ] ) ; if ( BcyylHe == 0 && x == 0 ) break ; int count = 0 ; for ( int i = 1 ; i <= BcyylHe - 2 ; i ++ ) { for ( int j = i + 1 ; j <= BcyylHe - 1 ; j ++ ) { for ( int k = j + 1 ; k <= BcyylHe ; k ++ ) { if ( ( i + j + k ) == x ) count ++ ; } } } System . out . println ( count ) ; } } } import java . util . * ; class PocxEn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String pocxDn = scan . next ( ) ; System . out . println ( pocxDn . matches ( " [A][a-z][a-z]*[C][a-z]*[a-z] " ) ? " AC " : " WA " ) ; } } import java . util . Scanner ; public class uawuQrw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UawuRvn = sc . nextInt ( ) ; int [ ] d1 = new int [ UawuRvn ] ; int [ ] d2 = new int [ UawuRvn ] ; for ( int i = 0 ; i <= UawuRvn - 1 ; i ++ ) { d1 [ i ] = sc . nextInt ( ) ; d2 [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i <= UawuRvn - 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 == UawuRvn - 3 ) { System . out . println ( " No " ) ; } } sc . close ( ) ; } } import java . util . * ; public class AhmAu { 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 ahmG = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == 'o' ) ahmG += 100 ; } System . out . println ( 700 + ahmG ) ; } 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 UpfkBuim { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int UpfkM = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; int [ ] dp = new int [ UpfkM ] ; for ( int i = 1 ; i < UpfkM ; 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 RsvOdq { public static void main ( String [ ] args ) { Scanner Input = new Scanner ( System . in ) ; String A = Input . next ( ) ; String B = Input . next ( ) ; int RsvPu = 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 ) ) { RsvPu ++ ; } } System . out . println ( RsvPu ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; public class qgoAp { public static boolean QgoFj = 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 ivcvG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IvcvRyso = sc . nextInt ( ) ; int A_2 = sc . nextInt ( ) ; int A_3 = sc . nextInt ( ) ; int [ ] S = new int [ ] { IvcvRyso , A_2 , A_3 } ; Arrays . sort ( S ) ; System . out . println ( ( S [ 2 ] - S [ 1 ] ) + ( S [ 1 ] - S [ 0 ] ) ) ; } } import java . util . * ; public class JdcGc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int jdcUl = sc . nextInt ( ) ; int [ ] x = new int [ jdcUl ] ; int [ ] y = new int [ jdcUl ] ; int sum = 0 ; for ( int i = 0 ; i < jdcUl ; i ++ ) { x [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < jdcUl ; i ++ ) { y [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < jdcUl ; i ++ ) { if ( x [ i ] >= y [ i ] ) { sum += x [ i ] - y [ i ] ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class yokgFjt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YokgXh = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int Z = sc . nextInt ( ) ; System . out . printf ( " %d %d %d " , Z , YokgXh , Y ) ; } } import java . io . * ; class AwdosVa { 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 AwdosZ = 0 ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { digit [ i ] = Character . getNumericValue ( str1 . charAt ( i ) ) ; AwdosZ += digit [ i ] ; } if ( AwdosZ == 0 ) { break ; } else System . out . println ( AwdosZ ) ; } } } import java . util . Scanner ; class AvzueaKibi { public static void main ( String [ ] args ) { Scanner S = new Scanner ( System . in ) ; while ( true ) { int AvzueaY = S . nextInt ( ) ; int y = S . nextInt ( ) ; if ( AvzueaY == 0 && y == 0 ) break ; if ( AvzueaY < y ) System . out . printf ( " %d %d \n " , AvzueaY , y ) ; else System . out . printf ( " %d %d \n " , y , AvzueaY ) ; } } } import java . util . * ; public class RpdZknqz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int RpdC = in . nextInt ( ) ; StringBuilder ans ; int cnt = 0 ; for ( int i = 1 ; i <= RpdC ; i ++ ) { ans = new StringBuilder ( " " + i ) ; if ( ans . length ( ) % 2 != 0 ) { cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class xjfjtwG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int XjfjtwQx = scan . nextInt ( ) ; int Y = scan . nextInt ( ) ; for ( int x = 0 ; x <= XjfjtwQx ; x ++ ) { for ( int y = 0 ; y <= XjfjtwQx - x ; y ++ ) { int total = x * 10000 + y * 5000 + 1000 * ( XjfjtwQx - x - y ) ; if ( total == Y ) { System . out . println ( x + " " + y + " " + ( XjfjtwQx - x - y ) ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . util . Scanner ; public class XzebMrv { 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 XzebM = 0 ; for ( int i = 2 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == 'C' ) { XzebM ++ ; } 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 ( XzebM == 1 ) { System . out . println ( " AC " ) ; } else { System . out . println ( " WA " ) ; } } } } import java . util . * ; public class IlpwOde { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IlpwWkd , i , j , count = 0 ; IlpwWkd = Integer . parseInt ( sc . next ( ) ) ; int [ ] height = new int [ IlpwWkd ] ; for ( i = 0 ; i < IlpwWkd ; 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 AjxwwnSgk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long ajxwwnNgt = scanner . nextLong ( ) ; String result = new String ( ) ; while ( ajxwwnNgt > 0 ) { int nums = ( int ) ( 'a' + ( ajxwwnNgt - 1 ) % 26 ) ; char temporal = ( char ) nums ; result = temporal + result ; ajxwwnNgt = ajxwwnNgt / 26 ; if ( temporal == 'z' ) ajxwwnNgt -- ; } System . out . print ( result ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class MrrkzVhwh { public static boolean isPalindrome ( int n ) { String s = " " + n ; String a = " " ; for ( int mrrkzY = s . length ( ) - 1 ; mrrkzY >= 0 ; mrrkzY -- ) { a += s . charAt ( mrrkzY ) ; } 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 mrrkzY = a ; mrrkzY <= b ; mrrkzY ++ ) { if ( isPalindrome ( mrrkzY ) ) count ++ ; } System . out . println ( count ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class eitmD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < String > list = new ArrayList < String > ( ) ; while ( true ) { String EitmMb = sc . nextLine ( ) ; if ( EitmMb . equals ( " 0 0 " ) ) { break ; } list . add ( EitmMb ) ; } for ( String EitmMb : list ) { String [ ] string = EitmMb . 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 IqzsSw { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int iqzsU = sc . nextInt ( ) ; String input = sc . next ( ) ; if ( iqzsU % 2 == 1 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < iqzsU / 2 ; i ++ ) { if ( input . charAt ( i ) != input . charAt ( iqzsU / 2 + i ) ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class gaurlK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String GaurlXpwd = sc . next ( ) ; char [ ] ss = GaurlXpwd . toCharArray ( ) ; if ( ss [ 0 ] + 0 >= 65 && ss [ 0 ] + 0 <= 90 ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . * ; public class CgvofxOs { public static void main ( String [ ] args ) { int cgvofxO = 0 ; int count7 = 0 ; Scanner sc = new Scanner ( System . in ) ; String [ ] line = sc . nextLine ( ) . split ( " " ) ; for ( String n : line ) { if ( n . equals ( " 5 " ) ) { cgvofxO ++ ; } if ( n . equals ( " 7 " ) ) { count7 ++ ; } } if ( cgvofxO == 2 && count7 == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; class LlkwZxo { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int llkwGuci = scn . nextInt ( ) ; String a = scn . next ( ) ; String b = scn . next ( ) ; String result = " " ; String [ ] c = new String [ llkwGuci ] ; String [ ] d = new String [ llkwGuci ] ; for ( int i = 0 ; i < llkwGuci ; 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 snaslNf { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int SnaslOsdog = scn . nextInt ( ) ; int k = scn . nextInt ( ) ; int [ ] h = new int [ SnaslOsdog ] ; for ( int i = 0 ; i < SnaslOsdog ; i ++ ) { h [ i ] = scn . nextInt ( ) ; } Arrays . sort ( h ) ; long att = 0 ; for ( int i = 0 ; i < SnaslOsdog - k ; i ++ ) { att = att + h [ i ] ; } System . out . println ( att ) ; } } import java . util . * ; public class caeOl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CaeUty = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int x = 0 ; if ( CaeUty <= b ) { x = x + b ; if ( CaeUty <= b - 1 ) { x = x + b - 1 ; } else { x = x + CaeUty ; } } else { x = x + CaeUty ; if ( b <= CaeUty - 1 ) { x = x + CaeUty - 1 ; } else { x = x + b ; } } System . out . println ( x ) ; } } import java . util . Scanner ; public class slfNg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int SlfStd = scan . nextInt ( ) ; int h = SlfStd / 3600 ; int d = ( SlfStd % 3600 ) / 60 ; int s = ( SlfStd % 3600 ) % 60 ; System . out . println ( h + " : " + d + " : " + s ) ; scan . close ( ) ; } } import java . util . Scanner ; import java . util . ArrayList ; public class ByxyZg { public static void main ( String [ ] args ) { String [ ] lines = getStdin ( ) ; String [ ] inputs = lines [ 0 ] . split ( " " ) ; int byxyInji = Integer . parseInt ( inputs [ 0 ] ) ; int y = Integer . parseInt ( inputs [ 1 ] ) ; System . out . println ( byxyInji * 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 ZanlkCpema { 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 ZanlkJo = sc . nextInt ( ) ; double d = 0.0 ; for ( int i = 0 ; i < ZanlkJo ; 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 NoejaUr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Queue < Integer > queue = new ArrayDeque < > ( ) ; int NoejaGa = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; String [ ] name = new String [ NoejaGa ] ; int [ ] time = new int [ NoejaGa ] ; for ( int i = 0 ; i < NoejaGa ; 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 ZtxyuxLqvsz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZtxyuxE = sc . nextInt ( ) ; int i = 1 ; int x = i ; int start = 0 ; while ( i <= ZtxyuxE ) { 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 hpbL { static String a ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int HpbVz = stdIn . nextInt ( ) ; int [ ] a = new int [ HpbVz ] ; for ( int i = 0 ; i < HpbVz ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; } show ( a , HpbVz ) ; insertionSort ( a , HpbVz ) ; } static void show ( int [ ] a , int HpbVz ) { System . out . print ( a [ 0 ] ) ; for ( int i = 1 ; i < HpbVz ; i ++ ) { System . out . print ( " " + a [ i ] ) ; } System . out . println ( ) ; } static void insertionSort ( int [ ] a , int HpbVz ) { for ( int i = 1 ; i < HpbVz ; 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 , HpbVz ) ; } } } import java . util . Scanner ; public class LvkvsLbiw { 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 lvkvsTi = 0 ; lvkvsTi < ch . length ; lvkvsTi ++ ) { if ( Character . isAlphabetic ( ch [ lvkvsTi ] ) ) { int x = ch [ lvkvsTi ] - 'a' ; count [ x ] ++ ; } } } for ( int lvkvsTi = 0 ; lvkvsTi < count . length ; lvkvsTi ++ ) { char x = ( char ) ( 'a' + lvkvsTi ) ; System . out . print ( x + " : " ) ; System . out . println ( count [ lvkvsTi ] ) ; } } } import java . util . * ; public class xzlkSzt { private static final int XzlkBhqw = 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 AlgDgekzx { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int AlgVv = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( AlgVv * b % 2 == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } scan . close ( ) ; } } import java . util . * ; public class pxwlvLk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PxwlvXzjip = sc . nextInt ( ) ; int [ ] h = new int [ PxwlvXzjip ] ; for ( int i = 0 ; i < PxwlvXzjip ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } if ( PxwlvXzjip == 2 ) { System . out . println ( Math . abs ( h [ 0 ] - h [ 1 ] ) ) ; return ; } int [ ] cost = new int [ PxwlvXzjip ] ; cost [ 0 ] = 0 ; cost [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < PxwlvXzjip ; 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 [ PxwlvXzjip - 1 ] ) ; } } import java . util . * ; public class clrtyhQa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double ClrtyhHe = 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 ) == ClrtyhHe && Math . floor ( i * rB ) == B ) { System . out . println ( i ) ; return ; } } System . out . println ( - 1 ) ; } } import java . util . Scanner ; class wjaxebM { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int WjaxebCan = scan . nextInt ( ) ; int [ ] a = new int [ WjaxebCan + 1 ] ; int [ ] b = new int [ WjaxebCan ] ; for ( int i = 0 ; i < WjaxebCan + 1 ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < WjaxebCan ; i ++ ) { b [ i ] = scan . nextInt ( ) ; } long ans = 0 ; for ( int j = 0 ; j < WjaxebCan ; 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 OyjTneujn { 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 OyjY = 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 ] ) { OyjY ++ ; } } } } System . out . println ( OyjY ) ; } } } import java . util . Scanner ; public class ZuqqGmt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zuqqUuxz = sc . nextInt ( ) ; for ( ; zuqqUuxz > 1 ; zuqqUuxz -- ) { for ( int i = 2 ; i < zuqqUuxz ; i ++ ) { int n = i * i ; if ( n > zuqqUuxz ) break ; while ( n <= zuqqUuxz ) { if ( n == zuqqUuxz ) { System . out . println ( zuqqUuxz ) ; return ; } n *= i ; } } } System . out . println ( zuqqUuxz ) ; } } import java . util . Scanner ; public class PhcizkVv { public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int PhcizkYl , b , c , hozon ; PhcizkYl = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; if ( PhcizkYl > b ) { hozon = PhcizkYl ; PhcizkYl = b ; b = hozon ; } if ( b > c ) { hozon = b ; b = c ; c = hozon ; } if ( PhcizkYl > b ) { hozon = PhcizkYl ; PhcizkYl = b ; b = hozon ; } System . out . println ( PhcizkYl + " " + 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 syvoGds { public static void main ( String [ ] args ) { int SyvoAunk , j ; Scanner sc = new Scanner ( in ) ; int n = parseInt ( sc . next ( ) ) ; String [ ] s = new String [ n ] ; for ( SyvoAunk = 0 ; SyvoAunk < n ; SyvoAunk ++ ) { s [ SyvoAunk ] = sc . next ( ) ; } sc . close ( ) ; String [ ] s2 ; for ( SyvoAunk = 0 ; SyvoAunk < n ; SyvoAunk ++ ) { s2 = s [ SyvoAunk ] . split ( " " ) ; Arrays . sort ( s2 ) ; s [ SyvoAunk ] = String . join ( " " , s2 ) ; } HashMap < String , Integer > c = new HashMap < > ( ) ; for ( SyvoAunk = 0 ; SyvoAunk < n ; SyvoAunk ++ ) { if ( c . containsKey ( s [ SyvoAunk ] ) ) { c . put ( s [ SyvoAunk ] , c . get ( s [ SyvoAunk ] ) + 1 ) ; } else { c . put ( s [ SyvoAunk ] , 1 ) ; } } long ans = 0 ; for ( Integer ii : c . values ( ) ) { ans += ( long ) ii * ( ii - 1 ) / 2 ; } out . println ( ans ) ; } } import java . util . * ; public class HrcTn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long hrcC = Long . parseLong ( sc . next ( ) ) ; int sqrt = ( int ) Math . sqrt ( hrcC ) ; for ( int i = sqrt ; i >= 1 ; i -- ) { if ( hrcC % i == 0 ) { System . out . println ( i + hrcC / i - 2 ) ; break ; } } } } import java . util . * ; public class enhuyoY { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String EnhuyoPokg = sc . next ( ) ; String ff = EnhuyoPokg . substring ( 2 , 4 ) ; String ee = EnhuyoPokg . 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 azequxRhh { public static long [ ] num = new long [ 1023 ] ; public static int AzequxYg = 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 BljxuGzbc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bljxuS = sc . nextInt ( ) ; int [ ] d = new int [ bljxuS ] ; long sum = 0 ; d [ 0 ] = sc . nextInt ( ) ; for ( int i = 1 ; i < bljxuS ; 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 AkrgnVow { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int akrgnXt = 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 SbhmlePk { public static void main ( String [ ] args ) { long sbhmleWu = 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 ] ) % sbhmleWu ; } System . out . println ( S [ n ] ) ; } } import java . io . * ; import java . util . * ; class pdmWf { public static void main ( String [ ] args ) throws IOException { int PdmJa , 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 ) ) ; } PdmJa = 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 ) <= PdmJa && 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 MdeUzagm { 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 MdeRj = Integer . parseInt ( st . nextToken ( ) ) ; int ac = 0 , wa = 0 , tle = 0 , re = 0 ; for ( int i = 0 ; i < MdeRj ; 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 vrjyuJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VrjyuFo = sc . nextInt ( ) ; int [ ] A = new int [ VrjyuFo ] ; for ( int i = 0 ; i < VrjyuFo ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int sortCount = 0 ; for ( int i = 0 ; i < VrjyuFo ; i ++ ) { int flag = 0 ; int minj = i ; for ( int j = i ; j < VrjyuFo ; 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 QgtnuaQekwvg { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; long QgtnuaDl = stdIn . nextInt ( ) ; long b = stdIn . nextInt ( ) ; long c = stdIn . nextInt ( ) ; long d = stdIn . nextInt ( ) ; System . out . println ( Math . max ( QgtnuaDl * c , Math . max ( QgtnuaDl * d , Math . max ( b * c , b * d ) ) ) ) ; } } import java . util . Scanner ; public class IhxcSqvlq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long IhxcR = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; if ( K <= IhxcR ) { IhxcR = IhxcR - K ; K = 0 ; } else { K = K - IhxcR ; IhxcR = 0 ; } if ( K <= B ) { B = B - K ; K = 0 ; } else { K = K - B ; B = 0 ; } System . out . println ( IhxcR + " " + B ) ; } } import java . util . Scanner ; public class BcoixqExc { 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 BcoixqO = 0 ; BcoixqO < S . length ( ) ; BcoixqO ++ ) { Sarr [ BcoixqO ] = S . substring ( BcoixqO ) + S . substring ( 0 , BcoixqO ) ; } boolean result = false ; for ( int BcoixqO = 0 ; BcoixqO < S . length ( ) ; BcoixqO ++ ) { if ( Sarr [ BcoixqO ] . equals ( T ) ) { result = true ; break ; } } System . out . println ( result ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class IhwkyqKs { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int IhwkyqY = sc . nextInt ( ) ; String S = sc . next ( ) ; char [ ] cs = S . toCharArray ( ) ; int count = 0 ; for ( int i = 0 ; i < IhwkyqY - 2 ; i ++ ) { if ( cs [ i ] == 'A' && cs [ i + 1 ] == 'B' && cs [ i + 2 ] == 'C' ) { count ++ ; } } System . out . println ( count ) ; } } } import java . util . * ; public class GlloVonyt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GlloH = Integer . parseInt ( sc . next ( ) ) ; int [ ] ary = new int [ GlloH ] ; 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 eugIk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EugEgv = sc . nextInt ( ) ; int [ ] hairetu = new int [ EugEgv ] ; 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 owbqV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OwbqWa = 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 ; OwbqWa ++ ; } System . out . println ( OwbqWa ) ; } } import java . util . Scanner ; public class UltevaVefc { void run ( ) { Scanner scan = new Scanner ( System . in ) ; double UltevaHh = scan . nextDouble ( ) ; System . out . printf ( " %f %f \n " , UltevaHh * UltevaHh * Math . PI , 2 * Math . PI * UltevaHh ) ; } 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 DzbYv { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int dzbB = 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 <= dzbB ; 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 TpfjcFrs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . nextLine ( ) ; String alp = " abcdefghijklmnopqrstuvwxyz " ; int tpfjcWmyf = alp . indexOf ( C ) ; System . out . println ( alp . charAt ( tpfjcWmyf + 1 ) ) ; } } import java . util . * ; public class IgattySul { public static void main ( String [ ] args ) { Scanner obj = new Scanner ( System . in ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; for ( int IgattyJio = 0 ; IgattyJio < 3 ; IgattyJio ++ ) { a . add ( obj . nextInt ( ) ) ; } Collections . sort ( a ) ; int sum = a . get ( 0 ) + a . get ( 1 ) ; System . out . println ( sum ) ; } } import java . util . * ; class xrlE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long XrlFzosj = sc . nextLong ( ) - 1 ; List < Integer > list = new ArrayList < > ( ) ; while ( XrlFzosj > 25 ) { list . add ( ( int ) ( XrlFzosj % 26 ) ) ; XrlFzosj = XrlFzosj / 26 - 1 ; } list . add ( ( int ) XrlFzosj ) ; 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 rnrxttQa { public static void main ( String [ ] argv ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String t = scan . next ( ) ; int RnrxttIzf = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; String u = scan . next ( ) ; if ( u . equals ( s ) ) RnrxttIzf -- ; if ( u . equals ( t ) ) b -- ; System . out . println ( RnrxttIzf + " " + b ) ; scan . close ( ) ; } } import java . util . * ; class CoveagYov { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ns = sc . next ( ) ; String [ ] s = ns . split ( " " ) ; int coveagOo = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( Integer . parseInt ( s [ i ] ) == 1 ) { coveagOo ++ ; } } System . out . println ( coveagOo ) ; } } import java . util . Scanner ; public class XcxslKehgyw { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int XcxslImi = 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 < XcxslImi ; 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 FzyUiyzo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int FzyZ = scan . nextInt ( ) ; int ans = 0 ; int b = 1 ; ArrayList < Integer > list = new ArrayList ( ) ; while ( FzyZ > 0 ) { list . add ( FzyZ % 10 ) ; FzyZ /= 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 qfegzvAhz { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String st = s . nextLine ( ) ; int QfegzvJawas = 0 ; for ( int i = 0 ; i < st . length ( ) ; i ++ ) { if ( st . charAt ( i ) == 'R' ) QfegzvJawas += 1 ; else if ( QfegzvJawas != 0 ) break ; } System . out . println ( QfegzvJawas ) ; } } import java . util . * ; public class jtaodUu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JtaodKndfu = 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 ( JtaodKndfu - set . size ( ) ) ; } } import java . util . * ; public class YzkbgiXy { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } private void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; int yzkbgiQhkn = scanner . nextInt ( ) ; int T = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; double nearOndo = 0 ; int nearIndex = 26 ; for ( int index = 0 ; index < yzkbgiQhkn ; 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 BajjmjYq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bajjmjI = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int pos = bajjmjI ; bajjmjI *= - 1 ; bajjmjI += 1 ; while ( bajjmjI < pos ) { System . out . print ( x + bajjmjI + " " ) ; bajjmjI ++ ; } } } import java . util . Scanner ; class FmxcasFhtk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String FmxcasDcx = sc . next ( ) ; if ( FmxcasDcx . matches ( " (dream|dreamer|erase|eraser)+? " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class titwkoYv { public static int TitwkoSgs ; public static int y ; public static int z ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; TitwkoSgs = sc . nextInt ( ) ; y = sc . nextInt ( ) ; if ( TitwkoSgs > y ) { solve ( TitwkoSgs , y ) ; } else { solve ( y , TitwkoSgs ) ; } 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 RxnkTtkj { static Scanner sc = new Scanner ( System . in ) ; static Scanner sc2 = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int rxnkL = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] c = new int [ rxnkL ] ; int [ ] t = new int [ rxnkL ] ; int min = 10000 ; for ( int i = 0 ; i < rxnkL ; i ++ ) { c [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < rxnkL ; 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 mjhoX { public static void main ( String ... args ) { final Scanner sc = new Scanner ( System . in ) ; final int MjhoPcw = sc . nextInt ( ) ; final int b = sc . nextInt ( ) ; System . out . printf ( " %d %d \n " , MjhoPcw * b , ( MjhoPcw + b ) * 2 ) ; } } public class mjhoX { public static void main ( String ... args ) { Rectangle . main ( ) ; } } import java . util . * ; import java . io . * ; public class UlikkXow { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int ulikkFn = Integer . parseInt ( br . readLine ( ) ) ; String [ ] Bstr = br . readLine ( ) . split ( " " ) ; int [ ] B = new int [ ulikkFn - 1 ] ; for ( int i = 0 ; i < ulikkFn - 1 ; i ++ ) { B [ i ] = Integer . parseInt ( Bstr [ i ] ) ; } int [ ] A = new int [ ulikkFn ] ; int sum = 0 ; for ( int i = 0 ; i < ulikkFn - 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 == ulikkFn - 2 ) sum += A [ ulikkFn - 1 ] ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class awaxlsBrh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int AwaxlsPboqt = S . length ( ) ; int lastIndex = S . length ( ) ; char [ ] sArray = S . toCharArray ( ) ; for ( int i = 0 ; i < sArray . length ; i ++ ) { if ( sArray [ i ] == 'A' ) { AwaxlsPboqt = i ; break ; } } for ( int i = 0 ; i < sArray . length ; i ++ ) { if ( sArray [ i ] == 'Z' ) lastIndex = i ; } System . out . println ( S . substring ( AwaxlsPboqt , lastIndex + 1 ) . length ( ) ) ; sc . close ( ) ; } } import java . util . Scanner ; class RqwedTzp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rqwedPa = sc . nextInt ( ) , sum = 0 ; double ave , tmpsum = 0 ; while ( rqwedPa != 0 ) { int [ ] s = new int [ rqwedPa ] ; for ( int i = 0 ; i < rqwedPa ; i ++ ) { s [ i ] = sc . nextInt ( ) ; sum += s [ i ] ; } ave = ( double ) sum / rqwedPa ; for ( int i = 0 ; i < rqwedPa ; i ++ ) tmpsum += ( s [ i ] - ave ) * ( s [ i ] - ave ) ; ave = tmpsum / rqwedPa ; System . out . println ( Math . sqrt ( ave ) ) ; sum = 0 ; tmpsum = 0 ; rqwedPa = sc . nextInt ( ) ; } } } import java . util . Scanner ; public class tdcX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 5 ] ; boolean TdcTkhr = 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 ) TdcTkhr = true ; else { TdcTkhr = false ; break out ; } } } if ( TdcTkhr == true ) System . out . print ( " Yay! " ) ; else System . out . print ( " :( " ) ; } } import java . util . * ; public class TwrOav { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int twrFj = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; double [ ] h = new double [ twrFj ] ; for ( int i = 0 ; i < twrFj ; i ++ ) { int b = sc . nextInt ( ) ; h [ i ] = t - b * 0.006 ; } double min = 1000000000 ; int ans = - 1 ; for ( int i = 0 ; i < twrFj ; 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 RwnXis { static class RwnXis { 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 rwnH = 0 ; rwnH < w . length ( ) ; rwnH ++ ) { int k = w . charAt ( rwnH ) - 'a' ; arr [ k ] = arr [ k ] + 1 ; } for ( int rwnH = 0 ; rwnH < 26 ; rwnH ++ ) { if ( arr [ rwnH ] % 2 != 0 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class arpBa { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int ArpOw = sc . nextInt ( ) ; int t , x , y , dis ; String ans = " Yes " ; for ( int i = 0 ; i < ArpOw ; 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 TwokmdTmi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int twokmdUedl = 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 NniyfEqed { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nniyfEkot = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; double [ ] Temp = new double [ nniyfEkot ] ; double min = ( double ) Integer . MAX_VALUE ; int minNum = - 1 ; for ( int i = 0 ; i < nniyfEkot ; 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 GwopTetnp { public static void main ( String [ ] hides ) { Scanner s = new Scanner ( System . in ) ; String GwopT = s . next ( ) ; switch ( GwopT ) { 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 ZmviaqEyd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; char [ ] c = s . toCharArray ( ) ; int ZmviaqSkh = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) if ( c [ i ] == '1' ) ZmviaqSkh = ZmviaqSkh + 1 ; System . out . println ( ZmviaqSkh ) ; } } import java . util . * ; public class MavirJiv { Scanner sc = new Scanner ( System . in ) ; final int mavirQuj = 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 ] ) % mavirQuj ; } if ( i + 2 < n ) { dp [ i + 2 ] = ( dp [ i + 2 ] + dp [ i ] ) % mavirQuj ; } } } System . out . println ( dp [ n - 1 ] ) ; } public static void main ( String [ ] args ) { new Main ( ) . doIt ( ) ; } } import java . util . * ; import java . lang . * ; public class zufowoZr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ZufowoCpmb = sc . nextLine ( ) ; if ( ZufowoCpmb . charAt ( 1 ) == 'R' ) System . out . println ( " ABC " ) ; else System . out . println ( " ARC " ) ; } } import java . util . * ; public class CghunVzn { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long CghunRs = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long divc = b / c - ( CghunRs - 1 ) / c ; long divd = b / d - ( CghunRs - 1 ) / d ; long lcmcd = lcm ( c , d ) ; long divcd = b / lcmcd - ( CghunRs - 1 ) / lcmcd ; System . out . println ( ( b - CghunRs + 1 ) - divc - divd + divcd ) ; } private static long gcd ( long CghunRs , long b ) { while ( b > 0 ) { long temp = b ; b = CghunRs % b ; CghunRs = temp ; } return CghunRs ; } private static long lcm ( long CghunRs , long b ) { return CghunRs * ( b / gcd ( CghunRs , b ) ) ; } } import java . util . Scanner ; public class QpxosEf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qpxosI = sc . nextInt ( ) ; int ans = 0 ; sc . close ( ) ; for ( int i = 1 ; i <= qpxosI ; i += 2 ) { if ( numYaku8 ( i ) ) ans += 1 ; } System . out . println ( ans ) ; } private static boolean numYaku8 ( int qpxosI ) { int yaku = 0 ; for ( int i = 1 ; i <= qpxosI ; i ++ ) { if ( qpxosI % i == 0 ) yaku += 1 ; } if ( yaku == 8 ) return true ; return false ; } } import java . util . * ; class SksuzhUyk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SksuzhY = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sho = 0 ; int amrS = 0 ; int ans = 0 ; for ( int i = 1 ; i < SksuzhY + 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 HkxErl { 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 hkxPip ; int val = strArraySub . length ; for ( int i = 1 ; i <= val ; i ++ ) { hkxPip = val - i ; System . out . print ( strArraySub [ hkxPip ] ) ; } System . out . println ( " " ) ; } } import java . util . * ; public class wjutD { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; int WjutMl = 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 < WjutMl ) ? " No " : " Yes " ) ; ob . close ( ) ; } } import java . util . * ; public class MmxOc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MmxK = Integer . parseInt ( sc . nextLine ( ) ) ; StringTokenizer dates = new StringTokenizer ( sc . nextLine ( ) ) ; StringTokenizer dates2 = new StringTokenizer ( sc . nextLine ( ) ) ; int mayor = 0 ; for ( int i = 0 ; i < MmxK ; 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 ZkqAnbyy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZkqPpi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; long i = ZkqPpi * x + b * y ; long ii = c * 2 * Math . max ( x , y ) ; long iii = 0 ; if ( x > y ) { iii = c * 2 * y + ZkqPpi * ( 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 RbaqcwIvygso { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int RbaqcwKm = sc . nextInt ( ) ; int [ ] a = new int [ RbaqcwKm ] ; for ( int i = 0 ; i < RbaqcwKm ; 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 < RbaqcwKm ; j ++ ) { System . out . println ( a [ j ] ) ; } } } } import java . util . * ; public class wcxtcmJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WcxtcmCax = sc . nextInt ( ) ; char [ ] [ ] s = new char [ WcxtcmCax ] [ 10 ] ; HashMap < String , Long > h = new HashMap < > ( ) ; long ans = 0 ; for ( int i = 0 ; i < WcxtcmCax ; 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 ohbaH { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long OhbaZqjzq = scan . nextInt ( ) ; scan . close ( ) ; System . out . println ( OhbaZqjzq / 2 + OhbaZqjzq % 2 ) ; } } import java . util . Scanner ; public class BbbpqTgr { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int BbbpqIp , b , c ; Scanner sc = new Scanner ( System . in ) ; String [ ] input = sc . nextLine ( ) . split ( " " ) ; BbbpqIp = Integer . parseInt ( input [ 0 ] ) ; b = Integer . parseInt ( input [ 1 ] ) ; c = Integer . parseInt ( input [ 2 ] ) ; int cnt = 0 ; for ( int i = BbbpqIp ; i <= b ; i ++ ) { if ( c % i == 0 ) cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . * ; public class IdzdNbcya { 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 IdzdUzg = scn . nextInt ( ) ; IdzdUzg > 0 ; IdzdUzg -- ) { 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 SxdPcv { public static void main ( String [ ] args ) { Scanner Sc = new Scanner ( System . in ) ; String sxdOiz = Sc . next ( ) ; if ( sxdOiz . contains ( " 7 " ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class lplhwYg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long LplhwTbfpg = scan . nextLong ( ) ; long value2 = ( long ) ( scan . nextDouble ( ) * 100 + 0.001 ) ; long sum = LplhwTbfpg * value2 / 100 ; scan . close ( ) ; System . out . println ( sum ) ; } } import java . util . * ; public class kpcuxK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] str = sc . next ( ) . toCharArray ( ) ; int KpcuxBt = 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' ) { KpcuxBt ++ ; } } System . out . println ( KpcuxBt == 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 shkolDo { 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 shkolDo { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int ShkolTyv = in . nextInt ( ) ; int b = in . nextInt ( ) ; if ( ShkolTyv == b ) out . println ( 0 ) ; else if ( ( ShkolTyv + b ) % 2 == 1 ) out . println ( " IMPOSSIBLE " ) ; else out . println ( ( ShkolTyv + b ) / 2 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class TfhxrsGi { 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 tfhxrsT = 0 ; tfhxrsT < 10 ; tfhxrsT ++ ) { input [ tfhxrsT ] = Integer . parseInt ( br . readLine ( ) ) ; checked [ tfhxrsT ] = false ; } for ( int tfhxrsT = 0 ; tfhxrsT < 3 ; tfhxrsT ++ ) { 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 NlmaztVpzc { 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 nlmaztIvxb = 0 ; for ( int i = 0 ; i < line_S . length ; i ++ ) { if ( line_S [ i ] . compareTo ( line_T [ i ] ) != 0 ) { nlmaztIvxb ++ ; } } System . out . println ( nlmaztIvxb ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class WlndSdjf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wlndPq = sc . nextInt ( ) ; ArrayList < Integer > arr = new ArrayList < > ( ) ; int ans = 0 ; for ( int i = 0 ; i < wlndPq ; i ++ ) { int a = sc . nextInt ( ) ; arr . add ( a ) ; } for ( int i = 1 ; i < ( wlndPq - 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 pjmRq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int PjmKpyy = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { for ( int j = i ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( i ) == t . charAt ( j ) ) PjmKpyy ++ ; break ; } } System . out . print ( PjmKpyy ) ; } } import java . util . Scanner ; public class AesypSuykv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long AesypW = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long lcm = c * d / gcd ( c , d ) ; long u = b - AesypW + 1 ; long cs = b / c - ( AesypW - 1 ) / c ; long ds = b / d - ( AesypW - 1 ) / d ; long lcms = b / lcm - ( AesypW - 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 VuiCjvghb { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String VuiZfy = stdIn . next ( ) ; if ( VuiZfy . equals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } else { System . out . println ( " ABC " ) ; } stdIn . close ( ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class ZhhaozVab { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int zhhaozSpgk = scanner . nextInt ( ) ; int next = 1 ; int [ ] a = new int [ zhhaozSpgk ] ; HashSet < Integer > hSet = new HashSet < > ( ) ; for ( int i = 0 ; i < zhhaozSpgk ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < zhhaozSpgk ; 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 YqzxxAslas { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YqzxxLe = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) , d = sc . nextInt ( ) , e = sc . nextInt ( ) , k = sc . nextInt ( ) ; String res = " Yay! " ; if ( e - YqzxxLe > k ) { res = " :( " ; } System . out . println ( res ) ; } } import java . util . Scanner ; public class OzwexLx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ozwexJv = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int plus = ozwexJv + b ; int minus = ozwexJv - b ; int multiplied = ozwexJv * 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 MjpcjfGpde { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int mjpcjfQ = 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 ( mjpcjfQ > tmp ) { mjpcjfQ = tmp ; } } System . out . println ( mjpcjfQ ) ; } } } import java . util . * ; class CstvQxy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CstvH = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] L = new int [ CstvH ] ; int [ ] D = new int [ CstvH + 1 ] ; D [ 0 ] = 0 ; for ( int i = 0 ; i < CstvH ; i ++ ) { L [ i ] = sc . nextInt ( ) ; } int ans = 1 ; for ( int i = 1 ; i <= CstvH ; i ++ ) { D [ i ] = D [ i - 1 ] + L [ i - 1 ] ; if ( D [ i ] <= X ) { ans += 1 ; } } System . out . println ( ans ) ; } } import java . util . * ; public class UrysdmZcvq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long urysdmKcn = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long C = sc . nextLong ( ) ; long D = sc . nextLong ( ) ; System . out . println ( count ( B , C , D ) - count ( urysdmKcn - 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 ZepvvCrobaw { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int ZepvvMm = 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 SmzgbdGimn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int smzgbdSas = scan . nextInt ( ) ; while ( smzgbdSas > 0 ) { int sum = 0 ; int [ ] s = new int [ smzgbdSas ] ; for ( int i = 0 ; i < smzgbdSas ; i ++ ) { s [ i ] = scan . nextInt ( ) ; sum += s [ i ] ; } double ave = ( double ) sum / smzgbdSas ; double HF = 0 ; for ( int i = 0 ; i < smzgbdSas ; i ++ ) { HF += ( ave - s [ i ] ) * ( ave - s [ i ] ) ; } HF /= ( double ) smzgbdSas ; HF = Math . pow ( HF , 0.5 ) ; System . out . println ( HF ) ; smzgbdSas = scan . nextInt ( ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class SsyRhne { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int ssyHy = scn . nextInt ( ) ; int b = scn . nextInt ( ) ; int c = scn . nextInt ( ) ; int [ ] arr = { ssyHy , 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 HpndjWty { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HpndjRz = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; double v = t + 0.5 ; int p = 0 ; p = ( int ) v / HpndjRz ; int r = 0 ; r = ( int ) p * b ; System . out . println ( r ) ; } } import java . util . * ; public class VgmxZjk { Scanner sc ; int vgmxAsn ; int [ ] v ; public Main ( ) { sc = new Scanner ( System . in ) ; } private void calc ( ) { vgmxAsn = sc . nextInt ( ) ; v = new int [ vgmxAsn ] ; for ( int i = 0 ; i < vgmxAsn ; i ++ ) v [ i ] = sc . nextInt ( ) ; Arrays . sort ( v ) ; double ans = ( double ) v [ 0 ] ; for ( int i = 1 ; i < vgmxAsn ; 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 VbdzMnzv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vbdzGzjg = sc . nextInt ( ) ; if ( vbdzGzjg == 1 ) { System . out . println ( 0 ) ; } else { int Ans = 0 ; int Temp = 0 ; int [ ] H = new int [ vbdzGzjg ] ; for ( int i = 0 ; i < vbdzGzjg ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < vbdzGzjg - 1 ; i ++ ) { if ( H [ i ] >= H [ i + 1 ] ) { Temp += 1 ; } if ( ( H [ i ] < H [ i + 1 ] ) | ( i == vbdzGzjg - 2 ) ) { if ( Ans < Temp ) { Ans = Temp ; } Temp = 0 ; } } System . out . println ( Ans ) ; } sc . close ( ) ; } } import java . io . * ; class UzxTr { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String taro , hanako , str ; int uzxVv = 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 ) uzxVv += 3 ; else { uzxVv ++ ; sh ++ ; } } System . out . println ( uzxVv + " " + sh ) ; } } import java . util . Scanner ; public class CgyqcgUb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cgyqcgXv = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int product = cgyqcgXv * l ; int around = 2 * ( cgyqcgXv + l ) ; System . out . println ( product + " " + around ) ; } } import java . util . Scanner ; public class UjffSi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ujffE = 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 kqlWi { public static void main ( String [ ] args ) { int KqlWjtrh ; int [ ] A1i ; int [ ] A2i ; Set < Integer > searched = new HashSet < > ( ) ; Queue < Integer > queue = new LinkedList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ) { KqlWjtrh = sc . nextInt ( ) ; A1i = new int [ KqlWjtrh ] ; A2i = new int [ KqlWjtrh ] ; for ( int i = 0 ; i < KqlWjtrh ; i ++ ) { A1i [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < KqlWjtrh ; i ++ ) { A2i [ i ] = sc . nextInt ( ) ; } } int [ ] Sum1 = new int [ KqlWjtrh ] ; int sum1 = 0 ; for ( int i = 0 ; i < KqlWjtrh ; i ++ ) { sum1 += A1i [ i ] ; Sum1 [ i ] = sum1 ; } int [ ] Sum2 = new int [ KqlWjtrh ] ; int sum2 = 0 ; for ( int i = KqlWjtrh - 1 ; i >= 0 ; i -- ) { sum2 += A2i [ i ] ; Sum2 [ i ] = sum2 ; } int result = 0 ; for ( int i = 0 ; i < KqlWjtrh ; i ++ ) { if ( result < Sum1 [ i ] + Sum2 [ i ] ) { result = Sum1 [ i ] + Sum2 [ i ] ; } } System . out . println ( result ) ; } } import java . util . * ; public class UqdsHmwca { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UqdsIy = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; if ( UqdsIy <= C && B <= C ) { System . out . println ( " 0 " ) ; } else if ( UqdsIy <= C && B <= D ) { System . out . println ( B - C ) ; } else if ( UqdsIy <= C && B > D ) { System . out . println ( D - C ) ; } else if ( UqdsIy > C && D <= UqdsIy ) { System . out . println ( " 0 " ) ; } else if ( UqdsIy > C && B >= D ) { System . out . println ( D - UqdsIy ) ; } else { System . out . println ( B - UqdsIy ) ; } } } import java . util . Scanner ; public class bmzYlt { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; char [ ] s = scanner . next ( ) . toCharArray ( ) ; for ( int BmzJxz = 1 ; BmzJxz < 3 ; BmzJxz ++ ) { if ( s [ BmzJxz ] != s [ BmzJxz - 1 ] ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class QzdVf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qzdTgyq = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int sum = l * qzdTgyq ; int [ ] aji = new int [ qzdTgyq ] ; for ( int i = 0 ; i < qzdTgyq ; i ++ ) { sum += i ; aji [ i ] = l + i ; } int min = Integer . MAX_VALUE / 2 ; int aji2 = 0 ; for ( int i = 0 ; i < qzdTgyq ; 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 GtriuBq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String alpha = " abcdefghijklmnopqrstuvwxyz " ; String target = sc . next ( ) ; for ( int gtriuUy = 0 ; gtriuUy <= 24 ; gtriuUy ++ ) { if ( String . valueOf ( alpha . charAt ( gtriuUy ) ) . equals ( target ) ) { System . out . println ( alpha . charAt ( gtriuUy + 1 ) ) ; } } } } import java . util . * ; public class RliyvHwn { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int rliyvFu = s . nextInt ( ) , x = s . nextInt ( ) , t = s . nextInt ( ) ; int count = 0 ; count = rliyvFu / x * t ; if ( rliyvFu % x > 0 ) count += t ; System . out . println ( count ) ; } } import java . util . Scanner ; public class QvldyqCjjqgk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QvldyqSsq = scan . nextInt ( ) ; int taro = 0 ; int hanako = 0 ; for ( int i = 0 ; i < QvldyqSsq ; 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 YknskcLrwsiw { 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 YknskcK = Integer . parseInt ( line [ 0 ] ) ; int W = Integer . parseInt ( line [ 1 ] ) ; if ( YknskcK != 0 && W != 0 ) { String yoko = Wwrite ( W ) ; Hwrite ( YknskcK , 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 YknskcK , String yoko ) { for ( int i = 0 ; i < YknskcK ; i ++ ) { System . out . println ( yoko ) ; } } } import java . util . * ; public class aqrtRdk { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int AqrtChp = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( AqrtChp + AqrtChp * AqrtChp + AqrtChp * AqrtChp * AqrtChp ) ; } } import java . util . * ; public class ZfyFy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zfyMghs = sc . nextInt ( ) ; int [ ] res = new int [ zfyMghs ] ; 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 JxtdiRkbn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String JxtdiF = sc . next ( ) ; String [ ] ar = JxtdiF . split ( " " ) ; for ( String s : ar ) { if ( s . equals ( " 1 " ) ) { System . out . print ( 9 ) ; } else { System . out . print ( 1 ) ; } } } } import java . util . Scanner ; public class UdudsEyi { static void putArray ( int [ ] array ) { System . out . print ( array [ 0 ] ) ; for ( int ududsLdd = 1 ; ududsLdd < array . length ; ududsLdd ++ ) { System . out . print ( " " + array [ ududsLdd ] ) ; } 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 ududsLdd = 0 ; ududsLdd < array . length ; ududsLdd ++ ) { array [ ududsLdd ] = sc . nextInt ( ) ; } putArray ( array ) ; for ( int ududsLdd = 1 ; ududsLdd < array . length ; ududsLdd ++ ) { int v = array [ ududsLdd ] ; int j = ududsLdd - 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 OpxivbQp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int OpxivbU = scan . nextInt ( ) ; int i = 0 ; int taro_count = 0 ; int hana_count = 0 ; for ( i = 0 ; i < OpxivbU ; 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 EszgSpjwj { public static int [ ] ans ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EszgO = sc . nextInt ( ) ; int [ ] list = new int [ EszgO ] ; for ( int i = 0 ; i < EszgO ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } int count = 0 ; boolean flag = true ; while ( flag ) { for ( int i = 0 ; i < EszgO ; i ++ ) { if ( list [ i ] % 2 == 1 ) { flag = false ; } list [ i ] = list [ i ] / 2 ; if ( i == EszgO - 1 && flag ) { count ++ ; } } } System . out . println ( count ) ; } } import java . math . BigInteger ; import java . util . * ; public class BxgpPadk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; long bxgpSali = sc . nextLong ( ) ; BigInteger K = BigInteger . valueOf ( bxgpSali ) ; 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 ubdB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UbdIaa = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long x = 1 ; long n = 0 ; while ( true ) { n = UbdIaa * x ; if ( n % b == 0 ) { break ; } x ++ ; } System . out . println ( n ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class cudtAjn { 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 CudtXvmr = Integer . parseInt ( arr [ 0 ] ) ; int x = Integer . parseInt ( arr [ 1 ] ) ; if ( CudtXvmr == 0 && x == 0 ) break ; int cnt = 0 ; for ( int i = 1 ; i <= CudtXvmr ; i ++ ) { for ( int j = i + 1 ; j <= CudtXvmr ; j ++ ) { for ( int k = j + 1 ; k <= CudtXvmr ; 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 YajbdXpq { 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 yajbdFwg = 0 ; yajbdFwg < intarray . length ; yajbdFwg ++ ) { intarray [ yajbdFwg ] = Integer . parseInt ( strarray [ yajbdFwg ] ) ; } return intarray ; } static Integer [ ] inputvalInteger ( ) throws Exception { String [ ] strarray = br . readLine ( ) . trim ( ) . split ( " " ) ; Integer [ ] intarray = new Integer [ strarray . length ] ; for ( int yajbdFwg = 0 ; yajbdFwg < intarray . length ; yajbdFwg ++ ) { intarray [ yajbdFwg ] = Integer . parseInt ( strarray [ yajbdFwg ] ) ; } return intarray ; } public static void main ( String [ ] args ) throws Exception { int n = Integer . parseInt ( br . readLine ( ) . trim ( ) ) ; HashSet < Integer > st = new HashSet < > ( ) ; for ( int yajbdFwg = 0 ; yajbdFwg < n ; yajbdFwg ++ ) { int d = Integer . parseInt ( br . readLine ( ) . trim ( ) ) ; st . add ( d ) ; } System . out . println ( st . size ( ) ) ; } } import java . util . Scanner ; public class MqdgfRm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String mqdgfUsj = scanner . next ( ) ; switch ( mqdgfUsj ) { 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 kggUs { 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 KggEk = input . length ; KggEk > 0 ; KggEk -- ) { System . out . print ( input [ KggEk - 1 ] ) ; } System . out . println ( ) ; } } } public class sgvrbKeb { public static void main ( String [ ] args ) { java . util . Scanner cin = new java . util . Scanner ( System . in ) ; int SgvrbYef ; for ( SgvrbYef = cin . nextInt ( ) ; SgvrbYef != 0 ; -- SgvrbYef ) { 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 QwzkbxOjpcys { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int QwzkbxD = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; if ( QwzkbxD == - 1 && f == - 1 && r == - 1 ) { break ; } if ( QwzkbxD == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } else { int S = QwzkbxD + 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 YhdmrRywp { 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 YhdmrF = Integer . parseInt ( scan . next ( ) ) ; for ( int i = 0 ; i < YhdmrF ; 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 meuyrB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MeuyrLy = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String q = " Odd " ; if ( MeuyrLy % 2 == 0 || b % 2 == 0 ) { q = " Even " ; } System . out . println ( q ) ; } } import java . util . Scanner ; public class YllbfPv { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int yllbfLr = scn . nextInt ( ) ; int ans = 0 ; int num = 0 ; while ( yllbfLr / ( 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 += yllbfLr - Math . pow ( 10 , num - 1 ) + 1 ; } System . out . println ( ans ) ; } } import java . util . * ; public class ywlkwyY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YwlkwySuyg = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; int sum = L * YwlkwySuyg + ( YwlkwySuyg * ( YwlkwySuyg - 1 ) ) / 2 ; if ( L > 0 ) sum -= L ; else if ( L + YwlkwySuyg - 1 < 0 ) sum -= L + YwlkwySuyg - 1 ; System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class pubmUs { 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 PubmYzx = sc . nextInt ( ) ; sc . close ( ) ; Arrays . parallelSort ( a ) ; for ( int i = 0 ; i < PubmYzx ; 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 UqqcbYg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uqqcbKdbb = sc . nextInt ( ) ; List < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; uqqcbKdbb > 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 ssoAst { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] a = new int [ 3 ] [ 3 ] ; for ( int SsoJnbw = 0 ; SsoJnbw < 3 ; SsoJnbw ++ ) for ( int j = 0 ; j < 3 ; j ++ ) a [ SsoJnbw ] [ 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 HhwCeqy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int hhwV = scan . nextInt ( ) ; int cnt = 0 ; boolean a = hhwV > 99 ; if ( a ) { cnt ++ ; hhwV = hhwV - 100 ; } boolean b = hhwV > 9 ; if ( b ) { hhwV = hhwV - 10 ; cnt ++ ; } boolean c = hhwV == 1 ; if ( c ) { cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class EvstmbBft { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int [ ] list = new int [ 9 ] ; int evstmbKj = scanner . nextInt ( ) ; for ( int i = 0 ; i < evstmbKj ; 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 UisKzjts { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UisUz = sc . nextInt ( ) ; int max = 1 ; String w = " " ; Map < String , Integer > map = new HashMap < > ( ) ; List < String > strArr = new ArrayList < > ( ) ; for ( int i = 0 ; i < UisUz ; 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 QkwgbEsawy { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int QkwgbK = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int A = 0 ; for ( int i = 0 ; i < N ; i ++ ) { A += sc . nextInt ( ) ; } System . out . println ( QkwgbK > A ? " No " : " Yes " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class vfxgkbK { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . VfxgkbBjjl ) ) ) { int VfxgkbBjjl = Integer . parseInt ( br . readLine ( ) ) ; System . out . println ( VfxgkbBjjl * 2 * Math . PI ) ; } } } import java . util . * ; public class WqpyvObrr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int wqpyvKxs = s . length ( ) ; int tlen = t . length ( ) ; int min = 10000 ; for ( int i = 0 ; i < wqpyvKxs - 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 WyynQjr { public static void main ( String ... args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int wyynD = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ wyynD ] ; for ( int i = 0 ; i < wyynD ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int [ ] dp = new int [ wyynD ] ; for ( int i = 0 ; i < wyynD ; 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 [ wyynD - 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 kqfGp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int KqfTree = scan . nextInt ( ) ; int q = scan . nextInt ( ) ; int r = scan . nextInt ( ) ; int [ ] a = { KqfTree , q , r } ; Arrays . sort ( a ) ; System . out . println ( a [ 0 ] + a [ 1 ] ) ; } } import java . util . * ; public class CkhaXaey { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ckhaYcfa = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int [ ] [ ] X = new int [ ckhaYcfa ] [ D ] ; for ( int i = 0 ; i < ckhaYcfa ; 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 < ckhaYcfa ; i ++ ) { for ( int j = i ; j < ckhaYcfa ; 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 gkeUq { public static void main ( String [ ] args ) throws java . lang . Exception { PrintWriter out = new PrintWriter ( System . out ) ; FastScanner fs = new FastScanner ( ) ; long GkeWg = fs . nextLong ( ) ; double b = fs . nextDouble ( ) ; BigDecimal bg1 = BigDecimal . valueOf ( GkeWg ) ; BigDecimal bg2 = BigDecimal . valueOf ( b ) ; out . println ( bg1 . multiply ( bg2 ) . setScale ( 0 , RoundingMode . DOWN ) ) ; out . close ( ) ; } static class gkeUq { 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 [ ] GkeWg = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) GkeWg [ i ] = nextInt ( ) ; return GkeWg ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } } import java . util . Scanner ; public class hkeYjo { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; int HkeTtbd = kb . nextInt ( ) ; int [ ] [ ] a = new int [ HkeTtbd ] [ 3 ] ; int x , y , z ; for ( int i = 0 ; i < HkeTtbd ; i ++ ) { a [ i ] [ 0 ] = kb . nextInt ( ) ; a [ i ] [ 1 ] = kb . nextInt ( ) ; a [ i ] [ 2 ] = kb . nextInt ( ) ; } for ( int i = 0 ; i < HkeTtbd ; 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 NvjzXdml { public static void main ( String [ ] args ) { run ( ) ; } static void run ( ) { Scanner sc = new Scanner ( System . in ) ; int NvjzI = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int ans = isDivisor ( NvjzI , b , c ) ; System . out . println ( ans ) ; } static int isDivisor ( int NvjzI , int b , int c ) { int ans = 0 ; for ( int i = NvjzI ; i <= b ; i ++ ) { if ( c % i == 0 ) { ans ++ ; } } return ans ; } } import java . util . HashMap ; import java . util . Scanner ; public class VpxXqmm { public static void main ( String [ ] args ) { HashMap < String , String > map = new HashMap < String , String > ( ) ; Scanner sc = new Scanner ( System . in ) ; int vpxX = sc . nextInt ( ) ; String str = sc . nextLine ( ) ; for ( int i = 0 ; i < vpxX ; i ++ ) { map . put ( sc . nextLine ( ) , " " ) ; } sc . close ( ) ; System . out . println ( map . size ( ) ) ; } } import java . util . * ; public class ZciawSamuy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZciawY = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] [ ] mat = new int [ ZciawY ] [ M ] ; for ( int i = 0 ; i < ZciawY ; 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 , ZciawY , M ) ) { answer = answer + 1 ; } } System . out . println ( answer ) ; } public static boolean isAllLike ( int [ ] [ ] mat , int x , int ZciawY , int M ) { boolean isLike = false ; for ( int i = 0 ; i < ZciawY ; 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 YyljaJlt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yyljaEbn = 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 <= yyljaEbn ; 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 ygsfnuPwr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String token = sc . next ( ) ; String [ ] strArray = token . split ( " " ) ; int YgsfnuQhro = 0 ; if ( strArray [ 0 ] . equals ( " 1 " ) ) { YgsfnuQhro ++ ; } if ( strArray [ 1 ] . equals ( " 1 " ) ) { YgsfnuQhro += 1 ; } if ( strArray [ 2 ] . equals ( " 1 " ) ) { YgsfnuQhro += 1 ; } System . out . println ( YgsfnuQhro ) ; sc . close ( ) ; } } import java . util . * ; public class mypdLg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MypdFo = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int min = 10001 ; for ( int i = 0 ; i < MypdFo ; 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 nznzH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NznzGj = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] mArray = new int [ m + 1 ] ; for ( int i = 0 ; i < NznzGj ; 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 ] == NznzGj ) result ++ ; } System . out . println ( result ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; public class rnrccmY { public static void main ( String [ ] args ) throws Exception { Scanner cin = new Scanner ( System . in ) ; int RnrccmFrg = cin . nextInt ( ) , b = cin . nextInt ( ) ; System . out . println ( GCD ( RnrccmFrg , b ) ) ; } public static int GCD ( int RnrccmFrg , int b ) { if ( b == 0 ) return RnrccmFrg ; return GCD ( b , RnrccmFrg % b ) ; } } import java . util . Scanner ; import java . util . Stack ; public class PwqzuOjt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String [ ] A = scan . nextLine ( ) . split ( " " ) ; Stack < Integer > num = new Stack < Integer > ( ) ; int pwqzuE = 0 ; int b = 0 ; for ( int i = 0 ; i < A . length ; i ++ ) { if ( A [ i ] . equals ( " + " ) ) { pwqzuE = num . pop ( ) ; b = num . pop ( ) ; num . add ( b + pwqzuE ) ; continue ; } if ( A [ i ] . equals ( " - " ) ) { pwqzuE = num . pop ( ) ; b = num . pop ( ) ; num . add ( b - pwqzuE ) ; continue ; } if ( A [ i ] . equals ( " * " ) ) { pwqzuE = num . pop ( ) ; b = num . pop ( ) ; num . add ( b * pwqzuE ) ; continue ; } if ( A [ i ] . equals ( " / " ) ) { pwqzuE = num . pop ( ) ; b = num . pop ( ) ; num . add ( b / pwqzuE ) ; 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 EknGjwlwh { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long EknPt , b = 0 ; long n = Long . parseLong ( br . readLine ( ) ) ; int digits , mindigits = 11 ; for ( EknPt = 1 ; EknPt <= Math . sqrt ( n ) ; EknPt ++ ) { if ( n % EknPt == 0 ) { b = n / EknPt ; digits = String . valueOf ( Math . max ( EknPt , b ) ) . length ( ) ; if ( digits < mindigits ) mindigits = digits ; } } System . out . println ( mindigits ) ; } } import java . util . * ; import java . lang . Double ; public class HramgiIrny { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; String hramgiCrt = reader . nextLine ( ) ; if ( hramgiCrt . equals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } else { System . out . println ( " ABC " ) ; } } } import java . util . Scanner ; public class ailaQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String AilaVl = sc . nextLine ( ) ; StringBuffer sb = new StringBuffer ( AilaVl ) ; String rv = sb . reverse ( ) . toString ( ) ; System . out . println ( rv ) ; } } import java . util . Scanner ; public class JapktIxxs { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int japktShy = stdIn . nextInt ( ) ; int [ ] a = new int [ japktShy + 1 ] ; for ( int i = 1 ; i <= japktShy ; 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 <= japktShy ; i ++ ) System . out . println ( a [ i ] ) ; } } import java . util . Scanner ; public class rkvzTm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RkvzBury = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int A = 10000 ; int B = 5000 ; int C = 1000 ; for ( int ai = 0 ; ai <= RkvzBury ; ai ++ ) { for ( int bi = 0 ; bi <= RkvzBury - ai ; bi ++ ) { int ci = RkvzBury - 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 CbtRvg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cbtS = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( y % 2 == 1 ) { System . out . println ( " No " ) ; return ; } if ( y >= 2 * cbtS && y <= 4 * cbtS ) { System . out . println ( " Yes " ) ; return ; } System . out . println ( " No " ) ; } } import java . util . * ; public class HqvoZztkb { static int HqvoYfp = ( 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 gejikwJut { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { String [ ] str = scan . nextLine ( ) . split ( " " ) ; int GejikwQokg = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 2 ] ) ; if ( " ? " . equals ( str [ 1 ] ) ) break ; if ( " + " . equals ( str [ 1 ] ) ) { System . out . println ( GejikwQokg + b ) ; } else if ( " - " . equals ( str [ 1 ] ) ) { System . out . println ( GejikwQokg - b ) ; } else if ( " * " . equals ( str [ 1 ] ) ) { System . out . println ( GejikwQokg * b ) ; } else if ( " / " . equals ( str [ 1 ] ) ) { System . out . println ( GejikwQokg / b ) ; } } } } import java . util . Scanner ; public class VzseYl { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String N = in . next ( ) ; int VzseMl = 0 ; for ( int i = 1 ; i <= Integer . parseInt ( N ) ; i ++ ) if ( String . valueOf ( i ) . length ( ) % 2 == 1 ) VzseMl ++ ; System . out . println ( VzseMl ) ; } } import java . util . * ; public class pokVm { 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 PokXnw = 0 ; PokXnw < 26 ; PokXnw ++ ) { alpha [ PokXnw ] = str . charAt ( PokXnw ) ; } int [ ] count = new int [ 26 ] ; for ( int PokXnw = 0 ; PokXnw < w . length ( ) ; PokXnw ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) { if ( w . charAt ( PokXnw ) == alpha [ j ] ) count [ j ] ++ ; } } for ( int PokXnw = 0 ; PokXnw < 26 ; PokXnw ++ ) { if ( count [ PokXnw ] % 2 != 0 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; class hhoeCqu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HhoeRi = sc . nextInt ( ) ; int [ ] t = new int [ HhoeRi + 1 ] ; t [ 0 ] = 0 ; int [ ] x = new int [ HhoeRi + 1 ] ; x [ 0 ] = 0 ; int [ ] y = new int [ HhoeRi + 1 ] ; x [ 0 ] = 0 ; for ( int i = 1 ; i <= HhoeRi ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < HhoeRi ; 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 CvbztVs { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int CvbztF = Integer . parseInt ( br . readLine ( ) ) ; Map < String , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < CvbztF ; 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 ByijxEjuc { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int byijxSdd = s . nextInt ( ) ; int m = s . nextInt ( ) ; int x = s . nextInt ( ) ; char [ ] road = new char [ byijxSdd ] ; 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 < byijxSdd ; 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 < byijxSdd ; q ++ ) { if ( road [ q ] == 'c' ) { ++ countC ; } } } System . out . println ( countC ) ; } } import java . util . * ; public class LzcrgUugkxe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] split = s . split ( " " ) ; int LzcrgKq ; int count = 0 , ans = 0 ; for ( LzcrgKq = 0 ; LzcrgKq < s . length ( ) ; LzcrgKq ++ ) { if ( split [ LzcrgKq ] . equals ( " A " ) || split [ LzcrgKq ] . equals ( " C " ) || split [ LzcrgKq ] . equals ( " G " ) || split [ LzcrgKq ] . 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 ikxR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; int IkxXic = Integer . parseInt ( s . replaceAll ( " " , " " ) ) ; int sqrt = ( int ) Math . sqrt ( IkxXic ) ; System . out . println ( ( sqrt * sqrt == IkxXic ) ? " Yes " : " No " ) ; } } import java . util . * ; public class IuziokDohi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Random rand = new Random ( ) ; int iuziokZv = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += sc . nextInt ( ) ; } if ( iuziokZv <= sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class CiknImu { static int CiknRno = 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 , CiknRno ) - 1 ) ; } public static void test ( long hp ) { hp = hp / 2 ; if ( hp == 0 ) return ; CiknRno ++ ; test ( hp ) ; } } import java . io . * ; public class LvzHt { 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 lvzV = Integer . parseInt ( arr [ 0 ] ) ; int w = Integer . parseInt ( arr [ 1 ] ) ; if ( lvzV == 0 && w == 0 ) { break ; } for ( int i = 0 ; i < lvzV ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( i == 0 || i == lvzV - 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 CcrraZp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ccrraHs = sc . nextInt ( ) ; int len = String . valueOf ( ccrraHs ) . 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 += ccrraHs - ( int ) Math . pow ( 10 , len - 1 ) + 1 ; } System . out . println ( res ) ; } } import java . util . * ; public class QkkvgZne { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qkkvgZfol = sc . nextInt ( ) ; String S = sc . next ( ) ; char Si = S . charAt ( 0 ) ; int count = 1 ; for ( int i = 1 ; i < qkkvgZfol ; i ++ ) { if ( S . charAt ( i ) == Si ) ; else { count ++ ; Si = S . charAt ( i ) ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class rmgqgN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RmgqgNcq = sc . nextInt ( ) ; int [ ] a = new int [ RmgqgNcq ] ; float sum = 0 ; for ( int y = 0 ; y < RmgqgNcq ; y ++ ) { a [ y ] = sc . nextInt ( ) ; sum += a [ y ] ; } int p = Math . round ( sum / RmgqgNcq ) ; int res = 0 ; for ( int i = 0 ; i < RmgqgNcq ; i ++ ) { res += ( a [ i ] - p ) * ( a [ i ] - p ) ; } System . out . println ( res ) ; sc . close ( ) ; } } import java . util . Scanner ; class KcxrqPewk { private static int gcd ( int a , int b ) { while ( b != 0 ) { int kcxrqJujr = a % b ; a = b ; b = kcxrqJujr ; } 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 pyqgA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] tmp = sc . nextLine ( ) . split ( " " ) ; int PyqgLqxyh = Integer . valueOf ( tmp [ 0 ] ) ; int b = Integer . valueOf ( tmp [ 1 ] ) ; int sum = judge ( PyqgLqxyh , b ) ; if ( PyqgLqxyh < b ) { b -- ; } else { PyqgLqxyh -- ; } sum += judge ( PyqgLqxyh , b ) ; System . out . println ( sum ) ; } public static int judge ( int PyqgLqxyh , int b ) { int res = 0 ; if ( PyqgLqxyh < b ) { res = b ; } else { res = PyqgLqxyh ; } return res ; } } import java . util . Scanner ; public class LhvrooYfw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LhvrooQey = scan . nextInt ( ) ; int A = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int cnt = 0 ; for ( int i = A ; i <= B ; i ++ ) { if ( i % LhvrooQey == 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 ftjcoHtt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int FtjcoHf = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int resultCount = 0 ; for ( int i = 0 ; i < FtjcoHf ; i ++ ) { final int num = sc . nextInt ( ) ; if ( num % 2 == 0 ) { list . add ( num ) ; } else { break ; } } if ( list . size ( ) != FtjcoHf ) { System . out . print ( resultCount ) ; return ; } boolean continueFlag = true ; while ( continueFlag ) { int count = 0 ; for ( int j = 0 ; j < FtjcoHf ; j ++ ) { int num = list . get ( j ) ; if ( num % 2 == 0 ) { list . set ( j , num / 2 ) ; count ++ ; } else { continueFlag = false ; break ; } } if ( count == FtjcoHf ) { resultCount ++ ; } } System . out . print ( resultCount ) ; sc . close ( ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class WogoqStl { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int WogoqIu = scanner . nextInt ( ) ; int count = 0 ; boolean flg = true ; List < Integer > numList = new ArrayList < > ( ) ; scanner . nextLine ( ) ; for ( int i = 0 ; i < WogoqIu ; 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 ygraFz { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] array = br . readLine ( ) . split ( " " ) ; int YgraXfo = Integer . parseInt ( array [ 0 ] ) ; int y = Integer . parseInt ( array [ 1 ] ) ; int z = y % 4 ; if ( ( z == 0 || z % 2 == 0 ) && 4 * YgraXfo >= y && 2 * YgraXfo <= 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 LbzopbBhcljb { public static void main ( String [ ] args ) throws NumberFormatException , IOException { try ( Scanner sc = new Scanner ( System . in ) ) { int LbzopbU = 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 RklTohg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; try { final int rklJki = 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 + rklJki ; 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 zscebF { public static void main ( String [ ] args ) { Scanner sc = new java . util . Scanner ( System . in ) ; int ZscebFv = 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 ) { ZscebFv += max ; } else { bob += max ; } iCards . remove ( iCards . indexOf ( max ) ) ; } System . out . println ( ZscebFv - bob ) ; } } import java . util . * ; public class iagvjR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . next ( ) ; char IagvjSf = C . charAt ( 0 ) ; System . out . println ( ++ IagvjSf ) ; } } import java . util . Scanner ; public class jwdwvsIi { public static int Int ( int a ) { int JwdwvsOpplt = 0 ; if ( a == 9 ) { JwdwvsOpplt = 1 ; } else { JwdwvsOpplt = 9 ; } return JwdwvsOpplt ; } 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 HqppplZcbmn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long HqppplJ = scanner . nextLong ( ) ; long R = scanner . nextLong ( ) ; if ( R - HqppplJ >= 2018L ) { System . out . println ( 0 ) ; return ; } long m1 = HqppplJ % 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 EtlolTmzxgk { public static void main ( String [ ] args ) { int EtlolJsq = 0 ; int K = 0 ; String S ; Scanner sc = new Scanner ( System . in ) ; EtlolJsq = 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 pbfiDzt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PbfiLqp = 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 < PbfiLqp ; 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 fgvblSji { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FgvblNxw = sc . nextInt ( ) ; int [ ] arr = new int [ FgvblNxw ] ; for ( int i = 0 ; i < FgvblNxw ; i ++ ) { arr [ sc . nextInt ( ) - 1 ] = i + 1 ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < FgvblNxw ; 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 IalrjJsr { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int IalrjOwo = input . nextInt ( ) ; String S = input . next ( ) ; if ( S . length ( ) <= IalrjOwo ) System . out . println ( S ) ; else System . out . println ( S . substring ( 0 , IalrjOwo ) + " ... " ) ; } } public class UfoZt { public void run ( java . util . Scanner sc ) { int [ ] a ; int ufoDb , j ; a = new int [ sc . nextInt ( ) ] ; for ( ufoDb = 0 ; ufoDb < a . length ; ++ ufoDb ) a [ ufoDb ] = sc . nextInt ( ) ; for ( ufoDb = 0 ; ufoDb < a . length ; ++ ufoDb ) { final int t = a [ ufoDb ] ; for ( j = ufoDb - 1 ; j >= 0 ; -- j ) { if ( t < a [ j ] ) { a [ j + 1 ] = a [ j ] ; a [ j ] = t ; } } printArray ( a ) ; } } private void printArray ( int [ ] a ) { int ufoDb ; for ( ufoDb = 0 ; ufoDb < a . length ; ++ ufoDb ) { System . out . print ( a [ ufoDb ] ) ; if ( ufoDb + 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 DhmQmjr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dhmT = 0 , H , A ; H = scan . nextInt ( ) ; A = scan . nextInt ( ) ; while ( H > 0 ) { H = H - A ; dhmT ++ ; } System . out . println ( dhmT ) ; } } import java . util . * ; class jgppY { int max ( int JgppAz , int b ) { if ( JgppAz < b ) return b ; else return JgppAz ; } int min ( int JgppAz , int b ) { if ( JgppAz > b ) return b ; else return JgppAz ; } Main ( ) { Scanner sc = new Scanner ( System . in ) ; int JgppAz , c , d ; JgppAz = sc . nextInt ( ) ; d = - 1000000000 ; c = sc . nextInt ( ) ; for ( int i = 0 ; i < JgppAz - 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 ckjouCe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double CkjouPish = 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 ( CkjouPish * CkjouPish + b * b - 2 * CkjouPish * b * Math . cos ( Math . toRadians ( kaku ) ) ) ; System . out . println ( result ) ; } } import java . io . * ; import java . util . * ; class DvkvuNuii { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dvkvuP = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; while ( dvkvuP != 0 || W != 0 ) { for ( int i = 0 ; i < dvkvuP ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { System . out . printf ( " # " ) ; } System . out . printf ( " \n " ) ; } System . out . printf ( " \n " ) ; dvkvuP = sc . nextInt ( ) ; W = sc . nextInt ( ) ; } } } import java . math . BigInteger ; import java . util . Scanner ; public class leiQol { public static void main ( String [ ] args ) { Long K ; Scanner sc = new Scanner ( System . in ) ; K = sc . nextLong ( ) ; Long bank = 100L ; int LeiXlvto = 0 ; while ( bank < K ) { bank = ( long ) ( bank * 1.01 ) ; LeiXlvto ++ ; } System . out . println ( LeiXlvto ) ; } } import java . util . * ; public class ylbgS { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int YlbgUt = sc . nextInt ( ) ; if ( YlbgUt / 10 == 0 ) { System . out . println ( YlbgUt % 10 ) ; } else if ( YlbgUt / 100 == 0 ) { System . out . println ( 9 ) ; } else if ( YlbgUt / 1000 == 0 ) { System . out . println ( YlbgUt % 1000 - 99 + 9 ) ; } else if ( YlbgUt / 10000 == 0 ) { System . out . println ( 909 ) ; } else if ( YlbgUt / 100000 == 0 ) { System . out . println ( YlbgUt % 100000 - 9999 + 900 + 9 ) ; } else { System . out . println ( 90909 ) ; } } } import java . util . * ; public class LzupYdvn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LzupN = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; if ( c - ( LzupN - b ) >= 0 ) { System . out . println ( c - ( LzupN - b ) ) ; } else { System . out . println ( 0 ) ; } } } import java . util . Scanner ; public class ifhcH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IfhcQds = sc . nextInt ( ) ; int [ ] A ; A = new int [ IfhcQds ] ; int count = 0 ; for ( int i = 0 ; i < IfhcQds ; ++ i ) { A [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < IfhcQds - 1 ; ++ i ) { for ( int j = 0 ; j < IfhcQds - 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 , IfhcQds ) ; System . out . println ( count ) ; } public static void print ( int [ ] A , int IfhcQds ) { for ( int i = 0 ; i < IfhcQds ; ++ i ) { System . out . print ( A [ i ] ) ; if ( i < IfhcQds - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } import java . util . * ; public class NydKmnpi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NydTf = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= NydTf ; 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 WwwMoqc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WwwOt = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; for ( int i = 1 ; i <= K ; i ++ ) { if ( K - WwwOt == 0 ) { System . out . println ( WwwOt * 1 ) ; return ; } if ( K - WwwOt < 0 ) { System . out . println ( K * 1 ) ; return ; } if ( ( K - WwwOt ) - B <= 0 ) { System . out . println ( WwwOt * 1 + B * 0 ) ; return ; } if ( ( K - WwwOt ) - B > 0 ) { System . out . println ( WwwOt * 1 + B * 0 + ( ( ( K - WwwOt ) - 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 NfnaadIvu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; for ( int nfnaadNwt = 0 ; nfnaadNwt < 10 ; nfnaadNwt ++ ) { 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 AlnmjiQc { 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 alnmjiBhcn = 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 ( alnmjiBhcn % ans == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class BcifIeccin { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BcifHx = sc . nextInt ( ) ; int cnt = 0 ; if ( BcifHx % 2 == 0 ) { cnt = BcifHx / 2 ; System . out . println ( cnt ) ; } else { cnt = ( int ) ( BcifHx / 2 ) + 1 ; System . out . println ( cnt ) ; } } } import java . util . Scanner ; public class CrtKlp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String crtSoqh = sc . next ( ) ; String str = sc . next ( ) ; sc . close ( ) ; crtSoqh += crtSoqh ; if ( crtSoqh . contains ( str ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class IonUilyw { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int IonJnl = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int [ ] H = new int [ IonJnl ] ; for ( int i = 0 ; i < IonJnl ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } double min = Double . MAX_VALUE ; int minPotision = 0 ; for ( int i = 0 ; i < IonJnl ; 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 ZfvIdz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zfvBkt = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sc . nextLine ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < zfvBkt ; 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 < zfvBkt ; 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 ( zfvBkt - 1 ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class TxqbpuRd { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int txqbpuFt = stdIn . nextInt ( ) ; int n1 = txqbpuFt / 100 ; txqbpuFt = txqbpuFt - n1 * 100 ; int n2 = txqbpuFt / 10 ; txqbpuFt = txqbpuFt - n2 * 10 ; if ( txqbpuFt == 2 || txqbpuFt == 4 || txqbpuFt == 5 || txqbpuFt == 7 || txqbpuFt == 9 ) { System . out . println ( " hon " ) ; } else if ( txqbpuFt == 0 || txqbpuFt == 1 || txqbpuFt == 6 || txqbpuFt == 8 ) { System . out . println ( " pon " ) ; } else { System . out . println ( " bon " ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class SdkalzQfj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SdkalzDem = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < > ( ) ; String newWord ; for ( int i = 0 ; i < SdkalzDem ; 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 eqlmXxk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String str = sc . next ( ) ; if ( str . equals ( " - " ) ) break ; int EqlmNlg = sc . nextInt ( ) ; int [ ] array = new int [ EqlmNlg ] ; String result = str ; for ( int i = 0 ; i < EqlmNlg ; i ++ ) { int shuffleNum = sc . nextInt ( ) ; result = result . substring ( shuffleNum ) + result . substring ( 0 , shuffleNum ) ; } System . out . println ( result ) ; } } } import java . util . * ; public class FrfgWua { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int frfgIzh = 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 ( frfgIzh - j ) ) ; } int a = frfgIzh - min ; if ( Arrays . asList ( p ) . contains ( a ) ) { System . out . println ( frfgIzh + min ) ; } else { System . out . println ( a ) ; } } } import java . util . * ; public class KnkuRutq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int KnkuU = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int day = 0 ; for ( int i = 0 ; i < M ; i ++ ) { day += scan . nextInt ( ) ; } if ( day > KnkuU ) { System . out . println ( - 1 ) ; } else { System . out . println ( KnkuU - day ) ; } } } import java . util . Scanner ; public class AblgPy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ablgOko = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= ablgOko ; i ++ ) { for ( int j = 1 ; j <= ablgOko ; j ++ ) { for ( int k = 1 ; k <= ablgOko ; 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 ewlrgRuw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EwlrgThun = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= EwlrgThun ; 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 CehkwaNanx { public static void main ( String [ ] args ) { BufferedReader inMsg = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String cehkwaKuxm = " " ; try { while ( ( cehkwaKuxm = inMsg . readLine ( ) ) != null ) { String [ ] ab = cehkwaKuxm . 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 CcbgxHn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] s = S . toCharArray ( ) ; int ccbgxMs = 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' ) ) { ccbgxMs += 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 ) { ccbgxMs += count0 * 2 ; } else { ccbgxMs += count1 * 2 ; } System . out . println ( ccbgxMs ) ; } } import java . util . Scanner ; public class QvforFepi { static float roundUp ( float value ) { float qvforIxwf = value % 1000 ; if ( qvforIxwf > 0 ) { value = value + ( 1000 - qvforIxwf ) ; } 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 EzbOh { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ezbWp = in . nextInt ( ) ; int i = 10 , res = 0 , sign = 1 ; while ( ezbWp >= i ) { res += ( i - 1 ) * sign ; sign *= - 1 ; i *= 10 ; } if ( res <= 0 ) res += ezbWp ; System . out . println ( res ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class MnlffxSvk { public static void main ( String [ ] args ) throws Exception { BufferedReader stdIn = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s ; int MnlffxXmo = 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 ( ++ MnlffxXmo , in1 , in2 ) ; } System . exit ( 0 ) ; } private static void doMain ( int MnlffxXmo , int in1 , int in2 ) { if ( in1 < in2 ) System . out . println ( in1 + " " + in2 ) ; else System . out . println ( in2 + " " + in1 ) ; } } import java . util . * ; class LnuplAlze { static int LnuplYke = 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 bagsjJ { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int BagsjHt = sc . nextInt ( ) ; int [ ] a = new int [ 100 ] ; for ( int i = 0 ; i < BagsjHt ; i ++ ) a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; int Alice = 0 ; int Bob = 0 ; for ( int i = 99 ; i > 99 - BagsjHt ; i -- ) if ( i % 2 == 1 ) Alice += a [ i ] ; else Bob += a [ i ] ; System . out . println ( Alice - Bob ) ; } } import java . util . * ; public class UaktNklu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uaktRv = sc . nextInt ( ) ; int ans = 0 ; for ( int i = uaktRv ; 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 UpwRfon { class UpwRfon { int upwI , 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 dikMw { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long DikJm = 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 ( DikJm ) + 10 ; l ++ ) { if ( DikJm % l == 0 ) { O = l ; T = DikJm / 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 unoXuk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int UnoKjjw = Integer . parseInt ( scanner . next ( ) ) ; int Y = Integer . parseInt ( scanner . next ( ) ) ; scanner . close ( ) ; for ( int x = 0 ; x <= UnoKjjw ; x ++ ) { for ( int y = 0 ; y <= UnoKjjw ; y ++ ) { int z = UnoKjjw - 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 VnuyhRmi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int vnuyhCelc = scan . nextInt ( ) ; int strlenge = scan . nextInt ( ) ; String [ ] output = new String [ vnuyhCelc ] ; for ( int i = 0 ; i < vnuyhCelc ; i ++ ) { output [ i ] = scan . next ( ) ; } Arrays . sort ( output ) ; for ( int i = 0 ; i < vnuyhCelc ; i ++ ) { System . out . print ( output [ i ] ) ; } scan . close ( ) ; } } import java . util . * ; public class EehwYdh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eehwN = sc . nextInt ( ) ; String n = String . valueOf ( eehwN ) ; char [ ] a = n . toCharArray ( ) ; char b = a [ 0 ] ; char [ ] c = { b , b , b } ; int ans = Integer . parseInt ( String . valueOf ( c ) ) ; if ( ans >= eehwN ) { System . out . println ( ans ) ; } else { ans += 111 ; System . out . println ( ans ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class ltoJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LtoUwucu = scan . nextInt ( ) ; String S = scan . next ( ) ; int S_length = S . length ( ) ; if ( LtoUwucu < S_length ) { for ( int i = 0 ; i < LtoUwucu ; i ++ ) { System . out . print ( S . charAt ( i ) ) ; } System . out . print ( " ... " ) ; } else { System . out . print ( S ) ; } } } import java . util . * ; public class QcyjhTnwz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qcyjhGrus = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int x = qcyjhGrus * 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 QtrvotWou { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int QtrvotQln = scanner . nextInt ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) { if ( QtrvotQln <= 111 * i ) { System . out . println ( 111 * i ) ; break ; } } } } import java . util . * ; public class PuwQdle { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int puwEmxd = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= puwEmxd ; 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 XyaqVwbks { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XyaqG = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ XyaqG ] ; 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 NsqvuQcg { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int nsqvuBkjr = Integer . parseInt ( br . readLine ( ) ) ; int count = 0 ; for ( int i = 0 ; i < nsqvuBkjr ; 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 wmrQdv { 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 WmrVm = scan . nextInt ( ) ; for ( int i = 0 ; i < WmrVm ; 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 awrpkxQku { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int AwrpkxQf = scan . nextInt ( ) ; int [ ] P = new int [ AwrpkxQf ] ; int countI = 1 ; for ( int i = 0 ; i < AwrpkxQf ; i ++ ) { int b = scan . nextInt ( ) ; P [ i ] = b ; } int j = 1 ; int Min = P [ 0 ] ; while ( j < AwrpkxQf ) { if ( P [ j ] < Min ) { Min = P [ j ] ; countI ++ ; } j ++ ; } System . out . println ( countI ) ; } } import java . util . * ; import java . io . * ; public class KwwlUam { public static void main ( String [ ] args ) throws Exception { int kwwlS = 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 tslbgyI { public static void main ( String [ ] args ) { int TslbgyYgkn ; try ( Scanner sc = new Scanner ( System . in ) ) { TslbgyYgkn = sc . nextInt ( ) ; } int maxKeta = ( int ) Math . floor ( Math . log10 ( ( double ) TslbgyYgkn ) + 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 += TslbgyYgkn - ( int ) ( Math . pow ( 10 , maxKeta - 1 ) ) + 1 ; } System . out . println ( answer ) ; } } import java . util . Scanner ; public class ArkqMt { static Scanner sc = new Scanner ( System . in ) ; static int arkqWolm = 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 < arkqWolm ; 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 = arkqWolm ; 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 NzgmlcQq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NzgmlcT = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int i = 1 ; int sum = 0 ; while ( NzgmlcT * i <= t ) { sum += b ; i += 1 ; } System . out . println ( sum ) ; } } import java . util . * ; public class ufyawqGhy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int UfyawqKed = 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 ) ) ) { UfyawqKed = Math . max ( UfyawqKed , i - leftIdx ) ; leftIdx = i + 1 ; } } UfyawqKed = Math . max ( UfyawqKed , s . length ( ) - leftIdx ) ; System . out . println ( UfyawqKed ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class UtzkyLa { static BufferedReader reader ; public static void main ( String [ ] args ) { reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strings = readLine ( ) ; int utzkyWr = Integer . parseInt ( strings [ 0 ] ) ; int A = Integer . parseInt ( strings [ 1 ] ) ; print ( ( utzkyWr + 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 clhnYm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ClhnJslw = scan . nextInt ( ) ; int num2 = scan . nextInt ( ) ; int num3 = scan . nextInt ( ) ; int count = 0 ; if ( ClhnJslw != num2 ) { count ++ ; } if ( num2 != num3 ) { count ++ ; } if ( ClhnJslw != num3 ) { count ++ ; } if ( count == 1 || count == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . lang . * ; public class hptsEcn { public static void solve ( long HptsVzqft , long b , long c , long d ) { while ( HptsVzqft > 0 && c > 0 ) { c -= b ; if ( c <= 0 ) { System . out . println ( " Yes " ) ; return ; } HptsVzqft -= d ; } if ( c == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void gora ( ) { Scanner scn = new Scanner ( System . in ) ; long HptsVzqft = scn . nextLong ( ) ; long b = scn . nextLong ( ) ; long c = scn . nextLong ( ) ; long d = scn . nextLong ( ) ; solve ( HptsVzqft , b , c , d ) ; } public static void main ( String [ ] args ) { gora ( ) ; } } import java . util . Scanner ; public class ZzvuCffdt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZzvuU = 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 < ZzvuU ; i ++ ) { System . out . print ( Schar [ i ] ) ; System . out . print ( Tchar [ i ] ) ; } return ; } } import java . util . * ; class WgoeHttu { public static void main ( String [ ] args ) { int wgoeO = 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' ) { wgoeO += 1 ; } } } System . out . println ( wgoeO ) ; } } import java . util . Scanner ; class tykT { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int TykAvc = scan . nextInt ( ) ; int kimatu = scan . nextInt ( ) ; int saisiken = scan . nextInt ( ) ; while ( TykAvc != - 1 || kimatu != - 1 || saisiken != - 1 ) { int y ; y = TykAvc + kimatu ; if ( TykAvc == - 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 " ) ; } TykAvc = scan . nextInt ( ) ; kimatu = scan . nextInt ( ) ; saisiken = scan . nextInt ( ) ; } } } import java . util . Scanner ; public class iemOxx { 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 IemTvvrz = true ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { IemTvvrz = true ; for ( int j = 0 ; j < n - i ; j ++ ) { if ( a [ j ] != b [ j + i ] ) { IemTvvrz = false ; break ; } } for ( int j = n - i ; j < n ; j ++ ) { if ( a [ j ] != b [ j - n + i ] ) { IemTvvrz = false ; break ; } } if ( IemTvvrz ) break ; } System . out . println ( IemTvvrz ? " Yes " : " No " ) ; } } import java . util . ArrayList ; import static java . util . Collections . reverse ; import java . util . List ; import java . util . Scanner ; public class MfxfvPdfb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int MfxfvR = scanner . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < MfxfvR ; 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 raxbAq { public static void main ( String [ ] args ) throws IOException { int RaxbTjx , b , f , r , v ; String [ ] list ; int [ ] [ ] [ ] building ; StringBuilder builder = new StringBuilder ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; RaxbTjx = Integer . parseInt ( br . readLine ( ) ) ; building = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int i = 0 ; i < RaxbTjx ; 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 yatZgr { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YatKms = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; int count1 = 0 ; int count2 = 0 ; int count3 = 0 ; int count4 = 0 ; for ( int i = 0 ; i < YatKms ; i ++ ) { list . add ( sc . next ( ) ) ; } for ( int i = 0 ; i < YatKms ; 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 rtozIq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; int RtozFahtg = scan . nextInt ( ) ; int x = 1 ; int y = 0 ; if ( RtozFahtg >= 3 && RtozFahtg <= 10000 ) { for ( int count = 0 ; count < RtozFahtg ; 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 HiqdtiGm { public static void main ( String [ ] args ) throws IOException { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; for ( ; ; ) { String [ ] str = br . readLine ( ) . split ( " " ) ; int hiqdtiQ = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 2 ] ) ; if ( str [ 1 ] . equals ( " ? " ) ) break ; switch ( str [ 1 ] ) { case " + " : System . out . println ( hiqdtiQ + b ) ; break ; case " - " : System . out . println ( hiqdtiQ - b ) ; break ; case " * " : System . out . println ( hiqdtiQ * b ) ; break ; case " / " : System . out . println ( hiqdtiQ / b ) ; break ; default : break ; } } br . close ( ) ; } catch ( Exception e ) { System . exit ( - 1 ) ; } } } import java . util . * ; public class XuhrpTmx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xuhrpCiy = 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 + xuhrpCiy ) % 26 ; ans [ i ] = ( char ) ( 'A' + c ) ; } System . out . println ( new String ( ans ) ) ; } } import java . util . Scanner ; public class QfzjvzIm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s , t ; int QfzjvzB ; s = scan . next ( ) ; t = scan . next ( ) ; QfzjvzB = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) QfzjvzB += 1 ; } System . out . println ( QfzjvzB ) ; } } import java . io . * ; import java . util . * ; class VgsbgYke { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int vgsbgEool = 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 < vgsbgEool ; i ++ ) { sb . append ( str_1 [ i ] ) ; sb . append ( str_2 [ i ] ) ; } System . out . println ( sb ) ; } } } import java . util . * ; public class hkxoqFhi { static int HkxoqTnozm = 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 BwhDzdhjj { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader sb = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Integer [ ] hList = new Integer [ 10 ] ; for ( int BwhUv = 0 ; BwhUv < 10 ; BwhUv ++ ) { int h = Integer . parseInt ( sb . readLine ( ) ) ; hList [ BwhUv ] = h ; } Arrays . sort ( hList , Collections . reverseOrder ( ) ) ; for ( int rank = 0 ; rank < 3 ; rank ++ ) { System . out . println ( hList [ rank ] ) ; } } } import java . util . Scanner ; public class LmrXjsrs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LmrRl = sc . nextInt ( ) ; int ans = ( 10000 - LmrRl ) % 1000 ; System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; public class JpldnAy { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int jpldnPwdc = sc . nextInt ( ) ; System . out . println ( ( jpldnPwdc / 3600 ) + " : " + ( jpldnPwdc % 3600 / 60 ) + " : " + ( jpldnPwdc % 60 ) ) ; } } import java . util . * ; class opkeqjCji { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OpkeqjXvlxz = 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 TusCt { public static void main ( String [ ] args ) { int tusMwyb ; int b ; Scanner sc = new Scanner ( System . in ) ; tusMwyb = sc . nextInt ( ) ; b = sc . nextInt ( ) ; int area = tusMwyb * b ; int syu = 2 * ( tusMwyb + b ) ; System . out . println ( area + " " + syu ) ; } } import java . util . * ; public class FfbvuBjfn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ffbvuQ = scanner . nextInt ( ) ; int a = 0 ; int b = 0 ; for ( int i = 1 ; i <= ffbvuQ ; i += 2 ) { for ( int j = 1 ; j <= ffbvuQ ; 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 GglJvndgc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int GglI = 1 , b = 1 ; while ( GglI != 0 && b != 0 ) { GglI = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; if ( GglI == 0 && b == 0 ) { break ; } for ( int i = 1 ; i <= GglI ; i ++ ) { for ( int j = 1 ; j <= b ; j ++ ) { if ( i == 1 && j != b ) { System . out . print ( " # " ) ; } else if ( i == GglI && 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 qdbScw { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int QdbDbn = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; scanner . close ( ) ; String ans = null ; if ( QdbDbn < b && b < c ) { ans = " Yes " ; } else { ans = " No " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class uxpntfGjt { public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . answer ( ) ; } private Scanner scan = new Scanner ( System . in ) ; private int UxpntfSs ; private int b ; public Main ( ) { UxpntfSs = Integer . parseInt ( scan . next ( ) ) ; b = Integer . parseInt ( scan . next ( ) ) ; scan . close ( ) ; } public final void answer ( ) { String ans = UxpntfSs * b % 2 == 0 ? " Even " : " Odd " ; System . out . println ( ans ) ; } } import java . util . Scanner ; class CvtipQjfj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cvtipAa , Q , R ; int max = 0 ; cvtipAa = sc . nextInt ( ) ; Q = sc . nextInt ( ) ; R = sc . nextInt ( ) ; if ( cvtipAa >= Q ) { if ( cvtipAa >= R ) { max = Q + R ; } else { max = cvtipAa + Q ; } } else if ( Q >= R ) { if ( Q >= cvtipAa ) { max = cvtipAa + R ; } else { max = Q + R ; } } else if ( R >= cvtipAa ) { if ( R >= Q ) { max = cvtipAa + Q ; } else { max = cvtipAa + R ; } } System . out . println ( max ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class gyrsrjZc { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; String GyrsrjSajon = st . nextToken ( ) ; System . out . println ( GyrsrjSajon . charAt ( 2 ) == GyrsrjSajon . charAt ( 3 ) && GyrsrjSajon . charAt ( 4 ) == GyrsrjSajon . charAt ( 5 ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class McdMzzgw { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . start ( ) ; } private void start ( ) { Scanner scanner = new Scanner ( System . in ) ; int McdWy = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; if ( McdWy < b && b < c ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class lakoN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; String [ ] s = S . split ( " / " ) ; int LakoRe = 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 KulEvvy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kulEnb = sc . nextInt ( ) ; String [ ] W = new String [ kulEnb ] ; for ( int i = 0 ; i < kulEnb ; i ++ ) { W [ i ] = sc . next ( ) ; } sc . close ( ) ; String result = " Yes " ; for ( int i = 0 ; i < kulEnb ; i ++ ) { for ( int j = i + 1 ; j < kulEnb ; j ++ ) { if ( W [ i ] . equals ( W [ j ] ) ) { result = " No " ; break ; } } if ( result == " No " ) { break ; } } String start = " " ; if ( result == " Yes " ) { for ( int i = 0 ; i < kulEnb ; 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 IstpdqVg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IstpdqU = sc . nextInt ( ) ; int variety = sc . nextInt ( ) ; int [ ] k = new int [ IstpdqU ] ; int [ ] preference = new int [ variety ] ; int ans = 0 ; for ( int i = 0 ; i < IstpdqU ; 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 ] == IstpdqU ) { ans ++ ; } } System . out . println ( ans ) ; sc . close ( ) ; } private static int gcd ( int m , int IstpdqU ) { if ( m < IstpdqU ) { return gcd ( IstpdqU , m ) ; } if ( IstpdqU == 0 ) { return m ; } return gcd ( IstpdqU , m % IstpdqU ) ; } } import java . util . Scanner ; public class AhlXxnayf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String AhlM = sc . next ( ) ; String ans ; if ( AhlM . equals ( " Sunny " ) ) { ans = " Cloudy " ; } else if ( AhlM . equals ( " Cloudy " ) ) { ans = " Rainy " ; } else { ans = " Sunny " ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class RzpnbjEbs { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int rzpnbjRa = stdIn . nextInt ( ) ; int Y = stdIn . nextInt ( ) / 1000 ; int ans10 = - 1 ; int ans5 = - 1 ; int ans1 = - 1 ; for ( int i = 0 ; i <= rzpnbjRa ; i ++ ) { for ( int j = 0 ; j <= rzpnbjRa - i ; j ++ ) { if ( 10 * i + 5 * j + ( rzpnbjRa - i - j ) == Y ) { ans10 = i ; ans5 = j ; ans1 = rzpnbjRa - i - j ; break ; } } } System . out . println ( ans10 + " " + ans5 + " " + ans1 ) ; } } import java . util . * ; class BxyfcGuhn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bxyfcQ = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 1 ; for ( int i = 1 ; i <= bxyfcQ ; i ++ ) { sum = sum * 100 ; } System . out . println ( sum * ( n + n / 100 ) ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class wnahwtBo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int WnahwtHqrge = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; HashSet h = new HashSet ( ) ; h . add ( WnahwtHqrge ) ; h . add ( b ) ; h . add ( c ) ; if ( h . size ( ) == 2 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class SlqjVmwdt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SlqjWe = sc . nextInt ( ) ; int yen = 1000 ; while ( yen < SlqjWe ) { yen = yen + 1000 ; } System . out . println ( yen - SlqjWe ) ; } } import java . util . Scanner ; public class BbfxbxVkm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bbfxbxYf = sc . nextInt ( ) ; int sum = 100000 ; for ( int i = 0 ; i < bbfxbxYf ; 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 KzvkxKlh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] strs = new String [ 100 ] ; int kzvkxXg = 0 ; while ( true ) { String str = sc . next ( ) ; if ( str . equals ( " - " ) ) { for ( int j = 0 ; j < kzvkxXg ; 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 [ kzvkxXg ] = str ; kzvkxXg ++ ; } } } import java . util . * ; public class RbrsuvQdoprs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " " ; for ( int RbrsuvCel = 0 ; RbrsuvCel < s . length ( ) ; RbrsuvCel ++ ) { String temp = s . substring ( RbrsuvCel , RbrsuvCel + 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 BujtBst { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String bujtY = sc . next ( ) ; String B = sc . next ( ) ; String C = sc . next ( ) ; System . out . println ( C + " " + bujtY + " " + B ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class CdhUtked { 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 CdhUa = Integer . parseInt ( items [ 0 ] ) ; int b = Integer . parseInt ( items [ 1 ] ) ; int c = Integer . parseInt ( items [ 2 ] ) ; int counter = 0 ; for ( int i = CdhUa ; i <= b ; i ++ ) { if ( c % i == 0 ) { counter ++ ; } } System . out . println ( counter ) ; } } import java . util . * ; public class EdcWyymo { 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 EdcPnd = x . charAt ( 0 ) ; if ( EdcPnd == '+' || EdcPnd == '-' || EdcPnd == '*' ) { int second = stack . pop ( ) ; int first = stack . pop ( ) ; if ( EdcPnd == '+' ) { first += second ; } else if ( EdcPnd == '-' ) { 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 yqxhMq { 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 YqxhKlzmc = Integer . parseInt ( repStr ) ; for ( int i = 0 ; i < YqxhKlzmc ; 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 kfmJw { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int KfmDu = stdIn . nextInt ( ) ; int k = stdIn . nextInt ( ) ; int [ ] h = new int [ KfmDu ] ; for ( int i = 0 ; i < KfmDu ; i ++ ) { h [ i ] = stdIn . nextInt ( ) ; } int [ ] dp = new int [ KfmDu ] ; Arrays . fill ( dp , Integer . MAX_VALUE ) ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 0 ; i < KfmDu ; i ++ ) { for ( int j = i + 1 ; j <= i + k ; j ++ ) { if ( j >= KfmDu ) { break ; } dp [ j ] = Math . min ( dp [ i ] + Math . abs ( h [ j ] - h [ i ] ) , dp [ j ] ) ; } } System . out . println ( dp [ KfmDu - 1 ] ) ; } } import java . util . * ; public class AkflhnOi { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; String s = scn . next ( ) ; int AkflhnDs = 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 { AkflhnDs = Math . max ( nans , AkflhnDs ) ; nans = 0 ; i ++ ; } } AkflhnDs = Math . max ( nans , AkflhnDs ) ; System . out . println ( AkflhnDs ) ; } } import java . util . Scanner ; public class uleIya { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UleOs = sc . nextInt ( ) ; int ans = 1 ; for ( int i = 2 ; i < UleOs ; i ++ ) { int j = i ; if ( UleOs >= Math . pow ( j , 2 ) ) { while ( j <= UleOs ) { j *= i ; } j /= i ; ans = Math . max ( ans , j ) ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class wsgmiG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WsgmiGk = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int max = Math . max ( WsgmiGk , c ) ; int min = Math . min ( b , d ) ; System . out . println ( Math . max ( 0 , min - max ) ) ; } } import java . util . Scanner ; public class UtswfvXvsgq { public static void main ( String [ ] args ) { int [ ] list ; int UtswfvSfa ; int primes = 0 ; Scanner keyboard = new Scanner ( System . in ) ; UtswfvSfa = keyboard . nextInt ( ) ; list = new int [ UtswfvSfa ] ; for ( int i = 0 ; i < UtswfvSfa ; i ++ ) { list [ i ] = keyboard . nextInt ( ) ; } for ( int i = 0 ; i < UtswfvSfa ; 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 blhIi { public static void main ( String [ ] args ) { int BlhGwdr ; Scanner sc = new Scanner ( System . in ) ; BlhGwdr = sc . nextInt ( ) ; int c = 0 ; int [ ] b = new int [ BlhGwdr ] ; for ( int i = 0 ; i < BlhGwdr ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } Arrays . sort ( b ) ; for ( int j = 0 ; j < BlhGwdr - 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 SchtauAxlm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int schtauIuzi = sc . nextInt ( ) ; while ( true ) { if ( BigInteger . valueOf ( schtauIuzi ) . isProbablePrime ( 100 ) ) { System . out . println ( schtauIuzi ) ; return ; } schtauIuzi ++ ; } } } import java . util . Scanner ; public class GhjXo { public static void main ( String [ ] args ) { int GhjWg ; Scanner sc = new Scanner ( System . in ) ; GhjWg = sc . nextInt ( ) ; System . out . println ( ( GhjWg / 500 ) * 1000 + ( GhjWg % 500 ) / 5 * 5 ) ; } } import java . util . Scanner ; class SwhbLrpt { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int SwhbOyc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int lower ; int bigger ; if ( SwhbOyc > b ) { lower = b ; bigger = SwhbOyc ; } else { lower = SwhbOyc ; 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 ttbykwPkt { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int TtbykwBuv = scanner . nextInt ( ) ; Integer [ ] nums = new Integer [ TtbykwBuv ] ; for ( int i = 0 ; i < TtbykwBuv ; i ++ ) { nums [ i ] = scanner . nextInt ( ) ; } int diff = 0 ; boolean isEven = ( TtbykwBuv % 2 ) == 0 ; Arrays . sort ( nums , Collections . reverseOrder ( ) ) ; int pairLastIndex = isEven ? TtbykwBuv - 1 : TtbykwBuv - 2 ; for ( int i = 0 ; i < pairLastIndex ; i = i + 2 ) { diff += nums [ i ] - nums [ i + 1 ] ; } if ( ! isEven ) diff += nums [ TtbykwBuv - 1 ] ; System . out . println ( diff ) ; } } import java . util . Scanner ; public class EyoqrtBul { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eyoqrtBs = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] A = new int [ eyoqrtBs ] ; int wa = 0 ; for ( int i = 0 ; i < eyoqrtBs ; i ++ ) { A [ i ] = sc . nextInt ( ) ; wa += A [ i ] ; } sc . close ( ) ; int ok = 0 ; for ( int i = eyoqrtBs - 1 ; i >= 0 ; i -- ) { ok += A [ i ] * ( 4 * M ) >= wa ? 1 : 0 ; } System . out . println ( ok >= M ? " Yes " : " No " ) ; } } import java . util . * ; public class ayxrrE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AyxrrTmoy = sc . nextInt ( ) ; int o = 0 ; int [ ] a = new int [ AyxrrTmoy ] ; PriorityQueue < Integer > num = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < AyxrrTmoy ; 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 < AyxrrTmoy ; i ++ ) { int b = sc . nextInt ( ) ; o += b ; } for ( int i = 0 ; i < AyxrrTmoy - 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 ltsPmj { 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 LtsOzez = Integer . parseInt ( a [ 0 ] ) ; int y = Integer . parseInt ( a [ 1 ] ) ; if ( LtsOzez > y ) { sb . append ( y + " " + LtsOzez + " \n " ) ; } else { sb . append ( LtsOzez + " " + y + " \n " ) ; } } System . out . print ( sb ) ; } } import java . util . * ; public class YcfjiqLqounl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YcfjiqL = 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 vqvybHb { 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 VqvybLm = 0 ; VqvybLm < weather . length ; ++ VqvybLm ) { if ( tw . equals ( weather [ VqvybLm ] ) ) { System . out . println ( weather [ ( VqvybLm + 1 ) % 3 ] ) ; break ; } } } } import java . util . Scanner ; public class qbjH { private void calc ( ) { Scanner scanner = new Scanner ( System . in ) ; int QbjWmmpv = scanner . nextInt ( ) ; int y = scanner . nextInt ( ) ; int d = QbjWmmpv / y ; int r = QbjWmmpv % y ; double f = ( double ) QbjWmmpv / ( 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 PgjpqGpbq { 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 HiffiFjrg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long HiffiXah = scan . nextInt ( ) ; long y = scan . nextInt ( ) ; scan . close ( ) ; if ( HiffiXah < y ) { long tmp = y ; y = HiffiXah ; HiffiXah = tmp ; } long ans = ( HiffiXah * y ) / gcd ( HiffiXah , y ) ; System . out . println ( ans ) ; } static long gcd ( long HiffiXah , long y ) { if ( HiffiXah % y == 0 ) return y ; else return gcd ( y , HiffiXah % y ) ; } } import java . util . Scanner ; class MktyrnQape { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int mktyrnKekk = scanner . nextInt ( ) ; int taroPoint = 0 ; int hanakoPoint = 0 ; scanner . nextLine ( ) ; for ( int i = 1 ; i <= mktyrnKekk ; 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 PkxpnGsdt { 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 PkxpnV = Integer . valueOf ( inputs [ 0 ] ) ; int width = Integer . valueOf ( inputs [ 1 ] ) ; StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < PkxpnV ; i ++ ) { if ( i == 0 || i == PkxpnV - 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 UttsvsEhdxrm { static int UttsvsBzq = 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 EfgYwby { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int efgQgh = Integer . parseInt ( a + b ) ; boolean bl = false ; for ( int i = 1 ; i * i <= efgQgh ; i ++ ) { if ( i * i == efgQgh ) { bl = true ; break ; } } System . out . println ( bl == true ? " Yes " : " No " ) ; } } import java . util . * ; public class YoxoLh { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; ArrayList < Character > caca = new ArrayList < Character > ( ) ; String n = scn . next ( ) ; for ( int YoxoLio = 0 ; YoxoLio < n . length ( ) ; YoxoLio ++ ) { if ( n . charAt ( YoxoLio ) == '1' ) caca . add ( '1' ) ; else if ( n . charAt ( YoxoLio ) == '0' ) caca . add ( '0' ) ; else if ( n . charAt ( YoxoLio ) == 'B' ) { if ( ! caca . isEmpty ( ) ) caca . remove ( caca . size ( ) - 1 ) ; } } for ( int YoxoLio = 0 ; YoxoLio < caca . size ( ) ; YoxoLio ++ ) System . out . print ( caca . get ( YoxoLio ) ) ; 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 rynElf { public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int RynJr = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= RynJr ; 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 SfsgecMbr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SfsgecZe = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; String ans ; if ( ( SfsgecZe == b && b == c ) || ( SfsgecZe != b && b != c && c != SfsgecZe ) ) ans = " No " ; else ans = " Yes " ; System . out . println ( ans ) ; } } import java . util . Scanner ; class ajmimTdw { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int AjmimSsd = sc . nextInt ( ) ; long sum = 0 , left = 0 ; int [ ] A = new int [ AjmimSsd + 1 ] ; for ( int i = 0 ; i <= AjmimSsd ; i ++ ) { A [ i ] = sc . nextInt ( ) ; sum += A [ i ] ; } for ( int i = 0 ; i < AjmimSsd ; 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 <= AjmimSsd ; 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 WfhyHfx { 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 difxwgVpl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DifxwgVnkuj = sc . nextInt ( ) ; int [ ] h = new int [ DifxwgVnkuj ] ; int max = 0 ; int idx = 0 ; for ( int i = 0 ; i < DifxwgVnkuj ; i ++ ) { h [ i ] = sc . nextInt ( ) ; if ( h [ i ] > max ) { max = h [ i ] ; idx = i ; } } int max2 = 0 ; for ( int i = 0 ; i < DifxwgVnkuj ; i ++ ) { if ( i != idx ) { if ( h [ i ] > max2 ) { max2 = h [ i ] ; } } } for ( int i = 0 ; i < DifxwgVnkuj ; 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 FiciwqIm { 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 wdsidS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WdsidLm = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] people = new int [ WdsidLm ] ; for ( int i = 0 ; i < WdsidLm ; 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 ywralEn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YwralUv = sc . nextInt ( ) ; int check = 1 ; for ( int i = 1 ; i < 10 ; i ++ ) { int f = YwralUv % i ; if ( f == 0 ) { int a = YwralUv / 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 UxtgRl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uxtgN = sc . nextInt ( ) ; int [ ] a = new int [ uxtgN + 1 ] ; for ( int i = 1 ; i <= uxtgN ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int cnt = 1 ; int point_now = 1 ; while ( cnt <= uxtgN ) { 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 QuzxBe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int quzxGq = sc . nextInt ( ) ; int ans = ( int ) pow ( quzxGq , 3 ) ; System . out . println ( ans ) ; } } import java . util . * ; public class jvnkXex { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long JvnkAi = Long . parseLong ( sc . next ( ) ) ; long k = Long . parseLong ( sc . next ( ) ) ; System . out . println ( Math . min ( JvnkAi % k , k - ( JvnkAi % k ) ) ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class ypgjsJcn { 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 YpgjsMjpi = 0 ; YpgjsMjpi < w . length ( ) ; ++ YpgjsMjpi ) { if ( map . containsKey ( w . charAt ( YpgjsMjpi ) ) ) { Integer cap = map . get ( w . charAt ( YpgjsMjpi ) ) ; map . remove ( w . charAt ( YpgjsMjpi ) ) ; map . put ( w . charAt ( YpgjsMjpi ) , cap + 1 ) ; } else { map . put ( w . charAt ( YpgjsMjpi ) , 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 CmkyyyNrh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cmkyyyC = sc . nextInt ( ) ; int [ ] a = new int [ cmkyyyC ] ; for ( int i = 0 ; i < cmkyyyC ; 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 BnpcqrLd { public static void main ( String [ ] args ) { try { Scanner sc = new Scanner ( System . in ) ; int bnpcqrMo = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k ; if ( bnpcqrMo == b ) { System . out . println ( " IMPOSSIBLE " ) ; } else if ( bnpcqrMo < 0 ) { System . out . println ( " IMPOSSIBLE " ) ; } else if ( b > 1000000000 ) { System . out . println ( " IMPOSSIBLE " ) ; } else { k = ( b + bnpcqrMo ) / 2 ; if ( ( k * 2 ) != ( bnpcqrMo + 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 LzjAab { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int lzjPs = 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 >= lzjPs ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class kqerkIr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KqerkTsrnv = sc . nextInt ( ) ; int [ ] p = new int [ KqerkTsrnv ] ; int flg = 0 ; String ans = " NO " ; for ( int i = 0 ; i < KqerkTsrnv ; 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 KooknGuha { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int kooknRq = sc . nextInt ( ) ; int [ ] p = new int [ kooknRq ] ; for ( int i = 0 ; i < kooknRq ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int min = 10000000 ; int count = 0 ; for ( int i = 0 ; i < kooknRq ; i ++ ) { if ( p [ i ] < min ) { count ++ ; min = p [ i ] ; } } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; class nqhRg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NqhIbwiv = sc . nextInt ( ) ; int [ ] a = new int [ NqhIbwiv ] ; for ( int i = 0 ; i < NqhIbwiv ; i ++ ) a [ i ] = sc . nextInt ( ) ; int [ ] dp = new int [ NqhIbwiv + 1 ] ; for ( int i = 2 ; i <= NqhIbwiv ; 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 [ NqhIbwiv ] ) ; } } import java . util . Scanner ; import java . util . Arrays ; class YqceEtpju { boolean [ ] primeTable ; public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; PrimeNum prime = new PrimeNum ( 100000010 ) ; prime . createTable ( ) ; int YqceLbf = cin . nextInt ( ) , ct = 0 ; for ( int i = 0 ; i < YqceLbf ; i ++ ) { int num = cin . nextInt ( ) ; if ( prime . judge ( num ) ) ct ++ ; } System . out . println ( ct ) ; } } class YqceEtpju { private boolean [ ] primeTable ; private int maxNum ; PrimeNum ( int YqceLbf ) { primeTable = new boolean [ YqceLbf ] ; Arrays . fill ( primeTable , true ) ; this . maxNum = YqceLbf ; } 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 YqceLbf ) { return ( primeTable [ YqceLbf ] ) ; } protected int serch ( int YqceLbf ) { for ( int i = 2 ; i < maxNum ; i ++ ) { if ( primeTable [ i ] ) YqceLbf -- ; if ( YqceLbf == 0 ) return ( i ) ; } return ( - 1 ) ; } } import java . util . Scanner ; public class CxnMjaxt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CxnO = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int r = Integer . parseInt ( sc . next ( ) ) ; int result = Math . min ( Math . min ( CxnO + q , q + r ) , CxnO + r ) ; System . out . println ( result ) ; } } import java . util . Scanner ; public class BplWxcr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bplSua = sc . nextInt ( ) ; for ( int i = 9 ; i >= 0 ; i -- ) { if ( bplSua > i * 111 ) { System . out . println ( ( i + 1 ) * 111 ) ; break ; } } } } import java . util . * ; import java . io . * ; public class CgtLu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CgtYp = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int ans = 0 ; int able = 2 * d + 1 ; for ( int i = 1 ; i < 20 ; i ++ ) { if ( i * able >= CgtYp ) { ans = i ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; public class DlhtYxh { public static void main ( String [ ] omkar ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; int DlhtVsy = Integer . parseInt ( st . nextToken ( ) ) ; int res = DlhtVsy / 500 ; res *= 1000 ; int lol = DlhtVsy % 500 - DlhtVsy % 5 ; System . out . println ( res + lol ) ; } } import java . util . * ; public class tgfjtkIl { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int TgfjtkNup = s . nextInt ( ) ; int m = s . nextInt ( ) ; int ans = 10000 ; for ( int i = 0 ; i < TgfjtkNup ; 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 JegKoo { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int JegJ = sc . nextInt ( ) ; int ans = 0 ; if ( JegJ >= 195 ) { ans = 5 ; } else if ( JegJ >= 189 ) { ans = 4 ; } else if ( JegJ >= 165 ) { ans = 3 ; } else if ( JegJ >= 135 ) { ans = 2 ; } else if ( JegJ >= 105 ) { ans = 1 ; } System . out . println ( ans ) ; } } import java . util . * ; public class ZmodceBe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zmodceO = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; int max = 1 ; for ( int i = 0 ; i < zmodceO ; 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 IjaaSveo { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; ArrayList < Integer > intArr = new ArrayList < Integer > ( ) ; for ( int ijaaC = 0 ; ijaaC < 3 ; ijaaC ++ ) 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 PgtnpVnladi { 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 QiaomjVlau { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String qiaomjU = sc . next ( ) ; if ( qiaomjU . equals ( " AAA " ) || qiaomjU . equals ( " BBB " ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; import java . io . * ; import java . math . * ; public class UlhbMwa { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ulhbZf = sc . nextInt ( ) ; int odd = sc . nextInt ( ) ; int ans = ulhbZf * ( ulhbZf - 1 ) / 2 + odd * ( odd - 1 ) / 2 ; System . out . println ( ans ) ; } } import java . util . * ; public class djmptF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DjmptTxpnd = 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 PjgszDaliiv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PjgszQb = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int abprice = PjgszQb * 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 = PjgszQb ; 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 letSod { 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 LetGlz = 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 == LetGlz && d == B ) { ans = i ; break ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class LqgpLb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LqgpY = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = LqgpY ; 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 AqccQrjwye { 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 AqccY = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { x [ i ] = sc . nextInt ( ) ; if ( x [ i ] == 0 ) { AqccY = i + 1 ; } } return AqccY ; } public void show ( int AqccY ) { System . out . println ( AqccY ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class HgcVs { 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 HgcCmt = ( char ) ( aa . charAt ( 0 ) + 1 ) ; String vv = HgcCmt + " " ; p ( vv ) ; } } import java . util . Scanner ; public class aiqmaG { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; double AiqmaMzth = in . nextDouble ( ) ; double d = in . nextDouble ( ) ; int ans = 0 ; while ( AiqmaMzth -- > 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 umatdHzf { final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int UmatdPaw = sc . nextInt ( ) ; if ( UmatdPaw % 2 == 1 ) { System . out . println ( " No " ) ; return ; } String s = sc . next ( ) ; int l = ( int ) ( UmatdPaw / 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 xqjoFhm { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int XqjoMd = Integer . parseInt ( br . readLine ( ) ) ; int [ ] seqS = new int [ XqjoMd ] ; String [ ] line = br . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < XqjoMd ; 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 UauzukPll { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uauzukWif = 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 ( uauzukWif > 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 ) { uauzukWif = uauzukWif - A_attack ; T_turn = 1 ; A_turn = 0 ; } } if ( uauzukWif > 0 ) { System . out . println ( " Yes " ) ; } else if ( uauzukWif <= 0 ) { System . out . println ( " No " ) ; } } } import java . util . * ; public class KlfrJnbd { static int gcd ( int a , int b ) { return b > 0 ? gcd ( b , a % b ) : a ; } static long KlfrL = 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 BgtjIcnlkk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long BgtjFx = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long x = scan . nextLong ( ) ; long y = scan . nextLong ( ) ; long c = BgtjFx * x ; long d = BgtjFx * 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 sdcCpu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String s1 = sc . next ( ) ; int SdcSxrkj = 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 <= SdcSxrkj && SdcSxrkj <= 20000 ) { if ( 0 <= b && b <= 20000 ) { if ( op == '+' ) { System . out . println ( SdcSxrkj + b ) ; } else if ( op == '-' ) { System . out . println ( SdcSxrkj - b ) ; } else if ( op == '*' ) { System . out . println ( SdcSxrkj * b ) ; } else if ( op == '/' ) { System . out . println ( SdcSxrkj / b ) ; } } } } } } import java . util . * ; public class AtycdyAn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int atycdyXis = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int plus = atycdyXis + b ; int minus = atycdyXis - b ; int mult = atycdyXis * 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 BzoiAyin { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int BzoiD = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean [ ] ac = new boolean [ BzoiD + 1 ] ; long [ ] wa = new long [ BzoiD + 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 <= BzoiD ; 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 QjfEb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QjfGwv = sc . nextInt ( ) ; int [ ] d = new int [ QjfGwv ] ; for ( int i = 0 ; i < QjfGwv ; i ++ ) { String line = sc . next ( ) ; d [ i ] = Integer . parseInt ( line ) ; } int K = 0 ; int count = 0 ; int countLeft = 0 ; int countRight = QjfGwv ; Arrays . sort ( d ) ; for ( int i = 0 ; i < QjfGwv ; 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 EeexkWn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eeexkB = 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 = eeexkB - ans ; if ( ans < 0 ) ans = - 1 ; sc . close ( ) ; System . out . println ( ans ) ; } } import java . util . * ; import java . math . * ; import java . io . * ; public class TdnpsdZmq { public static void main ( String [ ] args ) throws Exception { int tdnpsdEstu = 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 oyibQkt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . nextLine ( ) ; String result = " " ; for ( int OyibXu = 0 ; OyibXu < str . length ( ) ; OyibXu ++ ) { String s = str . substring ( OyibXu , OyibXu + 1 ) ; if ( s . equals ( s . toLowerCase ( ) ) ) { result += s . toUpperCase ( ) ; } else { result += s . toLowerCase ( ) ; } } System . out . println ( result ) ; } } import java . util . * ; public class fhsvirSl { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int FhsvirZf ; FhsvirZf = in . nextInt ( ) ; SortedMap < String , Integer > poll = new TreeMap < String , Integer > ( ) ; int maxvote = 0 ; for ( long i = 0 ; i < FhsvirZf ; 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 EfljZkc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int efljBk = sc . nextInt ( ) ; int [ ] A = new int [ efljBk ] ; for ( int i = 0 ; i < efljBk ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } boolean ok = true ; for ( int i = 0 ; i < efljBk ; 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 DcvsPw { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int DcvsI = scanner . nextInt ( ) ; long sum = 0 ; for ( long i = 1 ; i < DcvsI + 1 ; i ++ ) { if ( ! ( i % 3 == 0 || i % 5 == 0 ) ) { sum = sum + i ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class cuudsiY { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int CuudsiChuty = scanner . nextInt ( ) , y = scanner . nextInt ( ) ; System . out . println ( ( ( CuudsiChuty * 2 <= y ) && ( CuudsiChuty * 4 >= y ) && ( 0 == ( y & 1 ) ) ) ? " Yes " : " No " ) ; } } } import java . util . * ; import java . util . Collections ; public class ekytYk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int EkytJhk = 0 ; EkytJhk <= 2 ; EkytJhk ++ ) { list . add ( sc . nextInt ( ) ) ; } int K = sc . nextInt ( ) ; Collections . sort ( list , Collections . reverseOrder ( ) ) ; for ( int EkytJhk = 0 ; EkytJhk < K ; EkytJhk ++ ) { list . set ( 0 , list . get ( 0 ) * 2 ) ; } System . out . println ( list . get ( 0 ) + list . get ( 1 ) + list . get ( 2 ) ) ; } } import java . util . * ; public class ApgjdzVpul { Scanner sc = new Scanner ( System . in ) ; final int apgjdzYal = 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 gaguRg { static String a ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int GaguIrtlv = stdIn . nextInt ( ) ; int count = 0 ; IN : for ( int i = 0 ; i < GaguIrtlv ; 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 xooMc { static long XooNk = 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 YdjArzl { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int YdjGki = stdIn . nextInt ( ) ; String S = stdIn . next ( ) ; String answer = " Yes " ; if ( YdjGki % 2 != 0 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < YdjGki / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( YdjGki / 2 + i ) ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class krdjaLsv { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; String answer = " " ; final int KrdjaYd = scan . nextInt ( ) ; int len = scan . nextInt ( ) ; String [ ] words = new String [ KrdjaYd ] ; for ( int i = 0 ; i < KrdjaYd ; i ++ ) { words [ i ] = scan . next ( ) ; } for ( int i = 1 ; i < KrdjaYd ; 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 < KrdjaYd ; i ++ ) { answer = answer . concat ( words [ i ] ) ; } System . out . println ( answer ) ; } } import java . util . Scanner ; public class aitW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AitOar = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int x = 1 ; int result = 0 ; while ( x < B ) { x += ( AitOar - 1 ) ; result ++ ; } System . out . println ( result ) ; } } import java . util . * ; public class JwpxrfFou { static final long JwpxrfBa = ( 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 ] %= JwpxrfBa ; } } } System . out . println ( dp [ n ] ) ; sc . close ( ) ; } } import java . util . * ; import java . lang . Math ; public class TbtxTqd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tbtxYrou = sc . nextInt ( ) ; int count = 0 ; int count2 = 0 ; if ( tbtxYrou == 1 ) count -- ; if ( tbtxYrou == 2 ) count -= 2 ; while ( count2 < 2 ) { count ++ ; if ( tbtxYrou == 4 ) count2 ++ ; if ( tbtxYrou % 2 == 0 ) tbtxYrou /= 2 ; else tbtxYrou = tbtxYrou * 3 + 1 ; } System . out . println ( count ) ; } } import java . util . * ; public class XxzkxbTedkek { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int XxzkxbUc = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] price = new int [ XxzkxbUc ] ; for ( int i = 0 ; i < XxzkxbUc ; 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 IrapuOjz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int irapuEob = sc . nextInt ( ) ; int ac = 0 , wa = 0 , tle = 0 , re = 0 ; while ( irapuEob -- > 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 IlnasgQqu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ilnasgYp = Integer . parseInt ( sc . next ( ) ) ; int [ ] d = new int [ ilnasgYp ] ; for ( int i = 0 ; i < ilnasgYp ; i ++ ) { d [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( d ) ; System . out . println ( d [ ilnasgYp / 2 ] - d [ ilnasgYp / 2 - 1 ] ) ; } } import java . util . Scanner ; public class MxmgXffebh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MxmgXk = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; int ans = 0 ; for ( int i = 0 ; i < MxmgXk ; i ++ ) { int digit = sc . nextInt ( ) ; if ( min > digit ) { min = digit ; ans ++ ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class ncsabKs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NcsabArwpt , j , t ; int cnt = 0 ; int check = 0 ; int mini , minikey ; int n = sc . nextInt ( ) ; int [ ] num ; num = new int [ n ] ; for ( NcsabArwpt = 0 ; NcsabArwpt < n ; NcsabArwpt ++ ) { num [ NcsabArwpt ] = sc . nextInt ( ) ; } for ( NcsabArwpt = 0 ; NcsabArwpt < n - 1 ; NcsabArwpt ++ ) { mini = NcsabArwpt ; minikey = num [ NcsabArwpt ] ; for ( j = NcsabArwpt + 1 ; j < n ; j ++ ) { if ( num [ j ] < minikey ) { mini = j ; minikey = num [ j ] ; check ++ ; } } t = num [ NcsabArwpt ] ; num [ NcsabArwpt ] = num [ mini ] ; num [ mini ] = t ; if ( check > 0 ) cnt ++ ; check = 0 ; } for ( NcsabArwpt = 0 ; NcsabArwpt < n - 1 ; NcsabArwpt ++ ) { System . out . print ( num [ NcsabArwpt ] + " " ) ; } System . out . println ( num [ n - 1 ] ) ; System . out . println ( cnt ) ; sc . close ( ) ; } } import java . util . * ; class IbsCvldft { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IbsBiu = 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 ; IbsBiu = i ; } } } System . out . println ( IbsBiu ) ; 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 enooG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EnooHbu = 0 ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; while ( ( A - 1 ) * ( EnooHbu - 1 ) + A < B ) { EnooHbu ++ ; } System . out . println ( EnooHbu ) ; sc . close ( ) ; } } import java . util . * ; class SqjcGd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sqjcGo = sc . nextInt ( ) ; int ans = 0 ; for ( int i = sqjcGo ; 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 emcrKy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EmcrKkzpu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( EmcrKkzpu <= b ) { if ( b <= c ) { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * c + EmcrKkzpu + b ) ) ; } else { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * b + EmcrKkzpu + c ) ) ; } } else { if ( EmcrKkzpu <= c ) { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * c + EmcrKkzpu + b ) ) ; } else { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * EmcrKkzpu + b + c ) ) ; } } } } import java . util . Scanner ; public class faseX { private static int countPower ( int n ) { int FaseZi = 0 ; while ( n % 2 == 0 ) { ++ FaseZi ; n /= 2 ; } return FaseZi ; } 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 VwcoQd { public static int vwcoJplb ; 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 ) ; vwcoJplb = scan . nextInt ( ) ; List = new int [ vwcoJplb ] ; for ( int i = 0 ; i < vwcoJplb ; i ++ ) { List [ i ] = scan . nextInt ( ) ; } SelectionSort ( ) ; if ( vwcoJplb == 1 ) System . out . println ( List [ 0 ] ) ; else { for ( int i = 0 ; i < vwcoJplb ; i ++ ) { if ( i == vwcoJplb - 1 ) System . out . println ( List [ vwcoJplb - 1 ] ) ; else System . out . print ( List [ i ] + " " ) ; } } System . out . println ( Count ) ; } public static void SelectionSort ( ) { for ( int i = 0 ; i < vwcoJplb ; i ++ ) { min_j = i ; for ( int j = i ; j < vwcoJplb ; 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 sbtozDv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SbtozTwkp = 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 TotXxbxs { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner in = new Scanner ( System . in ) ; int TotTwa = in . nextInt ( ) ; int m = in . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) sum += in . nextInt ( ) ; int re = TotTwa - sum ; if ( re < 0 ) { System . out . println ( - 1 ) ; } else { System . out . println ( re ) ; } } } import java . util . Scanner ; public class ZfrTnm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZfrYuj = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] a = sc . nextLine ( ) . split ( " " ) ; int [ ] array = new int [ ZfrYuj ] ; for ( int i = 0 ; i < ZfrYuj ; i ++ ) { array [ i ] = Integer . parseInt ( a [ i ] ) ; } int changeCount = 0 ; int minj ; for ( int i = 0 ; i < ZfrYuj ; i ++ ) { minj = i ; for ( int j = i ; j < ZfrYuj ; 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 FwfmeqPdc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int FwfmeqTdk = scanner . nextInt ( ) ; int [ ] a = new int [ 10000 ] ; int max = - 1000000 ; int min = 1000000 ; long sum = 0 ; for ( int i = 0 ; i < FwfmeqTdk ; 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 KuhhBvt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kuhhKruk = sc . nextInt ( ) ; int [ ] h = new int [ kuhhKruk + 2 ] ; int maxh = 0 ; int zero1 = 0 ; int zero2 = kuhhKruk ; int ret = 0 ; for ( int i = 1 ; i < kuhhKruk + 1 ; i ++ ) { h [ i ] = sc . nextInt ( ) ; maxh = Math . max ( maxh , h [ i ] ) ; } h [ 0 ] = 0 ; h [ kuhhKruk + 1 ] = 0 ; for ( int i = 1 ; i <= maxh ; i ++ ) { zero1 = 0 ; zero2 = kuhhKruk ; for ( int j = 0 ; j < kuhhKruk + 2 ; j ++ ) { if ( h [ j ] == 0 ) { zero2 = j ; if ( zero2 - zero1 > 1 ) { ret ++ ; } zero1 = zero2 ; } } for ( int k = 0 ; k < kuhhKruk + 2 ; k ++ ) { if ( h [ k ] > 0 ) { h [ k ] -- ; } } } System . out . println ( ret ) ; } } import java . util . * ; public class xvhQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XvhSp = sc . nextInt ( ) ; int attack1 = sc . nextInt ( ) ; int hp2 = sc . nextInt ( ) ; int attack2 = sc . nextInt ( ) ; while ( XvhSp > 0 && hp2 > 0 ) { hp2 -= attack1 ; if ( hp2 <= 0 ) { System . out . println ( " Yes " ) ; continue ; } XvhSp -= attack2 ; if ( XvhSp <= 0 ) { System . out . println ( " No " ) ; continue ; } } } } import java . util . * ; public class XnzFiy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xnzOe = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int [ ] p = new int [ xnzOe ] ; for ( int i = 0 ; i < q ; i ++ ) p [ sc . nextInt ( ) - 1 ] ++ ; for ( int i = 0 ; i < xnzOe ; 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 kpnBdc { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int KpnUhvo = 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 [ KpnUhvo ] ; for ( int i = 0 ; i < q ; i ++ ) { a [ i ] = Integer . parseInt ( in . readLine ( ) ) ; count [ a [ i ] - 1 ] ++ ; } for ( int i = 0 ; i < KpnUhvo ; i ++ ) { if ( k - ( q - count [ i ] ) <= 0 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } } import java . util . * ; public class bfnH { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int BfnFh = sc . nextInt ( ) ; int [ ] d = new int [ BfnFh ] ; for ( int i = 0 ; i < BfnFh ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; int count = 0 ; for ( int i = 1 ; i < BfnFh ; i ++ ) { if ( d [ i ] == d [ i - 1 ] ) count ++ ; } System . out . println ( BfnFh - count ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . math . BigDecimal ; import java . util . Scanner ; public class PdbecwAi { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; long PdbecwSz = sc . nextInt ( ) ; long H = sc . nextInt ( ) ; long x = sc . nextInt ( ) ; long y = sc . nextInt ( ) ; sc . close ( ) ; String a = BigDecimal . valueOf ( ( ( double ) PdbecwSz * H ) / 2.0 ) . toPlainString ( ) ; out . print ( a ) ; out . print ( " " ) ; if ( PdbecwSz == 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 FfbeVqa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ffbeYmcz = 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 ( ( ffbeYmcz * ffbeYmcz ) + ( b * b ) - ( 2 * ffbeYmcz * b * cosA ) ) ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class UetvzJioa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UetvzAct = sc . nextInt ( ) ; for ( ; ; UetvzAct ++ ) { if ( isPrime ( UetvzAct ) ) break ; } System . out . println ( UetvzAct ) ; } public static boolean isPrime ( int UetvzAct ) { if ( ( UetvzAct % 2 == 0 && UetvzAct != 2 || UetvzAct == 1 ) ) return false ; for ( int i = 3 ; i <= Math . sqrt ( UetvzAct ) ; i += 2 ) { if ( UetvzAct % i == 0 ) return false ; } return true ; } } import java . util . * ; public class aaoPz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AaoTftel = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; if ( Y % 2 == 1 ) { System . out . println ( " No " ) ; } else { int y = Y / 2 ; if ( y - AaoTftel < 0 ) { System . out . println ( " No " ) ; } else if ( y - 2 * AaoTftel > 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } } import java . util . Scanner ; class XavnpfXkk { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int xavnpfY , b , c ; xavnpfY = scn . nextInt ( ) ; b = scn . nextInt ( ) ; c = scn . nextInt ( ) ; System . out . printf ( ( xavnpfY + b + c ) <= 21 ? " win " : " bust " ) ; } } import java . util . * ; class McppscIlmzai { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String McppscDjg = in . nextLine ( ) ; if ( McppscDjg . equals ( " ABC " ) ) System . out . println ( " ARC " ) ; else if ( McppscDjg . equals ( " ARC " ) ) System . out . println ( " ABC " ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class UtyQbs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int utyLym = sc . nextInt ( ) ; Integer [ ] a = new Integer [ utyLym ] ; Integer [ ] tmpA = new Integer [ utyLym ] ; for ( int i = 0 ; i < utyLym ; 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 < utyLym ; i ++ ) { if ( a [ i ] == first ) { System . out . println ( second ) ; } else { System . out . println ( first ) ; } } sc . close ( ) ; } } import java . util . Scanner ; class VryvHbovn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String s1 = sc . next ( ) ; int VryvNk = Integer . parseInt ( s1 ) ; String s2 = sc . next ( ) ; int W = Integer . parseInt ( s2 ) ; if ( VryvNk <= 300 && W <= 300 ) { if ( VryvNk == 0 && W == 0 ) { break ; } for ( int i = 1 ; i <= VryvNk ; i ++ ) { if ( i == 1 || i == VryvNk ) { 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 jfgfrH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int JfgfrDzs = s . length ; int res = 0 ; for ( int i = 0 ; i < ( JfgfrDzs - 1 - i ) ; i ++ ) { if ( s [ i ] != s [ JfgfrDzs - 1 - i ] ) { res ++ ; } } System . out . println ( res ) ; } } import java . util . * ; public class LbcrWd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lbcrUsv = 0 ; int W = 0 ; while ( true ) { lbcrUsv = sc . nextInt ( ) ; W = sc . nextInt ( ) ; if ( lbcrUsv != 0 && W != 0 ) { for ( int i = 0 ; i < lbcrUsv ; 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 UkcGkk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String cards = sc . next ( ) ; if ( cards . equals ( " - " ) ) { break ; } int ukcSy = sc . nextInt ( ) ; for ( int i = 0 ; i < ukcSy ; 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 ztsshjWfc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ZtsshjNrcl = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int counter = 0 ; for ( int i = ZtsshjNrcl ; 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 CvtHt { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int cvtTmgz = scanner . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; long total = 0 ; for ( int i = 0 ; i < cvtTmgz ; 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 WdyyeKod { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WdyyePr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] array = { 1 , 1 , 1 } ; array [ WdyyePr - 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 dzzpO { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int DzzpFcxv = in . nextInt ( ) ; if ( DzzpFcxv == 0 ) break ; int [ ] numbers = new int [ DzzpFcxv ] ; for ( int i = 0 ; i < DzzpFcxv ; i ++ ) numbers [ i ] = in . nextInt ( ) ; long double_sum = 0 ; for ( int i = 0 ; i < DzzpFcxv ; i ++ ) double_sum += numbers [ i ] ; double_sum = double_sum * double_sum ; long sum_double = 0 ; for ( int i = 0 ; i < DzzpFcxv ; i ++ ) sum_double += ( numbers [ i ] * numbers [ i ] ) ; double sd = Math . sqrt ( ( sum_double - double_sum / ( double ) DzzpFcxv ) / ( double ) DzzpFcxv ) ; System . out . printf ( " %5.8f " , sd ) ; System . out . println ( ) ; } } } import java . util . Scanner ; public class CsajCntm { public static void main ( String [ ] args ) { int CsajQc = 0 ; Scanner scan = new Scanner ( System . in ) ; ; while ( true ) { CsajQc ++ ; int a = scan . nextInt ( ) ; if ( a == 0 ) { break ; } System . out . println ( " Case " + CsajQc + " : " + a ) ; } scan . close ( ) ; } } import javax . swing . * ; import java . io . * ; import java . util . * ; import java . math . * ; import static java . util . Comparator . * ; public class xwembeE { public static void main ( String [ ] args ) throws IOException { FastReader s = new FastReader ( ) ; int XwembeXq = s . nextInt ( ) ; int b = s . nextInt ( ) ; int numOfSock = 1 ; int count = 0 ; while ( numOfSock < b ) { numOfSock -= 1 ; numOfSock += XwembeXq ; count ++ ; } System . out . println ( count ) ; } } class xwembeE { 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 KgnotaPqi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KgnotaHp = sc . nextInt ( ) ; boolean flg = true ; int i = 1 ; while ( flg ) { int cg = 1000 * i - KgnotaHp ; if ( cg >= 0 ) { flg = false ; System . out . println ( cg ) ; } i ++ ; } } } import java . util . Scanner ; import java . util . Arrays ; public class CimowZa { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cimowZ = scan . nextInt ( ) ; long [ ] a = new long [ cimowZ ] ; for ( int i = 0 ; i < cimowZ ; i ++ ) { a [ i ] = scan . nextLong ( ) ; if ( a [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } Arrays . sort ( a ) ; long ans = 1 ; for ( int i = cimowZ - 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 txcyW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TxcyNfm = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int left = 0 ; int right = TxcyNfm ; 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 YfoBhm { static int YfoGl = 0 ; public static void main ( String [ ] args ) { int anser = 100000000 ; Scanner scan = new Scanner ( System . in ) ; YfoGl = scan . nextInt ( ) ; ArrayList < Integer > address = new ArrayList < > ( ) ; for ( int i = 0 ; i < YfoGl ; i ++ ) { address . add ( scan . nextInt ( ) ) ; } Collections . sort ( address ) ; for ( int i = address . get ( 0 ) ; i <= address . get ( YfoGl - 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 < YfoGl ; i ++ ) { sum = sum + ( j - array . get ( i ) ) * ( j - array . get ( i ) ) ; } return sum ; } } import java . util . Scanner ; public class GhjJxy { public static void main ( String [ ] args ) { int ghjJeno = 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 ) { ghjJeno ++ ; if ( ghjJeno == 3 ) { hako = 1 ; } } else { ghjJeno = 0 ; } } if ( hako == 1 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; import java . util . stream . * ; class jimciwCo { 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 JimciwGfvi = sc . nextInt ( ) ; for ( int i = 0 ; i < JimciwGfvi ; 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 dzmzbgW { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int DzmzbgKo = scan . nextInt ( ) ; int last = DzmzbgKo % 100 ; int first = ( DzmzbgKo - 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 RetbUoq { public static void main ( String [ ] args ) { try { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String a = br . readLine ( ) ; int RetbU = 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 ( RetbU >= a . length ( ) ) { System . out . println ( " A " ) ; break ; } now = a . substring ( RetbU , RetbU + 1 ) ; RetbU ++ ; } 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 unxpO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final long UnxpNuohd = 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 ) - ( ( UnxpNuohd - 1 ) - ( UnxpNuohd - 1 ) / C - ( UnxpNuohd - 1 ) / D + ( UnxpNuohd - 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 LlmeKnw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int llmeGfnm = sc . nextInt ( ) ; int ans = 0 ; while ( llmeGfnm >= 5 ) { if ( llmeGfnm >= 500 ) { llmeGfnm -= 500 ; ans += 1000 ; } else { llmeGfnm -= 5 ; ans += 5 ; } } System . out . println ( ans ) ; } } import java . util . * ; public class eqoiSg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int EqoiTm = 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 < EqoiTm ; 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 bdvMg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; try { String w = sc . nextLine ( ) ; int BdvNet = w . length ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < BdvNet ; 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 bpsbK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; sc . useDelimiter ( " \\ s " ) ; int BpsbEhog = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int d = BpsbEhog / b ; int r = BpsbEhog % b ; double A = BpsbEhog ; 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 GvhzYg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gvhzCkhd = sc . nextInt ( ) ; Integer [ ] a = new Integer [ gvhzCkhd ] ; for ( int i = 0 ; i < gvhzCkhd ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( a , Collections . reverseOrder ( ) ) ; int A = a [ 0 ] , B = 0 ; for ( int i = 1 ; i < gvhzCkhd ; i ++ ) { if ( i % 2 == 0 ) { A += a [ i ] ; } else { B += a [ i ] ; } } System . out . println ( A - B ) ; } } import java . util . Scanner ; public class syvleI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SyvleXm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; sc . close ( ) ; if ( SyvleXm * b >= SyvleXm + b && SyvleXm * b >= SyvleXm - b ) { System . out . println ( SyvleXm * b ) ; } else if ( SyvleXm + b >= SyvleXm - b && SyvleXm + b >= SyvleXm * b ) { System . out . println ( SyvleXm + b ) ; } else { System . out . println ( SyvleXm - b ) ; } } } import java . util . Scanner ; public class PrqQv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; scan . close ( ) ; boolean PrqBri = true ; if ( S . charAt ( 2 ) != S . charAt ( 3 ) ) PrqBri = false ; else if ( S . charAt ( 4 ) != S . charAt ( 5 ) ) PrqBri = false ; if ( PrqBri ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class DsjifjXq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long DsjifjW = sc . nextLong ( ) ; long sum = 0 ; for ( int a = 1 ; a <= DsjifjW ; ++ a ) { for ( int b = 1 ; b <= DsjifjW ; ++ b ) { long g1 = findGcd ( a , b ) ; for ( int c = 1 ; c <= DsjifjW ; ++ 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 CuhzlaAbb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cuhzlaOitl = sc . nextInt ( ) ; int [ ] [ ] A = new int [ 2 ] [ cuhzlaOitl ] ; for ( int i = 0 ; i < cuhzlaOitl ; i ++ ) { A [ 0 ] [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < cuhzlaOitl ; i ++ ) { A [ 1 ] [ i ] = sc . nextInt ( ) ; } int ans ; int tempofans = 0 ; int num = 0 ; for ( int k = 0 ; k < cuhzlaOitl ; k ++ ) { num = 0 ; for ( int j = 0 ; j < cuhzlaOitl ; 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 FmpdiHpj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FmpdiQ = sc . nextInt ( ) ; int xx = 0 ; int yy = 0 ; int time = 0 ; for ( int i = 0 ; i < FmpdiQ ; 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 hrswgrQko { 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 HrswgrVd = sc . nextInt ( ) ; int color2_n = sc . nextInt ( ) ; final String target = sc . next ( ) ; if ( target . equals ( color1 ) ) { HrswgrVd -- ; } else if ( target . equals ( color2 ) ) { color2_n -- ; } System . out . println ( HrswgrVd + " " + color2_n ) ; sc . close ( ) ; } } import java . util . Scanner ; public class wliigeAym { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WliigeQj = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; sc . close ( ) ; int C = 1 ; int D = 0 ; while ( B > C ) { C += WliigeQj - 1 ; D ++ ; } System . out . println ( D ) ; } } import java . util . Scanner ; public class HrtwDfecwf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HrtwX = sc . nextInt ( ) ; int [ ] l = new int [ HrtwX ] ; for ( int i = 0 ; i < HrtwX ; i ++ ) { l [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int max = 0 ; int sum = 0 ; for ( int i = 0 ; i < HrtwX ; 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 RjkuEjx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rjkuYhl = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int tap = 1 ; int atap = 0 ; while ( tap < b ) { tap -- ; tap += rjkuYhl ; 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 KlwrJmctiu { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int KlwrBm = Integer . parseInt ( str [ 0 ] ) ; int y = Integer . parseInt ( str [ 1 ] ) ; System . out . println ( KlwrBm * y + " " + ( 2 * KlwrBm + 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 RplslUj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rplslCqa = 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 ) rplslCqa ++ ; } System . out . print ( rplslCqa ) ; System . out . println ( ) ; } } import java . util . Scanner ; public class SqjWjv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; int sqjTk = 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 ( sqjTk == tmp ) { result = " Yes " ; } } } System . out . println ( result ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class UsxgnFfu { public static void main ( String [ ] args ) throws Exception { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int usxgnS = Integer . parseInt ( reader . readLine ( ) ) ; String [ ] array = reader . readLine ( ) . split ( " " ) ; int [ ] H = new int [ usxgnS ] ; for ( int i = 0 ; i < usxgnS ; i ++ ) { H [ i ] = Integer . parseInt ( array [ i ] ) ; } boolean ret = true ; for ( int i = usxgnS - 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 KzcggjBapi { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int KzcggjDw = 1 ; while ( true ) { String str = input . nextLine ( ) ; if ( ! str . equals ( " 0 " ) ) { System . out . println ( " Case " + KzcggjDw + " : " + str ) ; KzcggjDw = KzcggjDw + 1 ; } else { break ; } } } } import java . util . Scanner ; public class CwxjxaXnt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CwxjxaDd = Integer . parseInt ( sc . next ( ) ) ; int [ ] p = new int [ CwxjxaDd ] ; int idx ; for ( idx = 0 ; idx < CwxjxaDd ; idx ++ ) { p [ idx ] = Integer . parseInt ( sc . next ( ) ) ; } int cnt = 0 ; for ( idx = 1 ; idx < CwxjxaDd - 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 IbeezjIbm { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ibeezjGcme = in . nextInt ( ) ; int [ ] [ ] A = new int [ 2 ] [ ibeezjGcme ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < ibeezjGcme ; j ++ ) { A [ i ] [ j ] = in . nextInt ( ) ; } } int ans = 0 ; for ( int i = 0 ; i < ibeezjGcme ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j <= i ; j ++ ) { sum += A [ 0 ] [ j ] ; } for ( int j = i ; j < ibeezjGcme ; j ++ ) { sum += A [ 1 ] [ j ] ; } ans = Math . max ( ans , sum ) ; } System . out . println ( ans ) ; in . close ( ) ; } } import java . util . * ; public class OrmtzhLlpcjv { public static Scanner in = new Scanner ( System . in ) ; public static int OrmtzhAqu = 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 == OrmtzhAqu - 1 ) { return 0 ; } else { if ( dp [ idx ] == - 1 ) { long c1 = solve ( idx + 1 ) + Math . abs ( h [ idx ] - h [ idx + 1 ] ) ; long c2 = oo ; if ( OrmtzhAqu - 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 ; } OrmtzhAqu = in . nextInt ( ) ; for ( int i = 0 ; i < OrmtzhAqu ; i ++ ) { h [ i ] = in . nextInt ( ) ; } System . out . println ( solve ( 0 ) ) ; } } import java . util . * ; public class OnwuFwfbr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int OnwuLl = sc . nextInt ( ) ; String [ ] S = new String [ OnwuLl ] ; for ( int i = 0 ; i < OnwuLl ; ++ i ) { S [ i ] = sc . next ( ) ; } int [ ] C = new int [ 4 ] ; for ( int i = 0 ; i < OnwuLl ; ++ 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 xluzwHys { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XluzwGoxe = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; sc . close ( ) ; int a = T / XluzwGoxe ; System . out . println ( a * B ) ; } } import java . util . * ; public class ImqaNhyt { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int ImqaYa = scn . nextInt ( ) ; int b = scn . nextInt ( ) ; int ans = ImqaYa * b ; int ans2 = 0 ; for ( int i = 0 ; i < b ; i ++ ) { ans2 += ImqaYa ; } System . out . println ( ans2 ) ; } } import java . util . Scanner ; class DctLoy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String DctMxf = sc . next ( ) ; System . out . println ( DctMxf . replaceAll ( " \\ - " , " " ) . length ( ) - ( 4 - DctMxf . replaceAll ( " \\ - " , " " ) . length ( ) ) ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class nrydA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NrydImbb = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; int [ ] A = new int [ NrydImbb ] ; for ( int i = 0 ; i < NrydImbb ; i ++ ) { int a = sc . nextInt ( ) ; map . put ( i , a ) ; A [ i ] = a ; } sc . close ( ) ; Arrays . sort ( A ) ; for ( int i = 0 ; i < NrydImbb ; i ++ ) { int except = map . get ( i ) ; System . out . println ( A [ NrydImbb - 1 ] == except ? A [ NrydImbb - 2 ] : A [ NrydImbb - 1 ] ) ; } } } import java . util . * ; import java . io . * ; public class AjsNtjcp { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int AjsF = in . nextInt ( ) ; System . out . println ( Math . min ( AjsF * in . nextInt ( ) , in . nextInt ( ) ) ) ; } } import java . util . Scanner ; public class FhpGt { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int FhpLmm = scanner . nextInt ( ) ; int ans = 0 ; if ( FhpLmm == 0 ) { ans = 1 ; } System . out . println ( ans ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class QoxxcwQbjy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QoxxcwJhq = sc . nextInt ( ) ; int [ ] nums = new int [ QoxxcwJhq ] ; for ( int i = 0 ; i < QoxxcwJhq ; 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 PmyxeOzpx { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int PmyxePgs = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( PmyxePgs * B ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class QrkFu { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . QrkMj ) ) ) { String QrkMj = br . readLine ( ) ; System . out . println ( QrkMj . equals ( " Sunny " ) ? " Cloudy " : QrkMj . equals ( " Cloudy " ) ? " Rainy " : " Sunny " ) ; } } } import java . util . * ; class QokvxqHue { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QokvxqBjm = 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 ( QokvxqBjm , c ) , 0 ) ) ; } } import java . util . Scanner ; public class otyDz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int OtyBcxe = 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 ) { OtyBcxe ++ ; } else { if ( maxCount < OtyBcxe ) { maxCount = OtyBcxe ; } OtyBcxe = 0 ; } actual = siguiente ; } if ( maxCount < OtyBcxe ) { maxCount = OtyBcxe ; } System . out . println ( maxCount ) ; } } import java . util . Scanner ; import java . lang . Math ; public class ffqlBb { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int FfqlNrdw = sc . nextInt ( ) ; int [ ] [ ] grid = new int [ 2 ] [ FfqlNrdw ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < FfqlNrdw ; j ++ ) { grid [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] ans = new int [ 2 ] [ FfqlNrdw ] ; ans [ 0 ] [ 0 ] = grid [ 0 ] [ 0 ] ; ans [ 1 ] [ 0 ] = grid [ 1 ] [ 0 ] + ans [ 0 ] [ 0 ] ; for ( int j = 1 ; j < FfqlNrdw ; j ++ ) { ans [ 0 ] [ j ] = grid [ 0 ] [ j ] + ans [ 0 ] [ j - 1 ] ; } for ( int j = 1 ; j < FfqlNrdw ; j ++ ) { ans [ 1 ] [ j ] = grid [ 1 ] [ j ] + Math . max ( ans [ 1 ] [ j - 1 ] , ans [ 0 ] [ j ] ) ; } System . out . println ( ans [ 1 ] [ FfqlNrdw - 1 ] ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; public class gldHwh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GldIfjqj = sc . nextInt ( ) ; double t = sc . nextDouble ( ) ; double a = sc . nextDouble ( ) ; double [ ] h = new double [ GldIfjqj ] ; double [ ] dist = new double [ GldIfjqj ] ; int answer = 0 ; double tmp = 10000000 ; for ( int i = 0 ; i < GldIfjqj ; i ++ ) { h [ i ] = sc . nextDouble ( ) ; } for ( int i = 0 ; i < GldIfjqj ; i ++ ) { dist [ i ] = Math . abs ( a - ( t - h [ i ] * 0.006 ) ) ; } for ( int i = 0 ; i < GldIfjqj ; i ++ ) { if ( tmp > dist [ i ] ) { answer = i ; tmp = dist [ i ] ; } } System . out . println ( answer + 1 ) ; } } import java . util . * ; public class NfzKzd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nfzXrjj = sc . nextInt ( ) ; int x = 0 ; while ( true ) { if ( nfzXrjj <= 1000 ) { x = 1000 - nfzXrjj ; break ; } else { nfzXrjj = nfzXrjj - 1000 ; } } System . out . println ( x ) ; } } import java . util . * ; public class XzobPmvbjj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String XzobCfq = sc . next ( ) ; String [ ] str2 = XzobCfq . 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 HbiSmzt { public static void main ( String [ ] args ) { try { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String a = reader . readLine ( ) ; String [ ] b = a . split ( " " ) ; int hbiR = Integer . parseInt ( b [ 0 ] ) ; int d = Integer . parseInt ( b [ 1 ] ) ; String [ ] e = new String [ d ] ; int [ ] [ ] f = new int [ hbiR ] [ d ] ; for ( int g = 0 ; g < hbiR ; 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 < hbiR ; 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 OziNil { 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 oziZms = Integer . parseInt ( line [ 0 ] ) ; int y = Integer . parseInt ( line [ 1 ] ) ; if ( oziZms == 0 && y == 0 ) { break ; } else { sb . append ( Integer . toString ( oziZms < y ? oziZms : y ) ) . append ( " " ) . append ( Integer . toString ( oziZms < y ? y : oziZms ) ) . append ( " \n " ) ; } } System . out . print ( sb ) ; } } import java . util . Scanner ; public class YnypcWi { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ynypcP = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; if ( k <= ynypcP + b ) { if ( k >= ynypcP ) { System . out . println ( ynypcP ) ; } else { System . out . println ( k ) ; } } else { System . out . println ( ynypcP - ( k - ynypcP - b ) ) ; } sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class BregmrYphc { public static void main ( String [ ] args ) { Scanner inData = new Scanner ( System . in ) ; int BregmrE = inData . nextInt ( ) ; int K = inData . nextInt ( ) ; int [ ] P = new int [ BregmrE ] ; for ( int i = 0 ; i < BregmrE ; 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 cwhKi { public static void main ( String [ ] args ) { try { int CwhHkn ; int paper ; Scanner scan = new Scanner ( System . in ) ; String N = scan . next ( ) ; CwhHkn = Integer . parseInt ( N ) ; if ( CwhHkn % 2 == 0 ) { paper = CwhHkn / 2 ; } else { paper = CwhHkn / 2 + 1 ; } System . out . println ( paper ) ; } catch ( Exception e ) { System . out . println ( " error " ) ; } } } import java . util . Scanner ; public class ZvqjtyJns { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( ( System . in ) ) ; int ZvqjtyN = sc . nextInt ( ) ; int [ ] a = new int [ ZvqjtyN ] ; int ans = 0 , o = 0 , e = 0 ; for ( int i = 0 ; i < ZvqjtyN ; i ++ ) { int x = sc . nextInt ( ) ; if ( x % 2 == 0 ) { a [ e ] = x ; e ++ ; } else { o ++ ; } } if ( o != ZvqjtyN ) { 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 MsbowMgj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long MsbowGoa = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long t = sc . nextLong ( ) ; if ( MsbowGoa <= x ) { System . out . println ( t ) ; return ; } long ans = 0 ; ans += ( MsbowGoa / x ) * t ; MsbowGoa %= x ; if ( MsbowGoa > 0 ) { ans += t ; } sc . close ( ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class LhcfnxQcm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String a = scan . next ( ) ; char lhcfnxT = a . charAt ( 0 ) ; char c = a . charAt ( 1 ) ; char d = a . charAt ( 2 ) ; char f = 'R' ; if ( lhcfnxT == c && c == d && d == f ) { System . out . println ( " 3 " ) ; } else if ( ( lhcfnxT == c && c == f ) || ( c == d && d == f ) ) { System . out . println ( " 2 " ) ; } else if ( ! ( lhcfnxT == f || c == f || d == f ) ) { System . out . println ( " 0 " ) ; } else { System . out . println ( " 1 " ) ; } } } class KhhbYc { public static void main ( String [ ] args ) { java . util . Scanner sc = new java . util . Scanner ( System . in ) ; final int khhbAv = sc . nextInt ( ) ; final int L = sc . nextInt ( ) ; int output = 0 ; if ( - 1 <= L - 1 ) { output -= L ; } else if ( L - 1 <= - khhbAv ) { output -= L + khhbAv - 1 ; } output += khhbAv * ( L - 1 ) + khhbAv * ( khhbAv + 1 ) / 2 ; System . out . println ( output ) ; } } import java . util . * ; public class OvshZdfce { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OvshYqk = 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 ; OvshYqk ++ ; } } System . out . println ( OvshYqk ) ; } } import java . util . Scanner ; public class NndulcLcba { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] ary = sc . next ( ) . toCharArray ( ) ; int NndulcAo = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( ary [ i ] == '+' ) { NndulcAo ++ ; } else { NndulcAo -- ; } } sc . close ( ) ; System . out . println ( NndulcAo ) ; } } import java . util . Scanner ; public class QkxhFj { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; String W = scn . nextLine ( ) ; int qkxhChlw = 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 ) ) { qkxhChlw ++ ; } } System . out . println ( qkxhChlw ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class wcqYpu { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int WcqEvanv = scanner . nextInt ( ) ; Map < String , Long > counts = new HashMap < > ( ) ; for ( int i = 0 ; i < WcqEvanv ; ++ 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 SnnschHcy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SnnschDqc = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int [ ] point = new int [ SnnschDqc ] ; Arrays . fill ( point , k - q ) ; for ( int i = 0 ; i < q ; i ++ ) { point [ Integer . parseInt ( sc . next ( ) ) - 1 ] ++ ; } for ( int i = 0 ; i < SnnschDqc ; i ++ ) { if ( point [ i ] >= 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class XriNfn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xriAadq = scan . nextInt ( ) ; System . out . println ( ( double ) ( xriAadq - xriAadq / 2 ) / ( double ) ( xriAadq ) ) ; } } import java . util . Scanner ; public class FzpdQsss { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line1 = sc . nextLine ( ) ; int fzpdRsxc = Integer . parseInt ( line1 ) ; String line2 = sc . nextLine ( ) ; String [ ] kari = line2 . split ( " " ) ; int [ ] A = new int [ fzpdRsxc ] ; for ( int i = 0 ; i < fzpdRsxc ; i ++ ) { A [ i ] = Integer . parseInt ( kari [ i ] ) ; } System . out . println ( line2 ) ; int v = 0 ; int j = 0 ; for ( int i = 1 ; i < fzpdRsxc ; 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 < fzpdRsxc - 1 ; k ++ ) { System . out . print ( A [ k ] ) ; System . out . print ( " " ) ; } System . out . println ( A [ fzpdRsxc - 1 ] ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class xninjP { 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 XninjDus = in . nextLong ( ) ; long b = in . nextLong ( ) ; long max = Math . max ( XninjDus , b ) ; for ( long i = 0 ; i < max ; i ++ ) { if ( Math . abs ( XninjDus - i ) == Math . abs ( b - i ) ) { out . println ( i ) ; out . close ( ) ; return ; } } out . println ( " IMPOSSIBLE " ) ; out . close ( ) ; } static class xninjP { 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 dkihmdH { 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 DkihmdXqq , b ; for ( int i = 0 ; i < line . length ; i ++ ) { switch ( line [ i ] ) { case " + " : DkihmdXqq = stack . pollLast ( ) ; b = stack . pollLast ( ) ; stack . offer ( b + DkihmdXqq ) ; break ; case " - " : DkihmdXqq = stack . pollLast ( ) ; b = stack . pollLast ( ) ; stack . offer ( b - DkihmdXqq ) ; break ; case " * " : DkihmdXqq = stack . pollLast ( ) ; b = stack . pollLast ( ) ; stack . offer ( b * DkihmdXqq ) ; break ; default : stack . offer ( Integer . parseInt ( line [ i ] ) ) ; break ; } } System . out . println ( stack . poll ( ) ) ; } } import java . util . Scanner ; public class ZaasjlErx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZaasjlNhj = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; while ( 0 < c && 0 < ZaasjlNhj ) { c -= b ; if ( c <= 0 ) { break ; } ZaasjlNhj -= d ; } if ( 0 < ZaasjlNhj ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class fkxaqgDj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FkxaqgGzxd = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int s = ( FkxaqgGzxd >= B ) ? FkxaqgGzxd : B ; int f = ( FkxaqgGzxd >= B ) ? B : FkxaqgGzxd ; 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 zuioxsOj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZuioxsXrd = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; while ( ZuioxsXrd > 0 ) { String a = sc . next ( ) ; if ( map . containsKey ( a ) ) { map . put ( a , map . get ( a ) + 1 ) ; } else { map . put ( a , 1 ) ; } ZuioxsXrd -- ; } 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 croxdPz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int CroxdTlwc = scan . nextInt ( ) ; long total = 0 ; for ( int a = 1 ; a < CroxdTlwc + 1 ; a ++ ) { for ( int b = 1 ; b < CroxdTlwc + 1 ; b ++ ) { for ( int c = 1 ; c < CroxdTlwc + 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 DxxgbXh { 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 dxxgbD = 0 ; int maxCount = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( acgt . contains ( sArray [ i ] ) ) { dxxgbD ++ ; if ( dxxgbD > maxCount ) { maxCount = dxxgbD ; } } else { dxxgbD = 0 ; } } System . out . println ( maxCount ) ; } } import java . util . Scanner ; class HwbygmMfu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; int hwbygmQxg = Integer . parseInt ( s1 ) ; String s2 = sc . next ( ) ; int b = Integer . parseInt ( s2 ) ; double p = Math . pow ( 10 , 9 ) ; if ( 1 <= hwbygmQxg && hwbygmQxg <= p ) { if ( 1 <= b && b <= p ) { int d = hwbygmQxg / b ; int r = hwbygmQxg % b ; double f = ( double ) hwbygmQxg / ( double ) b ; System . out . println ( d + " " + r + " " + String . format ( " %1$3f " , f ) ) ; } } } } import java . util . * ; class VxyorbWhbwpt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VxyorbU = sc . nextInt ( ) ; long [ ] A = new long [ VxyorbU + 2 ] ; long [ ] B = new long [ VxyorbU + 1 ] ; long cnt = 0 ; long wk = 0 ; long wk2 = 0 ; for ( int i = 0 ; i < VxyorbU + 1 ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < VxyorbU ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < VxyorbU ; 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 wnvuiXjo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int WnvuiQx = str . WnvuiQx ( ) ; for ( int i = 0 ; i < WnvuiQx ; 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 PjxdtLtwy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pjxdtDhmm = sc . nextInt ( ) ; HashSet < Integer > set = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < pjxdtDhmm ; i ++ ) { int number = sc . nextInt ( ) ; set . add ( number ) ; } System . out . println ( set . size ( ) ) ; } } import java . util . Scanner ; class MrnYv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String mrnP = sc . nextLine ( ) ; mrnP = mrnP . replaceAll ( " eraser " , " " ) ; mrnP = mrnP . replaceAll ( " erase " , " " ) ; mrnP = mrnP . replaceAll ( " dreamer " , " " ) ; mrnP = mrnP . replaceAll ( " dream " , " " ) ; if ( mrnP . equals ( " " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . io . IOException ; import java . util . Arrays ; import java . util . Scanner ; public class IgmzolJupo { public static void main ( String [ ] args ) throws IOException { try ( Scanner s = new Scanner ( System . in ) ) { int IgmzolMc = 3 ; int [ ] array = new int [ IgmzolMc ] ; for ( int i = 0 ; i < IgmzolMc ; 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 JpsjKkj { public static void main ( String [ ] args ) { HashMap < Integer , Integer > h = new HashMap < > ( ) ; int JpsjK = 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 ) { JpsjK ++ ; } } System . out . println ( JpsjK ) ; } } import java . util . Scanner ; import java . util . InputMismatchException ; class hdlqJ { public static void main ( String [ ] args ) { int HdlqBnqj = 0 , y = 0 ; int [ ] [ ] z ; Scanner scanner = new Scanner ( System . in ) ; HdlqBnqj = 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 PjkyuOsi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pjkyuHhw = sc . nextInt ( ) ; System . out . println ( pjkyuHhw * 2 * 3.14 ) ; } } import java . util . * ; public class MtkuoRat { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mtkuoNiu = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] [ ] vectorA = new int [ mtkuoNiu ] [ m ] ; int [ ] vectorB = new int [ m ] ; int [ ] vectorC = new int [ mtkuoNiu ] ; for ( int i = 0 ; i < mtkuoNiu ; 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 < mtkuoNiu ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { vectorC [ i ] += vectorA [ i ] [ j ] * vectorB [ j ] ; } } for ( int i = 0 ; i < mtkuoNiu ; 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 QhcHomtid { 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 QhcG = Integer . parseInt ( s ) ; s = in . readLine ( ) ; String [ ] as = s . split ( " " ) ; int [ ] a = new int [ QhcG ] ; for ( int i = 0 ; i < QhcG ; i ++ ) { a [ i ] = Integer . parseInt ( as [ i ] ) ; } output ( a ) ; insertionSort ( a , QhcG ) ; } private static void insertionSort ( int [ ] a , int QhcG ) { for ( int i = 1 ; i < QhcG ; 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 KdwWch { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kdwJ , second ; kdwJ = sc . nextInt ( ) ; second = sc . nextInt ( ) ; if ( kdwJ > 0 && kdwJ < 10 && second > 0 && second < 10 ) System . out . println ( kdwJ * second ) ; else System . out . println ( " -1 " ) ; } } import java . util . * ; import java . io . * ; class puetceKsa { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; long PuetceEnuf = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; long nA = Math . max ( 0 , PuetceEnuf - K ) ; long nB = Math . max ( 0 , B - Math . max ( K - PuetceEnuf , 0 ) ) ; System . out . println ( nA + " " + nB ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } } import java . util . * ; public class ItduzFy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ItduzC = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; String [ ] S = sc . next ( ) . split ( " - " ) ; if ( S . length == 2 ) { if ( S [ 0 ] . length ( ) == ItduzC && 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 AjiuIq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ajiuNf ; while ( ( ajiuNf = scan . nextInt ( ) ) != 0 ) { int [ ] s = new int [ ajiuNf ] ; double m = 0 ; for ( int i = 0 ; i < ajiuNf ; i ++ ) { s [ i ] = scan . nextInt ( ) ; m += s [ i ] ; } m /= ajiuNf ; double sum = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { sum += ( s [ i ] - m ) * ( s [ i ] - m ) ; } System . out . println ( Math . sqrt ( sum / ajiuNf ) ) ; } } } import java . util . Scanner ; public class aqgvKd { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int AqgvYa = in . nextInt ( ) ; int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int sum2 = 0 ; for ( int i = 1 ; i <= AqgvYa ; 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 MjfyQi { 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 PpykpMwkljy { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int PpykpFa = 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 ( ) ) ) { PpykpFa ++ ; } } } System . out . println ( PpykpFa ) ; } } import java . util . Scanner ; public class odnaV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OdnaNb = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] ACs = new int [ OdnaNb + 1 ] ; int [ ] WAs = new int [ OdnaNb + 1 ] ; for ( int i = 0 ; i < OdnaNb + 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 <= OdnaNb ; 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 jaxjgsT { public static void main ( String [ ] args ) { int JaxjgsWr , 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 ++ ) { JaxjgsWr = n ; l = 0 ; m = n / 2 ; while ( true ) { if ( s [ m ] == t [ j ] ) { count ++ ; break ; } if ( m == l ) { break ; } if ( s [ m ] > t [ j ] ) { JaxjgsWr = m ; m = ( JaxjgsWr + l ) / 2 ; } if ( s [ m ] < t [ j ] ) { l = m + 1 ; m = ( JaxjgsWr + l ) / 2 ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class MyntQjwh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long MyntZ = Long . parseLong ( sc . next ( ) ) ; long b = Long . parseLong ( sc . next ( ) ) ; long k = Long . parseLong ( sc . next ( ) ) ; long resultA = MyntZ - 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 kgfzilQay { private static int [ ] heights ; private static int KgfzilYndio , ans = Integer . MAX_VALUE , k ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; KgfzilYndio = sc . nextInt ( ) ; k = sc . nextInt ( ) ; heights = new int [ KgfzilYndio + 3 ] ; dp = new int [ KgfzilYndio + 3 ] ; for ( int i = 1 ; i <= KgfzilYndio ; 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 == KgfzilYndio ) return 0 ; if ( dp [ ind ] != - 1 ) { return dp [ ind ] ; } int min = Integer . MAX_VALUE ; for ( int i = ind + 1 ; i <= Math . min ( KgfzilYndio , 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 xencIf { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String XencFecp = " No " ; String inStr = br . readLine ( ) ; String target = br . readLine ( ) ; String ring = inStr + inStr ; if ( inStr . length ( ) >= target . length ( ) ) { if ( ring . indexOf ( target ) != - 1 ) XencFecp = " Yes " ; } System . out . println ( XencFecp ) ; } } } import java . io . * ; class gsruFv { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int GsruOhyi = Integer . parseInt ( buf . readLine ( ) ) ; String [ ] str ; int tarou = 0 ; int hanako = 0 ; for ( int i = 0 ; i < GsruOhyi ; 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 qvhxxnMtn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] T = new int [ 5 ] ; int [ ] D = new int [ 5 ] ; for ( int QvhxxnKx = 0 ; QvhxxnKx < 5 ; QvhxxnKx ++ ) { T [ QvhxxnKx ] = sc . nextInt ( ) ; } int sum = 0 ; for ( int QvhxxnKx = 0 ; QvhxxnKx < 5 ; QvhxxnKx ++ ) { if ( T [ QvhxxnKx ] % 10 == 0 ) { D [ QvhxxnKx ] = T [ QvhxxnKx ] ; } else { D [ QvhxxnKx ] = ( T [ QvhxxnKx ] / 10 ) * 10 + 10 ; } } int max = 0 ; for ( int QvhxxnKx = 0 ; QvhxxnKx < 5 ; QvhxxnKx ++ ) { if ( ( D [ QvhxxnKx ] - T [ QvhxxnKx ] ) > max ) { max = D [ QvhxxnKx ] - T [ QvhxxnKx ] ; } sum = sum + D [ QvhxxnKx ] ; } System . out . println ( sum - max ) ; } } import java . util . Scanner ; public class DvcAxsu { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int dvcT = s . nextInt ( ) ; int [ ] a = new int [ dvcT ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = 0 ; } for ( int i = 0 ; i < dvcT - 1 ; i ++ ) { a [ s . nextInt ( ) - 1 ] ++ ; } for ( int i : a ) { System . out . println ( i ) ; } } } import java . util . * ; public class tsaAx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int TsaBskl = 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 ++ ; } TsaBskl = Math . TsaBskl ( TsaBskl , sum ) ; } System . out . println ( TsaBskl ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; class FunujxLjb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int FunujxC = scanner . nextInt ( ) ; List < Integer > numList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < FunujxC ; i ++ ) { numList . add ( scanner . nextInt ( ) ) ; } scanner . close ( ) ; int flag = 1 ; int c = 0 ; while ( flag == 1 ) { flag = 0 ; for ( int j = FunujxC - 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 < FunujxC ; i ++ ) { System . out . print ( numList . get ( i ) ) ; if ( i < FunujxC - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; System . out . println ( c ) ; } } import java . util . Scanner ; public class TobwjtSbla { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TobwjtSzh = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ TobwjtSzh ] ; int [ ] b = new int [ TobwjtSzh ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ sc . nextInt ( ) - 1 ] ++ ; b [ sc . nextInt ( ) - 1 ] ++ ; } sc . close ( ) ; for ( int i = 0 ; i < TobwjtSzh ; i ++ ) { System . out . println ( a [ i ] + b [ i ] ) ; } } } import java . util . Scanner ; public class TrqyPs { 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 trqyAlo = 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 ] ) { trqyAlo = false ; break ; } trqyAlo = true ; } if ( trqyAlo == true ) { msg = " Yes " ; break ; } } System . out . println ( msg ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class JleYv { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; long jleAth = stdIn . nextLong ( ) ; double b = stdIn . nextDouble ( ) ; BigDecimal bd1 = BigDecimal . valueOf ( jleAth ) ; BigDecimal bd2 = BigDecimal . valueOf ( b ) ; BigDecimal ans = bd1 . multiply ( bd2 ) . setScale ( 0 , BigDecimal . ROUND_DOWN ) ; System . out . println ( ans ) ; } } import java . util . * ; class KkkxEp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kkkxEjar = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . printf ( " %d " , c ) ; System . out . printf ( " %d " , kkkxEjar ) ; System . out . print ( b ) ; } } import java . util . LinkedList ; import java . util . Scanner ; public class IcnyluRmbud { 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 IcnyluK ; int op2 ; for ( String item : items ) { switch ( item ) { case " + " : op2 = stack . pop ( ) ; IcnyluK = stack . pop ( ) ; stack . push ( IcnyluK + op2 ) ; break ; case " - " : op2 = stack . pop ( ) ; IcnyluK = stack . pop ( ) ; stack . push ( IcnyluK - op2 ) ; break ; case " * " : op2 = stack . pop ( ) ; IcnyluK = stack . pop ( ) ; stack . push ( IcnyluK * op2 ) ; break ; default : stack . push ( Integer . parseInt ( item ) ) ; } } System . out . println ( stack . pop ( ) ) ; } } class IcnyluRmbud { 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 ImwyCari { public static void main ( String [ ] args ) { boolean imwyCb = 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 UuwqNwj { static class UuwqNwj { public void find ( int perimeter , int [ ] arr ) { arr [ arr . length - 1 ] = perimeter ; int UuwqImo = Integer . MAX_VALUE ; int antiClock = ( arr [ 0 ] + perimeter ) % perimeter ; UuwqImo = Math . min ( UuwqImo , perimeter - ( perimeter - arr [ arr . length - 2 ] ) - antiClock ) ; UuwqImo = Math . min ( UuwqImo , perimeter - ( arr [ 1 ] - arr [ 0 ] ) ) ; for ( int i = 1 ; i < arr . length - 1 ; i ++ ) { UuwqImo = Math . min ( UuwqImo , perimeter - ( arr [ i + 1 ] - arr [ i ] ) ) ; UuwqImo = Math . min ( UuwqImo , perimeter - ( arr [ i ] - arr [ i - 1 ] ) ) ; } System . out . println ( UuwqImo ) ; } } 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 FxxazYy { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int fxxazP = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; String [ ] A = new String [ fxxazP ] ; for ( int i = 0 ; i < fxxazP ; 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 FbvfQec { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] [ ] rooms = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int fbvfJoq = 0 ; fbvfJoq < 4 ; fbvfJoq ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { rooms [ fbvfJoq ] [ j ] [ k ] = 0 ; } } } int n = sc . nextInt ( ) ; for ( int fbvfJoq = 0 ; fbvfJoq < n ; fbvfJoq ++ ) { 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 fbvfJoq = 0 ; fbvfJoq < 4 ; fbvfJoq ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { System . out . print ( " " + rooms [ fbvfJoq ] [ j ] [ k ] ) ; } System . out . println ( " " ) ; } if ( fbvfJoq < 3 ) { System . out . println ( " #################### " ) ; } } sc . close ( ) ; } } import java . util . Scanner ; class raqxFk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int RaqxAbds = Integer . parseInt ( scan . next ( ) ) ; int a = Integer . parseInt ( scan . next ( ) ) ; int b = Integer . parseInt ( scan . next ( ) ) ; int sum = 0 ; for ( int i = 1 ; i < RaqxAbds + 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 AbxHbd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int abxJugm = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int num = abxJugm / a ; int amari = abxJugm % a ; System . out . println ( amari == 0 ? num : num + 1 ) ; } } import java . util . Scanner ; public class BzvdQf { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { String bzvdK = scanner . nextLine ( ) ; System . out . println ( " 2018/01/ " + bzvdK . split ( " / " ) [ 2 ] ) ; } } } import java . util . * ; public class UgeEakm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UgeEb = sc . nextInt ( ) ; int ans = 0 ; int count = 0 ; if ( UgeEb < 105 ) { System . out . println ( 0 ) ; return ; } for ( int i = 105 ; i <= UgeEb ; 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 qnlushVul { public static void main ( String ... args ) { Scanner in = new Scanner ( System . in ) ; int QnlushIrw = in . nextInt ( ) ; int k = in . nextInt ( ) ; int q = in . nextInt ( ) ; int [ ] poinst = new int [ QnlushIrw ] ; 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 HpeciiYg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HpeciiQ = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) HpeciiQ += sc . nextInt ( ) ; System . out . println ( HpeciiQ < 22 ? " win " : " bust " ) ; } } import java . util . * ; public class AumlmhWkxe { public static void main ( String [ ] args ) { solve_148_A ( ) ; return ; } private static void solve_148_A ( ) { Scanner sc = new Scanner ( System . in ) ; int aumlmhP = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C ; C = ( 6 - aumlmhP - B ) ; System . out . println ( C ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class AlumuHof { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int alumuXfz = sc . nextInt ( ) ; HashSet < Long > hs = new HashSet < > ( ) ; for ( int i = 0 ; i < alumuXfz ; i ++ ) { hs . add ( sc . nextLong ( ) ) ; } String ans = hs . size ( ) == alumuXfz ? " 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 ihnuxaV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IhnuxaOc = Integer . parseInt ( sc . next ( ) ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int sumA = A * IhnuxaOc ; System . out . println ( ( sumA >= B ? B : sumA ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class ekofGh { static boolean binary_search ( int x , int [ ] data ) { int EkofEcn = 0 , right = data . length ; while ( true ) { int mid = ( EkofEcn + right ) / 2 ; if ( EkofEcn > right ) return false ; if ( data [ mid ] == x ) { return true ; } else if ( data [ mid ] < x ) { EkofEcn = 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 RtkJn { public static void main ( String [ ] args ) throws Exception { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int rtkVezg = in . nextInt ( ) ; int W = in . nextInt ( ) ; System . out . println ( W >= rtkVezg ? " unsafe " : " safe " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class vevmldV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VevmldUw = 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 ( VevmldUw ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . io . * ; class HedfpiUwdkp { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String HedfpiQwq = br . readLine ( ) ; String p = br . readLine ( ) ; HedfpiQwq = HedfpiQwq + HedfpiQwq ; if ( HedfpiQwq . equals ( " " ) || p . equals ( " " ) ) System . exit ( 0 ) ; if ( HedfpiQwq . indexOf ( p ) != - 1 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } catch ( Exception e ) { System . err . println ( e ) ; } } } import java . util . * ; class kbuqwmX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KbuqwmGogv = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; for ( int i = 0 ; i <= KbuqwmGogv ; i ++ ) { int x = i * 10000 ; if ( x > Y ) break ; for ( int j = 0 ; j <= KbuqwmGogv - i ; j ++ ) { int y = j * 5000 ; if ( ( x + y ) > Y ) break ; if ( ( Y - x - y ) / 1000 == ( KbuqwmGogv - i - j ) ) { System . out . println ( i + " " + j + " " + ( Y - x - y ) / 1000 ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . util . Scanner ; public class MofhvSs { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; int mofhvZm = Integer . parseInt ( std . next ( ) ) ; int [ ] line = new int [ mofhvZm ] ; int temp = 0 ; int exchange = 0 ; for ( int i = 0 ; i < mofhvZm ; i ++ ) { line [ i ] = Integer . parseInt ( std . next ( ) ) ; } boolean flag = true ; while ( flag ) { flag = false ; for ( int j = ( mofhvZm - 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 < mofhvZm ; i ++ ) { outsd += " " + line [ i ] ; } System . out . println ( outsd ) ; System . out . println ( exchange ) ; } } import java . util . Scanner ; public class HqilktKjh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HqilktHaw = 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 , HqilktHaw ) ; System . out . println ( front + lower + back ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class lgqetY { 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 LgqetVs = 0 ; LgqetVs < aa . length ; LgqetVs ++ ) { a [ LgqetVs ] = Long . parseLong ( aa [ LgqetVs ] ) ; } 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 GxjqelEis { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int gxjqelGsws = 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 <= gxjqelGsws ; 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 QyunZdwc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int qyunNryh = sc . nextInt ( ) ; if ( qyunNryh == 0 ) { break ; } double [ ] s = new double [ qyunNryh ] ; double sum = 0 ; for ( int i = 0 ; i < qyunNryh ; i ++ ) { s [ i ] = sc . nextDouble ( ) ; sum += s [ i ] ; } double average = sum / qyunNryh ; double res = 0 ; for ( int i = 0 ; i < qyunNryh ; i ++ ) { res += Math . pow ( s [ i ] - average , 2 ) / qyunNryh ; } System . out . println ( Math . sqrt ( res ) ) ; } } } import java . util . Scanner ; public class PahmkMten { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int pahmkY = 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 ; } } pahmkY = Math . pahmkY ( pahmkY , cnt ) ; } System . out . println ( pahmkY ) ; } } import java . util . * ; public class BwcHnza { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int BwcIop = stdIn . nextInt ( ) ; int [ ] s = new int [ BwcIop ] ; s [ 2 ] = BwcIop % 10 ; BwcIop /= 10 ; s [ 1 ] = BwcIop % 10 ; BwcIop /= 10 ; s [ 0 ] = BwcIop % 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 AjkmrOwjkz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long AjkmrIu = sc . nextLong ( ) ; long n = ( int ) ( Math . log ( AjkmrIu ) / Math . log ( 2 ) ) + 1 ; long ans = ( long ) Math . pow ( 2 , n ) - 1 ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class RhfdVp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int RhfdL = scan . nextInt ( ) ; int ans = RhfdL + RhfdL * RhfdL + RhfdL * RhfdL * RhfdL ; 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 WfvhUtxmfz { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; Integer [ ] mountains = new Integer [ 10 ] ; for ( int WfvhF = 0 ; WfvhF < 10 ; WfvhF ++ ) { mountains [ WfvhF ] = sc . nextInt ( ) ; } Arrays . sort ( mountains , Collections . reverseOrder ( ) ) ; StringBuilder sb = new StringBuilder ( " " ) ; for ( int WfvhF = 0 ; WfvhF < 3 ; WfvhF ++ ) { sb . append ( mountains [ WfvhF ] ) ; sb . append ( '\n' ) ; } System . out . print ( sb ) ; } } import java . util . * ; public class UkmpzyUu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ukmpzyF = sc . nextInt ( ) ; int [ ] array = new int [ ukmpzyF ] ; int sum = 0 ; for ( int i = 0 ; i < ukmpzyF ; i ++ ) { array [ i ] = sc . nextInt ( ) ; sum += array [ i ] ; } int sum2 = 0 ; int dif = 0 ; int min = 10000 ; for ( int i = 0 ; i < ukmpzyF ; 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 RhvHd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rhvWb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int result = 0 ; int lower ; int upper ; lower = Math . max ( rhvWb , c ) ; upper = Math . min ( b , d ) ; if ( upper >= lower ) { result = upper - lower ; } System . out . println ( result ) ; } } import java . util . Scanner ; public class IepaQn { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int iepaAi = sc . nextInt ( ) ; sc . close ( ) ; for ( int i = iepaAi ; 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 ziuOx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ZiuAjq = sc . nextLong ( ) ; long ans = 100 ; for ( long i = 1 ; i * i <= ZiuAjq ; i ++ ) { if ( ZiuAjq % i == 0 ) { ans = Math . min ( ans , getDigits ( ZiuAjq / 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 BxbwdAtd { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { final String s = reader . readLine ( ) ; int BxbwdG = Integer . parseInt ( s ) ; boolean flg = false ; for ( int i = 0 ; i <= BxbwdG ; i ++ ) { for ( int j = 0 ; j <= BxbwdG ; j ++ ) { if ( BxbwdG == 4 * i + 7 * j ) { flg = true ; break ; } } } System . out . println ( flg ? " Yes " : " No " ) ; } } } import java . util . Scanner ; import java . util . Scanner ; public class ixujC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; boolean IxujLihz = false ; for ( int i = 0 ; i < s . length ( ) ; i = i + 2 ) { if ( ! ( s . charAt ( i ) == 'R' || s . charAt ( i ) == 'U' || s . charAt ( i ) == 'D' ) ) { IxujLihz = 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' ) ) { IxujLihz = true ; break ; } } if ( IxujLihz ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class GliyPu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gliyK = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = gliyK * b ; int d = gliyK + b ; int e = gliyK - 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 YdzOxnn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YdzHn = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = YdzHn - 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 UgmcPjw { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ugmcDmcs = in . nextInt ( ) ; System . out . println ( 2 * 3.14 * ugmcDmcs ) ; } } import java . util . Scanner ; public class KmdgxAyc { static Scanner scan ; public static boolean judgePN ( int a ) { if ( a == 1 ) return false ; int KmdgxL = a ; for ( int i = 2 ; i < a ; i ++ ) { KmdgxL = a / i ; if ( a % i == 0 ) return false ; if ( i > KmdgxL ) 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 OkoiGm { public static void main ( final String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; boolean okoiB = true ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { char tap = S . charAt ( i ) ; if ( i % 2 == 1 ) { if ( tap == 'R' ) okoiB = false ; } else { if ( tap == 'L' ) okoiB = false ; } } System . out . println ( okoiB ? " Yes " : " No " ) ; } } import java . util . * ; import static java . util . Map . Entry . comparingByValue ; import static java . util . stream . Collectors . toMap ; public class UygEseg { public static void main ( String [ ] args ) { Scanner Input = new Scanner ( System . in ) ; int uygIc = Input . nextInt ( ) ; HashMap < String , Integer > HM = new HashMap ( ) ; for ( int I = 0 ; I < uygIc ; I ++ ) { String S = Input . next ( ) ; if ( ! HM . containsKey ( S ) ) { HM . put ( S , 0 ) ; } } System . out . println ( HM . size ( ) ) ; } } import java . util . Scanner ; public class YwfknxWgrzz { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int YwfknxUh = s . nextInt ( ) ; int b = s . nextInt ( ) ; int from = b - ( YwfknxUh - 1 ) ; int to = b + ( YwfknxUh - 1 ) ; for ( int i = from ; i <= to ; i ++ ) { System . out . print ( i + " " ) ; } } } import java . util . * ; public class TaaZjf { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; int taaJ = ob . nextInt ( ) ; int k = ob . nextInt ( ) ; int [ ] a = new int [ taaJ ] ; for ( int i = 0 ; i < taaJ ; i ++ ) { a [ i ] = ob . nextInt ( ) ; } int min = 0 ; int [ ] arr = new int [ taaJ ] ; 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 [ taaJ - 1 ] ) ; ob . close ( ) ; } } import java . util . * ; public class DoxiIjyf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int doxiT = Integer . parseInt ( sc . nextLine ( ) ) ; int max = 1 ; for ( int i = 2 ; i <= Math . sqrt ( doxiT ) ; i ++ ) { int n = i ; for ( int j = 2 ; n * i <= doxiT ; j ++ ) { n *= i ; } max = max < n ? n : max ; } System . out . println ( max ) ; } } import java . util . Scanner ; public class WnposcHt { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int wnposcEtwn = 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 , wnposcEtwn + 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 * wnposcEtwn , 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 LmbtiQp { 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 LmbtiQp { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String [ ] S = in . next ( ) . split ( " " ) ; String [ ] T = in . next ( ) . split ( " " ) ; int LmbtiT = 0 ; for ( int i = 0 ; i < S . length ; i ++ ) { if ( S [ i ] . compareTo ( T [ i ] ) == 0 ) { LmbtiT ++ ; } } out . println ( LmbtiT ) ; } } } import java . util . * ; public class NuarVmk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NuarFw = sc . nextInt ( ) ; String ans = " Yes " ; int nowT = 0 ; int nowX = 0 ; int nowY = 0 ; for ( int i = 0 ; i < NuarFw ; 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 IhtSjjyf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int IhtHs = scan . nextInt ( ) ; int N = scan . nextInt ( ) ; int [ ] box = new int [ N ] ; int con = 0 ; int min = IhtHs + 100 ; int judge = 0 ; int nbox ; for ( int i = 0 ; i < N ; i ++ ) { box [ i ] = scan . nextInt ( ) ; if ( IhtHs == box [ i ] ) { con = 1 ; } } if ( con == 0 ) { System . out . print ( IhtHs ) ; } else { for ( int i = 1 ; i <= 200 - IhtHs ; i ++ ) { int a = IhtHs - i ; int b = IhtHs + 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 nwrepmCsy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NwrepmJmrsd = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; String s = sc . next ( ) ; int [ ] pos = new int [ NwrepmJmrsd ] ; for ( int i = 0 ; i < NwrepmJmrsd - 1 ; i ++ ) { if ( s . charAt ( i ) == 'A' && s . charAt ( i + 1 ) == 'C' ) { pos [ i ] = 1 ; } } int [ ] num = new int [ NwrepmJmrsd ] ; num [ 0 ] = pos [ 0 ] ; for ( int i = 1 ; i < NwrepmJmrsd - 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 IcydwHbo { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; String w = sc . next ( ) ; for ( int icydwKxf = 0 ; icydwKxf < w . length ( ) ; icydwKxf ++ ) { int sum = 0 ; for ( int j = 0 ; j < w . length ( ) ; j ++ ) { if ( w . charAt ( icydwKxf ) == 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 aiunYb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AiunZyu = sc . nextInt ( ) ; LinkedList < Integer > inputs = new LinkedList < > ( ) ; for ( int i = 0 ; i < AiunZyu ; i ++ ) { inputs . add ( sc . nextInt ( ) ) ; } Collections . sort ( inputs ) ; double beforeParam = inputs . pop ( ) ; for ( int i = 0 ; i < AiunZyu - 1 ; i ++ ) { beforeParam = ( beforeParam + inputs . pop ( ) ) / 2 ; } System . out . println ( beforeParam ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class DpcEze { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int DpcUkb = scan . nextInt ( ) ; String str = scan . next ( ) ; if ( DpcUkb >= str . length ( ) ) { System . out . println ( str ) ; } else { System . out . println ( str . substring ( 0 , DpcUkb ) + " ... " ) ; } } } import java . util . * ; public class vikblQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VikblVv = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; if ( S . length ( ) > VikblVv ) S = S . substring ( 0 , VikblVv ) + " ... " ; System . out . println ( S ) ; } } import java . util . * ; public class YsleIpz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YsleCnp = sc . nextInt ( ) ; int [ ] h = new int [ YsleCnp ] ; int landCt = 0 ; int answer = 0 ; for ( int i = 0 ; i < YsleCnp ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int start = h [ 0 ] ; for ( int i = 0 ; i < 101 ; i ++ ) { landCt = 0 ; for ( int j = 0 ; j < YsleCnp - 1 ; j ++ ) { if ( ( h [ j ] == 0 && h [ j + 1 ] > 0 ) || ( j == 0 && h [ 0 ] > 0 ) ) { landCt = landCt + 1 ; } } answer = answer + landCt ; oneMinus ( h ) ; } if ( YsleCnp != 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 jtgoyQsp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String in = sc . nextLine ( ) ; int JtgoyYwrny = 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 = JtgoyYwrny ; 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 " , JtgoyYwrny , ( ( 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 PhgcXup { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int phgcJk = 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 = phgcJk ; 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 IomSjgaqv { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String search = scanner . nextLine ( ) ; boolean IomTw = true ; int count = 0 ; String end = " END_OF_TEXT " ; while ( IomTw ) { String word = scanner . next ( ) ; int result = word . lastIndexOf ( end ) ; if ( result != - 1 ) { IomTw = false ; } else { word = word . toLowerCase ( ) ; } if ( word . equals ( search ) ) { count ++ ; } } System . out . println ( count ) ; scanner . close ( ) ; } } import java . util . Scanner ; public class AsepoAddd { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; String T = scan . next ( ) ; for ( int AsepoIl = 0 ; AsepoIl < S . length ( ) ; AsepoIl ++ ) { if ( S . charAt ( AsepoIl ) != T . charAt ( AsepoIl ) ) { System . out . println ( " No " ) ; break ; } else if ( ( AsepoIl == 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 TaxzpjDmim { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; while ( true ) { int TaxzpjJ = cin . nextInt ( ) , x = cin . nextInt ( ) ; int res = 0 ; if ( TaxzpjJ == 0 && x == 0 ) break ; for ( int i = 1 ; i <= TaxzpjJ - 2 ; i ++ ) { for ( int j = i + 1 ; j <= TaxzpjJ - 1 ; j ++ ) { for ( int k = j + 1 ; k <= TaxzpjJ ; k ++ ) { if ( i + j + k == x ) res ++ ; } } } System . out . println ( res ) ; } } } import java . util . Scanner ; public class nmgafqL { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int NmgafqDoxyb = s . nextInt ( ) ; long res = NmgafqDoxyb ; res += NmgafqDoxyb * NmgafqDoxyb + NmgafqDoxyb * NmgafqDoxyb * NmgafqDoxyb ; System . out . println ( res ) ; } } import java . util . Scanner ; public class expoR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ExpoHupq = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int target = 0 ; int kekka = 10000 ; while ( target < 10000 ) { if ( ( int ) Math . floor ( ( double ) target * 0.08 ) == ExpoHupq && ( 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 qsgD { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String num = scan . nextLine ( ) ; int QsgRl = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { char c = num . charAt ( i ) ; if ( c == '1' ) { QsgRl ++ ; } } System . out . println ( QsgRl ) ; } } import java . util . Scanner ; public class IepkPfw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int iepkHjd = scan . nextInt ( ) ; String s = scan . next ( ) ; String t = scan . next ( ) ; String ans = " " ; for ( int i = 0 ; i < iepkHjd ; 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 UmiQo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int umiFhtu = Integer . parseInt ( sc . next ( ) ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int result = n ; if ( umiFhtu == 0 && n == 100 ) { result ++ ; } else if ( 0 < umiFhtu ) { for ( int i = 0 ; i < umiFhtu ; i ++ ) { result *= 100 ; } if ( n == 100 ) { int add = 1 ; for ( int i = 0 ; i < umiFhtu ; i ++ ) { add *= 100 ; } result += add ; } } System . out . println ( result ) ; sc . close ( ) ; } } import java . util . Scanner ; public class UuqmZs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String day = sc . next ( ) ; int uuqmB = 0 ; switch ( day ) { case " SUN " : uuqmB = 7 ; break ; case " MON " : uuqmB = 6 ; break ; case " TUE " : uuqmB = 5 ; break ; case " WED " : uuqmB = 4 ; break ; case " THU " : uuqmB = 3 ; break ; case " FRI " : uuqmB = 2 ; break ; case " SAT " : uuqmB = 1 ; break ; } System . out . println ( uuqmB ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class rxnwJxx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RxnwOg = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; int ans = RxnwOg ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } for ( int dif = 0 ; dif <= n ; dif ++ ) { if ( ! list . contains ( RxnwOg - dif ) ) { ans = RxnwOg - dif ; break ; } if ( ! list . contains ( RxnwOg + dif ) ) { ans = RxnwOg + dif ; break ; } } if ( n > 100 ) { System . out . println ( " error " ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class PwgpwvFtneh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] antennaArr = new int [ 5 ] ; for ( int PwgpwvB = 0 ; PwgpwvB < antennaArr . length ; PwgpwvB ++ ) { antennaArr [ PwgpwvB ] = sc . nextInt ( ) ; } int border = sc . nextInt ( ) ; boolean canConnect = true ; for ( int PwgpwvB = 0 ; PwgpwvB < antennaArr . length ; PwgpwvB ++ ) { for ( int j = 0 ; j < antennaArr . length ; j ++ ) { if ( PwgpwvB >= j ) { continue ; } if ( antennaArr [ j ] - antennaArr [ PwgpwvB ] > border ) { canConnect = false ; } } } if ( canConnect ) { System . out . println ( " Yay! " ) ; } else { System . out . println ( " :( " ) ; } } } import java . io . * ; import java . util . Scanner ; public class lwpaqkQ { public static boolean range ( int LwpaqkOp , int b , int c ) { if ( LwpaqkOp >= b ) return false ; if ( b >= c ) return false ; return true ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LwpaqkOp = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( range ( LwpaqkOp , b , c ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . io . * ; class mmwfrM { static PrintStream out = System . out ; static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int MmwfrEthd = in . nextInt ( ) ; int a = in . nextInt ( ) ; long min = a , max = a , sum = a ; for ( int i = 1 ; i < MmwfrEthd ; 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 TprkGkwh { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int TprkPg = 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 BulbrmUwo { public static void main ( String [ ] args ) { int bulbrmB = 1 ; int p = 2 ; double max = 0 ; double result ; Scanner scanner = new Scanner ( System . in ) ; int x = scanner . nextInt ( ) ; while ( bulbrmB < 1000 ) { while ( p < 1000 ) { result = Math . pow ( bulbrmB , p ) ; if ( result > x ) break ; if ( result >= max ) max = result ; p ++ ; } p = 2 ; bulbrmB ++ ; } System . out . println ( ( int ) max ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class FpuuxMbx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int fpuuxXyds = 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 ( fpuuxXyds - i ) < abs ) { abs = Math . abs ( fpuuxXyds - i ) ; ans = i ; } } } if ( n == 0 || ! ( list . contains ( fpuuxXyds ) ) ) { System . out . println ( fpuuxXyds ) ; } else { System . out . println ( ans ) ; } } } import java . util . Scanner ; public class OgidwEdk { 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 MuxWjb { 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 muxGroh = 0 ; muxGroh < Integer . parseInt ( b ) ; muxGroh ++ ) { A += a ; } for ( int muxGroh = 0 ; muxGroh < Integer . parseInt ( a ) ; muxGroh ++ ) { B += b ; } System . out . print ( ( A . compareTo ( B ) ) < 0 ? A : B ) ; } } import java . util . Scanner ; public class MdwcYsql { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long mdwcLpz = in . nextLong ( ) ; long tk = 0 ; long pchso = mdwcLpz / 500 ; tk = pchso * 1000 ; int baki = ( int ) ( mdwcLpz % 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 ldlI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LdlGqj = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; List < Integer > k = new ArrayList < > ( ) ; List < List < Integer > > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < LdlGqj ; 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 < LdlGqj ; i ++ ) { correct . retainAll ( a . get ( i ) ) ; } System . out . println ( correct . size ( ) ) ; } } import java . util . Scanner ; public class htvcGjz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int HtvcApwub = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int H = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; double degree = calculateAngle ( H , M ) ; double side = Math . sqrt ( HtvcApwub * HtvcApwub + B * B - 2 * HtvcApwub * 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 GcwcvnFaj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int gcwcvnQfbi = scan . nextInt ( ) ; double debt = 100000 ; for ( int i = 0 ; i < gcwcvnQfbi ; 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 giocfKoz { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; String input = scan . next ( ) ; char [ ] inputArray = input . toCharArray ( ) ; int GiocfJgmaf = 0 ; for ( int i = 0 ; i < inputArray . length ; i ++ ) { if ( inputArray [ i ] == '1' ) { GiocfJgmaf ++ ; } } System . out . println ( GiocfJgmaf ) ; } 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 GiocfJgmaf = 1 ; if ( josu == 0 ) return 1 ; if ( primeNumMod_0 == 0 ) { while ( josu > 0 ) { if ( josu % 2 == 0 ) { kisu *= kisu ; josu = josu / 2 ; } else { GiocfJgmaf *= kisu ; josu -- ; } } return GiocfJgmaf ; } else { kisu = myMod ( kisu , primeNumMod_0 ) ; while ( josu > 0 ) { if ( josu % 2 == 0 ) { kisu *= myMod ( kisu , primeNumMod_0 ) ; josu = josu / 2 ; } else { GiocfJgmaf *= myMod ( kisu , primeNumMod_0 ) ; josu -- ; } } return myMod ( GiocfJgmaf , primeNumMod_0 ) ; } } } import java . util . Scanner ; public class YzzuWia { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yzzuDeo = sc . nextInt ( ) , b = sc . nextInt ( ) ; int c = sc . nextInt ( ) , x = sc . nextInt ( ) ; sc . close ( ) ; int tmpa = yzzuDeo , 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 <= yzzuDeo && tmp >= 0 ) ++ ans ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class AkjiNz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int akjiOuwy = sc . nextInt ( ) ; int last = sc . nextInt ( ) ; int res = last ; for ( int i = 0 ; i < akjiOuwy - 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 zslcmyCe { 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 ZslcmyOxdrc = Integer . parseInt ( input1 [ 0 ] ) ; int k = Integer . parseInt ( input1 [ 1 ] ) ; String [ ] input2 = br . readLine ( ) . split ( " " ) ; int [ ] numbers = new int [ ZslcmyOxdrc ] ; int ans = 0 ; for ( int i = 0 ; i < ZslcmyOxdrc ; i ++ ) { numbers [ i ] = Integer . parseInt ( input2 [ i ] ) ; if ( numbers [ i ] >= k ) { ans ++ ; } } out . println ( ans ) ; out . close ( ) ; } } import java . util . Scanner ; public class IcblhcUdsp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int IcblhcOw = scan . nextInt ( ) ; int [ ] h = new int [ IcblhcOw ] ; int i ; for ( i = 0 ; i < IcblhcOw ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } for ( i = IcblhcOw - 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 PomjHsmm { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int pomjI = sc . nextInt ( ) ; int [ ] A = new int [ pomjI ] ; int i ; int count = 0 ; for ( i = 0 ; i < pomjI ; 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 IxfQjdd { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int ixfRyz = stdIn . nextShort ( ) ; int n1 = 1 ; int n2 ; do { n2 = 100 * n1 + 10 * n1 + n1 ; if ( ixfRyz <= n2 ) { System . out . println ( n2 ) ; return ; } n1 = n1 + 1 ; } while ( n1 <= 9 ) ; } } import java . util . Scanner ; public class TogqqyCpz { public static void main ( String [ ] args ) { int togqqyX , a , b , digitsSum = 0 , totalSum = 0 ; Scanner sc = new Scanner ( System . in ) ; togqqyX = sc . nextInt ( ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; for ( int i = 1 ; i <= togqqyX ; 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 GspvgXpjp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int GspvgB = sc . nextInt ( ) ; final int W = sc . nextInt ( ) ; sc . close ( ) ; if ( GspvgB > W ) { System . out . println ( " safe " ) ; } else { System . out . println ( " unsafe " ) ; } } } import java . util . * ; import java . io . * ; class VccwvSxk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int vccwvXa = Integer . parseInt ( br . readLine ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; int count = 0 ; int a = 1 , b ; if ( vccwvXa >= 3 && vccwvXa <= 10000 ) { for ( ; count < vccwvXa ; 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 HjoTf { public static void main ( String [ ] args ) { Main mainObj = new Main ( ) ; mainObj . solve ( ) ; } public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int HjoFzf = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] heightStrArr = sc . nextLine ( ) . split ( " " ) ; sc . close ( ) ; int [ ] heightArr = new int [ HjoFzf ] ; for ( int i = 0 ; i < HjoFzf ; i ++ ) { heightArr [ i ] = Integer . parseInt ( heightStrArr [ i ] ) ; } if ( heightArr [ 0 ] > 0 ) { heightArr [ 0 ] = heightArr [ 0 ] - 1 ; } for ( int i = 1 ; i < HjoFzf ; 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 OjwzYyuie { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OjwzIp = Integer . parseInt ( sc . next ( ) ) ; int m = Integer . parseInt ( sc . next ( ) ) ; int [ ] love = new int [ m ] ; int k , a ; for ( int i = 0 ; i < OjwzIp ; 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 ] == OjwzIp ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; class gxfqdbIf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GxfqdbLvdn = sc . nextInt ( ) ; int [ ] cnt = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { cnt [ i ] = 0 ; } String [ ] s = new String [ GxfqdbLvdn ] ; for ( int i = 0 ; i < GxfqdbLvdn ; 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 lahtGc { void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int LahtPq = sc . nextInt ( ) ; int [ ] p = new int [ LahtPq ] ; for ( int i = 0 ; i < LahtPq ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } if ( isOK ( p ) ) { System . out . println ( " YES " ) ; return ; } for ( int i = 0 ; i <= LahtPq - 2 ; i ++ ) { for ( int j = i + 1 ; j <= LahtPq - 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 fgmNic { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] dance = sc . next ( ) . toCharArray ( ) ; boolean FgmSlkxd = true ; for ( int i = 0 ; i < dance . length ; i ++ ) { if ( i % 2 == 0 ) { if ( dance [ i ] == 'L' ) { FgmSlkxd = false ; break ; } } else { if ( dance [ i ] == 'R' ) { FgmSlkxd = false ; break ; } } } if ( FgmSlkxd ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class rdkzxW { public Main ( ) { } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RdkzxEll ; int h ; int index ; int index2 ; int result = 1 ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; RdkzxEll = sc . nextInt ( ) ; for ( index = 0 ; index < RdkzxEll ; index ++ ) { h = sc . nextInt ( ) ; map . put ( index , h ) ; } sc . close ( ) ; loop1 : for ( index = 1 ; index < RdkzxEll ; 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 jkevA { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String x = sc . next ( ) ; double JkevXqzto = Double . valueOf ( x ) ; int ans = 0 ; double tot = 100 ; while ( tot < JkevXqzto ) { tot = Math . floor ( tot * 1.01 ) ; ans ++ ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class VbfiYeay { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String VbfiJ = sc . nextLine ( ) ; sc . close ( ) ; System . out . println ( VbfiJ . lastIndexOf ( " Z " ) - VbfiJ . indexOf ( " A " ) + 1 ) ; } } import java . util . Scanner ; public class NwvuucXum { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nwvuucQco = Integer . parseInt ( sc . next ( ) ) ; int [ ] H = new int [ nwvuucQco ] ; for ( int i = 0 ; i < nwvuucQco ; i ++ ) { H [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int prev = ( H [ 0 ] > 1 ) ? H [ 0 ] - 1 : H [ 0 ] ; for ( int i = 1 ; i < nwvuucQco - 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 kevriRj { 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 KevriVrc = Integer . parseInt ( arr [ 0 ] ) ; int b = Integer . parseInt ( arr [ 1 ] ) ; System . out . println ( KevriVrc < b ? repeat ( arr [ 0 ] , b ) : repeat ( arr [ 1 ] , KevriVrc ) ) ; } } import java . util . * ; public class KcjRm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kcjUn = sc . nextInt ( ) ; char [ ] nChar = String . valueOf ( kcjUn ) . toCharArray ( ) ; int sn = 0 ; for ( int i = 0 ; i < nChar . length ; i ++ ) { sn += Integer . parseInt ( String . valueOf ( nChar [ i ] ) ) ; } if ( kcjUn % sn == 0 ) { System . out . println ( " Yes " ) ; return ; } System . out . println ( " No " ) ; } } import java . util . * ; class iydwbBun { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IydwbDgk = 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 ; IydwbDgk -= D ; if ( IydwbDgk <= 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 LwbKw { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; String LwbYu = s . next ( ) ; switch ( LwbYu ) { 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 FnruUv { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; long FnruUug = scn . nextInt ( ) ; long num2 = scn . nextInt ( ) ; System . out . println ( CommonMultipleNum . cmn ( FnruUug , num2 ) ) ; } } class FnruUv { static long cmn ( long FnruUug , long num2 ) { long tmp ; long num3 = FnruUug ; num3 *= num2 ; while ( ( tmp = FnruUug % num2 ) != 0 ) { FnruUug = num2 ; num2 = tmp ; } return ( long ) ( num3 / num2 ) ; } } import java . util . * ; class IwfhQmo { public static void main ( String [ ] args ) { Scanner inp = new Scanner ( System . in ) ; do_ ( inp ) ; inp . close ( ) ; } public static void do_ ( Scanner inp ) { int IwfhNp = inp . nextInt ( ) ; int b = inp . nextInt ( ) ; int c = inp . nextInt ( ) ; System . out . println ( c + " " + IwfhNp + " " + b ) ; } } import java . util . * ; public class YubZn { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String [ ] x = s . nextLine ( ) . split ( " " ) ; int YubHwa = 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 ) YubHwa / d ; if ( YubHwa % 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 CkpfxyKmz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CkpfxyKg = sc . nextInt ( ) ; if ( CkpfxyKg % 10 == 3 || CkpfxyKg % 100 == 3 ) { System . out . println ( " bon " ) ; } else if ( CkpfxyKg % 10 == 0 || CkpfxyKg % 10 == 1 | CkpfxyKg % 10 == 6 || CkpfxyKg % 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 sutCri { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int SutJhl = in . nextInt ( ) ; int n = in . nextInt ( ) ; if ( n == 100 ) n = 101 ; for ( int i = 0 ; i < SutJhl ; i ++ ) n *= 100 ; System . out . println ( n ) ; in . close ( ) ; } } import java . util . Scanner ; public class OjiunxFm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int OjiunxPtc = scanner . nextInt ( ) ; int result = OjiunxPtc + ( int ) Math . pow ( OjiunxPtc , 2 ) + ( int ) Math . pow ( OjiunxPtc , 3 ) ; System . out . println ( result ) ; } } import java . util . * ; public class AtlFb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int atlWxa = 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 ( ( atlWxa - sum ) <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class QbbhPtd { static int [ ] stack = new int [ 1000 ] ; static int qbbhCgvi = 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 ( ) { qbbhCgvi -- ; return stack [ qbbhCgvi + 1 ] ; } public static void push ( int i ) { qbbhCgvi ++ ; stack [ qbbhCgvi ] = i ; } } import java . util . Scanner ; public class UgwHlez { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . next ( ) ; String t = scanner . next ( ) ; int ugwI = t . length ( ) ; String T = t . substring ( 0 , ugwI - 1 ) ; if ( s . equals ( T ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scanner . close ( ) ; } } import java . util . * ; public class IhucrJv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ihucrU = sc . nextInt ( ) ; int [ ] a = new int [ ihucrU + 1 ] ; for ( int i = 0 ; i < ihucrU + 1 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } long sum = 0 ; for ( int i = 0 ; i < ihucrU ; 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 KxyNr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] x = new int [ 5 ] ; int KxyDv = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { x [ i ] = sc . nextInt ( ) ; if ( x [ i ] != i + 1 ) KxyDv = i + 1 ; } System . out . println ( KxyDv ) ; } } import java . util . * ; public class eyvxfVt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EyvxfWcy = 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 ) EyvxfWcy / 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 MosppKbogzx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int MosppCg = s . length ( ) ; for ( int i = 0 ; i < MosppCg ; i ++ ) { System . out . print ( " x " ) ; } System . out . println ( " " ) ; } } import java . util . * ; public class TfxizqQfn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tfxizqVkdz = sc . nextInt ( ) ; int n = tfxizqVkdz ; 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 ( tfxizqVkdz % s == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class IckmxcFvv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ickmxcJym = sc . nextLong ( ) ; ickmxcJym -- ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long total = b - ickmxcJym ; long divD = b / d - ickmxcJym / d ; long divC = b / c - ickmxcJym / c ; long lcm = getLcm ( c , d ) ; long divL = b / lcm - ickmxcJym / 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 sauvX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SauvIacn = Integer . parseInt ( sc . next ( ) ) ; TreeMap < String , Integer > S = new TreeMap < String , Integer > ( ) ; String tmp ; int max = 1 ; int count ; for ( int i = 0 ; i < SauvIacn ; 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 bpcvvA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BpcvvGg = sc . nextInt ( ) ; long Y = sc . nextLong ( ) ; sc . close ( ) ; int A = 0 ; int B = 0 ; int C = 0 ; for ( int i = 0 ; i <= BpcvvGg ; i ++ ) { A = i * 10000 ; for ( int j = 0 ; j <= BpcvvGg ; j ++ ) { B = j * 5000 ; C = ( BpcvvGg - i - j ) * 1000 ; if ( A + B + C == Y && C >= 0 ) { System . out . println ( i + " " + j + " " + ( BpcvvGg - i - j ) ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . util . Scanner ; public class rhsvpyLak { 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 RhsvpyAo = 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 yltVp { public static void main ( String [ ] args ) { Scanner yomi = new Scanner ( System . in ) ; String YltBu = yomi . next ( ) ; if ( YltBu . equals ( " SUN " ) ) { System . out . println ( 7 ) ; } else if ( YltBu . equalsIgnoreCase ( " MON " ) ) { System . out . println ( 6 ) ; } else if ( YltBu . equalsIgnoreCase ( " TUE " ) ) { System . out . println ( 5 ) ; } else if ( YltBu . equalsIgnoreCase ( " WED " ) ) { System . out . println ( 4 ) ; } else if ( YltBu . equalsIgnoreCase ( " THU " ) ) { System . out . println ( 3 ) ; } else if ( YltBu . equalsIgnoreCase ( " FRI " ) ) { System . out . println ( 2 ) ; } else if ( YltBu . equalsIgnoreCase ( " SAT " ) ) { System . out . println ( 1 ) ; } } } import java . util . * ; public class MmdKfpj { public static void main ( String [ ] args ) throws NumberFormatException { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) . trim ( ) ; String [ ] segments = S . split ( " " ) ; int mmdZe = Integer . parseInt ( segments [ 0 ] ) ; int K = Integer . parseInt ( segments [ 1 ] ) ; double result = 0 ; double np = ( double ) 1.0 / mmdZe ; for ( int i = 1 ; i <= mmdZe ; 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 TfvTzr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TfvLxj = sc . nextInt ( ) ; String S = sc . next ( ) ; String S1 = S . substring ( TfvLxj / 2 ) ; String S2 = S . substring ( 0 , TfvLxj / 2 ) ; String S3 = S1 + S2 ; sc . close ( ) ; if ( TfvLxj % 2 == 1 ) { System . out . println ( " No " ) ; } else { if ( S . equals ( S3 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; class FboIibe { Scanner sc = new Scanner ( System . in ) ; void main ( ) { int fboDzy = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] [ ] x = new int [ fboDzy + 1 ] [ c + 1 ] ; for ( int i = 0 ; i < fboDzy ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { x [ i ] [ j ] = sc . nextInt ( ) ; x [ i ] [ c ] += x [ i ] [ j ] ; } } for ( int i = 0 ; i < fboDzy ; i ++ ) for ( int j = 0 ; j < c + 1 ; j ++ ) x [ fboDzy ] [ j ] += x [ i ] [ j ] ; for ( int i = 0 ; i < fboDzy + 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 fdmaBc { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int FdmaTkyv = in . nextInt ( ) ; int b = in . nextInt ( ) ; int min = b ; int max = b ; long sum = b ; for ( int i = 0 ; i < FdmaTkyv - 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 EobhwdHpwv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long EobhwdJpp = sc . nextLong ( ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long C = EobhwdJpp / ( A + B ) ; long D = EobhwdJpp % ( 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 ShqoEqtdr { 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 ShqoA = Long . parseLong ( Ws [ 0 ] ) ; long B = Long . parseLong ( Ws [ 1 ] ) ; long K = ShqoA + 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 adwdaMx { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] Aandb = ( input . readLine ( ) ) . split ( " \\ s " ) ; int AdwdaZcet = Integer . parseInt ( Aandb [ 0 ] ) ; int m = Integer . parseInt ( Aandb [ 1 ] ) ; int [ ] [ ] A = new int [ AdwdaZcet ] [ m ] ; String [ ] z = null ; for ( int i = 0 ; i < AdwdaZcet ; 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 < AdwdaZcet ; 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 BfzLq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int BfzMk = scan . nextInt ( ) ; for ( int i = BfzMk ; 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 KodovcUwi { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int kodovcC = 0 ; String [ ] line ; line = new String [ 10000 ] ; try { while ( kodovcC < 10000 ) { line [ kodovcC ] = reader . readLine ( ) ; if ( line [ kodovcC ] . equals ( " 0 " ) ) break ; kodovcC ++ ; } kodovcC = 0 ; while ( kodovcC < 10000 ) { if ( line [ kodovcC ] . equals ( " 0 " ) ) break ; System . out . println ( " Case " + ( kodovcC + 1 ) + " : " + line [ kodovcC ] ) ; kodovcC ++ ; } } catch ( IOException e ) { System . out . println ( e ) ; } catch ( NumberFormatException e ) { System . out . println ( e ) ; } } } import java . util . * ; public class TgrmnhWzuexl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TgrmnhM = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] S = sc . nextLine ( ) . split ( " " ) ; int count = 0 ; int now = 0 ; for ( int i = 0 ; i < TgrmnhM ; 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 cwcwXuf { 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 CwcwBt = 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 -- ) { CwcwBt -= A [ i ] ; if ( CwcwBt <= 0 ) break ; } if ( CwcwBt <= 0 ) os . println ( " Yes " ) ; else os . println ( " No " ) ; } } import java . util . * ; class tsztEe { public static void main ( String [ ] str ) { Scanner s = new Scanner ( System . in ) ; String s1 = s . next ( ) ; String s2 = s . next ( ) ; int TsztLo = s2 . length ( ) ; int i = 0 ; String res = s2 . substring ( i , TsztLo - 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 YjxbziVx { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int yjxbziRzoj = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int t = scan . nextInt ( ) ; int time = 0 ; while ( yjxbziRzoj > 0 ) { yjxbziRzoj -= x ; time += t ; } System . out . println ( time ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class LorQj { public static void main ( String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; int lorD = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] problems = new int [ lorD ] ; int [ ] was = new int [ lorD ] ; 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 < lorD ; i ++ ) { if ( problems [ i ] == 1 ) { wa += was [ i ] ; } } System . out . println ( Arrays . stream ( problems ) . sum ( ) + " " + wa ) ; } } import java . util . Scanner ; class YgjHiuj { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int ygjUnd = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int a1 = ygjUnd * b ; int a2 = 2 * ( ygjUnd + b ) ; System . out . printf ( " %d %d \n " , a1 , a2 ) ; } } import java . util . Scanner ; public class MwiMrc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mwiQ = sc . nextInt ( ) ; long res = 0 ; for ( int i = 1 ; i <= mwiQ ; i ++ ) if ( String . valueOf ( i ) . length ( ) % 2 == 1 ) res ++ ; System . out . println ( res ) ; } } import java . util . * ; public class aobiZt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AobiLavt = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; int count = 1 ; int ans = 0 ; for ( int i = 0 ; i < AobiLavt ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp == count ) { ans ++ ; count ++ ; } list . add ( tmp ) ; } if ( ans == 0 ) { System . out . println ( " -1 " ) ; } else { System . out . println ( AobiLavt - ans ) ; } } } import java . util . * ; public class UdigpEz { 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 TxujoyYh { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int TxujoyG = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int c = stdIn . nextInt ( ) ; int x = stdIn . nextInt ( ) ; int y = stdIn . nextInt ( ) ; if ( c - 0.5 * TxujoyG - 0.5 * b > 0 ) { System . out . println ( TxujoyG * 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 ( TxujoyG * ( x - y ) + 2 * c * y <= 2 * c * x ) { System . out . println ( TxujoyG * ( x - y ) + 2 * c * y ) ; } else { System . out . println ( 2 * c * x ) ; } } } } } import java . util . * ; class ZovzxqBrd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int zovzxqIu = scan . nextInt ( ) ; String [ ] S = new String [ zovzxqIu + 1 ] ; int [ ] C = { 0 , 0 , 0 , 0 } ; for ( int i = 0 ; i < zovzxqIu + 1 ; i ++ ) { S [ i ] = scan . nextLine ( ) ; } for ( int i = 0 ; i < zovzxqIu + 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 MtlqbjEuz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mtlqbjFhk = sc . nextInt ( ) ; int [ ] h = new int [ mtlqbjFhk ] ; for ( int i = 0 ; i < mtlqbjFhk ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int ans = 0 ; while ( true ) { boolean flg = true ; int count = 0 ; for ( int i = 0 ; i < mtlqbjFhk ; 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 == mtlqbjFhk ) { System . out . println ( ans ) ; return ; } } } } } import java . util . Scanner ; public class gprdrIru { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; boolean GprdrNerb = 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 FnhNvm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fnhX = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; String ans = " No " ; if ( fnhX == B && B != C ) ans = " Yes " ; if ( fnhX == C && fnhX != B ) ans = " Yes " ; if ( B == C && fnhX != B ) ans = " Yes " ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class TlpvtLxjm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tlpvtUj = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] array = new int [ tlpvtUj ] ; int swap1 , swap2 ; byte garbage ; for ( int i = 0 ; i < tlpvtUj ; 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 < tlpvtUj ; i ++ ) { System . out . println ( array [ i ] ) ; } } } import java . util . Scanner ; public class FcaOtl { public static void fcaZf ( String str ) { boolean fcaZf = false ; if ( fcaZf == 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 RxpbdrHlp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int RxpbdrXo = 0 ; int b = 0 ; int c = 0 ; int n = scanner . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { RxpbdrXo = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; c = scanner . nextInt ( ) ; if ( c * c == RxpbdrXo * RxpbdrXo + b * b || b * b == RxpbdrXo * RxpbdrXo + c * c || RxpbdrXo * RxpbdrXo == 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 XhsfbrPpc { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int xhsfbrQay = in . nextInt ( ) ; int [ ] value = new int [ xhsfbrQay ] ; for ( int i = 0 ; i < xhsfbrQay ; i ++ ) { value [ i ] = in . nextInt ( ) ; } int [ ] cost = new int [ xhsfbrQay ] ; for ( int j = 0 ; j < xhsfbrQay ; j ++ ) { cost [ j ] = in . nextInt ( ) ; } int result = solve ( xhsfbrQay , value , cost ) ; System . out . println ( result ) ; in . close ( ) ; } public static int solve ( int xhsfbrQay , int [ ] value , int [ ] cost ) { int result = 0 ; for ( int i = 0 ; i < xhsfbrQay ; i ++ ) { if ( ( value [ i ] - cost [ i ] ) > 0 ) { result += value [ i ] - cost [ i ] ; } } return result ; } } import java . util . * ; import java . util . stream . * ; public class nvzG { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int NvzFritd = in . nextInt ( ) ; int L = in . nextInt ( ) ; int min = Integer . MAX_VALUE ; int sum = 0 ; for ( int i = 0 ; i < NvzFritd ; 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 CsaiJr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int csaiLn = sc . nextInt ( ) ; int cnt = 0 ; Set < Integer > set = new TreeSet < > ( ) ; for ( int i = 1 ; i <= csaiLn ; 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 WveuoMo { 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 wveuoUi = sc . nextInt ( ) ; for ( int i = 0 ; i < wveuoUi ; 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 JznsbNzbp { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int JznsbR = sc . nextInt ( ) ; int [ ] num = new int [ 1000000 ] ; int ans = 0 ; num [ 0 ] = JznsbR ; for ( int i = 1 ; i < 1000000 ; i ++ ) { if ( JznsbR % 2 == 0 ) { num [ i ] = JznsbR / 2 ; JznsbR = JznsbR / 2 ; } else if ( JznsbR % 2 == 1 ) { num [ i ] = 3 * JznsbR + 1 ; JznsbR = 3 * JznsbR + 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 buvxH { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = reader . readLine ( ) . split ( " " ) ; int BuvxOttux , Y ; BuvxOttux = Integer . parseInt ( arr [ 0 ] ) ; Y = Integer . parseInt ( arr [ 1 ] ) ; int C , T ; C = 2 * BuvxOttux - Y / 2 ; T = - BuvxOttux + Y / 2 ; System . out . println ( 0 <= C && 0 <= T && 2 * C + 4 * T == Y && C + T == BuvxOttux ? " Yes " : " No " ) ; return ; } } import java . util . * ; public class SiceoaGvimxz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SiceoaG = sc . nextInt ( ) ; int [ ] P = new int [ SiceoaG ] ; P [ 0 ] = sc . nextInt ( ) ; int error = 0 ; boolean asc = true ; boolean once = true ; for ( int i = 1 ; i < SiceoaG ; 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 WzjaJiqi { 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 wzjaLek = 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 ) ) { wzjaLek ++ ; } } } System . out . println ( wzjaLek ) ; } } import java . util . Scanner ; public class pdujbdSdp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] m = new int [ 200 ] ; int PdujbdXx = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; int sum = 0 ; for ( int i = 0 ; i < PdujbdXx ; i ++ ) m [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < PdujbdXx ; i ++ ) X -= m [ i ] ; for ( int i = 0 ; i < PdujbdXx ; i ++ ) if ( m [ i ] < min ) min = m [ i ] ; sum = PdujbdXx + ( X / min ) ; System . out . println ( sum ) ; } } import java . util . Scanner ; import java . lang . Math ; public class qfwF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QfwLac = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( solve ( QfwLac ) ) ; } public static int solve ( int QfwLac ) { int ans = 0 ; for ( int i = 1 ; i <= QfwLac ; 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 KaxvFe { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int kaxvM = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d ; d = 0 ; while ( kaxvM <= b ) { if ( c % kaxvM == 0 ) { d = d + 1 ; } kaxvM = kaxvM + 1 ; } System . out . println ( d ) ; } } import java . util . Scanner ; import java . util . Stack ; class BrnbtBhrd { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; int brnbtI = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] nanbon = new int [ brnbtI ] ; for ( int i = 0 ; i < M ; i ++ ) { nanbon [ sc . nextInt ( ) - 1 ] ++ ; nanbon [ sc . nextInt ( ) - 1 ] ++ ; } for ( int i = 0 ; i < brnbtI ; i ++ ) { System . out . println ( nanbon [ i ] ) ; } } } import java . util . LinkedList ; import java . util . Queue ; import java . util . Scanner ; public class wyrgsyX { public static void main ( String [ ] args ) { int WyrgsyRlgyx ; 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 ) ; WyrgsyRlgyx = Integer . parseInt ( input . next ( ) ) ; quantum = Integer . parseInt ( input . next ( ) ) ; for ( int i = 0 ; i < WyrgsyRlgyx ; 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 QddeKcx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qddeGqib = 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 sbkXxq { public static void main ( String [ ] args ) { solve ( ) ; } private static void solve ( ) { Scanner input = new Scanner ( System . in ) ; int SbkDh = input . nextInt ( ) ; int [ ] nums = new int [ SbkDh ] ; int first = 0 ; int second = 0 ; for ( int i = 0 ; i < SbkDh ; 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 < SbkDh ; i ++ ) { if ( nums [ i ] == first ) { System . out . println ( second ) ; } else { System . out . println ( first ) ; } } } } import java . util . * ; public class JzcpYtl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JzcpWng = sc . nextInt ( ) ; int [ ] a = new int [ JzcpWng ] ; int sumA = 0 ; int sumB = 0 ; for ( int i = 0 ; i < JzcpWng ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int i = JzcpWng - 1 ; i >= 0 ; i -= 2 ) { sumA += a [ i ] ; } for ( int i = JzcpWng - 2 ; i >= 0 ; i -= 2 ) { sumB += a [ i ] ; } System . out . println ( sumA - sumB ) ; } } import java . util . * ; public class PqzOiyqvb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PqzTtj = 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 < PqzTtj ) ps [ i ] = Math . abs ( PqzTtj - istack ) * 2 ; else ps [ i ] = Math . abs ( PqzTtj - 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 ) PqzTtj -= ans / 2 ; else PqzTtj += ans / 2 ; System . out . println ( PqzTtj ) ; } } import java . util . Scanner ; public class thbpsZkb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ThbpsFv = scan . nextInt ( ) ; int [ ] ar = new int [ ThbpsFv ] ; int ans = 0 ; int pre = 0 ; int cur ; for ( int i = 0 ; i < ThbpsFv ; 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 XdkWc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xdkZxqv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int [ ] result = getMax ( xdkZxqv , b , c ) ; xdkZxqv = result [ 0 ] ; b = result [ 1 ] ; c = result [ 2 ] ; } System . out . println ( xdkZxqv + b + c ) ; } private static int [ ] getMax ( int xdkZxqv , int b , int c ) { int [ ] newInput = new int [ ] { xdkZxqv , b , c } ; if ( xdkZxqv <= b && c <= b ) { newInput [ 1 ] = 2 * b ; } else if ( b <= xdkZxqv && c <= xdkZxqv ) { newInput [ 0 ] = 2 * xdkZxqv ; } else if ( xdkZxqv <= c && b <= c ) { newInput [ 2 ] = 2 * c ; } return newInput ; } } import java . util . Scanner ; class WmcUnwzbt { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int WmcVt = scan . nextInt ( ) ; int H = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; double area = ( double ) WmcVt * H / 2 ; int flag = 0 ; if ( x * 2 == WmcVt && y * 2 == H ) { flag = 1 ; } System . out . println ( area + " " + flag ) ; } } import java . util . Scanner ; public class svuccUsg { static int [ ] subTreeSize ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long SvuccEmoc = sc . nextLong ( ) ; SvuccEmoc -- ; int idx = 0 ; for ( ; idx < s . length ( ) && s . charAt ( idx ) == '1' ; idx ++ ) ; char ans = SvuccEmoc < idx ? '1' : s . charAt ( idx ) ; System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class vhsGcp { public static void main ( String [ ] args ) throws Exception { try { long VhsAjb = 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 ] ) ; VhsAjb = VhsAjb + x ; if ( x < min ) { min = x ; } if ( x > max ) { max = x ; } } System . out . println ( min + " " + max + " " + VhsAjb ) ; } catch ( Exception e ) { System . out . println ( " ???????????? " ) ; } } } import java . util . Scanner ; public class sdmxUz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int SdmxLad = scan . nextInt ( ) * scan . nextInt ( ) ; scan . close ( ) ; System . out . println ( SdmxLad ) ; } } import java . util . Scanner ; public class VqrvixQld { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int VqrvixGk = stdIn . nextInt ( ) ; int n = stdIn . nextInt ( ) ; int [ ] [ ] a = new int [ VqrvixGk ] [ n ] ; int [ ] b = new int [ n ] ; int ans ; for ( int i = 0 ; i < VqrvixGk ; 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 < VqrvixGk ; 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 EopIv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int eopZpk = 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 ) % eopZpk == 0 ) { count += 1 ; } else { } } if ( count > 0 ) { System . out . println ( " OK " ) ; } if ( count == 0 ) { System . out . println ( " NG " ) ; } } } import java . util . Scanner ; public class YlhmnfGbdv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YlhmnfF = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; double d = YlhmnfF / 0.08 ; int x = ( int ) ( YlhmnfF / 0.08 ) ; if ( d != x ) x ++ ; System . err . println ( x ) ; int min = YlhmnfF ; int max = YlhmnfF ; int xmin = x ; int xmax = x ; int i = 0 ; while ( min == YlhmnfF ) { xmin -- ; min = ( int ) ( xmin * 0.08 ) ; } while ( max == YlhmnfF ) { 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 ibxwqlRz { 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 IbxwqlCxz = Integer . valueOf ( arr01 [ 0 ] ) ; Boolean chkflg = true ; for ( int i = 0 ; i < IbxwqlCxz - 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 AmnecDw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int amnecKert = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; long [ ] arr = new long [ amnecKert ] ; for ( int i = 0 ; i < amnecKert ; i ++ ) { arr [ i ] = sc . nextLong ( ) ; } Arrays . sort ( arr ) ; long total = 0 ; for ( int j = 0 ; j < amnecKert - K ; j ++ ) { total += arr [ j ] ; } System . out . println ( total ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class limkLz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; String t = in . next ( ) ; int LimkGwbz = 0 ; int min = 9999 ; for ( int i = 0 ; i <= s . length ( ) - t . length ( ) ; i ++ ) { LimkGwbz = 0 ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( i + j ) == t . charAt ( j ) ) { } else { LimkGwbz ++ ; } } if ( min > LimkGwbz ) { min = LimkGwbz ; } } 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 ceozXx { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strArray = br . readLine ( ) . split ( " " ) ; int CeozSo = Integer . parseInt ( strArray [ 0 ] ) ; int b = Integer . parseInt ( strArray [ 1 ] ) ; System . out . println ( getGCD ( CeozSo , b ) ) ; } public static int getGCD ( int CeozSo , int b ) { if ( CeozSo == b ) return CeozSo ; else if ( CeozSo < b ) { return getGCD ( CeozSo , b - CeozSo ) ; } else return getGCD ( CeozSo - b , CeozSo ) ; } } import java . util . Scanner ; public class vrdE { 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 VrdAr = 0 ; int b = 0 ; int c = 0 ; char currentChar = 'a' ; while ( true ) { if ( currentChar == 'a' ) { if ( VrdAr == s_a . length ( ) ) { System . out . println ( 'A' ) ; break ; } currentChar = s_a . charAt ( VrdAr ) ; VrdAr ++ ; } 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 FgcGwhjc { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int FgcO = scanner . nextInt ( ) , w = scanner . nextInt ( ) ; System . out . println ( ( FgcO > w ) ? " safe " : " unsafe " ) ; } } } import java . io . * ; import java . util . * ; public class arpcuoDdf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ArpcuoGxfx , B ; ArpcuoGxfx = 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 == ArpcuoGxfx && ( int ) ( i * tax10 + i ) - i == B ) { price = i ; break ; } } System . out . println ( price ) ; } } import java . util . * ; class HsekgWiu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HsekgNpi = sc . nextInt ( ) ; int [ ] t = new int [ HsekgNpi + 1 ] , x = new int [ HsekgNpi + 1 ] , y = new int [ HsekgNpi + 1 ] ; boolean flag = true ; t [ 0 ] = 0 ; x [ 0 ] = 0 ; y [ 0 ] = 0 ; for ( int i = 1 ; i < HsekgNpi + 1 ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < HsekgNpi + 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 katlcxUk { static int KatlcxNyb = 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 tuyouKc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TuyouClg = sc . nextInt ( ) ; int a = 1000 ; int i = 2 ; while ( a < TuyouClg ) { a = 1000 * i ; i ++ ; } System . out . println ( a - TuyouClg ) ; } } import java . util . * ; public class gpozraLe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int GpozraFr = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int q = scan . nextInt ( ) ; int [ ] g = new int [ GpozraFr ] ; for ( int i = 0 ; i < q ; i ++ ) { int t = scan . nextInt ( ) ; g [ t - 1 ] += 1 ; } for ( int j = 0 ; j < GpozraFr ; 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 podlwR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PodlwKmej = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < PodlwKmej ; 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 QceGq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qceFz = sc . nextInt ( ) ; int [ ] st = new int [ qceFz ] ; for ( int i = 0 ; i < qceFz ; i ++ ) { st [ i ] = sc . nextInt ( ) ; } Arrays . sort ( st ) ; int a = st [ 0 ] ; int b = st [ qceFz - 1 ] ; System . out . println ( Math . abs ( a - b ) ) ; } } import java . util . * ; import java . lang . Math ; class hpzpqvVu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double HpzpqvRhc = sc . nextInt ( ) ; double tmp = Math . ceil ( HpzpqvRhc / 2 ) ; double ans = tmp / HpzpqvRhc ; System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class VfjzAyp { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int vfjzYsg = 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 < vfjzYsg ; 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 EglXisi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eglX = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 1 ; i <= eglX ; 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 CwfwoXss { 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 cwfwoYx = 0 ; cwfwoYx <= N ; cwfwoYx ++ ) { for ( int m = 0 ; m <= N - cwfwoYx ; m ++ ) { int n = N - cwfwoYx - m ; if ( cwfwoYx * 10000 + m * 5000 + n * 1000 == Y ) { System . out . println ( cwfwoYx + " " + m + " " + n ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . io . * ; class DrvufTfxx { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int drvufZprw = Integer . parseInt ( br . readLine ( ) ) ; int count = 0 ; for ( int i = 0 ; i < drvufZprw ; 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 sqxxEgc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SqxxXbew = 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 ( SqxxXbew <= attack ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class ltnO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LtnNfq = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int len = ( LtnNfq < B ) ? LtnNfq : B ; List r = new ArrayList < Integer > ( ) ; for ( int i = 1 ; i <= len ; i ++ ) { if ( LtnNfq % i == 0 && B % i == 0 ) r . add ( i ) ; } System . out . println ( r . get ( r . size ( ) - K ) ) ; } } import java . util . Scanner ; public class VchLdm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vchW = sc . nextInt ( ) ; long [ ] townmonster = new long [ vchW + 1 ] ; for ( int i = 0 ; i < vchW + 1 ; i ++ ) { townmonster [ i ] = sc . nextLong ( ) ; } long [ ] yusha = new long [ vchW + 1 ] ; for ( int i = 0 ; i < vchW ; i ++ ) { yusha [ i ] = sc . nextLong ( ) ; } yusha [ vchW ] = 0 ; long count = 0 ; long yojou = 0 ; for ( int i = 0 ; i < vchW + 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 SgfueqRie { 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 sgfueqP = 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 " ) ) { sgfueqP = 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 " ) ) { sgfueqP = false ; } } if ( sgfueqP ) { 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 RhkAhn { 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 RhkYoc = Integer . parseInt ( list . get ( 0 ) ) ; String s = list . get ( 1 ) ; br . close ( ) ; int count = 0 ; int size = RhkYoc ; 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 pxtknN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PxtknBcr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int max = Math . max ( PxtknBcr , b ) ; max = Math . max ( max , c ) ; int sum = 0 ; if ( max == PxtknBcr ) { for ( int i = 0 ; i < n ; i ++ ) { PxtknBcr *= 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 = PxtknBcr + 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 PxtknBcr , int b ) { if ( b == 0 ) return PxtknBcr ; return gcd ( b , PxtknBcr % b ) ; } public static int lcm ( int PxtknBcr , int b ) { return PxtknBcr * b / gcd ( PxtknBcr , b ) ; } } import java . util . Scanner ; public class taoemRwx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TaoemDpzqn = 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 < TaoemDpzqn ; 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 ] == TaoemDpzqn ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class jmqfBom { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final long JmqfYr = 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 > JmqfYr || y - r < 0 || y + r > H ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class RfoUnl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rfoKq = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] lot = new int [ rfoKq ] ; String bar ; String [ ] s ; int a ; int b ; int save ; for ( int i = 0 ; i < rfoKq ; 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 < rfoKq ; i ++ ) { System . out . println ( " " + lot [ i ] ) ; } } } import java . util . Scanner ; class RhdvwgCd { public static void main ( String [ ] args ) { int rhdvwgAyl ; int M ; int X ; int i ; int a = 0 ; int b = 0 ; int [ ] A = new int [ 99 ] ; Scanner sc = new Scanner ( System . in ) ; rhdvwgAyl = 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 ssmbN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SsmbPxldg = sc . nextInt ( ) ; int wk = 0 ; int ans = 0 ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 2 ; i <= SsmbPxldg ; 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 <= SsmbPxldg ; 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 JxadopYs { public static void main ( String [ ] args ) throws Exception { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int JxadopWuh = Integer . parseInt ( stdReader . readLine ( ) ) ; String [ ] A = stdReader . readLine ( ) . split ( " " , 0 ) ; int j = 0 ; System . out . println ( String . join ( " " , A ) ) ; for ( int i = 1 ; i < JxadopWuh ; 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 PdcguFp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int PdcguTgb = 0 ; int min2 = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( i % 2 == Character . getNumericValue ( str . charAt ( i ) ) ) { PdcguTgb += 1 ; } else { min2 += 1 ; } } System . out . println ( Math . min ( PdcguTgb , min2 ) ) ; } } import java . util . Scanner ; class ElimwjKtey { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ElimwjKhf = sc . nextInt ( ) ; int numCol1Row2 = sc . nextInt ( ) ; int numCol2 = sc . nextInt ( ) ; int [ ] [ ] mat1 = new int [ ElimwjKhf ] [ numCol1Row2 ] ; int [ ] [ ] mat2 = new int [ numCol1Row2 ] [ numCol2 ] ; long [ ] [ ] matOut = new long [ ElimwjKhf ] [ numCol2 ] ; int i , j , k ; for ( i = 0 ; i < ElimwjKhf ; 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 < ElimwjKhf ; 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 IauNcby { 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 iauNydr = Integer . parseInt ( tmpArray [ 0 ] ) ; int b = Integer . parseInt ( tmpArray [ 1 ] ) ; System . out . println ( GCD ( iauNydr , b ) + " " + LCM ( iauNydr , b ) ) ; } } static long GCD ( long iauNydr , long b ) { long candidate = iauNydr ; while ( b % iauNydr != 0 ) { candidate = b % iauNydr ; b = iauNydr ; iauNydr = candidate ; } return candidate ; } static long LCM ( long iauNydr , long b ) { long GCD = GCD ( iauNydr , b ) ; return GCD * ( iauNydr / GCD ) * ( b / GCD ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class XjtsspDaq { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] ar = br . readLine ( ) . split ( " " ) ; int xjtsspTls = Integer . parseInt ( ar [ 0 ] ) ; int col = Integer . parseInt ( ar [ 1 ] ) ; int [ ] [ ] a = new int [ xjtsspTls ] [ 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 YgahutUc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ygahutKx = sc . nextInt ( ) ; int th = ygahutKx / 500 ; int g = ( ygahutKx - ( th * 500 ) ) / 5 ; int ans = ( th * 1000 ) + ( g * 5 ) ; System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class MzsstVues { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MzsstCr = sc . nextInt ( ) ; double D = sc . nextDouble ( ) ; int cnt = 0 ; double [ ] X = new double [ MzsstCr ] ; double [ ] Y = new double [ MzsstCr ] ; for ( int i = 0 ; i < MzsstCr ; 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 ( MzsstCr == 0 || d > D ) { continue ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class KqrpSz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kqrpMny = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ kqrpMny ] ; for ( int i = 0 ; i < kqrpMny ; 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 JrcUecg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String jrcS = sc . nextLine ( ) ; if ( jrcS . equals ( " 5 5 7 " ) || jrcS . equals ( " 5 7 5 " ) || jrcS . equals ( " 7 5 5 " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class WkzhYsspb { 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 WkzhQly = 0 ; for ( int i = 2 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == 'C' ) { WkzhQly ++ ; } } if ( WkzhQly != 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 rdrVdv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int RdrHeo = scan . nextInt ( ) ; int [ ] A = new int [ RdrHeo ] ; for ( int i = 0 ; i < RdrHeo ; i ++ ) { A [ i ] = scan . nextInt ( ) ; } insertionSort ( A , RdrHeo ) ; } public static void insertionSort ( int [ ] A , int RdrHeo ) { String output = Arrays . toString ( A ) . replaceAll ( " , " , " " ) ; System . out . println ( output . substring ( 1 , output . length ( ) - 1 ) ) ; for ( int i = 1 ; i < RdrHeo ; 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 EmgoneIik { 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 emgoneZfqe = 0 ; for ( int i = 1 ; i < a . length ; i ++ ) { emgoneZfqe += a [ i ] - a [ i - 1 ] ; } System . out . println ( emgoneZfqe ) ; } } import java . util . Scanner ; public class GyqfvcYzaa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GyqfvcCus = Integer . parseInt ( sc . next ( ) ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int sum = 0 ; for ( int i = 1 ; i < GyqfvcCus + 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 UpvjxDmxfu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double UpvjxO = scan . nextDouble ( ) ; double tmp = UpvjxO / 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 wqxU { 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 wqxU { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int WqxBfw = 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 < WqxBfw ; 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 MrhYj { public static void main ( String [ ] args ) throws Exception { int mrhIlld = 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 slodM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SlodWhtsm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( SlodWhtsm > b ) { System . out . println ( 2 * SlodWhtsm - 1 ) ; } else if ( SlodWhtsm == b ) { System . out . println ( 2 * SlodWhtsm ) ; } else { System . out . println ( 2 * b - 1 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; class MpneoQbq { static Scanner sc = new Scanner ( ) ; public static void main ( final String [ ] args ) throws IOException { int MpneoC = sc . nextInt ( ) ; int [ ] a = new int [ MpneoC ] ; for ( int i = 0 ; i < MpneoC ; i ++ ) { a [ sc . nextInt ( ) - 1 ] = i + 1 ; } for ( int i = 0 ; i < MpneoC ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } } static class MpneoQbq { 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 hezrsAdb { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int HezrsNa = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < HezrsNa ; 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 FmokaEsg { void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int fmokaFm = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; long min = Long . MAX_VALUE ; for ( int i = fmokaFm ; 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 uphdLnc { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int UphdLego = 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 < UphdLego ; 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 KxnbzDhktzo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] data = sc . nextLine ( ) . split ( " " ) ; int KxnbzH = Integer . parseInt ( data [ 0 ] ) ; int b = Integer . parseInt ( data [ 1 ] ) ; int c = Integer . parseInt ( data [ 2 ] ) ; if ( KxnbzH + b + c >= 22 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } } } import java . util . * ; public class ByjxYaiq { public static int digit ( int x ) { int ByjxQ = 0 , tmp = x ; if ( x == 0 ) return 1 ; while ( tmp != 0 ) { tmp /= 10 ; ++ ByjxQ ; } return ByjxQ ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; sc . close ( ) ; String [ ] ByjxQ = { " 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 ( ByjxQ [ an ] ) ; } } import java . util . Scanner ; class auqP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AuqDttt = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int C = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( C - ( AuqDttt - B ) > 0 ? C - ( AuqDttt - B ) : 0 ) ; } } import java . util . Scanner ; public class grqheiHbc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long GrqheiKajo = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long c = scan . nextLong ( ) ; long d = scan . nextLong ( ) ; scan . close ( ) ; long numC = b / c - ( GrqheiKajo - 1 ) / c ; long numD = b / d - ( GrqheiKajo - 1 ) / d ; long lcmCD = lcm ( c , d ) ; long numCD = b / lcmCD - ( GrqheiKajo - 1 ) / lcmCD ; System . out . println ( b - GrqheiKajo + 1 - numC - numD + numCD ) ; } public static long lcm ( long GrqheiKajo , long b ) { return GrqheiKajo * b / gcd ( GrqheiKajo , b ) ; } public static long gcd ( long GrqheiKajo , long b ) { if ( GrqheiKajo < b ) { return gcd ( b , GrqheiKajo ) ; } if ( b == 0 ) { return GrqheiKajo ; } return gcd ( b , GrqheiKajo % b ) ; } } import java . util . Scanner ; public class TioyUbl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int TioyMx = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( TioyMx == 0 && y == 0 ) { break ; } else if ( TioyMx < y ) { System . out . print ( TioyMx + " " ) ; System . out . println ( y ) ; } else { System . out . print ( y + " " ) ; System . out . println ( TioyMx ) ; } } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class CarysYxsq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int CarysM = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; Integer [ ] [ ] array = new Integer [ CarysM ] [ m ] ; for ( int i = 0 ; m > i ; i ++ ) { int a = sc . nextInt ( ) ; list . add ( a ) ; } for ( int i = 0 ; CarysM > i ; i ++ ) { for ( int j = 0 ; m > j ; j ++ ) { int a = sc . nextInt ( ) ; array [ i ] [ j ] = a ; } } int count = 0 ; for ( int i = 0 ; CarysM > 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 SjrbCcgr { 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 SjrbL = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int ab = abs ( SjrbL - B ) ; int bc = abs ( B - C ) ; int ca = abs ( C - SjrbL ) ; int minus = max3 ( ab , bc , ca ) ; System . out . println ( ab + bc + ca - minus ) ; } } import java . util . * ; public class jhgFe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char JhgAulpz = s . charAt ( 0 ) ; String ans = " Good " ; for ( int i = 1 ; i < 4 ; i ++ ) { if ( JhgAulpz == s . charAt ( i ) ) ans = " Bad " ; JhgAulpz = s . charAt ( i ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class SuvtgLqz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int SuvtgKfi = sc . nextInt ( ) ; if ( SuvtgKfi == 0 ) { break ; } int [ ] scores = new int [ SuvtgKfi ] ; 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 ] / SuvtgKfi ; } for ( int i = 0 ; i < scores . length ; i ++ ) { variance += ( double ) ( scores [ i ] - average ) * ( scores [ i ] - average ) / SuvtgKfi ; } System . out . println ( Math . sqrt ( variance ) ) ; } } } import java . util . * ; public class NnfvleUhk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String numM = scan . next ( ) ; int nnfvleTogr = Integer . parseInt ( numM ) ; int startNum = 0 ; for ( int i = 0 ; i < numM . length ( ) ; i ++ ) { startNum = startNum + Integer . parseInt ( String . valueOf ( numM . charAt ( i ) ) ) ; } if ( nnfvleTogr % startNum == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class AhumqrHz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long [ ] inputs = new long [ 3 ] ; for ( int ahumqrVsd = 0 ; ahumqrVsd < 3 ; ahumqrVsd ++ ) { inputs [ ahumqrVsd ] = sc . nextLong ( ) ; } Arrays . sort ( inputs ) ; for ( int ahumqrVsd = 0 ; ahumqrVsd < 3 ; ahumqrVsd ++ ) { System . out . print ( inputs [ ahumqrVsd ] + ( ( ahumqrVsd != 2 ) ? " " : " " ) ) ; } System . out . println ( ) ; } } import java . util . * ; public class EwwLvrq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ewwV = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < ewwV ; i ++ ) { sum += l + i ; } if ( ewwV + l <= 0 ) { System . out . println ( sum - ( ewwV + l - 1 ) ) ; } else if ( l < 0 ) { System . out . println ( sum ) ; } else { System . out . println ( sum - l ) ; } } } import java . util . Scanner ; public class QsivgZpc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] s = S . toCharArray ( ) ; boolean QsivgMm = false ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s [ i ] == s [ i + 1 ] ) { QsivgMm = true ; break ; } } if ( QsivgMm ) { System . out . println ( " Bad " ) ; } else { System . out . println ( " Good " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class tjryZ { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int TjryZd = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; int [ ] [ ] matrix = new int [ TjryZd ] [ m ] ; int [ ] vector = new int [ m ] ; for ( int i = 0 ; i < TjryZd ; 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 < TjryZd ; 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 KycoanSonl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] T = sc . next ( ) . toCharArray ( ) ; int KycoanB = 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 ++ ; KycoanB = Math . max ( KycoanB , now ) ; } } System . out . println ( KycoanB ) ; } } import java . util . * ; import java . lang . * ; public class HnoWc { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int hnoLmd ; hnoLmd = sc . nextInt ( ) ; if ( hnoLmd % 10 == 3 ) { System . out . println ( " bon " ) ; } else if ( ( hnoLmd % 10 == 0 ) || ( hnoLmd % 10 == 1 ) || ( hnoLmd % 10 == 6 ) || ( hnoLmd % 10 == 8 ) ) { System . out . println ( " pon " ) ; } else { System . out . println ( " hon " ) ; } } } import java . util . * ; public class NgqhrWiv { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String ngqhrMfz = sc . next ( ) ; String T = sc . next ( ) ; String end = T . substring ( ngqhrMfz . length ( ) , ngqhrMfz . length ( ) + 1 ) ; if ( T . equals ( ngqhrMfz + end ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class AsjaHpor { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AsjaAkx = sc . nextInt ( ) ; int [ ] a = new int [ AsjaAkx + 1 ] ; for ( int i = 0 ; i < AsjaAkx ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int max ; for ( int i = 0 ; i < AsjaAkx ; i ++ ) { for ( int j = i ; j < AsjaAkx ; 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 < AsjaAkx ; 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 EtajvYanu { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner scanner = new Scanner ( System . in ) ; int etajvLd = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = etajvLd + 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 thlNon { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] str = new String [ 3 ] ; int [ ] count = new int [ 3 ] ; for ( int ThlPvwn = 0 ; ThlPvwn < 3 ; ++ ThlPvwn ) { str [ ThlPvwn ] = sc . next ( ) ; count [ ThlPvwn ] = str [ ThlPvwn ] . length ( ) ; } int ThlPvwn = 0 ; while ( true ) { if ( count [ ThlPvwn ] == 0 && ThlPvwn == 0 ) { System . out . println ( " A " ) ; return ; } else if ( count [ ThlPvwn ] == 0 && ThlPvwn == 1 ) { System . out . println ( " B " ) ; return ; } else if ( count [ ThlPvwn ] == 0 && ThlPvwn == 2 ) { System . out . println ( " C " ) ; return ; } if ( str [ ThlPvwn ] . charAt ( str [ ThlPvwn ] . length ( ) - count [ ThlPvwn ] ) == 'a' ) { count [ ThlPvwn ] -- ; ThlPvwn = 0 ; } else if ( str [ ThlPvwn ] . charAt ( str [ ThlPvwn ] . length ( ) - count [ ThlPvwn ] ) == 'b' ) { count [ ThlPvwn ] -- ; ThlPvwn = 1 ; } else if ( str [ ThlPvwn ] . charAt ( str [ ThlPvwn ] . length ( ) - count [ ThlPvwn ] ) == 'c' ) { count [ ThlPvwn ] -- ; ThlPvwn = 2 ; } } } } import java . io . * ; import java . util . * ; class XkdcKjnwna { 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 XkdcYc = Integer . parseInt ( st . nextToken ( ) ) ; int f = Integer . parseInt ( st . nextToken ( ) ) ; int r = Integer . parseInt ( st . nextToken ( ) ) ; if ( XkdcYc == - 1 && f == - 1 && r == - 1 ) { break ; } if ( XkdcYc == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } else if ( ( XkdcYc + f ) >= 80 ) { System . out . println ( " A " ) ; } else if ( ( XkdcYc + f ) >= 65 ) { System . out . println ( " B " ) ; } else if ( ( ( XkdcYc + f ) >= 50 ) || ( ( XkdcYc + f ) >= 30 && r >= 50 ) ) { System . out . println ( " C " ) ; } else if ( ( XkdcYc + 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 vfxaU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VfxaCrx = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int max = 0 ; for ( int i = 0 ; VfxaCrx > i ; i ++ ) { int a = sc . nextInt ( ) ; list . add ( a ) ; } for ( int i = 0 ; VfxaCrx - 1 > i ; i ++ ) { for ( int j = i + 1 ; VfxaCrx > 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 AlawqqPpu { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int AlawqqR = sc . nextInt ( ) ; int [ ] a = new int [ AlawqqR ] ; int [ ] b = new int [ AlawqqR ] ; for ( int i = 0 ; i < AlawqqR ; i ++ ) a [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < AlawqqR ; i ++ ) b [ i ] = sc . nextInt ( ) ; int c = 0 , s = 0 ; for ( int i = 0 ; i < AlawqqR ; 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 QkdjiXfubfn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QkdjiTvf = 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 == QkdjiTvf && k2 == b ) { bool = false ; System . out . println ( i ) ; break loop ; } } if ( bool ) { System . out . println ( " -1 " ) ; } sc . close ( ) ; } } import java . util . * ; public class YpiktCmj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YpiktMg = sc . nextInt ( ) ; if ( YpiktMg == 1 ) { YpiktMg = 0 ; } else { YpiktMg = 1 ; } System . out . println ( YpiktMg ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class PyoZti { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { final int PyoA = 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 dhwdprSzd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DhwdprJvwb = sc . nextInt ( ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; String ans = " " ; for ( int i = 0 ; i < DhwdprJvwb ; 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 XrdrhBdp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int xrdrhUd = 0 ; int ans = 0 ; for ( char ss : s ) { if ( ss == 'R' ) { xrdrhUd ++ ; } else { xrdrhUd = 0 ; } ans = Math . max ( xrdrhUd , ans ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class VlcUaqpe { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int VlcYzz = in . nextInt ( ) ; int b = in . nextInt ( ) ; int ans = VlcYzz * b ; System . out . print ( ans ) ; } } import java . util . Scanner ; public class GungRqx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gungY = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] p = new int [ N ] ; int a = gungY ; int ans1 = gungY ; int ans2 = gungY ; 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 ] != gungY ) { s ++ ; } } if ( s == N ) { ans1 = gungY ; break ; } s = 0 ; gungY = gungY - 1 ; } gungY = a ; s = 0 ; for ( int i = 0 ; i < N + 1 ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( p [ j ] != gungY ) { s ++ ; } } if ( s == N ) { ans2 = gungY ; break ; } s = 0 ; gungY = gungY + 1 ; } gungY = a - ans1 ; N = ans2 - a ; if ( gungY <= N ) { System . out . println ( ans1 ) ; } else { System . out . println ( ans2 ) ; } } } import java . util . * ; class pkwboI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PkwboLpqh = sc . nextInt ( ) ; Set < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < PkwboLpqh ; i ++ ) { set . add ( sc . next ( ) ) ; } if ( set . size ( ) < PkwboLpqh ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } } import java . util . Scanner ; class PeiRoq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String peiEdk = scan . next ( ) ; peiEdk = peiEdk . replaceAll ( " 0 " , " " ) ; System . out . print ( peiEdk . length ( ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class bbmkpyFn { 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 BbmkpyFqv = Integer . parseInt ( st . nextToken ( ) ) ; int W = Integer . parseInt ( st . nextToken ( ) ) ; if ( W == 0 && BbmkpyFqv == 0 ) break ; if ( BbmkpyFqv >= 300 && W >= 300 ) break ; ; for ( int i = 1 ; i <= BbmkpyFqv ; 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 wmbivjYt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WmbivjOkeil = sc . nextInt ( ) ; int [ ] param = new int [ WmbivjOkeil ] ; for ( int i = 0 ; i < WmbivjOkeil ; i ++ ) { param [ i ] = sc . nextInt ( ) ; } Arrays . sort ( param ) ; int alice = 0 ; int bob = 0 ; if ( WmbivjOkeil % 2 == 0 ) { for ( int i = 0 ; i < WmbivjOkeil ; i ++ ) { if ( i % 2 == 0 ) { bob += param [ i ] ; } else { alice += param [ i ] ; } } } else { for ( int i = 0 ; i < WmbivjOkeil ; 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 SgxIk { public static void main ( String [ ] args ) throws IOException { int SgxV = 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 ( " " ) ; SgxV = Integer . parseInt ( result [ 0 ] ) ; b = Integer . parseInt ( result [ 1 ] ) ; c = Integer . parseInt ( result [ 2 ] ) ; for ( int i = SgxV ; i <= b ; i += 1 ) { if ( c % i == 0 ) { answer ++ ; } } System . out . println ( answer ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; public class WiwkqwQyg { 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 WiwkqwG = 0 ; WiwkqwG < 5 ; WiwkqwG ++ ) a [ WiwkqwG ] = 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 RbujnsYm { 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 rbujnsJv = 0 ; rbujnsJv < s . length ( ) ; rbujnsJv ++ ) { String str = " " ; for ( int j = 0 ; j < p . length ( ) ; j ++ ) { int k = rbujnsJv + 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 JmboaMnadaa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JmboaBn = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] ab = { JmboaBn + b , JmboaBn - b , JmboaBn * 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 MudlpNb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MudlpOq = sc . nextInt ( ) ; Map < Integer , Boolean > map = new HashMap < > ( ) ; String ans = " YES " ; for ( int i = 0 ; i < MudlpOq ; 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 NjumLj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int njumKla = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; int q = sc . nextInt ( ) ; int [ ] a = new int [ q ] ; int [ ] win = new int [ njumKla ] ; 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 < njumKla ; i ++ ) { if ( k - ( q - win [ i ] ) > 0 ) { System . out . println ( " Yes " ) ; continue ; } System . out . println ( " No " ) ; } } } import java . util . * ; public class ltcryFzy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LtcryFl , f , r ; while ( true ) { LtcryFl = scan . nextInt ( ) ; f = scan . nextInt ( ) ; r = scan . nextInt ( ) ; if ( LtcryFl + f + r == - 3 ) break ; int s = LtcryFl + f ; if ( LtcryFl == - 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 TttnbXxjdy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TttnbW = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int c = 0 ; int x , y , z , w ; for ( int i = TttnbW ; 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 segbmRz { public static void main ( String [ ] a ) throws Exception { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s ; int SegbmGa ; double total ; while ( ( s = r . readLine ( ) ) != null ) { SegbmGa = Integer . parseInt ( s ) ; total = 100000 ; for ( int i = 0 ; i < SegbmGa ; i ++ ) { total *= 1.05 ; total /= 1000 ; total = Math . ceil ( total ) * 1000 ; } System . out . printf ( " %.0f \n " , total ) ; } } } import java . util . * ; class obkKb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int ObkYcyw = - 1 ; String [ ] ss = { " SUN " , " MON " , " TUE " , " WED " , " THU " , " FRI " , " SAT " } ; for ( int i = 0 ; i < ss . length ; i ++ ) { if ( ss [ i ] . equals ( s ) ) { ObkYcyw = i ; } } System . out . println ( 7 - ObkYcyw ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class jnwRrg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JnwUwfka = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; long count = 0 ; long count1 = 0 ; int [ ] array = new int [ 3 ] ; Arrays . sort ( array ) ; if ( JnwUwfka <= 9 && m <= 9 ) { System . out . println ( JnwUwfka * m ) ; } else { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; public class kiaymPgz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long KiaymZn = Long . parseLong ( scanner . nextLine ( ) ) ; char [ ] ans = scanner . nextLine ( ) . toCharArray ( ) ; int a = 0 ; for ( int i = 0 ; i < KiaymZn ; i ++ ) { if ( i < KiaymZn - 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 sfdhNjp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SfdhEphh = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = 0 ; for ( int i = 0 ; i < SfdhEphh - 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 WbjxrgHwa { public static void main ( String [ ] args ) throws IOException { Scanner scane = new Scanner ( System . in ) ; int wbjxrgVo = scane . nextInt ( ) ; long [ ] nums = new long [ wbjxrgVo ] ; for ( int i = 0 ; i < wbjxrgVo ; 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 lbecIdx { 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 lbecIdx { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String [ ] inputs = in . nextLine ( ) . split ( " " ) ; long LbecExaj = Long . parseLong ( inputs [ 0 ] ) ; long b = Long . parseLong ( inputs [ 1 ] . replaceAll ( " \\ . " , " " ) ) ; out . append ( String . valueOf ( LbecExaj * b / 100 ) ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class GdabqCode { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int gdabqTin = 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 ] ) ) ; gdabqTin ++ ; } } } import java . util . * ; public class LhrhCojn { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int lhrhZok = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = Math . min ( lhrhZok * b , c ) ; System . out . println ( d ) ; } } import java . util . Scanner ; public class UfqcScnd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ufqcIk = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; sc . close ( ) ; int s = - 1 ; for ( int i = 1 ; i <= 1009 ; i ++ ) { if ( ( int ) ( i * 0.08 ) == ufqcIk && ( int ) ( i * 0.1 ) == B ) { s = i ; break ; } } System . out . println ( s ) ; } } import java . util . Scanner ; public class GmowuGavz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GmowuX = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; if ( GmowuX > m ) { System . out . println ( " a > b " ) ; } if ( GmowuX < m ) { System . out . println ( " a < b " ) ; } if ( GmowuX == m ) { System . out . println ( " a == b " ) ; } } } import java . util . * ; public class VqzSr { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; float VqzWsj = in . nextFloat ( ) , t = in . nextFloat ( ) , s = in . nextFloat ( ) ; if ( ( VqzWsj / s ) <= t ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class RcpsFguh { public static void main ( String [ ] args ) { Scanner o = new Scanner ( System . in ) ; int RcpsGg = o . nextInt ( ) ; int b = o . nextInt ( ) ; int c = o . nextInt ( ) ; int k = o . nextInt ( ) ; int ans = 0 ; ans += Math . min ( k , RcpsGg ) ; k -= ans ; RcpsGg -= 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 wxiveEk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; list . add ( sc . nextInt ( ) ) ; for ( int WxiveJaga = 1 ; WxiveJaga < 10001 ; WxiveJaga ++ ) { if ( list . get ( WxiveJaga - 1 ) == 0 ) { break ; } System . out . println ( " Case " + WxiveJaga + " : " + list . get ( WxiveJaga - 1 ) ) ; list . add ( sc . nextInt ( ) ) ; } } } import java . util . Scanner ; public class KouwlrNe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String sline = sc . next ( ) ; int kouwlrXvo = 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 < kouwlrXvo ; ) { boolean can = false ; for ( String w : words ) { int end = w . length ( ) ; if ( i + end > kouwlrXvo ) 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 tswioX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TswioOjxgz = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int s = 0 ; if ( TswioOjxgz < b ) { for ( ; TswioOjxgz < b ; TswioOjxgz ++ ) { if ( c % TswioOjxgz == 0 ) s ++ ; } } else if ( TswioOjxgz > b ) ; { for ( ; b < TswioOjxgz ; b ++ ) { if ( c % b == 0 ) s ++ ; } } if ( TswioOjxgz == b ) if ( c % TswioOjxgz == 0 ) s ++ ; System . out . println ( s ) ; } } import java . util . Scanner ; import java . util . Arrays ; import java . util . ArrayList ; public class BqpqDmyoww { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > A = new ArrayList < > ( ) ; int BqpqM = sc . nextInt ( ) ; for ( int a = 0 ; a < BqpqM ; ++ 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 bggoojUs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long BggoojZrgml = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; System . out . println ( helper ( BggoojZrgml , b ) ) ; sc . close ( ) ; } static long helper ( long BggoojZrgml , long b ) { long v = BggoojZrgml , u = b , y ; while ( b > 0 ) { y = BggoojZrgml % b ; BggoojZrgml = b ; b = y ; } return v * u / BggoojZrgml ; } } import java . util . Scanner ; public class DaiuzlBss { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String daiuzlRw = sc . next ( ) ; String t = sc . next ( ) ; if ( ( daiuzlRw . length ( ) == t . length ( ) ) && ( daiuzlRw + daiuzlRw ) . 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 EqzNyyi { 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 eqzQq = 0 ; eqzQq < arrayLength ; eqzQq ++ ) { for ( byte y = ( byte ) ( arrayLength - 1 ) ; y > eqzQq ; 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 KgaojUn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KgaojLh = sc . nextInt ( ) ; String slimes = sc . next ( ) ; StringBuilder ans = new StringBuilder ( ) ; String [ ] slimesarr = new String [ KgaojLh + 1 ] ; for ( int i = 0 ; i < KgaojLh ; i ++ ) { slimesarr [ i ] = String . valueOf ( slimes . charAt ( i ) ) ; } for ( int i = 0 ; i < KgaojLh ; 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 blnbF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < String > box = new ArrayList < > ( ) ; int BlnbQdut = sc . nextInt ( ) ; String each = null ; for ( int i = 0 ; i < BlnbQdut ; i ++ ) { box . add ( sc . next ( ) ) ; } List < String > list = new ArrayList < String > ( new LinkedHashSet < > ( box ) ) ; System . out . println ( list . size ( ) ) ; } } import java . util . * ; public class ghejwNx { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int GhejwZn = 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 rntkR { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int RntkAmcu = 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 AmailjBo { 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 AmailjMxl = 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 KcrKeduwg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KcrX = sc . nextInt ( ) ; int [ ] t = new int [ KcrX + 1 ] ; int [ ] x = new int [ KcrX + 1 ] ; int [ ] y = new int [ KcrX + 1 ] ; for ( int i = 1 ; i <= KcrX ; 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 <= KcrX ; 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 dheS { static final long DheFgtme = 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 dheS 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 WddvvJlkq { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int WddvvMb = sc . nextInt ( ) ; while ( IsPrime ( WddvvMb ) == false ) { WddvvMb ++ ; } System . out . println ( WddvvMb ) ; } 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 qxvZvm { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int QxvBicr = Integer . parseInt ( tokenizer . nextToken ( ) ) ; String [ ] a = new String [ QxvBicr ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = input . readLine ( ) ; } Arrays . sort ( a ) ; StringBuilder out = new StringBuilder ( ) ; for ( int i = 0 ; i < QxvBicr ; i ++ ) { out . append ( a [ i ] ) ; } System . out . println ( out ) ; } } import java . util . Scanner ; public class QgvajIe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QgvajHdn = scan . nextInt ( ) ; int [ ] h = new int [ QgvajHdn ] ; for ( int i = 0 ; i < QgvajHdn ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; int check = 1 ; if ( QgvajHdn != 1 ) { for ( int i = QgvajHdn - 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 crnWo { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int CrnIjkp = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; System . out . println ( Integer . toString ( CrnIjkp , K ) . length ( ) ) ; } } import java . util . Scanner ; class vrjksvX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VrjksvSp = sc . nextInt ( ) ; String nn = String . valueOf ( VrjksvSp ) ; 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 GflzrCp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String gflzrSxo = sc . next ( ) ; if ( gflzrSxo . length ( ) < 6 ) { System . out . print ( " No " ) ; } else { if ( gflzrSxo . charAt ( 2 ) == gflzrSxo . charAt ( 3 ) && gflzrSxo . charAt ( 4 ) == gflzrSxo . charAt ( 5 ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } } import java . util . * ; public class kbtbqjCy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KbtbqjLrqxg = sc . nextInt ( ) ; int [ ] w = new int [ KbtbqjLrqxg + 1 ] ; int sum = 0 ; for ( int i = 1 ; i <= KbtbqjLrqxg ; i ++ ) { w [ i ] = sc . nextInt ( ) ; sum += w [ i ] ; } int s1 = 0 ; int s2 = 0 ; int ans = sum ; for ( int i = 1 ; i <= KbtbqjLrqxg ; 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 JjiQmj { 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 JjiU : c ) { if ( JjiU == '0' ) ans . append ( " 0 " ) ; if ( JjiU == '1' ) ans . append ( " 1 " ) ; if ( JjiU == '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 LgyxekQn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int lgyxekIzqp = 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 ) { lgyxekIzqp = 48 ; } else { lgyxekIzqp = 49 ; } if ( tile [ i ] != lgyxekIzqp ) { changedCntFrm0 ++ ; } } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { lgyxekIzqp = 49 ; } else { lgyxekIzqp = 48 ; } if ( tile [ i ] != lgyxekIzqp ) { changedCntFrm1 ++ ; } } if ( changedCntFrm0 >= changedCntFrm1 ) { System . out . println ( changedCntFrm1 ) ; } else { System . out . println ( changedCntFrm0 ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class cwksqfGo { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] tmp = scanner . nextLine ( ) . split ( " " ) ; int CwksqfTxvbp = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { if ( Integer . parseInt ( tmp [ i ] ) == 0 ) { CwksqfTxvbp = i + 1 ; break ; } } System . out . println ( CwksqfTxvbp ) ; } } import java . util . * ; public class wsazjV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WsazjAw = sc . nextInt ( ) ; int [ ] num = new int [ WsazjAw + 1 ] ; for ( int i = 1 ; i <= WsazjAw ; i ++ ) { num [ i ] = sc . nextInt ( ) ; } int number = 1 ; int count = 0 ; boolean key = false ; for ( int i = 1 ; i <= WsazjAw ; 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 KonkkNz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int konkkHwbq = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int x = y / 1000 - konkkHwbq ; int coefficient1 = 9 ; int coefficient2 = 4 ; int [ ] result = { - 1 , - 1 , - 1 } ; for ( int i = 0 ; i <= konkkHwbq ; i ++ ) { int tmp = x - ( 9 * i ) ; int [ ] tmp2 = new int [ 3 ] ; if ( tmp % 4 == 0 && tmp >= 0 && tmp <= 4 * konkkHwbq ) { tmp2 [ 0 ] = i ; tmp2 [ 1 ] = tmp / 4 ; tmp2 [ 2 ] = konkkHwbq - tmp2 [ 0 ] - tmp2 [ 1 ] ; if ( tmp2 [ 2 ] >= 0 && tmp2 [ 2 ] <= konkkHwbq ) { 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 iodnwiE { 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 iodnwiE { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int IodnwiXwkhi = in . nextInt ( ) ; int min = Integer . MAX_VALUE , max = 0 ; for ( int i = 0 ; i < IodnwiXwkhi ; i ++ ) { int a = in . nextInt ( ) ; min = Math . min ( min , a ) ; max = Math . max ( max , a ) ; } out . println ( max - min ) ; } } } import java . util . * ; public class kevfbO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; int KevfbWogx = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String U = sc . next ( ) ; if ( U . equals ( S ) ) { System . out . printf ( " %d %d " , KevfbWogx - 1 , B ) ; } else { System . out . printf ( " %d %d " , KevfbWogx , B - 1 ) ; } } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class cfteRy { 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 CfteXx = scan . nextLong ( ) ; long depo = 100 ; int ans = 0 ; while ( CfteXx > depo ) { depo *= 1.01 ; ans ++ ; } os . println ( ans ) ; } } import java . util . * ; class GfhnRqfu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gfhnWxte = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= gfhnWxte ; 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 LgjMv { private static BufferedReader br = null ; public static void main ( String [ ] args ) { String n = read ( 1 ) [ 0 ] ; for ( int lgjZ = 0 ; lgjZ < n . length ( ) ; lgjZ ++ ) { System . out . print ( n . charAt ( lgjZ ) == '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 lgjZ = 0 ; lgjZ < len ; lgjZ ++ ) { 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 lojgtoTj { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; long LojgtoMsvxd = 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 = LojgtoMsvxd - sum + first ; if ( saigo > max ) { max = saigo ; } System . out . println ( LojgtoMsvxd - max ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class JxcmBh { static class JxcmBh { boolean JxcmSv ; int waCount ; Result ( boolean JxcmSv , int waCount ) { this . JxcmSv = JxcmSv ; this . waCount = waCount ; } int getPenaltyCount ( ) { return JxcmSv ? 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 . JxcmSv = true ; } else { if ( ! result . JxcmSv ) { 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 ( ) . JxcmSv ? 1 : 0 ; penaltyCount += entry . getValue ( ) . getPenaltyCount ( ) ; } System . out . println ( acCount + " " + penaltyCount ) ; } } import java . util . * ; public class BjzcUz { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int bjzcGg = scn . nextInt ( ) ; int [ ] Nmonster = new int [ bjzcGg + 1 ] ; for ( int i = 0 ; i < bjzcGg + 1 ; i ++ ) { Nmonster [ i ] = scn . nextInt ( ) ; } long Nbeaten = 0 ; for ( int i = 0 ; i < bjzcGg ; 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 IpqHscg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ipqJ = sc . nextLine ( ) ; if ( ipqJ . compareTo ( " 2019/04/30 " ) > 0 ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } try { Date date1 = DateFormat . getDateInstance ( ) . parse ( ipqJ ) ; } catch ( ParseException e ) { } } } import java . io . InputStream ; import java . io . IOException ; import java . util . HashSet ; class EbcoxXjsra { InputStream stream ; public MyScanner ( ) { stream = System . in ; } public int nextInt ( ) { int EbcoxUvk = 0 ; try { while ( true ) { char readed = ( char ) stream . read ( ) ; if ( readed < '0' || readed > '9' ) { break ; } EbcoxUvk = EbcoxUvk * 10 + ( readed - '0' ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { return EbcoxUvk ; } } } class EbcoxXjsra { 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 WirMu { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; Map < String , Integer > count = new HashMap < > ( ) ; int WirXk = in . nextInt ( ) ; for ( int i = 0 ; i < WirXk ; 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 sqfrgIbw { private static int solution ( int [ ] array ) { int SqfrgObnpy = 1 ; int score = 1 ; int minimum = array [ 0 ] ; while ( SqfrgObnpy < array . length ) { if ( array [ SqfrgObnpy ] < minimum ) { minimum = array [ SqfrgObnpy ] ; score ++ ; } SqfrgObnpy ++ ; } 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 DavrdSl { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DavrdPqj = sc . nextInt ( ) ; int val = 0 ; if ( DavrdPqj != 0 ) { val = ( DavrdPqj / 500 ) * 1000 ; val += ( DavrdPqj % 500 ) / 5 * 5 ; } System . out . println ( val ) ; } } import java . util . Scanner ; public class LfezdfUtud { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String LfezdfAq = sc . next ( ) ; if ( LfezdfAq . matches ( " ^((dreamer)|(eraser)|(dream)|(erase))+$ " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class kcwP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KcwHnq = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int te = - 1 ; for ( int i = 0 ; i < 10000 ; i ++ ) { if ( ( int ) ( i * 0.08 ) == KcwHnq && ( int ) ( i * 0.1 ) == b ) { te = i ; break ; } } System . out . print ( te ) ; } } import java . util . * ; class rhawrQ { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int RhawrRk = stdIn . nextInt ( ) ; int ans = - 1000000000 ; int min = stdIn . nextInt ( ) ; for ( int i = 1 ; i < RhawrRk ; 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 DwwnEzpz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long dwwnAga = Long . parseLong ( scan . next ( ) ) ; scan . close ( ) ; StringBuilder sb = new StringBuilder ( ) ; while ( dwwnAga > 0 ) { long l = dwwnAga % 26 ; if ( l == 0 ) { sb . append ( 'z' ) ; dwwnAga -= 1 ; } else { char c = 'a' ; c += l - 1 ; sb . append ( c ) ; } dwwnAga /= 26 ; } System . out . println ( sb . reverse ( ) . toString ( ) ) ; } } import java . util . * ; public class NxfvnWfpy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nxfvnCru = sc . nextInt ( ) ; sc . close ( ) ; int count = 0 ; for ( int i = 1 ; i <= nxfvnCru ; 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 KjxqunWcwf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long kjxqunQlm = sc . nextLong ( ) ; if ( kjxqunQlm == 1 ) { System . out . println ( 1 ) ; return ; } long x = kjxqunQlm ; 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 cyqR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CyqMx = sc . nextInt ( ) ; String S = sc . next ( ) ; String T = " " ; if ( S . length ( ) <= CyqMx ) { T = S ; } else { for ( int i = 0 ; i < CyqMx ; i ++ ) { T += S . charAt ( i ) ; } T += " ... " ; } sc . close ( ) ; System . out . println ( T ) ; } } import java . util . * ; public class tsaokEh { final static int TsaokOj = 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 PycNq { 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 pycIjb = 0 ; for ( String weather : weathers ) { if ( weather . equals ( today ) ) { System . out . println ( weathers [ ( pycIjb + 1 ) % 3 ] ) ; return ; } pycIjb ++ ; } } } import java . math . BigInteger ; import java . util . Scanner ; import java . util . Arrays ; public class LjteMyg { public static void main ( String [ ] args ) { int ljteGg , 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 ] ; ljteGg = sc . nextInt ( ) ; k = 50000000 ; for ( i = 0 ; i < ljteGg ; i ++ ) { o = sc . nextInt ( ) ; if ( k > o ) { k = o ; } ar [ i ] = o ; br [ i ] = k ; } k = 0 ; for ( i = 1 ; i < ljteGg ; i ++ ) { if ( ar [ i ] <= br [ i ] ) { k ++ ; } } System . out . println ( k + 1 ) ; } } import java . util . * ; public class gcqxabPx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GcqxabNjpj = sc . nextInt ( ) ; int x = 100000 ; for ( int i = 0 ; i < GcqxabNjpj ; i ++ ) { x = ( int ) ( 1.05 * x ) ; if ( x % 1000 != 0 ) { x = ( ( x / 1000 ) + 1 ) * 1000 ; } } System . out . println ( x ) ; } } import java . util . * ; public class emnIm { 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 EmnUqte = 0 ; EmnUqte < s . length ; EmnUqte ++ ) { 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 KywePouhvz { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int KyweQef = sc . nextInt ( ) ; final int b = sc . nextInt ( ) ; final int c = sc . nextInt ( ) ; final int k = sc . nextInt ( ) ; sc . close ( ) ; int result = 0 ; if ( KyweQef >= k ) { result = k ; } else if ( b >= k - KyweQef ) { result = KyweQef ; } else if ( c >= k - b - KyweQef ) { result = 2 * KyweQef + b - k ; } System . out . println ( result ) ; } } import java . util . * ; public class XzsGs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xzsAv = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( xzsAv % 2 == 1 ) { System . out . println ( " No " ) ; return ; } String ss = s . substring ( xzsAv / 2 , xzsAv ) ; s = s . substring ( 0 , xzsAv / 2 ) ; if ( s . equals ( ss ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class TysJs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tysAqpi = sc . nextInt ( ) , b = sc . nextInt ( ) ; while ( tysAqpi != 0 && b != 0 ) { int c = b ; b = tysAqpi % b ; tysAqpi = c ; } System . out . println ( tysAqpi + b ) ; } } import java . util . Scanner ; public class MlrwklLtcrx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MlrwklUhw = 0 ; String str = sc . next ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( str . charAt ( i ) == '+' ) MlrwklUhw ++ ; else MlrwklUhw -- ; } System . out . println ( MlrwklUhw ) ; } } import java . util . Scanner ; public class TeyDl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TeyJu = sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; String s = ( e - TeyJu <= k ) ? " Yay! " : " :( " ; System . out . println ( s ) ; } } import java . io . * ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; class lvbvhkZg { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; int LvbvhkJj = in . nextInt ( ) ; int H = in . nextInt ( ) ; int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; int r = in . nextInt ( ) ; if ( 0 <= x - r && x + r <= LvbvhkJj && 0 <= y - r && y + r <= H ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class VccbolJi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int VccbolVj = S . length ( ) ; String a = " AC " ; int b = 0 ; int sum = 0 ; int [ ] x = new int [ VccbolVj + 1 ] ; if ( S . charAt ( 0 ) != a . charAt ( 0 ) ) { System . out . println ( " WA " ) ; } else { for ( int i = 2 ; i <= VccbolVj - 2 ; i ++ ) { if ( S . charAt ( i ) == a . charAt ( 1 ) ) { break ; } if ( i == VccbolVj - 2 ) { System . out . println ( " WA " ) ; b = VccbolVj - 2 ; } } if ( b != VccbolVj - 2 ) { String US = S . toUpperCase ( ) ; for ( int i = 0 ; i < VccbolVj ; 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 VhobkOd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vhobkV = 0 ; int [ ] num = new int [ 9 ] ; for ( int i = 0 ; i < 9 ; i ++ ) { num [ i ] = sc . nextInt ( ) ; vhobkV += 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 ( vhobkV % 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 MbxkspYc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mbxkspF = sc . nextInt ( ) ; String ans = " No " ; int c = 0 ; int d = 0 ; while ( 4 * c + 7 * d <= mbxkspF ) { while ( 4 * c + 7 * d <= mbxkspF ) { if ( 4 * c + 7 * d == mbxkspF ) { ans = " Yes " ; break ; } else d ++ ; } c ++ ; d = 0 ; } System . out . println ( ans ) ; } } public class qnqrJjp { public void run ( java . io . InputStream in , java . io . PrintStream out ) { java . util . Scanner sc = new java . util . Scanner ( in ) ; int QnqrKitsq , h , x , y , r ; QnqrKitsq = sc . nextInt ( ) ; h = sc . nextInt ( ) ; x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; r = sc . nextInt ( ) ; if ( x >= r && y >= r && QnqrKitsq >= ( 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 CstDcp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; char [ ] chars = str . toCharArray ( ) ; for ( int cstQ = 0 ; cstQ < str . length ( ) ; cstQ ++ ) { if ( 'a' <= chars [ cstQ ] && chars [ cstQ ] <= 'z' ) chars [ cstQ ] = Character . toUpperCase ( chars [ cstQ ] ) ; else if ( 'A' <= chars [ cstQ ] && chars [ cstQ ] <= 'Z' ) chars [ cstQ ] = Character . toLowerCase ( chars [ cstQ ] ) ; } 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 LkqvGwe { static Scanner sc = new Scanner ( System . in ) ; static int lkqvZ = 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 = lkqvZ * lkqvZ + B * B - 2 * lkqvZ * B * Math . cos ( Math . toRadians ( kakudo ) ) ; double result = Math . sqrt ( dC ) ; System . out . print ( result ) ; } } import java . util . Scanner ; import java . util . Arrays ; class VnvdRiu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vnvdOc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( Math . max ( Math . max ( vnvdOc , b ) , c ) - Math . min ( Math . min ( vnvdOc , b ) , c ) ) ; } } import java . util . Scanner ; public class OkdcDreyc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int OkdcRo = solve ( S ) ; System . out . println ( OkdcRo ) ; } private static int solve ( String s ) { int OkdcRo = 0 ; char [ ] sn = s . toCharArray ( ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( sn [ i - 1 ] == sn [ i ] ) { OkdcRo ++ ; sn [ i ] = sn [ i ] == '0' ? '1' : '0' ; } } return OkdcRo ; } } import java . util . * ; public class VatvEljm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vatvRxy = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; int z = Integer . parseInt ( sc . next ( ) ) ; int work ; work = vatvRxy ; vatvRxy = y ; y = work ; work = vatvRxy ; vatvRxy = z ; z = work ; System . out . print ( vatvRxy ) ; System . out . print ( " " ) ; System . out . print ( y ) ; System . out . print ( " " ) ; System . out . print ( z ) ; } } import java . util . Scanner ; public class bhzqWg { 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 BhzqPlcp = Integer . parseInt ( lines [ 0 ] ) ; int B = Integer . parseInt ( lines [ 1 ] ) ; int plus = BhzqPlcp + B ; int minus = BhzqPlcp - B ; int multi = BhzqPlcp * 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 LqzlTu { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int lqzlI = Integer . parseInt ( scan . next ( ) ) ; int q = Integer . parseInt ( scan . next ( ) ) ; int sumTime = 0 ; Queue < Process > queue = new ArrayDeque < Process > ( ) ; for ( int i = 0 ; i < lqzlI ; 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 LqzlTu { String name ; int pTime ; public Process ( String name , int pTime ) { this . name = name ; this . pTime = pTime ; } } import java . util . * ; public class GtrDodqw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GtrLym = 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 + GtrLym - 1 ) / d ; if ( tk <= ao ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class WbzcTmi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int wbzcCret = 0 ; wbzcCret < 5 ; wbzcCret ++ ) { list . add ( Integer . parseInt ( sc . next ( ) ) ) ; } sc . close ( ) ; for ( int wbzcCret = 0 ; wbzcCret < 5 ; wbzcCret ++ ) { if ( list . get ( wbzcCret ) == 0 ) { int ans = wbzcCret + 1 ; System . out . println ( ans ) ; return ; } } } } import java . util . Scanner ; public class RkutoqWlaeu { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int RkutoqQka = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] ave = new int [ RkutoqQka ] ; 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 cpwloqLg { public static void main ( String [ ] args ) { int CpwloqOsle , n2 , n3 ; String str1 , str2 , str3 ; Scanner in = new Scanner ( System . in ) ; str1 = in . next ( ) ; str2 = in . next ( ) ; str3 = in . next ( ) ; CpwloqOsle = Integer . parseInt ( str1 ) ; n2 = Integer . parseInt ( str2 ) ; n3 = Integer . parseInt ( str3 ) ; if ( CpwloqOsle < 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 EfhqnqIuv { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int efhqnqAokq = in . nextInt ( ) ; int x = in . nextInt ( ) ; int t = in . nextInt ( ) ; int ans = efhqnqAokq / x ; if ( efhqnqAokq % x != 0 ) ans ++ ; ans *= t ; System . out . println ( ans ) ; } } import java . util . Scanner ; class dxbG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int DxbLrn , m , i , j ; int [ ] [ ] a = new int [ 100 ] [ 100 ] ; int [ ] b = new int [ 100 ] ; int [ ] c = new int [ 100 ] ; DxbLrn = scan . nextInt ( ) ; m = scan . nextInt ( ) ; for ( i = 0 ; i < DxbLrn ; 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 < DxbLrn ; 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 GgaOq { public static void main ( String [ ] args ) throws Exception { String ggaIrla = readLine ( ) ; String WA = " WA " ; String AC = " AC " ; if ( ggaIrla . startsWith ( " A " ) ) { if ( ggaIrla . substring ( 0 , 2 ) . indexOf ( " C " ) != - 1 || ggaIrla . endsWith ( " C " ) ) { System . out . println ( WA ) ; return ; } if ( ggaIrla . replace ( " C " , " " ) . length ( ) != ggaIrla . length ( ) - 1 ) { System . out . println ( WA ) ; return ; } String str1 = ggaIrla . 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 BrviAkk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int brviOuy = sc . nextInt ( ) ; ArrayList < Integer > array = new ArrayList < Integer > ( ) ; long ans = 0 ; for ( int i = 1 ; i <= brviOuy ; 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 TjofuuPwe { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int TjofuuJ = reader . nextInt ( ) ; int B = reader . nextInt ( ) ; int ans = Math . max ( TjofuuJ + TjofuuJ - 1 , B + B - 1 ) ; ans = Math . max ( ans , TjofuuJ + B ) ; System . out . print ( ans ) ; reader . close ( ) ; } } import java . util . Scanner ; public class ijtpfjHxa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int IjtpfjTs = 0 ; int b = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { char c = s [ i ] ; if ( i % 2 == 0 ) { if ( c == '0' ) IjtpfjTs ++ ; else b ++ ; } else { if ( c == '1' ) IjtpfjTs ++ ; else b ++ ; } } System . out . println ( Math . min ( IjtpfjTs , b ) ) ; } } import java . util . * ; public class NbngdiVerpde { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NbngdiCx = sc . nextInt ( ) ; int [ ] X = new int [ NbngdiCx ] ; for ( int i = 0 ; i < NbngdiCx ; i ++ ) { X [ i ] = sc . nextInt ( ) ; } boolean flag = true ; for ( int i = NbngdiCx - 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 BbjLx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int BbjJm = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ BbjJm ] ; int first = 0 ; int second = 0 ; int loc = 0 ; for ( int i = 0 ; i < BbjJm ; 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 < BbjJm ; j ++ ) { if ( j == loc ) { System . out . println ( second ) ; } else { System . out . println ( first ) ; } } } } import java . util . * ; public class WxwKge { 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 wxwLtx = 0 ; wxwLtx < array . length ; wxwLtx ++ ) { if ( wxwLtx % 2 == 0 && ( array [ wxwLtx ] == 'R' || array [ wxwLtx ] == 'U' || array [ wxwLtx ] == 'D' ) ) { ans = " Yes " ; } else if ( wxwLtx % 2 == 1 && ( array [ wxwLtx ] == 'L' || array [ wxwLtx ] == 'U' || array [ wxwLtx ] == 'D' ) ) { ans = " Yes " ; } else { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; class djqespCub { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char DjqespYgbe = sc . next ( ) . charAt ( 0 ) ; int d = DjqespYgbe + 1 ; char ans = ( char ) d ; System . out . println ( ans ) ; } } import java . util . * ; public class MolkUvzr { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int molkLevz = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int count = 0 ; if ( b != 1 ) { count = 1 ; } int sum = molkLevz ; while ( b > sum ) { sum += molkLevz - 1 ; count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class hogffdG { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; boolean HogffdAeow = 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 { HogffdAeow = false ; } } } System . out . println ( HogffdAeow ? po : ( po == 0 ) ? 0 : - 1 ) ; } } import java . util . * ; public class ShshWkrm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int shshJ = sc . nextInt ( ) ; String a1 ; String a2 ; a1 = sc . next ( ) ; a2 = sc . next ( ) ; String ans = " " ; for ( int i = 0 ; i < shshJ ; 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 jtgavsJu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JtgavsLmw = 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 XegfjWnr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XegfjWs = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; for ( int i = 0 ; i <= XegfjWs ; i ++ ) { if ( i * 2 + ( XegfjWs - 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 FjfgnWig { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FjfgnZry = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; if ( n == 0 ) { System . out . println ( FjfgnZry ) ; 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 = FjfgnZry ; while ( underPos == null ) { if ( p . contains ( startPos ) != true ) { underPos = startPos ; } startPos -- ; } startPos = FjfgnZry ; while ( upwardPos == null ) { if ( p . contains ( startPos ) != true ) { upwardPos = startPos ; } startPos ++ ; } int underDist = Math . abs ( FjfgnZry - underPos ) ; int upwardDist = Math . abs ( FjfgnZry - 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 FqyOpb { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; String patt = ob . next ( ) ; int fqyXtt = 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 ; } } fqyXtt = Math . max ( fqyXtt , temp ) ; } System . out . println ( fqyXtt ) ; ob . close ( ) ; } } import java . util . Scanner ; class itvbeBsy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; StringBuilder str = new StringBuilder ( ) ; while ( true ) { int ItvbeZprs = scan . nextInt ( ) ; int w = scan . nextInt ( ) ; if ( ItvbeZprs == 0 && w == 0 ) break ; for ( int i = 0 ; i < ItvbeZprs ; 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 zclxX { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; int ZclxBehoa = Integer . parseInt ( stdin . nextLine ( ) ) ; boolean boo = true ; int [ ] seq = new int [ ZclxBehoa ] ; if ( ZclxBehoa <= 100 ) { for ( int i = 0 ; i < ZclxBehoa ; i ++ ) { seq [ i ] = stdin . nextInt ( ) ; if ( seq [ i ] >= 0 && seq [ i ] <= 1000 ) { continue ; } else { boo = false ; break ; } } } if ( boo == true ) { for ( int j = ZclxBehoa ; 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 wizpufWaw { Scanner sc = new Scanner ( System . in ) ; void run ( ) { long WizpufSgru , y , z ; long first , second ; long tmp ; while ( sc . hasNext ( ) ) { first = sc . nextLong ( ) ; second = sc . nextLong ( ) ; WizpufSgru = first ; y = second ; if ( WizpufSgru < y ) { tmp = WizpufSgru ; WizpufSgru = y ; y = tmp ; } do { z = WizpufSgru % y ; WizpufSgru = y ; y = z ; } while ( z != 0 ) ; System . out . println ( WizpufSgru + " " + first * second / WizpufSgru ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; class EevOdds { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String S = sc . nextLine ( ) ; for ( int eevZgu = 0 ; eevZgu < S . length ( ) ; eevZgu ++ ) { if ( Character . isUpperCase ( S . charAt ( eevZgu ) ) ) { System . out . print ( Character . toLowerCase ( S . charAt ( eevZgu ) ) ) ; } else { System . out . print ( Character . toUpperCase ( S . charAt ( eevZgu ) ) ) ; } } System . out . println ( " " ) ; } } } import java . util . Scanner ; public class KflOr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kflZ = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int result2 = kflZ ; int result = 0 ; do { result2 = result2 / K ; result ++ ; } while ( result2 != 0 ) ; System . out . println ( result ) ; } } public class xidhZm { public static void main ( String [ ] args ) { java . util . Scanner sc = new java . util . Scanner ( System . in ) ; int XidhKv = sc . nextInt ( ) ; int [ ] x = new int [ XidhKv ] ; double sum = 0 ; int total = 0 ; for ( int i = 0 ; i < XidhKv ; i ++ ) { x [ i ] = sc . nextInt ( ) ; sum += x [ i ] ; } double val = sum / XidhKv ; val = Math . round ( val ) ; int avg = ( int ) val ; for ( int i = 0 ; i < XidhKv ; i ++ ) { int num = avg - x [ i ] ; num = num * num ; total += num ; } System . out . println ( total ) ; } } import java . util . * ; public class QptoEjt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qptoNqog = sc . nextInt ( ) ; int count = 0 ; int valLen = String . valueOf ( qptoNqog ) . length ( ) ; for ( int i = valLen ; i > 0 ; i -- ) { if ( i % 2 == 1 ) { if ( i == valLen ) { count += qptoNqog % Math . pow ( 10 , i - 1 ) + 1 ; count += ( ( qptoNqog / ( 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 MdkpmJje { static int mdkpmWhs = 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 ( mdkpmWhs ) ; } 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 ) mdkpmWhs ++ ; } } import java . util . Scanner ; public class rtkcTk { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int RtkcHh = stdIn . nextInt ( ) ; int A = stdIn . nextInt ( ) ; int B = stdIn . nextInt ( ) ; int z = 1 , y = 0 , x = 0 , ans = 0 ; while ( z <= RtkcHh ) { 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 XhmIwz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] nyu = sc . nextLine ( ) . split ( " " ) ; int XhmBo = Integer . parseInt ( nyu [ 0 ] ) ; int B = Integer . parseInt ( nyu [ 1 ] ) ; int C = Integer . parseInt ( nyu [ 2 ] ) ; int [ ] num = { XhmBo , 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 QwoygNdp { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int [ ] [ ] C = new int [ 3 ] [ 3 ] ; for ( int QwoygGq = 0 ; QwoygGq < 3 ; QwoygGq ++ ) { for ( int c = 0 ; c < 3 ; c ++ ) { C [ QwoygGq ] [ 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 QwoygGq = 0 ; QwoygGq < 3 ; QwoygGq ++ ) { for ( int c = 0 ; c < 3 ; c ++ ) { a2 [ QwoygGq ] [ c ] = C [ QwoygGq ] [ c ] - b [ c ] ; } } for ( int QwoygGq = 0 ; QwoygGq < 3 ; QwoygGq ++ ) { for ( int c = 1 ; c < 3 ; c ++ ) { if ( a2 [ QwoygGq ] [ c - 1 ] != a2 [ QwoygGq ] [ c ] ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class NfiCxjciz { 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 NfiNt = sc1 . nextInt ( ) ; Arrays . sort ( num ) ; for ( int i = 0 ; i < NfiNt ; i ++ ) { num [ 2 ] *= 2 ; } System . out . println ( num [ 0 ] + num [ 1 ] + num [ 2 ] ) ; sc1 . close ( ) ; } } import java . io . * ; public class AnpVdx { 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 AnpQbj = numbers . length - 1 ; AnpQbj >= 0 ; AnpQbj -- ) { System . out . print ( numbers [ AnpQbj ] ) ; } System . out . println ( ) ; } } } import java . util . Scanner ; public class LedpFx { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long LedpIi = Long . parseLong ( s . next ( ) ) ; System . out . println ( atack ( LedpIi ) ) ; } 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 nvzlxBfe { public static void main ( String [ ] args ) { FastReader f = new FastReader ( ) ; String line = f . nextLine ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( char NvzlxEt : line . toCharArray ( ) ) { if ( ! Character . isAlphabetic ( NvzlxEt ) ) { sb . append ( NvzlxEt ) ; } else if ( NvzlxEt < 97 ) { sb . append ( Character . toChars ( NvzlxEt + 32 ) ) ; } else { sb . append ( Character . toChars ( NvzlxEt - 32 ) ) ; } } System . out . println ( sb ) ; } static class nvzlxBfe { 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 JiaMyg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int jiaFe = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; if ( jiaFe > w ) System . out . println ( " safe " ) ; else System . out . println ( " unsafe " ) ; } static class JiaMyg { StringTokenizer st ; BufferedReader br ; public Scanner ( InputStream jiaFe ) { br = new BufferedReader ( new InputStreamReader ( jiaFe ) ) ; } 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 JtjLntv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jtjSzx = sc . nextInt ( ) ; String s = sc . next ( ) ; sc . close ( ) ; if ( ( jtjSzx + 2 ) % 2 != 0 ) { System . out . println ( " No " ) ; return ; } if ( jtjSzx == 2 ) { System . out . println ( s . charAt ( 0 ) == s . charAt ( 1 ) ? " Yes " : " No " ) ; return ; } System . out . println ( s . substring ( 0 , jtjSzx / 2 - 1 ) . equals ( s . substring ( jtjSzx / 2 , jtjSzx - 1 ) ) ? " Yes " : " No " ) ; } } import java . util . * ; public class ZlzjKap { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zlzjP = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int count1 = 0 ; int count2 = 0 ; if ( zlzjP >= 2 ) { count1 = ( zlzjP * ( zlzjP - 1 ) ) / 2 ; } if ( m >= 2 ) { count2 = ( m * ( m - 1 ) ) / 2 ; } System . out . println ( count1 + count2 ) ; } } import java . util . Scanner ; public class SilgaxHsml { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SilgaxJ = sc . nextInt ( ) ; double T = sc . nextDouble ( ) , A = sc . nextInt ( ) , temp = 60001 ; int ans = 0 ; for ( int i = 1 ; i <= SilgaxJ ; 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 uyvwtVev { 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 UslAmsgpv { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String S = sc . next ( ) ; boolean UslGf = true ; for ( int i = 0 ; i < S . length ( ) / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( S . length ( ) - i - 1 ) ) { UslGf = false ; break ; } } for ( int i = 0 ; i < S . length ( ) / 4 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( S . length ( ) / 2 - i - 1 ) ) { UslGf = false ; break ; } } System . out . println ( UslGf ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class EwnsjVi { public static void main ( String [ ] args ) { Scanner inputs = new Scanner ( System . in ) ; int ewnsjJgx = inputs . nextInt ( ) ; int x = inputs . nextInt ( ) ; int t = inputs . nextInt ( ) ; int takoyakiMade = 0 ; int timeTook = 0 ; do { timeTook += t ; takoyakiMade += x ; } while ( takoyakiMade < ewnsjJgx ) ; System . out . println ( timeTook ) ; } } import java . util . Scanner ; public class nolQad { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NolZvlpj = 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 EfyxLx { public static void main ( String [ ] args ) { int efyxIfcz ; Scanner in = new Scanner ( System . in ) ; efyxIfcz = Integer . parseInt ( in . next ( ) ) ; int cnt ; int ans = 0 ; for ( int i = 1 ; i <= efyxIfcz ; 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 RpfaxAyv { public static void main ( String [ ] args ) throws Exception { int RpfaxZv ; 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 ( ) ; RpfaxZv = Integer . parseInt ( line ) ; if ( isPrime ( RpfaxZv ) ) { prime . add ( RpfaxZv ) ; } } 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 IxkaVh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ixkaKqdu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int tmp = ixkaKqdu ; ixkaKqdu = b ; b = tmp ; tmp = ixkaKqdu ; ixkaKqdu = c ; c = tmp ; System . out . println ( ixkaKqdu + " " + b + " " + c ) ; } } import java . util . * ; public class PwwDnwagq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PwwVh = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] num = new int [ Q ] ; int [ ] count = new int [ PwwVh ] ; int t = 0 ; for ( int i = 0 ; i < Q ; i ++ ) { num [ i ] = sc . nextInt ( ) ; count [ num [ i ] - 1 ] ++ ; } for ( int j = 0 ; j < PwwVh ; j ++ ) { if ( ( count [ j ] + K - Q ) > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class CzibBnkczx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long CzibTse = sc . nextLong ( ) ; long t = ( long ) Math . sqrt ( CzibTse ) ; long a = 1 ; for ( long i = t ; 1 <= i ; i -- ) { if ( CzibTse % i == 0 ) { a = CzibTse / i ; break ; } } System . out . print ( ( CzibTse / a ) + a - 2 ) ; } } import java . util . Scanner ; public class FptbtJdupx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FptbtP = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( FptbtP * y ) ; sc . close ( ) ; } } import java . util . * ; public class bihijYb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) , b = sc . next ( ) , c = sc . next ( ) ; char BihijNlzc = 'a' ; int ac = 0 , bc = 0 , cc = 0 ; while ( true ) { if ( BihijNlzc == 'a' ) { if ( ac == a . length ( ) ) { System . out . println ( " A " ) ; break ; } BihijNlzc = a . charAt ( ac ) ; ac ++ ; } else if ( BihijNlzc == 'b' ) { if ( bc == b . length ( ) ) { System . out . println ( " B " ) ; break ; } BihijNlzc = b . charAt ( bc ) ; bc ++ ; } else if ( BihijNlzc == 'c' ) { if ( cc == c . length ( ) ) { System . out . println ( " C " ) ; break ; } BihijNlzc = c . charAt ( cc ) ; cc ++ ; } } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class WbgjjVuwg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Set < Integer > set = new HashSet < > ( ) ; for ( int WbgjjCs = 0 ; WbgjjCs < 3 ; WbgjjCs ++ ) set . add ( sc . nextInt ( ) ) ; System . out . println ( set . size ( ) == 2 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class sbbrA { public static void main ( final String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int SbbrQopbj = scanner . nextInt ( ) ; Point currentPoint = new Point ( 0 , 0 ) ; for ( int i = 0 ; i < SbbrQopbj ; 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 sbbrA { int x ; int y ; Point ( final int x , final int y ) { this . x = x ; this . y = y ; } } } import java . util . * ; public class qvcrUnf { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int QvcrLv = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = QvcrLv + B ; ans = ans < QvcrLv - B ? QvcrLv - B : ans ; ans = ans < QvcrLv * B ? QvcrLv * B : ans ; System . out . print ( ans ) ; } } import java . io . * ; import java . util . * ; public class xhvuyJo { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int XhvuyMdtu = Integer . parseInt ( st . nextToken ( ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; int [ ] y = new int [ XhvuyMdtu ] ; int p = 0 ; while ( st . hasMoreTokens ( ) ) { y [ p ] = Integer . parseInt ( st . nextToken ( ) ) ; p ++ ; } Arrays . sort ( y ) ; System . out . println ( y [ XhvuyMdtu - 1 ] - y [ 0 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class udmkJ { 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 udmkJ { int UdmkUhij ; int cnt ; public void init ( ) { UdmkUhij = 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 < UdmkUhij ; } public void readBody ( String str ) { cnt ++ ; } public void solve ( ) { } } import java . util . * ; public class IdqjuFt { public static void main ( String [ ] args ) { ALDS1_1_A ( ) ; } public static void ALDS1_1_A ( ) { Scanner sc = new Scanner ( System . in ) ; int IdqjuLaw = sc . nextInt ( ) ; int [ ] a = new int [ IdqjuLaw ] ; for ( int i = 0 ; i < IdqjuLaw ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < IdqjuLaw ; i ++ ) { for ( int j = 0 ; j < IdqjuLaw ; j ++ ) { if ( j == IdqjuLaw - 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 < IdqjuLaw ; j ++ ) { if ( j == IdqjuLaw - 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 TqpcjpGi { 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 tqpcjpHsy = 0 ; tqpcjpHsy < s . length ( ) ; tqpcjpHsy ++ ) { if ( s . charAt ( tqpcjpHsy ) == 'A' ) { A . add ( tqpcjpHsy ) ; } else if ( s . charAt ( tqpcjpHsy ) == 'Z' ) { Z . add ( tqpcjpHsy ) ; } } System . out . println ( Z . last ( ) - A . first ( ) + 1 ) ; } } import java . util . Scanner ; class TxwndtOooe { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int TxwndtR ; double t , a ; TxwndtR = scan . nextInt ( ) ; t = scan . nextDouble ( ) ; a = scan . nextDouble ( ) ; double [ ] h = new double [ TxwndtR ] ; for ( int i = 0 ; i < TxwndtR ; i ++ ) { h [ i ] = scan . nextDouble ( ) ; } double min = 99999999.0 ; double x ; int ans = 0 ; for ( int i = 0 ; i < TxwndtR ; 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 RomKpkw { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; if ( scanner . hasNextLine ( ) ) { String [ ] array = scanner . nextLine ( ) . split ( " " ) ; long RomY = Integer . parseInt ( array [ 0 ] ) ; long b = Integer . parseInt ( array [ 1 ] ) ; long c = Integer . parseInt ( array [ 2 ] ) ; int k = Integer . parseInt ( scanner . nextLine ( ) ) ; if ( RomY > b && RomY > c ) { for ( int i = 0 ; i < k ; ++ i ) { RomY *= 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 ( RomY + b + c ) ; } } } import java . util . Scanner ; public class LixnUylq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String lixnXzcd = scan . next ( ) ; String anser = " No " ; if ( lixnXzcd . contains ( " A " ) && lixnXzcd . contains ( " B " ) ) { anser = " Yes " ; } System . out . println ( anser ) ; } } import java . util . Scanner ; public class LyskZqp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LyskM = Integer . parseInt ( sc . next ( ) ) ; LyskM += Integer . parseInt ( sc . next ( ) ) ; LyskM += Integer . parseInt ( sc . next ( ) ) ; if ( LyskM > 21 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } sc . close ( ) ; } } import java . util . * ; public class SfiEsbj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sfiUofl = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int a = - 1 ; int b = - 1 ; int c = - 1 ; for ( int i = 0 ; i <= sfiUofl ; i ++ ) { for ( int j = 0 ; j <= sfiUofl ; j ++ ) { if ( y / 1000 - 10 * i - 5 * j == sfiUofl - j - i && sfiUofl - j - i >= 0 ) { a = i ; b = j ; c = sfiUofl - i - j ; break ; } } } System . out . println ( a + " " + b + " " + c ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class NqldbwJx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int NqldbwKos = scan . nextInt ( ) ; if ( NqldbwKos == 1 ) { System . out . println ( 1 ) ; return ; } int answer = 0 ; while ( NqldbwKos != 1 ) { answer += 1 ; NqldbwKos /= 2 ; } System . out . println ( ( int ) Math . pow ( 2 , answer ) ) ; } } import java . util . * ; import static java . lang . Math . * ; import java . math . BigInteger ; public class fvdjzN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; for ( int FvdjzXt = 0 ; FvdjzXt < n . length ( ) ; FvdjzXt ++ ) { if ( n . charAt ( FvdjzXt ) == '1' ) System . out . print ( 9 ) ; if ( n . charAt ( FvdjzXt ) == '9' ) System . out . print ( 1 ) ; } } } import java . io . * ; class VspXzp { 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 VspE = 0 , p = 0 ; VspE < cmd . length ; VspE ++ ) { if ( cmd [ VspE ] . equals ( " + " ) ) { p -- ; S [ p - 1 ] += S [ p ] ; } else if ( cmd [ VspE ] . equals ( " - " ) ) { p -- ; S [ p - 1 ] -= S [ p ] ; } else if ( cmd [ VspE ] . equals ( " * " ) ) { p -- ; S [ p - 1 ] *= S [ p ] ; } else { S [ p ] = Integer . parseInt ( " " + cmd [ VspE ] ) ; 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 OltbmHpgaoj { 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 OltbmKu = 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 ++ ; } OltbmKu = Math . min ( OltbmKu , na ) ; } System . out . println ( OltbmKu ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class BfbgNdfrv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BfbgSyz = sc . nextInt ( ) ; double T = sc . nextDouble ( ) ; int A = sc . nextInt ( ) ; double [ ] H = new double [ BfbgSyz ] ; for ( int i = 0 ; i < BfbgSyz ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } double tmp = 2000000000 ; double ans = 2000000000 ; int res = 0 ; for ( int i = 0 ; i < BfbgSyz ; 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 IywgeUzudde { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int IywgeYlz = in . nextInt ( ) ; int [ ] d = new int [ IywgeYlz ] ; for ( int i = 0 ; i < d . length ; ++ i ) { d [ i ] = in . nextInt ( ) ; } Arrays . sort ( d ) ; int mid1 = d [ IywgeYlz / 2 - 1 ] ; int mid2 = d [ IywgeYlz / 2 ] ; System . out . println ( mid2 - mid1 ) ; } } } import java . util . Scanner ; public class UibwraWozbiq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String input = scan . nextLine ( ) ; int UibwraJqk = Integer . parseInt ( input . split ( " " ) [ 0 ] ) ; double d = Integer . parseInt ( input . split ( " " ) [ 1 ] ) ; int c = 0 ; int [ ] [ ] x = new int [ UibwraJqk ] [ 2 ] ; for ( int i = 0 ; i < UibwraJqk ; 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 QwwVkx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qwwNyld = sc . nextInt ( ) ; int int100 = sc . nextInt ( ) ; int int50 = sc . nextInt ( ) ; int total = sc . nextInt ( ) ; int count = 0 ; for ( int a = 0 ; a <= qwwNyld ; 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 ynkNrg { 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 fytmxyVho { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FytmxyFnnom = 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 = FytmxyFnnom - 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 SdfumhGiky { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int SdfumhC = scan . nextInt ( ) , l = scan . nextInt ( ) ; ArrayList < String > dict = new ArrayList < String > ( ) ; for ( int i = 0 ; i < SdfumhC ; i ++ ) { dict . add ( scan . next ( ) ) ; } Collections . sort ( dict ) ; String result = " " ; for ( int i = 0 ; i < SdfumhC ; i ++ ) { result += dict . get ( i ) ; } System . out . println ( result ) ; } } import java . util . Scanner ; public class WrofEco { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; int WrofF = std . nextInt ( ) ; int b = std . nextInt ( ) ; if ( WrofF >= 13 ) { System . out . println ( b ) ; } else if ( WrofF <= 5 ) { System . out . println ( " 0 " ) ; } else { System . out . println ( b / 2 ) ; } } } import java . util . Scanner ; public class XvpGvz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xvpVd = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; if ( a * xvpVd < b ) ans = a * xvpVd ; else ans = b ; System . out . println ( ans ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class ysgN { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int YsgOo = scanner . nextInt ( ) ; int [ ] nums = new int [ YsgOo ] ; for ( int i = 0 ; i < YsgOo ; i ++ ) nums [ i ] = scanner . nextInt ( ) ; bubbleSort ( YsgOo , nums ) ; } private static void bubbleSort ( int YsgOo , int [ ] a ) { boolean flg = true ; int i = 0 ; int sw = 0 ; while ( flg ) { flg = false ; for ( int j = YsgOo - 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 ObwlzkUannk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; double ObwlzkT = Double . parseDouble ( br . readLine ( ) ) ; System . out . printf ( " %.6f %.6f " , ObwlzkT * ObwlzkT * Math . PI , 2 * ObwlzkT * Math . PI ) ; } } import java . util . * ; public class hmecQxt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] time = new int [ 5 ] , wait = new int [ 5 ] ; int HmecFb = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { time [ i ] = sc . nextInt ( ) ; wait [ i ] = ( 10 - time [ i ] % 10 ) % 10 ; HmecFb += time [ i ] + wait [ i ] ; } int idx = maxIdx ( wait ) ; HmecFb -= wait [ idx ] ; System . out . println ( HmecFb ) ; } 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 hpygucG { public static String check ( int x , int y ) { return " " ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int HpygucTpz = in . nextInt ( ) ; int count = 0 ; int vit = 0 ; while ( HpygucTpz -- != 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 rycXth { 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 RycZj = 0 ; while ( money . compareTo ( k ) == - 1 ) { RycZj += 1 ; money = money . multiply ( a ) ; BigDecimal bd1 = money . setScale ( 0 , BigDecimal . ROUND_DOWN ) ; money = bd1 ; } System . out . println ( RycZj ) ; } } import java . util . * ; import java . io . * ; public class melalIaf { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; String s = sc . next ( ) ; int MelalUyt = 0 ; int run = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == 'R' ) { run ++ ; } else { MelalUyt = Math . max ( MelalUyt , run ) ; run = 0 ; } } MelalUyt = Math . max ( MelalUyt , run ) ; out . println ( MelalUyt ) ; out . close ( ) ; } public static class melalIaf { 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 PxudwCq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PxudwRo = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] L = new int [ PxudwRo + 1 ] ; L [ 0 ] = 0 ; for ( int i = 1 ; i < PxudwRo + 1 ; i ++ ) { L [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; System . out . println ( Bounding ( PxudwRo + 1 , X , L , 0 , 0 ) ) ; } public static int Bounding ( int PxudwRo , int X , int [ ] L , int index , int sum ) { if ( PxudwRo <= index ) { return 0 ; } if ( sum + L [ index ] <= X ) { return 1 + Bounding ( PxudwRo , X , L , index + 1 , sum + L [ index ] ) ; } return 0 ; } } import java . util . HashSet ; import java . util . Scanner ; public class LbbuiGdk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lbbuiJi = sc . nextInt ( ) ; HashSet < Integer > set = new HashSet < > ( ) ; for ( int i = 0 ; i < lbbuiJi ; i ++ ) { set . add ( sc . nextInt ( ) ) ; } System . out . println ( set . size ( ) ) ; } } import java . util . * ; public class QwplyDcia { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int qwplyBeqb = Integer . parseInt ( sc . next ( ) ) ; if ( qwplyBeqb < 105 ) { System . out . println ( 0 ) ; } else if ( qwplyBeqb < 135 ) { System . out . println ( 1 ) ; } else if ( qwplyBeqb < 165 ) { System . out . println ( 2 ) ; } else if ( qwplyBeqb < 189 ) { System . out . println ( 3 ) ; } else if ( qwplyBeqb < 195 ) { System . out . println ( 4 ) ; } else { System . out . println ( 5 ) ; } } } import java . util . Scanner ; public class pjwclnT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String color1 = sc . next ( ) ; sc . next ( ) ; int PjwclnZpnlj = sc . nextInt ( ) ; int color2Cnt = sc . nextInt ( ) ; String disposed = sc . next ( ) ; if ( disposed . equals ( color1 ) ) { System . out . printf ( " %d %d " , PjwclnZpnlj - 1 , color2Cnt ) ; return ; } System . out . printf ( " %d %d " , PjwclnZpnlj , color2Cnt - 1 ) ; } } import java . io . * ; class esfWra { 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 EsfAol = 0 ; EsfAol < ch . length ; EsfAol ++ ) { if ( Character . isUpperCase ( ch [ EsfAol ] ) ) { ch [ EsfAol ] = Character . toLowerCase ( ch [ EsfAol ] ) ; } else ch [ EsfAol ] = Character . toUpperCase ( ch [ EsfAol ] ) ; } for ( int EsfAol = 0 ; EsfAol < ch . length ; EsfAol ++ ) { System . out . print ( ch [ EsfAol ] ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class SnpTt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SnpT = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int s = 0 ; for ( int i = 1 ; i <= SnpT ; i ++ ) { s = s + l + i - 1 ; } int a = 0 ; for ( int i = 1 ; i <= SnpT ; i ++ ) { if ( l - 1 + i == 0 ) { a = i ; } } if ( a == 0 ) { if ( l * l > ( l + SnpT - 1 ) * ( l + SnpT - 1 ) ) { a = SnpT ; } else { a = 1 ; } } System . out . println ( s - l + 1 - a ) ; sc . close ( ) ; } } import java . util . * ; class VpdzQptu { final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int vpdzGyki = sc . nextInt ( ) ; Set < Long > set = new HashSet < > ( ) ; for ( int i = 0 ; i < vpdzGyki ; 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 TcglJkqc { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String input = br . readLine ( ) ; for ( int tcglX = 0 ; tcglX < input . length ( ) ; tcglX ++ ) { char a = input . charAt ( tcglX ) ; 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 YbsFsoehy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long YbsDzy = sc . nextLong ( ) ; for ( long j = YbsDzy ; j < 1000000 ; j ++ ) { int count = 0 ; for ( long i = 2 ; i < YbsDzy ; i ++ ) { if ( YbsDzy % i == 0 ) { count ++ ; } } if ( count == 0 ) { System . out . println ( YbsDzy ) ; System . exit ( 0 ) ; } YbsDzy ++ ; } } } import java . util . Scanner ; public class QsucUsl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int QsucB = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != t . charAt ( i ) ) { QsucB ++ ; } } System . out . println ( QsucB ) ; } } import java . util . Scanner ; public class GbdqVjuuz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] str ; str = new String [ 3 ] ; int GbdqH , num2 , Ans ; Ans = 0 ; for ( int i = 1 ; ; i ++ ) { str [ 0 ] = in . next ( ) ; str [ 1 ] = in . next ( ) ; str [ 2 ] = in . next ( ) ; GbdqH = Integer . parseInt ( str [ 0 ] ) ; num2 = Integer . parseInt ( str [ 2 ] ) ; if ( str [ 1 ] . equals ( " ? " ) ) { break ; } else { if ( str [ 1 ] . equals ( " + " ) ) { Ans = GbdqH + num2 ; } if ( str [ 1 ] . equals ( " - " ) ) { Ans = GbdqH - num2 ; } if ( str [ 1 ] . equals ( " * " ) ) { Ans = GbdqH * num2 ; } if ( str [ 1 ] . equals ( " / " ) ) { Ans = GbdqH / num2 ; } System . out . println ( Ans ) ; } } } } import java . util . Scanner ; public class VjicSqw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VjicVde = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= 9 ; i ++ ) { for ( int j = 1 ; j <= 9 ; j ++ ) { if ( i * j == VjicVde ) { count = 200 ; } else { count ++ ; } } } if ( count >= 200 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; class CqcQcdhi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double CqcJqg = sc . nextDouble ( ) ; double t = sc . nextDouble ( ) ; double s = sc . nextDouble ( ) ; double sum = CqcJqg / s ; if ( sum <= t ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . * ; import java . io . * ; public class opapFdh { 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 OpapBmcmc = 0 ; OpapBmcmc < Integer . parseInt ( turn ) ; OpapBmcmc ++ ) { 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 PhqQmc { 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 phqP = 0 ; phqP < c . length ; phqP ++ ) c [ phqP ] = 'x' ; pw . println ( c ) ; pw . flush ( ) ; pw . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class LxellkLxfl { public static void main ( String [ ] args ) { try { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String lxellkMak = stdReader . readLine ( ) ; String [ ] inputStr = lxellkMak . 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 ehpqqeDok { public static void main ( String [ ] args ) { BufferedReader kb = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String [ ] str = kb . readLine ( ) . split ( " " ) ; int EhpqqeDxurg = 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 < EhpqqeDxurg ; 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 HbrduvXmc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hbrduvYpc = 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 ( hbrduvYpc - 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 JlwaWyqvv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JlwaH = 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 NsbGeb { 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 NsbLw = 0 ; NsbLw < n ; NsbLw ++ ) { arr [ NsbLw ] = ipar ( ) ; } return arr ; } public long lpar ( ) { return Long . parseLong ( tok . nextToken ( ) ) ; } public long [ ] lapar ( int n ) { long [ ] arr = new long [ n ] ; for ( int NsbLw = 0 ; NsbLw < n ; NsbLw ++ ) { arr [ NsbLw ] = 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 SrxxYlm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double srxxTb = scanner . nextDouble ( ) ; System . out . println ( String . format ( " %.5f " , Math . pow ( srxxTb , ( double ) 2 ) * Math . PI ) + " " + String . format ( " %.5f " , srxxTb * ( double ) 2 * Math . PI ) ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; public class VbygPgda { static class VbygPgda { 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 vbygL = ob . nextInt ( ) ; HashMap < String , Integer > map = new HashMap < > ( ) ; int count = 0 ; for ( int i = 0 ; i < vbygL ; i ++ ) { String s1 = ob . next ( ) ; if ( ! map . containsKey ( s1 ) ) { map . put ( s1 , 0 ) ; count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class gbyjgnL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double GbyjgnDm = sc . nextDouble ( ) ; double odd = 0 ; double notOdd = 0 ; for ( int i = 1 ; i <= GbyjgnDm ; i ++ ) { if ( i % 2 == 0 ) { notOdd ++ ; } else { odd ++ ; } } System . out . println ( odd / GbyjgnDm ) ; } } import java . util . Scanner ; public class hfqqhHnx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int HfqqhBdwt = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int total = 0 ; for ( int i = HfqqhBdwt ; 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 JqiUvh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int JqiU = scanner . nextInt ( ) ; int X = scanner . nextInt ( ) ; int s = X - ( JqiU - 1 ) ; int e = X + ( JqiU - 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 DjoEmmn { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] lines = br . readLine ( ) . split ( " " ) ; int djoQvpw = Integer . parseInt ( lines [ 0 ] ) ; int m = Integer . parseInt ( lines [ 1 ] ) ; int [ ] rowSum = new int [ m ] ; for ( int i = 0 ; i < djoQvpw ; 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 ynuTs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long YnuBqcwd = sc . nextLong ( ) ; long H = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; double ans = ( YnuBqcwd * H ) / 2.0 ; int can = 0 ; if ( x * 2 == YnuBqcwd && y * 2 == H ) { can = 1 ; } System . out . println ( ans + " " + can ) ; } } import java . util . Scanner ; public class BpquNwrun { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long BpquJ = scan . nextInt ( ) ; long B = scan . nextInt ( ) ; long gcd = GCD ( BpquJ , B ) ; long lcm = LCM ( BpquJ , 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 bupIab { final static long BupZshm = 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 XcmacNp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XcmacHx = sc . nextInt ( ) ; Integer [ ] ans = new Integer [ XcmacHx ] ; for ( int n = 0 ; n < XcmacHx ; 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 ( XcmacHx - sunuke ) ; } } } import java . util . Scanner ; public class GmovsUa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GmovsO = Integer . parseInt ( sc . next ( ) ) ; int [ ] ans = new int [ GmovsO ] ; for ( int i = 0 ; i < GmovsO ; 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 AczPj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; sc . close ( ) ; String [ ] S = s . split ( " " ) ; int aczTrjz = Integer . parseInt ( S [ 0 ] ) ; int b = Integer . parseInt ( S [ 1 ] ) ; int count = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( aczTrjz > b ) { count += aczTrjz ; aczTrjz -- ; } else { count += b ; b -- ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class ydcMox { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YdcUp = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] [ ] matrix = new int [ YdcUp ] [ c ] ; for ( int i = 0 ; i < YdcUp ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { matrix [ i ] [ j ] = sc . nextInt ( ) ; } } int rc_sum = 0 ; for ( int i = 0 ; i < YdcUp ; 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 [ YdcUp - 1 ] [ j ] + " " ) ; } System . out . println ( rc_sum ) ; } } import java . util . Scanner ; import java . util . regex . * ; class lqxDrq { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) . useDelimiter ( " [ \t , \n ] " ) ; int LqxMja = stdin . nextInt ( ) ; int line = stdin . nextInt ( ) ; int [ ] nums = new int [ LqxMja + 1 ] ; for ( int i = 1 ; i <= LqxMja ; 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 <= LqxMja ; i ++ ) { System . out . println ( nums [ i ] ) ; } } } import java . util . Scanner ; public class WdkNxv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] [ ] BigHouse = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int wdkN = 0 ; wdkN < 4 ; wdkN ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { BigHouse [ wdkN ] [ j ] [ k ] = 0 ; } } } int order = sc . nextInt ( ) ; for ( int wdkN = 0 ; wdkN < order ; wdkN ++ ) { 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 wdkN = 0 ; wdkN < 4 ; wdkN ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { System . out . print ( " " + BigHouse [ wdkN ] [ j ] [ k ] ) ; } System . out . println ( ) ; } if ( wdkN != 3 ) { System . out . println ( " #################### " ) ; } } } } import java . util . * ; public class ZstmxwOuv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long zstmxwIc = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = a + b ; long p = zstmxwIc / c ; long q = zstmxwIc % c ; if ( q > a ) { q = a ; } long ans = a * p + q ; System . out . println ( ans ) ; } } import java . util . Scanner ; class zledttBkf { public void cubic ( ) { Scanner sc = new Scanner ( System . in ) ; int ZledttPom = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; String out = " No " ; if ( ZledttPom < 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 TmxhBx { 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 TmxhBx { public String anotherSolve ( String input ) { List < Integer > inputList = new ArrayList < Integer > ( ) ; int tmxhHbl = 0 ; int seven = 0 ; for ( String s : input . split ( " " ) ) { if ( Integer . parseInt ( s ) == 5 ) { tmxhHbl ++ ; } else if ( Integer . parseInt ( s ) == 7 ) { seven ++ ; } } if ( tmxhHbl == 2 && seven == 1 ) { return " YES " ; } else { return " NO " ; } } } } import java . util . Scanner ; public class PuhkwvEee { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; char [ ] ca = str . toCharArray ( ) ; for ( int PuhkwvO = 0 ; PuhkwvO < ca . length ; PuhkwvO ++ ) { System . out . print ( ca [ ca . length - 1 - PuhkwvO ] ) ; } System . out . println ( ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class RtxmOs { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int rtxmB = sc . nextInt ( ) ; int [ ] d = nextIntArray ( sc , rtxmB ) ; sc . close ( ) ; int ans = 0 ; for ( int i = 0 ; i < rtxmB - 1 ; i ++ ) { for ( int j = i + 1 ; j < rtxmB ; 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 ZyxrveRp { public static void main ( String [ ] args ) { Scanner In = new Scanner ( System . in ) ; int zyxrveIvq ; do { zyxrveIvq = In . nextInt ( ) ; } while ( zyxrveIvq <= 2 && zyxrveIvq >= 200000 ) ; int [ ] a = new int [ zyxrveIvq ] ; for ( int i = 0 ; i < zyxrveIvq ; 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 <= zyxrveIvq - 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 tthcbX { public static void main ( String [ ] args ) { int TthcbQmg = 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 ++ ) { TthcbQmg += input [ i + 1 ] - input [ i ] ; } System . out . println ( TthcbQmg ) ; } } import java . util . * ; public class WhzOg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int whzY = sc . nextInt ( ) ; int [ ] array = new int [ whzY ] ; long count = 0 ; for ( int i = 0 ; i < whzY ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < ( whzY - 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 ZiatWfyf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZiatX = sc . nextInt ( ) ; int otoshidama = sc . nextInt ( ) ; int x = - 1 ; int y = - 1 ; int z = - 1 ; boolean isFinish = false ; for ( int i = 0 ; i <= ZiatX ; i ++ ) { for ( int j = 0 ; j <= ZiatX ; j ++ ) { if ( ZiatX - i - j >= 0 && i + j + ( ZiatX - i - j ) == ZiatX ) { if ( i * 10000 + j * 5000 + ( ZiatX - i - j ) * 1000 == otoshidama ) { x = i ; y = j ; z = ZiatX - i - j ; isFinish = true ; break ; } else if ( ZiatX - i - j < 0 ) { break ; } } } if ( isFinish ) { break ; } } System . out . println ( x + " " + y + " " + z ) ; } } import java . util . Scanner ; public class lsqlyAlr { private static final String LsqlyGx = " 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 LsqlyGx : r = CLOUDY ; break ; case CLOUDY : r = RAINY ; break ; case RAINY : r = LsqlyGx ; break ; default : break ; } System . out . println ( r ) ; sc . close ( ) ; } } import java . util . Scanner ; public class HpjpuAarm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HpjpuRn = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; if ( HpjpuRn != 1 && Y != 1 ) System . out . println ( 1 ) ; else if ( HpjpuRn != 2 && Y != 2 ) System . out . println ( 2 ) ; else System . out . println ( 3 ) ; } } import java . util . Scanner ; public class wpnXu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String WpnAi = sc . next ( ) ; char [ ] c = WpnAi . toCharArray ( ) ; System . out . println ( ( char ) ( c [ 0 ] + 0x01 ) ) ; sc . close ( ) ; } } import java . math . BigInteger ; import java . util . Scanner ; public class TmexabZz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String tmexabSfum = scan . nextLine ( ) ; scan . close ( ) ; String [ ] substr = tmexabSfum . 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 UmtjzwDc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int umtjzwRp = sc . nextInt ( ) ; int [ ] p = new int [ umtjzwRp ] ; for ( int i = 0 ; i < umtjzwRp ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int min = umtjzwRp + 1 ; int ans = 0 ; for ( int i = 0 ; i < umtjzwRp ; i ++ ) { if ( p [ i ] < min ) { min = p [ i ] ; ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class YlcTifl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ylcRvrr = sc . nextInt ( ) ; double Ad = ( double ) ylcRvrr ; 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 LkzCip { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int LkzXid = Integer . parseInt ( sc . next ( ) ) ; final int K = Integer . parseInt ( sc . next ( ) ) ; int result = 0 ; int [ ] pricelist = new int [ LkzXid ] ; for ( int i = 0 ; i < LkzXid ; 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 VnjvtDjow { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; int VnjvtVp = 0 ; for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = j + 1 ; k < S . length ( ) ; k ++ ) { if ( S . charAt ( j ) == S . charAt ( k ) ) { VnjvtVp ++ ; } } } if ( VnjvtVp == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class HsakhVudo { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int HsakhRia = in . nextInt ( ) ; int M = in . nextInt ( ) ; long sum = 0 ; sum = 1 ; sum *= HsakhRia ; sum *= ( HsakhRia - 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 CusjzOtc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cusjzU = scan . nextInt ( ) ; int price = scan . nextInt ( ) ; if ( cusjzU >= 13 ) { System . out . println ( price ) ; } else if ( cusjzU >= 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 PhxeZr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int PhxeWu = scan . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < PhxeWu ; 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 LapvNxx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lapvN = sc . nextInt ( ) ; sc . close ( ) ; boolean can = false ; for ( int i = 0 ; i < 25 ; ++ i ) { for ( int j = 0 ; j < 25 ; ++ j ) { if ( lapvN == 4 * i + 7 * j ) { can = true ; } } } if ( can == true ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . Scanner ; class pkaFum { 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 PkaLjnci = scn . nextInt ( ) ; if ( anntena [ 4 ] - anntena [ 0 ] > PkaLjnci ) { System . out . println ( " :( " ) ; } else { System . out . println ( " Yay! " ) ; } } } import java . util . Scanner ; public class WefjdfWpzwl { 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 WefjdfZ = sc . nextInt ( ) ; for ( int i = 0 ; i < WefjdfZ ; 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 UwrndIhkl { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; double uwrndMnb = reader . nextDouble ( ) ; System . out . println ( 2 * uwrndMnb * 3.14159265 ) ; } } import java . util . Scanner ; import java . lang . Math ; public class qqjkgR { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QqjkgTux ; double [ ] ans = new double [ 1000 ] ; int k = 0 ; while ( true ) { QqjkgTux = scan . nextInt ( ) ; if ( QqjkgTux == 0 ) break ; int [ ] a = new int [ QqjkgTux ] ; int sum = 0 ; for ( int i = 0 ; i < QqjkgTux ; i ++ ) { a [ i ] = scan . nextInt ( ) ; sum += a [ i ] ; } double ave = ( double ) sum / QqjkgTux ; double var = 0 ; for ( int i = 0 ; i < QqjkgTux ; i ++ ) { var = var + ( ( a [ i ] - ave ) * ( a [ i ] - ave ) / QqjkgTux ) ; } 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 nvjsfwTe { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int NvjsfwVzsjh = 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 LfbnaVki { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lfbnaDbv , h , x , y , r ; lfbnaDbv = sc . nextInt ( ) ; h = sc . nextInt ( ) ; x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; r = sc . nextInt ( ) ; if ( x + r > lfbnaDbv || y + r > h || x - r < 0 || y - r < 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; class aduE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String AduKvhd = sc . nextLine ( ) ; AduKvhd = AduKvhd . replace ( " 2017/ " , " 2018/ " ) ; System . out . println ( AduKvhd ) ; } } import java . util . Scanner ; public class UhxokArlv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uhxokMe = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sc . close ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= uhxokMe ; i ++ ) { int cnt = 0 ; double p = i ; while ( p < K ) { cnt ++ ; p *= 2.0 ; } ans += 1.0 / uhxokMe * Math . pow ( 0.5 , cnt ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class ytnvTx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YtnvCy = 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 < YtnvCy ; 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 NzxmyLkv { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int nzxmyQoo = in . nextInt ( ) ; int r = solve ( nzxmyQoo ) ; System . out . println ( r ) ; } private static int solve ( int nzxmyQoo ) { if ( nzxmyQoo == 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 >= nzxmyQoo ) return i ; } } } } import java . util . Scanner ; public class asmwvsVxl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; long AsmwvsTgdpq = sc . nextLong ( ) ; if ( S . length ( ) == 1 ) { System . out . println ( S ) ; return ; } int i = 0 ; while ( i < S . length ( ) && S . charAt ( i ) == '1' ) { i ++ ; } if ( AsmwvsTgdpq <= i ) { System . out . println ( 1 ) ; return ; } System . out . print ( S . charAt ( i ) ) ; } } import java . util . * ; public class YkkhBoydpv { static void swap ( int [ ] A , int i , int j ) { int YkkhQ = A [ i ] ; A [ i ] = A [ j ] ; A [ j ] = YkkhQ ; } 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 ZfmfLlttyw { 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 ZfmfXir = 0 ; ZfmfXir < str . length ; ZfmfXir ++ ) { sb . setLength ( 0 ) ; for ( int j = ZfmfXir ; j < ZfmfXir + 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 ( ZfmfXir == str . length - 1 ) { System . out . println ( " No " ) ; } } } } import java . util . * ; public class YmtweEx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; String r = " " ; for ( char ymtweRmli : n . toCharArray ( ) ) { r += solve ( ymtweRmli ) ; } System . out . print ( r ) ; } static char solve ( char ymtweRmli ) { switch ( ymtweRmli ) { case '1' : return '9' ; case '9' : return '1' ; default : return ymtweRmli ; } } } import java . util . Scanner ; public class UzxyffYe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UzxyffH = sc . nextInt ( ) ; boolean flg = false ; int cnt = 0 ; for ( int i = 0 ; i < UzxyffH ; 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 TyfkhZf { Scanner sc ; void calc ( ) { sc = new Scanner ( System . in ) ; String tyfkhPauy = sc . next ( ) ; if ( tyfkhPauy . charAt ( 2 ) == tyfkhPauy . charAt ( 3 ) && tyfkhPauy . charAt ( 4 ) == tyfkhPauy . 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 AqjeuHq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AqjeuVa = Integer . parseInt ( sc . next ( ) ) ; int l = Integer . parseInt ( sc . next ( ) ) ; int [ ] x = new int [ AqjeuVa + 1 ] ; x [ 0 ] = 0 ; for ( int i = 1 ; i < AqjeuVa + 1 ; i ++ ) { x [ i ] = x [ i - 1 ] + Integer . parseInt ( sc . next ( ) ) ; } int ans = 0 ; for ( int i = 0 ; i < AqjeuVa + 1 ; i ++ ) { if ( x [ i ] > l ) { ans = i ; break ; } if ( i == AqjeuVa ) { ans = i + 1 ; } } System . out . println ( ans ) ; } } import java . util . * ; public class TnrgRfo { 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 ArhlKgwfz { 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 ArhlD = Integer . parseInt ( br . readLine ( ) ) ; if ( ArhlD == 0 ) break ; String [ ] line = br . readLine ( ) . split ( " " ) ; double [ ] points = new double [ ArhlD ] ; for ( int i = 0 ; i < ArhlD ; 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 OzrqQgsp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] str = sc . next ( ) . toCharArray ( ) ; int ozrqIss = 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' ) ) { ozrqIss ++ ; } } 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 ( ozrqIss , tmpCount ) ) ; } } import java . util . * ; public class EoiiUeezmj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EoiiA = 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 < EoiiA ; 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 vltiJg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int VltiYklwj = sc . nextInt ( ) ; System . out . println ( solve ( VltiYklwj ) ) ; } public static int solve ( int VltiYklwj ) { int max = ( int ) Math . pow ( VltiYklwj , 0.5 ) + 1 ; int ret = 1 ; for ( int i = 2 ; i < max ; i ++ ) { int pow = 2 ; while ( Math . pow ( i , pow ) <= VltiYklwj ) { ret = Math . max ( ret , ( int ) Math . pow ( i , pow ) ) ; pow ++ ; } } return ret ; } } import java . util . * ; class ohhL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long OhhNyl = sc . nextLong ( ) + sc . nextLong ( ) ; if ( OhhNyl % 2 == 1 ) System . out . println ( " IMPOSSIBLE " ) ; else System . out . println ( OhhNyl / 2 ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class waslhaWtx { static class waslhaWtx { 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 WaslhaCde = " " ; try { WaslhaCde = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return WaslhaCde ; } } public static void main ( String [ ] args ) { FastReader obj = new FastReader ( ) ; String WaslhaCde = obj . next ( ) ; System . out . println ( ( WaslhaCde . compareTo ( " ABC " ) == 0 ) ? " ARC " : " ABC " ) ; } } import java . util . Scanner ; public class BlvhHfk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int BlvhVb = sc . nextInt ( ) ; int taro = 0 , hanako = 0 ; for ( int i = 0 ; i < BlvhVb ; 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 LkamVajkni { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LkamMz = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; String S = sc . next ( ) ; int [ ] count = new int [ LkamMz ] ; Arrays . fill ( count , 0 ) ; for ( int i = 1 ; i < LkamMz ; 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 QdzzXmog { public static void main ( String [ ] age ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int qdzzUi = 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 ( qdzzUi = 1 ; qdzzUi <= H ; qdzzUi ++ ) { for ( j = 1 ; j <= W ; j ++ ) { if ( qdzzUi % 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 GugblKiai { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gugblXmi = sc . nextInt ( ) ; int [ ] a = new int [ gugblXmi ] ; for ( int i = 0 ; i < gugblXmi ; 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 BtsgLvjec { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BtsgYbj = 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 ) { BtsgYbj ++ ; h ++ ; } else { BtsgYbj += 3 ; } } System . out . println ( BtsgYbj + " " + h ) ; } } import java . util . * ; class qvqT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long QvqFrb = sc . nextLong ( ) ; long money = 100 ; int year = 0 ; while ( money < QvqFrb ) { money *= 1.01 ; year ++ ; } System . out . println ( year ) ; } } import java . util . * ; public class EwmDmz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ewmX = sc . nextInt ( ) ; int [ ] values = new int [ ewmX ] ; for ( int i = 0 ; i < ewmX ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } int count = 0 ; hoge : while ( true ) { for ( int i = 0 ; i < ewmX ; i ++ ) { if ( values [ i ] % 2 != 0 ) { break hoge ; } values [ i ] = values [ i ] / 2 ; } count ++ ; } System . out . println ( count ) ; } } import java . io . * ; class gvlgcAv { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int GvlgcIkyri = 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 > GvlgcIkyri ) break ; } System . out . print ( " \n " ) ; } } import java . util . Scanner ; public class MgulmPllg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mgulmDys = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; double d = 0.0 ; int coin = 0 ; int calc = 0 ; for ( int i = 1 ; i <= mgulmDys ; i ++ ) { calc = i ; coin = 0 ; for ( ; calc < K ; coin ++ ) calc *= 2 ; d += ( 1.0 / mgulmDys ) * 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 dboYo { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int DboKirfq = 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 ( DboKirfq = a ; DboKirfq <= b ; DboKirfq ++ ) { if ( c % DboKirfq == 0 ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; class XsskFi { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int xsskJ , b , c ; xsskJ = cin . nextInt ( ) ; b = cin . nextInt ( ) ; c = cin . nextInt ( ) ; int res = serch_divisor_number ( xsskJ , b , c ) ; System . out . println ( res ) ; } private static int serch_divisor_number ( int xsskJ , int b , int c ) { int m = 0 ; for ( int i = xsskJ ; i <= b ; i ++ ) { if ( c % i == 0 ) m ++ ; } return ( m ) ; } } import java . util . Scanner ; public class HkkaCkr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; for ( int HkkaKuh = 0 ; HkkaKuh < s . length ( ) ; HkkaKuh ++ ) { 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 VpuieRp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vpuieQ = sc . nextInt ( ) ; int num2 = sc . nextInt ( ) ; int tap = 0 ; int outlet = 1 ; while ( num2 > outlet ) { outlet += vpuieQ - 1 ; tap ++ ; } System . out . println ( tap ) ; } } import java . util . * ; import java . lang . * ; public class qawimcJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QawimcAr = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= 3 ; i ++ ) { int b = ( int ) Math . pow ( QawimcAr , i ) ; sum = sum + b ; } System . out . println ( sum ) ; } } import java . util . * ; public class KziwegGzj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KziwegV = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ KziwegV + 1 ] ; for ( int i = 1 ; i <= KziwegV ; i ++ ) h [ i ] = sc . nextInt ( ) ; int [ ] dp = new int [ KziwegV + 1 ] ; dp [ 1 ] = 0 ; for ( int i = 2 ; i <= KziwegV ; 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 [ KziwegV ] ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class EhscnAnqh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ehscnU = 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 ++ ) { ehscnU = x ; if ( min * x > X ) { break ; } } ehscnU += N ; System . out . println ( ehscnU ) ; } } import java . util . * ; public class VfreYwzbk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long VfreC = sc . nextLong ( ) ; long checkx = 0 ; long x = 0 ; long checky = 0 ; long y = 0 ; for ( checkx = 1 ; checkx <= Math . sqrt ( VfreC ) ; checkx ++ ) { if ( VfreC % checkx == 0 ) { checky = VfreC / 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 BjuaocGgtoxp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BjuaocJg = 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 XrptnwVmkiqv { 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 XrptnwDo = str . length - 1 ; XrptnwDo >= 0 ; XrptnwDo -- ) { if ( XrptnwDo != 0 ) { System . out . print ( str [ XrptnwDo ] + " " ) ; } else { System . out . print ( str [ XrptnwDo ] ) ; } } System . out . println ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class VhqRddpx { 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 VhqPia ; for ( int i = 0 ; i < data . length / 2 ; i ++ ) { VhqPia = data [ i ] ; data [ i ] = data [ data . length - 1 - i ] ; data [ data . length - 1 - i ] = VhqPia ; } System . out . println ( data ) ; } } import java . io . * ; public class GgsdrJyy { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int ggsdrN = Integer . parseInt ( br . readLine ( ) ) ; if ( ggsdrN == 0 ) System . out . println ( " 1 " ) ; else System . out . println ( " 0 " ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; public class RpgRgqozb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int RpgOc = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int T = scan . nextInt ( ) ; int i = 0 , count = 0 ; ; while ( i + RpgOc <= ( T + 0.5 ) ) { count ++ ; i += RpgOc ; } System . out . println ( B * count ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class OtmJyva { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int otmKmqv = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 1 ] ) ; int c = Integer . parseInt ( str [ 2 ] ) ; int d = Integer . parseInt ( str [ 3 ] ) ; int x = ( otmKmqv + d - 1 ) / d ; int y = ( c + b - 1 ) / b ; System . out . println ( x >= y ? " Yes " : " No " ) ; } } import java . util . * ; public class kktnjYpt { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; double KktnjJvq = scn . nextDouble ( ) ; double h = scn . nextDouble ( ) ; double x = scn . nextDouble ( ) ; double y = scn . nextDouble ( ) ; double ans = KktnjJvq * h / 2 ; int check = 0 ; if ( x == KktnjJvq / 2 && y == h / 2 ) check = 1 ; System . out . println ( ans + " " + check ) ; } } import java . util . * ; public class KmkGfl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kmkLwc = sc . nextInt ( ) ; boolean b = false ; for ( int i = 1 ; i < 10 ; i ++ ) { for ( int j = i ; j < 10 ; j ++ ) { if ( i * j == kmkLwc ) { b = true ; } } } if ( b ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class FyosdMa { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int fyosdAim = sc . nextInt ( ) ; int [ ] A = new int [ fyosdAim ] ; for ( int i = 0 ; i < fyosdAim - 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 NuginUzso { static final Scanner sc = new Scanner ( System . in ) ; static int nuginU = sc . nextInt ( ) ; static long [ ] a = new long [ nuginU ] ; public static void main ( String [ ] args ) { int sum = 0 ; for ( int i = 0 ; i < nuginU ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long x = 0 ; for ( int i = 0 ; i < nuginU ; 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 GapuebMvzbm { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int GapuebIov = input . nextInt ( ) ; GapuebIov %= 10 ; String ans = " " ; if ( GapuebIov == 3 ) ans = " bon " ; else if ( GapuebIov == 0 || GapuebIov == 1 || GapuebIov == 6 || GapuebIov == 8 ) ans = " pon " ; else ans = " hon " ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class ieySbx { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; String answer = " " ; String input = scan . next ( ) ; int IeyQirwx = input . length ( ) ; for ( int i = 0 ; i < IeyQirwx ; 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 xgxwG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XgxwMzfc = sc . nextInt ( ) ; int intB = sc . nextInt ( ) ; double dbF ; dbF = ( double ) XgxwMzfc / ( double ) intB ; String f2 = String . format ( " %.5f " , dbF ) ; System . out . println ( XgxwMzfc / intB + " " + XgxwMzfc % intB + " " + f2 ) ; } } import java . util . Scanner ; public class quigWsq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QuigTrhg = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; sc . close ( ) ; if ( S . substring ( 0 , QuigTrhg / 2 ) . equals ( S . substring ( QuigTrhg / 2 , QuigTrhg ) ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class ijkwpK { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( true ) { int IjkwpPdz = in . nextInt ( ) ; int term_end = in . nextInt ( ) ; int retest = in . nextInt ( ) ; int sum = IjkwpPdz + term_end ; if ( IjkwpPdz == - 1 && term_end == - 1 && retest == - 1 ) { break ; } else if ( IjkwpPdz == - 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 MkolosAndxy { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int MkolosXre = 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 SmyrYgwql { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String a = " " ; String okikae = " " ; for ( int SmyrJo = 0 ; SmyrJo < s . length ( ) ; SmyrJo ++ ) { okikae = s . substring ( SmyrJo , SmyrJo + 1 ) ; okikae = " x " ; a = a + okikae ; } System . out . println ( a ) ; scan . close ( ) ; } } import java . util . * ; public class GnkzkOr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gnkzkRxa = sc . nextInt ( ) ; HashMap < String , Integer > map = new HashMap < String , Integer > ( ) ; long ans = 0 ; for ( int i = 0 ; i < gnkzkRxa ; 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 icfXko { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IcfVchmh = sc . nextInt ( ) ; Set < Integer > set = new HashSet < > ( ) ; int past = IcfVchmh ; 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 WgmwNy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WgmwZdt = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int max = Math . max ( WgmwZdt - B , WgmwZdt + B ) ; max = Math . max ( max , WgmwZdt * B ) ; System . out . println ( max ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class mtbzFkg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int MtbzAxg = 0 ; MtbzAxg < 3 ; MtbzAxg ++ ) { a [ MtbzAxg ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( a ) ; int cost = 0 ; for ( int MtbzAxg = 0 ; MtbzAxg < 3 ; MtbzAxg ++ ) { if ( MtbzAxg != 0 ) { cost += a [ MtbzAxg ] - a [ MtbzAxg - 1 ] ; } } System . out . println ( cost ) ; } } import java . util . * ; public class PejpmZak { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solveB ( ) ; } private void solveA ( ) { Scanner sc = new Scanner ( System . in ) ; int PejpmJ = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String s ; if ( PejpmJ >= 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 DgxCq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int dgxOb = 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 FcglCfww { public static void main ( String [ ] args ) { int fcglHwv , t ; int minCost = 1001 ; Scanner sc = new Scanner ( System . in ) ; fcglHwv = sc . nextInt ( ) ; t = sc . nextInt ( ) ; for ( int i = 0 ; i < fcglHwv ; ++ 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 bieaJpu { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int BieaEr = Integer . parseInt ( sc . next ( ) ) ; long [ ] a = new long [ BieaEr ] ; for ( int i = 0 ; i < BieaEr ; 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 < BieaEr ; 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 hikdqzCh { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int HikdqzJn = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int [ ] ans = null ; for ( int m = 0 ; m <= HikdqzJn ; m ++ ) { for ( int g = 0 ; g <= HikdqzJn - m ; g ++ ) { int s = HikdqzJn - ( 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 ZlcthEzfor { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] list = { sc . next ( ) , sc . next ( ) , sc . next ( ) } ; int ZlcthWe = 0 ; int seven_count = 0 ; for ( String l : list ) { if ( l . equals ( " 5 " ) ) ZlcthWe ++ ; else if ( l . equals ( " 7 " ) ) seven_count ++ ; } if ( ZlcthWe == 2 && seven_count == 1 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . * ; public class ZpoxpTy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zpoxpX = 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 ( zpoxpX <= damage ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class vvyqpxMxl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VvyqpxOd , b , f , r , v ; int [ ] [ ] [ ] house = new int [ 4 ] [ 3 ] [ 10 ] ; String output ; String [ ] input = new String [ 4 ] ; VvyqpxOd = Integer . parseInt ( sc . nextLine ( ) ) ; for ( int i = 0 ; i < VvyqpxOd ; 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 XzkggUz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XzkggMth = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int p ; String S ; int [ ] AC = new int [ XzkggMth ] ; int [ ] WA = new int [ XzkggMth ] ; for ( int i = 0 ; i < XzkggMth ; 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 < XzkggMth ; i ++ ) { clear = clear + AC [ i ] ; } System . out . print ( clear + " " + penalty ) ; } } import java . util . * ; class JwwlhpWdyxz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] nl = scanner . nextLine ( ) . split ( " " , 2 ) ; int JwwlhpFcq = Integer . parseInt ( nl [ 0 ] ) ; int l = Integer . parseInt ( nl [ 1 ] ) ; String [ ] arr = new String [ JwwlhpFcq ] ; for ( int i = 0 ; i < JwwlhpFcq ; i ++ ) { arr [ i ] = scanner . nextLine ( ) ; } Arrays . sort ( arr ) ; for ( int i = 0 ; i < JwwlhpFcq ; i ++ ) { System . out . print ( arr [ i ] ) ; } System . out . print ( " \n " ) ; } } import java . util . * ; public class AzeGu { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String n = s . nextLine ( ) ; String s1 = String . valueOf ( n . charAt ( 0 ) ) ; int azeBgn = 0 ; int i2 = 0 ; String s2 = " " ; for ( int i = 0 ; i < n . length ( ) ; i ++ ) { if ( String . valueOf ( n . charAt ( i ) ) . equals ( s1 ) ) { azeBgn ++ ; } else { if ( s2 . equals ( " " ) || String . valueOf ( n . charAt ( i ) ) . equals ( s2 ) ) { s2 = String . valueOf ( n . charAt ( i ) ) ; i2 ++ ; } } } System . out . println ( azeBgn == 2 && i2 == 2 ? " Yes " : " No " ) ; } } import java . util . * ; class SbkPako { static int SbkJ ; 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 ; SbkJ = scanner . nextInt ( ) ; a = new int [ SbkJ ] ; 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 feettzOe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FeettzDf = Integer . parseInt ( sc . nextLine ( ) ) ; double debt = 100000 ; while ( FeettzDf > 0 ) { debt *= 1.05 ; debt = 1000.0 * Math . ceil ( debt / 1000.0 ) ; FeettzDf -- ; } System . out . println ( String . format ( " %.0f " , debt ) ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class MhrdeAr { 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 WnfcWcb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wnfcG = sc . nextInt ( ) ; ArrayList < Integer > vList = new ArrayList < > ( ) ; for ( int i = 0 ; i < wnfcG ; i ++ ) { vList . add ( sc . nextInt ( ) ) ; } Collections . sort ( vList ) ; double ans = ( double ) vList . get ( 0 ) ; for ( int i = 1 ; i < wnfcG ; i ++ ) { double sum = ans + ( double ) vList . get ( i ) ; ans = sum / 2 ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class UynfYher { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uynfRsaq = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { uynfRsaq -= sc . nextInt ( ) ; } if ( uynfRsaq <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class MyqrjHujopu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MyqrjG = sc . nextInt ( ) ; int [ ] array = new int [ MyqrjG ] ; int [ ] DP = new int [ MyqrjG + 1 ] ; Arrays . fill ( DP , Integer . MAX_VALUE ) ; DP [ 0 ] = 0 ; for ( int i = 0 ; i < MyqrjG ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < MyqrjG - 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 [ MyqrjG - 1 ] = Math . min ( DP [ MyqrjG - 1 ] , DP [ MyqrjG - 2 ] + Math . abs ( array [ MyqrjG - 1 ] - array [ MyqrjG - 2 ] ) ) ; System . out . println ( DP [ MyqrjG - 1 ] ) ; } } import java . util . * ; public class BhbZbmj { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int BhbEad = in . nextInt ( ) ; int t = in . nextInt ( ) ; int s = in . nextInt ( ) ; double time = ( double ) BhbEad / s ; if ( time - t > 0 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . * ; public class orkrB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] data = new int [ 3 ] ; for ( int OrkrKj = 0 ; OrkrKj < 3 ; OrkrKj ++ ) { data [ OrkrKj ] = sc . nextInt ( ) ; } int K = sc . nextInt ( ) ; int maxIdx = 0 ; int max = data [ 0 ] ; for ( int OrkrKj = 1 ; OrkrKj < 3 ; OrkrKj ++ ) { if ( max < data [ OrkrKj ] ) { max = data [ OrkrKj ] ; maxIdx = OrkrKj ; } } for ( int OrkrKj = 0 ; OrkrKj < K ; OrkrKj ++ ) { data [ maxIdx ] *= 2 ; } System . out . println ( data [ 0 ] + data [ 1 ] + data [ 2 ] ) ; sc . close ( ) ; } } import java . util . * ; public class FscCts { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FscIa = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int m = 0 ; int flag = 0 ; if ( y <= FscIa * 2 || y <= FscIa * 4 ) { for ( int i = 1 ; i <= FscIa ; i ++ ) { int j = i * 2 ; m = i * 4 ; int h = y - j ; int h1 = y - m ; if ( ( h1 % 2 == 0 && h1 / 2 == FscIa - i ) || ( h % 4 == 0 && h / 4 == FscIa - 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 WjdoYv { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int wjdoLw = 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 / wjdoLw ) ; System . out . println ( Math . min ( ( wjdoLw * p * p - 2 * p * s + sumsq ) , ( wjdoLw * ( 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 WgshtoOkif { 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 wgshtoH ; Map < String , Integer > map = new TreeMap < String , Integer > ( ) ; Main ( Scanner sc ) { this . sc = sc ; this . wgshtoH = sc . nextInt ( ) ; } private List < String > solve ( ) { int max = 0 ; List < String > answer = new ArrayList < String > ( ) ; for ( int i = 0 ; i < wgshtoH ; 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 eviZo { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String S = stdIn . next ( ) ; char [ ] s = new char [ S . length ( ) ] ; for ( int EviDvp = 0 ; EviDvp < S . length ( ) ; EviDvp ++ ) { s [ EviDvp ] = S . charAt ( EviDvp ) ; } s [ 3 ] = '8' ; System . out . println ( s ) ; } } import java . util . * ; public class WtzmKo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wtzmPgwi = sc . nextInt ( ) ; String s = sc . next ( ) ; boolean val = true ; if ( s . length ( ) % 2 != 0 ) val = false ; else { for ( int i = 0 ; i < wtzmPgwi / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i + wtzmPgwi / 2 ) ) { val = false ; break ; } } } System . out . println ( val ? " Yes " : " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class EuzRbus { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word ; int euzMl = 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 ) ) { euzMl ++ ; } else { continue ; } } } System . out . println ( euzMl ) ; } } import java . util . * ; public class TyjtGm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TyjtPu = 1 ; while ( true ) { int a = sc . nextInt ( ) ; if ( a != 0 ) System . out . println ( " Case " + TyjtPu + " : " + a ) ; else break ; TyjtPu = TyjtPu + 1 ; } } } import java . util . * ; public class EwwezpOv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ewwezpKt = 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 = ewwezpKt + 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 ( ewwezpKt - d ) ; } } import java . util . Scanner ; public class sljAh { 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 SljDx = 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 - SljDx > k ) System . out . println ( NO ) ; else System . out . println ( OK ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class ApcjfcIavuou { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long ApcjfcSt = 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 OcbmhOzn { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int ocbmhNy = sc . nextInt ( ) ; int [ ] A = new int [ ocbmhNy ] ; for ( int i = 0 ; i < ocbmhNy ; i ++ ) { A [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; int [ ] B = A . clone ( ) ; Arrays . sort ( B ) ; int max = B [ ocbmhNy - 1 ] ; int nextmax = B [ ocbmhNy - 2 ] ; for ( int i = 0 ; i < ocbmhNy ; i ++ ) { if ( A [ i ] == max ) { System . out . println ( nextmax ) ; } else { System . out . println ( max ) ; } } } } import java . util . * ; class nzbwqnUgv { Scanner sc = new Scanner ( System . in ) ; public int ini ( ) { return sc . nextInt ( ) ; } public int [ ] vi ( int n ) { int [ ] a = new int [ n ] ; for ( int NzbwqnVlzbj = 0 ; NzbwqnVlzbj < n ; NzbwqnVlzbj ++ ) a [ NzbwqnVlzbj ] = sc . nextInt ( ) ; return a ; } } public class nzbwqnUgv 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 NzbwqnVlzbj = 0 ; NzbwqnVlzbj < n - 1 ; NzbwqnVlzbj ++ ) { for ( int j = NzbwqnVlzbj + 1 ; j < n ; j ++ ) { ans += a [ NzbwqnVlzbj ] * a [ j ] ; } } return ans ; } void show ( int ans ) { System . out . println ( ans ) ; } } import java . util . Scanner ; public class OjejfoTnxscb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OjejfoIrx = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) ; int x = sc . nextInt ( ) , y = sc . nextInt ( ) ; int min = x * OjejfoIrx + y * b ; min = Math . min ( min , 2 * y * c + Math . max ( 0 , x - y ) * OjejfoIrx ) ; 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 wgrCrb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int WgrOd = 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 = WgrOd - i ; if ( tmp2 < 0 ) { tmp2 = i - WgrOd ; } if ( tmp2 < min ) { min = tmp2 ; result = i ; } } } System . out . println ( result ) ; } } import java . util . * ; public class KedRljb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kedIjdi , b , sum ; kedIjdi = sc . nextInt ( ) ; b = sc . nextInt ( ) ; sum = 0 ; if ( ( kedIjdi == 1 || kedIjdi == 2 ) && ( b == 1 || b == 2 ) ) { sum = 3 ; System . out . println ( sum ) ; } else if ( ( kedIjdi == 1 || kedIjdi == 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 ByokfPfxw { 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 byokfYf = 0 ; byokfYf < strArray . length ; byokfYf ++ ) { if ( Character . isUpperCase ( strArray [ byokfYf ] ) ) { strArray [ byokfYf ] = Character . toLowerCase ( strArray [ byokfYf ] ) ; } else if ( Character . isLowerCase ( strArray [ byokfYf ] ) ) { strArray [ byokfYf ] = Character . toUpperCase ( strArray [ byokfYf ] ) ; } else { strArray [ byokfYf ] = strArray [ byokfYf ] ; } } for ( int byokfYf = 0 ; byokfYf < strArray . length - 1 ; byokfYf ++ ) { System . out . print ( strArray [ byokfYf ] ) ; } System . out . println ( strArray [ strArray . length - 1 ] ) ; } } import java . util . * ; public class VbnlkTd { 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 vbnlkJ = 0 ; vbnlkJ < tc . length ; vbnlkJ ++ ) { if ( vbnlkJ < sc . length && sc [ vbnlkJ ] != tc [ vbnlkJ ] ) { System . out . println ( " No " ) ; break ; } if ( vbnlkJ == tc . length - 1 ) { System . out . println ( " Yes " ) ; } } } } import java . util . Scanner ; public class rapwX { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int RapwZaiwg = 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 < RapwZaiwg ; 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 akvakpPy { 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 AkvakpBldk = 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 ( AkvakpBldk - input [ N - 1 ] + input [ 0 ] , max ) ; System . out . println ( AkvakpBldk - 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 DsveVy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dsveS = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] A = new int [ dsveS ] ; 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 NilYm { 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 nilFntb = Double . parseDouble ( readLineArray [ 0 ] ) ; double S = Math . PI * nilFntb * nilFntb ; double L = 2 * Math . PI * nilFntb ; System . out . printf ( " %.5f %.5f " , S , L ) ; } } import java . util . Scanner ; public class tavjQem { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int TavjMcr = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int min = 0 ; for ( int i = 1 ; i <= 1009 ; i ++ ) { if ( ( int ) ( i * 0.08 ) == TavjMcr && ( int ) ( i * 0.1 ) == b ) { min = i ; break ; } else { min = - 1 ; } } System . out . println ( min ) ; scan . close ( ) ; } } import java . util . * ; class dwiAxv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String [ ] S = scan . nextLine ( ) . split ( " " ) ; int DwiPslfd = 0 ; for ( int i = 0 ; i < S . length / 2 ; i ++ ) { if ( ! ( S [ i ] . equals ( S [ S . length - 1 - i ] ) ) ) { DwiPslfd ++ ; } } System . out . println ( DwiPslfd ) ; } } import java . awt . * ; import java . awt . geom . * ; import java . io . * ; import java . util . * ; class rmgsoU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int RmgsoRjk = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( RmgsoRjk == 0 && b == 0 ) break ; System . out . println ( ( RmgsoRjk < b ) ? ( RmgsoRjk + " " + b ) : ( b + " " + RmgsoRjk ) ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class RgulqDbl { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; char [ ] c = ob . next ( ) . toCharArray ( ) ; int rgulqNpz = 0 ; for ( int i = 0 ; i < c . length ; i ++ ) { rgulqNpz = rgulqNpz + Character . getNumericValue ( c [ i ] ) ; } if ( rgulqNpz % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . * ; import java . util . * ; public class HirimcBbxa 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 HirimcSp = sc . nextInt ( ) ; if ( HirimcSp > 50 ) { HirimcSp = 50 ; } String S = sc . next ( ) ; int Y = 0 ; int U = 0 ; for ( int i = 0 ; i < HirimcSp ; 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 UkhmZhgccm { 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 UkhmX = 0 ; UkhmX < hairetsu . length ; UkhmX ++ ) { array . add ( Integer . parseInt ( hairetsu [ UkhmX ] ) ) ; } for ( int UkhmX = 0 ; UkhmX < array . size ( ) ; UkhmX ++ ) { array2 . add ( array . get ( array . size ( ) - 1 - UkhmX ) ) ; } for ( int UkhmX = 0 ; UkhmX < array2 . size ( ) ; UkhmX ++ ) { System . out . print ( array2 . get ( UkhmX ) ) ; if ( UkhmX < array2 . size ( ) - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } import java . util . * ; public class zdhmqH { public static void main ( String [ ] args ) throws Exception { String [ ] lines = getStdin ( ) ; String str = lines [ 0 ] ; long ZdhmqRw = Long . parseLong ( str ) ; long sum = 100 ; int count = 0 ; while ( sum < ZdhmqRw ) { 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 YqezvBnya { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long yqezvIv = sc . nextLong ( ) ; long min = Integer . MAX_VALUE ; for ( long a = 1 ; a <= Math . sqrt ( ( double ) yqezvIv ) ; a ++ ) { if ( yqezvIv % a == 0 ) { long b = yqezvIv / 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 KhsVjtsay { public static void main ( String [ ] Arguments ) throws IOException { BufferedReader BR = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer ST = new StringTokenizer ( BR . readLine ( ) ) ; int KhsC = 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 <= KhsC ) ? KhsC - homeworkDays : - 1 ) ; } } import java . util . Scanner ; public class ZtjjGj { 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 ZtjjZbk = 0 ; ZtjjZbk < str . length ; ZtjjZbk ++ ) { if ( str [ ZtjjZbk ] . equals ( S ) ) { if ( ZtjjZbk == 6 ) { System . out . println ( 7 ) ; } else { System . out . println ( 7 - ( ZtjjZbk + 1 ) ) ; } } } } } import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class OdoyWjpt { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; String OdoyIr = keyboard . nextLine ( ) ; String SB = keyboard . nextLine ( ) ; String SC = keyboard . nextLine ( ) ; String input = OdoyIr . substring ( 0 , 1 ) ; keyboard . close ( ) ; System . out . print ( solve ( OdoyIr , 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 EzyhVo { public static int ezyhW = 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 ( ezyhW ) ; } 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 ] ; ezyhW ++ ; } } } } 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 VcyscTgu { 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 vcyscMmmt = false ; if ( s . length ( ) >= i + 7 && s . substring ( i , i + 7 ) . equals ( " dreamer " ) ) { vcyscMmmt |= judge ( s , i + 7 ) ; } if ( s . length ( ) >= i + 5 && s . substring ( i , i + 5 ) . equals ( " dream " ) ) { vcyscMmmt |= judge ( s , i + 5 ) ; } if ( s . length ( ) >= i + 6 && s . substring ( i , i + 6 ) . equals ( " eraser " ) ) { vcyscMmmt |= judge ( s , i + 6 ) ; } if ( s . length ( ) >= i + 5 && s . substring ( i , i + 5 ) . equals ( " erase " ) ) { vcyscMmmt |= judge ( s , i + 5 ) ; } return vcyscMmmt ; } } 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 ehntbCyl { 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 EhntbPuwkh = in . nextInt ( ) ; int [ ] H = new int [ EhntbPuwkh ] ; for ( int i = 0 ; i < EhntbPuwkh ; 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 txgEbi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int TxgCrsz = 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 ( TxgCrsz < tmp ) TxgCrsz = tmp ; } else { if ( TxgCrsz < tmp ) TxgCrsz = tmp ; tmp = 0 ; } } System . out . println ( TxgCrsz ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . text . Collator ; public class skggdYxw { 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 SkggdHv = Integer . parseInt ( br . readLine ( ) ) ; int pointA = 0 ; int pointB = 0 ; int result = 0 ; for ( int i = 0 ; i < SkggdHv ; 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 OgegQk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int OgegC = scan . nextInt ( ) ; int [ ] a = new int [ OgegC ] ; long sum = 0 ; for ( int i = 0 ; i < OgegC ; 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 QxrtdnFespq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QxrtdnJtl = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; String [ ] s = new String [ QxrtdnJtl ] ; for ( int i = 0 ; i < QxrtdnJtl ; i ++ ) { s [ i ] = sc . next ( ) ; } Arrays . sort ( s ) ; String ans = " " ; for ( int i = 0 ; i < QxrtdnJtl ; i ++ ) { ans += s [ i ] ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class BqhKvqh { 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 BqhNmn = list . BqhNmn ( ) ; if ( BqhNmn % 2 == 0 ) { int pos = BqhNmn / 2 ; long a = list . get ( pos ) ; long b = list . get ( pos - 1 ) ; System . out . println ( a + b - 2 ) ; } else { int pos = BqhNmn / 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 . BqhNmn ( ) - 1 ) ; int BqhNmn = list . BqhNmn ( ) ; if ( num / temp == temp ) { BqhNmn = BqhNmn - 1 ; } for ( int i = BqhNmn - 1 ; i > 0 ; i -- ) { Long n = list . get ( i ) ; list . add ( num / n ) ; } return list ; } } import java . io . * ; import java . util . Arrays ; public class YfzfCthn { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { int yfzfOf = 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 ) { yfzfOf ++ ; } } } } System . out . println ( yfzfOf ) ; } } } import java . util . Scanner ; class DgcswqDdq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int dgcswqJcrd = 1 ; while ( true ) { int x = scanner . nextInt ( ) ; if ( x == 0 ) break ; System . out . println ( " Case " + dgcswqJcrd + " : " + x ) ; dgcswqJcrd += 1 ; } } } import java . util . * ; public class udaM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UdaLh = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int temp = y ; if ( y % 2 == 0 && y >= ( UdaLh * 2 ) && y <= UdaLh * 4 ) { System . out . print ( " Yes " ) ; } else System . out . print ( " No " ) ; } } import java . util . * ; import java . util . Scanner ; public class hcxijBq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int HcxijZydwu = sc . nextInt ( ) ; int [ ] a = new int [ HcxijZydwu ] ; int res = 0 ; for ( int i = 0 ; i < HcxijZydwu ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; if ( a [ HcxijZydwu / 2 - 1 ] != a [ HcxijZydwu / 2 ] ) { res = a [ HcxijZydwu / 2 ] - a [ HcxijZydwu / 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 SxeygcTfo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sxeygcH = sc . nextInt ( ) ; int wk = 0 ; int ans = 0 ; ans = sxeygcH / 2 ; wk = sxeygcH % 2 ; if ( wk == 1 ) { ans = ans + 1 ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class RzpvclYi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rzpvclO = 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 * rzpvclO ; 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 QihwcLgt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QihwcAiw = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; String S = sc . next ( ) ; int [ ] cnt = new int [ QihwcAiw + 1 ] ; for ( int i = 0 ; i < QihwcAiw - 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 KnoDwuv { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; int knoFv = keyboard . nextInt ( ) ; HashMap < String , Integer > count = new HashMap < String , Integer > ( ) ; for ( int s = 0 ; s < knoFv ; 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 ZyvywYuft { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; for ( ; ; ) { int zyvywZaap = scan . nextInt ( ) ; double sum = 0 ; double m = 0 ; if ( zyvywZaap == 0 ) break ; double [ ] s = new double [ zyvywZaap ] ; for ( int i = 0 ; i < zyvywZaap ; i ++ ) { s [ i ] = scan . nextDouble ( ) ; sum += s [ i ] ; } m = ( double ) sum / zyvywZaap ; double a = 0 ; for ( int i = 0 ; i < zyvywZaap ; i ++ ) { a += ( s [ i ] - m ) * ( s [ i ] - m ) ; } double ans = Math . sqrt ( a / zyvywZaap ) ; if ( ans >= 0 ) { System . out . println ( ans ) ; } } } } import java . util . Scanner ; class UmzuKj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int UmzuAp = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( UmzuAp < 10 && b < 10 ) { System . out . println ( UmzuAp * b ) ; } else { System . out . println ( - 1 ) ; } scan . close ( ) ; } } import java . util . * ; public class GngBidhkj { static int GngPzv = 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 ; GngPzv = 0 ; } System . out . println ( sum_power ) ; } } static int doublet ( int n , int f ) { if ( n < f ) { GngPzv = GngPzv + 1 ; return doublet ( 2 * n , f ) ; } else return GngPzv ; } } import java . util . * ; public class JcyzzhLh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double jcyzzhWani = sc . nextDouble ( ) ; double A = ( double ) jcyzzhWani * jcyzzhWani * Math . PI ; double L = ( double ) jcyzzhWani * 2 * Math . PI ; System . out . println ( String . format ( " %f " , A ) + " " + String . format ( " %f " , L ) ) ; } } import java . util . Scanner ; public class zcvyqT { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String ZcvyqJwkov = " ABCDEFGHIJKLMNOPQRSTUVWXYZ " ; String lowercase = " abcdefghijklmnopqrstuvwxyz " ; String alpha = scanner . nextLine ( ) ; if ( ZcvyqJwkov . contains ( alpha ) ) System . out . println ( " A " ) ; else System . out . println ( " a " ) ; } } import java . math . BigInteger ; import java . util . * ; import java . io . * ; public class XkgwvPj { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int XkgwvQch = sc . nextInt ( ) ; pw . println ( 1 - XkgwvQch ) ; pw . flush ( ) ; } static class XkgwvPj { 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 XkgwvQch ) throws IOException { int [ ] arr = new int [ XkgwvQch ] ; for ( int i = 0 ; i < XkgwvQch ; i ++ ) { arr [ i ] = Integer . parseInt ( next ( ) ) ; } return arr ; } } } import java . util . * ; public class SraNnnrai { 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 SraCa ; 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 ++ ) { SraCa = t . charAt ( j ) ; sj = s . charAt ( j + startcount ) ; if ( SraCa == 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 OtlKu { 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 otlXkii = Integer . parseInt ( str [ 0 ] ) + Integer . parseInt ( str [ 1 ] ) ; System . out . println ( Integer . toString ( otlXkii ) . length ( ) ) ; } br . close ( ) ; } catch ( Exception e ) { } } } import java . util . ArrayList ; import java . util . Scanner ; public class rnefKt { public static void main ( String [ ] args ) { int RnefSgato = 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 ( RnefSgato ) ; break me ; } } RnefSgato ++ ; } } } import java . util . Scanner ; public class VxwnSuw { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int vxwnOerw = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= vxwnOerw ; i ++ ) { int sum = 0 ; for ( int j = 1 ; j <= vxwnOerw ; j ++ ) { if ( i % j == 0 ) { sum ++ ; } } if ( sum == 8 && i % 2 != 0 ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class RedcoVycqt { 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 RedcoMm ; int B ; int C ; Main ( Scanner sc ) { this . sc = sc ; this . RedcoMm = sc . nextInt ( ) ; this . B = sc . nextInt ( ) ; this . C = sc . nextInt ( ) ; } private String solve ( ) { String answer = " No " ; if ( RedcoMm == B && B != C || RedcoMm == C && B != C || B == C && C != RedcoMm ) { answer = " Yes " ; } return answer ; } public void show ( String answer ) { System . out . println ( answer ) ; } } import java . util . * ; public class CouYpy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String n = scan . nextLine ( ) ; String [ ] array = n . split ( " " ) ; int couI = 0 ; for ( String a : array ) { if ( a . equals ( " 7 " ) ) { couI = 1 ; } } if ( couI == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . io . * ; public class ocftDr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int OcftPtuqs = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; if ( n == 0 ) { System . out . println ( OcftPtuqs ) ; 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 ( OcftPtuqs - i <= 0 ) continue ; if ( OcftPtuqs + i > 200 ) continue ; if ( number [ OcftPtuqs - i ] == 1 ) { System . out . println ( OcftPtuqs - i ) ; System . exit ( 0 ) ; } if ( number [ OcftPtuqs + i ] == 1 ) { System . out . println ( OcftPtuqs + i ) ; System . exit ( 0 ) ; } } System . out . println ( 0 ) ; } } class ocftDr { } import java . util . * ; import java . util . Arrays ; public class PdtIwqs { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int [ ] a = new int [ 10 ] ; for ( int pdtGjm = 0 ; pdtGjm < a . length ; pdtGjm ++ ) { a [ pdtGjm ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int pdtGjm = 9 ; pdtGjm > 6 ; pdtGjm -- ) { System . out . println ( a [ pdtGjm ] ) ; } } } import java . util . Scanner ; public class grmX { public static void main ( String [ ] a ) { Scanner scan = new Scanner ( System . in ) ; String [ ] t = scan . nextLine ( ) . split ( " \\ s " ) ; int GrmMtypy = 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 WgmhzeOryv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String wgmhzeB = sc . next ( ) ; String S1 = wgmhzeB . substring ( 0 , 1 ) ; String S2 = wgmhzeB . substring ( 1 , 2 ) ; String S3 = wgmhzeB . substring ( 2 , 3 ) ; String S4 = wgmhzeB . 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 GjeeIzuhp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long GjeeWe = Long . parseLong ( sc . next ( ) ) ; long B = Long . parseLong ( sc . next ( ) ) ; long n = Math . abs ( GjeeWe - ( GjeeWe - B ) / 2 ) ; if ( Math . abs ( GjeeWe - n ) == Math . abs ( B - n ) ) { System . out . println ( n ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . util . Scanner ; public class SomirXdmgvw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int SomirS = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int ans = 0 ; if ( SomirS == 0 && x == 0 ) break ; for ( int i = 1 ; i < SomirS + 1 ; i ++ ) { for ( int j = i + 1 ; j < SomirS + 1 ; j ++ ) { for ( int k = j + 1 ; k < SomirS + 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 AbsvdMr { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int absvdI = scan . nextInt ( ) ; int inputQ = scan . nextInt ( ) ; int [ ] memory = new int [ absvdI + 1 ] ; memory [ 0 ] = 0 ; String inputStr = scan . next ( ) ; for ( int n = 2 ; n < absvdI + 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 wrqaQ { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int WrqaZd = sc . nextInt ( ) ; int No = 0 ; int [ ] buka = new int [ WrqaZd + 1 ] ; while ( sc . hasNext ( ) ) { buka [ sc . nextInt ( ) ] ++ ; } for ( int i = 1 ; i <= WrqaZd ; i ++ ) { System . out . println ( buka [ i ] ) ; } } } import java . io . * ; public class cvvnmeFqr { 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 CvvnmeRg = Integer . parseInt ( sec_ ) ; m . SecToTime ( CvvnmeRg ) ; } public void SecToTime ( int CvvnmeRg ) { int h = 0 , m = 0 ; while ( CvvnmeRg >= 3600 ) { h ++ ; CvvnmeRg -= 3600 ; } while ( CvvnmeRg >= 60 ) { m ++ ; CvvnmeRg -= 60 ; } System . out . println ( h + " : " + m + " : " + CvvnmeRg ) ; } } import java . util . * ; public class CzleYjyh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int czleAayi = sc . nextInt ( ) ; String [ ] list = new String [ czleAayi ] ; String ans = " No " ; for ( int i = 0 ; i < czleAayi ; i ++ ) { list [ i ] = sc . next ( ) ; } for ( int i = 1 ; i < czleAayi ; 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 < czleAayi ; i ++ ) { String a = list [ i ] ; for ( int j = i + 1 ; j < czleAayi ; 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 ssoIn { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int SsoOt = 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 < SsoOt ; 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 JwkWz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jwkFga = scan . nextInt ( ) ; int [ ] ar = new int [ jwkFga ] ; for ( int i = 0 ; i < jwkFga ; i ++ ) { ar [ i ] = scan . nextInt ( ) ; } Arrays . parallelSort ( ar ) ; float ans = 0 ; float [ ] lol = new float [ jwkFga ] ; lol [ 0 ] = ar [ 0 ] ; for ( int i = 1 ; i < jwkFga ; i ++ ) { lol [ i ] = ( float ) ( ( ar [ i ] + lol [ i - 1 ] ) / 2 ) ; } System . out . printf ( " %.04f " , lol [ jwkFga - 1 ] ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class UlmrcxVouxt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UlmrcxG = sc . nextInt ( ) ; ArrayList < Integer > A = new ArrayList < Integer > ( ) ; ArrayList < Integer > B = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < UlmrcxG ; i ++ ) { int n = sc . nextInt ( ) ; A . add ( n ) ; B . add ( 0 ) ; } for ( int i = 0 ; i < UlmrcxG ; i ++ ) { B . set ( A . get ( i ) - 1 , i + 1 ) ; } for ( int i = 0 ; i < UlmrcxG ; i ++ ) { System . out . print ( B . get ( i ) + " " ) ; } sc . close ( ) ; } } import java . util . Scanner ; class WskzrfBsn { 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 wskzrfCgfo = 0 ; for ( char c : s . toCharArray ( ) ) { wskzrfCgfo += c - '0' ; } System . out . println ( wskzrfCgfo ) ; } } } import java . util . * ; public class RlqbalDk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . next ( ) ; int rlqbalYezm , j , flag = 0 ; for ( rlqbalYezm = 0 ; rlqbalYezm < w . length ( ) ; rlqbalYezm ++ ) { int cnt = 0 ; for ( j = 0 ; j < w . length ( ) ; j ++ ) { if ( w . charAt ( rlqbalYezm ) == 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 GkfxcTe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int gkfxcA = 1 ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; String s = scan . next ( ) ; if ( s . length ( ) != a + b + 1 ) { gkfxcA = 0 ; } for ( int i = 0 ; i < a ; i ++ ) { if ( '0' <= s . charAt ( i ) && s . charAt ( i ) <= '9' ) { } else { gkfxcA = 0 ; } } if ( s . charAt ( a ) != '-' ) { gkfxcA = 0 ; } for ( int i = a + 1 ; i < s . length ( ) ; i ++ ) { if ( '0' <= s . charAt ( i ) && s . charAt ( i ) <= '9' ) { } else { gkfxcA = 0 ; } } if ( gkfxcA == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class ofbkzcKmx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OfbkzcApkp = 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 MvihcSvi { 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 eaabjmIy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EaabjmVrk = scan . nextInt ( ) ; int [ ] length = new int [ EaabjmVrk ] ; 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 okealkLn { 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 okealkLn { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int OkealkEu = in . nextInt ( ) ; String a = in . next ( ) ; String b = in . next ( ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < OkealkEu ; 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 unrKl { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; int UnrCzq = scanner . nextInt ( ) ; for ( int i = 3 ; i <= UnrCzq ; i ++ ) { if ( i % 3 == 0 || String . valueOf ( i ) . contains ( " 3 " ) ) System . out . print ( " " + i ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class sisgahB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; long SisgahWs = sc . nextLong ( ) ; int x = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { x ++ ; if ( S . charAt ( i ) == '1' && x < SisgahWs ) { continue ; } else { System . out . println ( S . charAt ( i ) ) ; break ; } } } } import java . util . Arrays ; import java . util . Scanner ; public class PbuiwLehc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PbuiwR = sc . nextInt ( ) ; int [ ] A = new int [ PbuiwR ] ; for ( int i = 0 ; i < PbuiwR ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } Arrays . parallelSort ( A ) ; int count = 1 ; for ( int i = PbuiwR - 1 ; i > 0 ; i -- ) { if ( A [ i ] != A [ i - 1 ] ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class kgsWra { public void main ( Scanner sc ) { int KgsOaf = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int a3 = sc . nextInt ( ) ; int max = Math . max ( KgsOaf , Math . max ( a2 , a3 ) ) ; int min = Math . min ( KgsOaf , 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 KqykzhQypv { public static void main ( String [ ] args ) { int [ ] input = new int [ 10 ] ; Scanner s = new Scanner ( System . in ) ; for ( int KqykzhVl = 0 ; KqykzhVl < 10 ; KqykzhVl ++ ) { input [ KqykzhVl ] = s . nextInt ( ) ; } Arrays . sort ( input ) ; int KqykzhVl = input . length - 1 ; while ( KqykzhVl > input . length - 4 ) { System . out . println ( input [ KqykzhVl ] ) ; KqykzhVl -- ; } } } import java . util . Scanner ; public class mgkhdrWwh { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final String MgkhdrNxdpy = sc . next ( ) ; sc . close ( ) ; if ( Character . isUpperCase ( MgkhdrNxdpy . charAt ( 0 ) ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } return ; } } import java . util . Arrays ; import java . util . Scanner ; public class CjpfvWano { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cjpfvQbh = sc . nextInt ( ) , k = sc . nextInt ( ) ; int [ ] array = new int [ cjpfvQbh ] ; for ( int i = 0 ; i < cjpfvQbh ; i ++ ) array [ i ] = sc . nextInt ( ) ; Arrays . sort ( array ) ; for ( int i = cjpfvQbh - 1 ; i >= cjpfvQbh - k ; i -- ) { if ( i >= 0 ) array [ i ] = 0 ; else break ; } long sum = 0 ; for ( int i = 0 ; i < cjpfvQbh ; i ++ ) sum += array [ i ] ; System . out . println ( sum ) ; } } import java . util . * ; public class bujrlKtc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { long BujrlDt = sc . nextLong ( ) ; long a1 = BujrlDt ; long b = sc . nextLong ( ) ; long b1 = b ; long i ; if ( BujrlDt > b ) { for ( ; ; ) { if ( a1 % b == 0 ) { break ; } a1 += BujrlDt ; } if ( BujrlDt % b == 0 ) { System . out . println ( b + " " + a1 ) ; } else { for ( i = b / 2 ; i > 0 ; i -- ) { if ( BujrlDt % i == 0 && b % i == 0 ) { break ; } } System . out . println ( i + " " + a1 ) ; } } else if ( BujrlDt < b ) { for ( ; ; ) { if ( b1 % BujrlDt == 0 ) { break ; } b1 += b ; } if ( b % BujrlDt == 0 ) { System . out . println ( BujrlDt + " " + b1 ) ; } else { for ( i = BujrlDt / 2 ; i > 0 ; i -- ) { if ( BujrlDt % i == 0 && b % i == 0 ) { break ; } } System . out . println ( i + " " + b1 ) ; } } else { System . out . println ( b + " " + b1 ) ; } } } } import java . util . Scanner ; public class lgiyBxx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . nextLine ( ) ; char LgiyMjun = S . charAt ( 0 ) ; System . out . println ( Character . isUpperCase ( LgiyMjun ) ? " A " : " a " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class QypeyMei { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QypeySy = sc . nextInt ( ) ; int su ; int num = 0 ; String mark ; Boolean [ ] s = new Boolean [ 52 ] ; Arrays . fill ( s , false ) ; for ( int i = 0 ; i < QypeySy ; 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 MvlhdRym { public static void main ( String [ ] args ) throws Exception { Scanner cin = new Scanner ( System . in ) ; int mvlhdXfnn = cin . nextInt ( ) , b = cin . nextInt ( ) ; int c = mvlhdXfnn * b ; if ( c % 2 == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Scanner ; public class UruaWji { public static void main ( String [ ] args ) { Scanner entrada = new Scanner ( System . in ) ; char UruaTl = entrada . next ( ) . charAt ( 0 ) ; if ( Character . isUpperCase ( UruaTl ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class hrlzJim { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HrlzEf = sc . nextInt ( ) ; String [ ] w = new String [ HrlzEf ] ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < HrlzEf ; i ++ ) { w [ i ] = sc . next ( ) ; set . add ( w [ i ] ) ; } for ( int i = 1 ; i < HrlzEf ; 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 ( ) == HrlzEf ) ? " Yes " : " No " ) ; } } import java . util . * ; class UiuAv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UiuJ = Integer . parseInt ( sc . next ( ) ) ; String str = sc . next ( ) ; if ( UiuJ % 2 == 1 ) { System . out . println ( " No " ) ; return ; } else { String s_1 = str . substring ( 0 , UiuJ / 2 ) ; String s_2 = str . substring ( UiuJ / 2 , UiuJ ) ; if ( s_1 . equals ( s_2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } } import java . util . * ; public class ypftgAjc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = String . valueOf ( sc . nextInt ( ) ) ; String rn = " " ; for ( int YpftgQvirz = 0 ; YpftgQvirz < 3 ; YpftgQvirz ++ ) { if ( n . charAt ( YpftgQvirz ) == '1' ) rn += " 9 " ; else rn += " 1 " ; } System . out . println ( Integer . valueOf ( rn ) ) ; } } import java . util . Scanner ; public class JopfHqzuxg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JopfQd = sc . nextInt ( ) ; int min = sc . nextInt ( ) ; int ans = Integer . MIN_VALUE ; for ( int i = 0 ; i < JopfQd - 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 HhuRwfw { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int HhuLve = 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 ] == '+' ) HhuLve = HhuLve + 1 ; else HhuLve = HhuLve - 1 ; } System . out . print ( HhuLve ) ; } } import java . util . * ; import java . math . BigDecimal ; public class OluMq { 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 MgypynMw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MgypynZla = sc . nextInt ( ) ; int [ ] h = new int [ MgypynZla ] ; for ( int i = 0 ; i < MgypynZla ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int max = 1 ; for ( int i = 0 ; i < MgypynZla ; 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 VnasipVu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] C = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; int vnasipZzt = C . length ; int st = 0 ; for ( int i = 0 ; i < vnasipZzt ; ++ i ) { if ( C [ i ] == 'A' ) { st = i ; break ; } } int gl = 0 ; for ( int i = vnasipZzt - 1 ; i >= 0 ; -- i ) { if ( C [ i ] == 'Z' ) { gl = i ; break ; } } System . out . println ( gl - st + 1 ) ; } } import java . util . Scanner ; public class mmbpOvy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String MmbpMbskm = sc . next ( ) ; System . out . println ( MmbpMbskm . contains ( " 7 " ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class PplupPsp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PplupPpp = 0 ; int b = 0 ; int c = 0 ; int d = 0 ; int score = 0 ; String x = " " ; PplupPpp = sc . nextInt ( ) ; x = sc . next ( ) ; if ( x . length ( ) > PplupPpp ) { x = x . substring ( 0 , PplupPpp ) + " ... " ; } System . out . print ( x ) ; } } import java . util . * ; import java . io . * ; public class BgapqIzx { public static void main ( String [ ] args ) throws Exception { InputStreamReader r = new InputStreamReader ( System . in ) ; String S = nextString ( r ) ; int bgapqAy = S . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < bgapqAy / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( bgapqAy - 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 rrysZ { static int keta ( int s ) { int RrysGvw = 0 ; while ( s > 0 ) { RrysGvw += ( s % 10 ) ; s /= 10 ; } return RrysGvw ; } 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 RrysGvw = 0 ; for ( int i = 1 ; i < N + 1 ; i ++ ) { if ( keta [ i ] >= A && keta [ i ] <= B ) RrysGvw += i ; } System . out . println ( RrysGvw ) ; } } import java . util . * ; public class spdbvcXpm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String SpdbvcOetqn = sc . next ( ) ; if ( SpdbvcOetqn . 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 OjgmEcu { public static final int ojgmIc = 200000 ; public static void main ( String [ ] args ) throws IOException { int [ ] Nums = new int [ ojgmIc ] ; 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 JdstTlme { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jdstC = sc . nextInt ( ) ; int max = 0 ; int result = 1 ; for ( int i = 1 ; i <= jdstC ; 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 egaRw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EgaXv = scan . nextInt ( ) ; String S = scan . next ( ) ; int x = S . length ( ) ; if ( x > EgaXv ) { String ans = S . substring ( 0 , EgaXv ) ; System . out . println ( ans + " ... " ) ; } else { System . out . println ( S ) ; } } } import java . util . * ; class DdkUpzc { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int ddkTic = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; String s = String . valueOf ( ddkTic ) + 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 CkohLu { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int ckohJm = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= ckohJm ; i ++ ) { int x = 1 ; int j = i ; while ( j < k ) { x *= 2 ; j *= 2 ; } x *= ckohJm ; ans += ( double ) 1 / ( double ) x ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; class AxjjzOlcm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AxjjzXu = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] m = new int [ AxjjzXu ] ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < AxjjzXu ; 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 IhvfGeh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ihvfF = sc . nextInt ( ) ; long [ ] A = new long [ ihvfF ] ; for ( int i = 0 ; i < ihvfF ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } sc . close ( ) ; long result = 0 ; for ( int i = 1 ; i < ihvfF ; 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 RmyqavSopp { 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 rmyqavS = 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 = rmyqavS ; x <= b ; x ++ ) { if ( c % x == 0 ) { count ++ ; } } } else { for ( int x = rmyqavS ; 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 ibbzEcr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] N = sc . next ( ) . toCharArray ( ) ; int IbbzKw = 0 ; for ( int i = 0 ; i < N . length ; i ++ ) { IbbzKw = ( IbbzKw + Character . getNumericValue ( N [ i ] ) ) % 9 ; } if ( IbbzKw % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . HashSet ; import java . util . Scanner ; public class LawmdNzp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lawmdEz = sc . nextInt ( ) ; HashSet < Integer > A = new HashSet < > ( ) ; for ( int i = 0 ; i < lawmdEz ; i ++ ) { if ( ! A . add ( sc . nextInt ( ) ) ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class TssIfy { private static int TssA ( int aNum , int bNum , int cNum , int k ) { int TssA = 0 ; if ( k <= aNum ) { return k ; } else { TssA += aNum ; k -= aNum ; } if ( k <= bNum ) { return TssA ; } else { k -= bNum ; } return TssA + 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 ( TssA ( aNum , bNum , cNum , k ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class FqyVhu { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long fqyQ = scanner . nextLong ( ) ; long a = scanner . nextLong ( ) ; long b = scanner . nextLong ( ) ; long aa = fqyQ % ( long ) ( ( long ) a + ( long ) b ) ; long as = ( long ) ( ( long ) fqyQ / ( 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 QmmMwi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qmmUe = 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 ) { qmmUe += 3 ; } else if ( taro_card . compareTo ( hanako_card ) == 0 ) { qmmUe += 1 ; hanako_score += 1 ; } else { hanako_score += 3 ; } } System . out . println ( qmmUe + " " + hanako_score ) ; } } import java . util . Scanner ; public class NdawLavoog { static class NdawLavoog { Integer [ ] [ ] dp ; public void find ( int k ) { dp = new Integer [ k + 1 ] [ k + 1 ] ; long NdawU = 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 ; } NdawU += val2 ; } } } System . out . println ( NdawU ) ; } 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 GyqngdZq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gyqngdAg = sc . nextInt ( ) ; int cent = sc . nextInt ( ) ; int yes = 0 ; for ( int i = 0 ; i < gyqngdAg ; i ++ ) { int height = sc . nextInt ( ) ; if ( height >= cent ) { yes ++ ; } } System . out . print ( yes ) ; } } import java . util . * ; import java . io . * ; class LowskiAed { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s ; int [ ] num = new int [ 26 ] ; char lowskiZz ; while ( ( s = br . readLine ( ) ) != null ) { if ( s . length ( ) >= 1200 ) break ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { lowskiZz = s . charAt ( j ) ; if ( lowskiZz >= 0x41 && lowskiZz <= 0x5a ) { lowskiZz -= 0x41 ; num [ lowskiZz ] += 1 ; } else if ( lowskiZz >= 0x61 && lowskiZz <= 0x7a ) { lowskiZz -= 0x61 ; num [ lowskiZz ] += 1 ; } } } for ( int i = 0 ; i < 26 ; i ++ ) { lowskiZz = ( char ) ( 0x61 + i ) ; System . out . println ( lowskiZz + " : " + num [ i ] ) ; } } } import java . util . Scanner ; public class SdlLlwrvb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SdlQwh = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( s . charAt ( SdlQwh ) != '-' ) { System . out . println ( " No " ) ; return ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i != SdlQwh ) { 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 QrmqnbNler { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qrmqnbK = sc . nextInt ( ) , m = sc . nextInt ( ) ; int k , a ; int [ ] [ ] food = new int [ qrmqnbK ] [ m + 1 ] ; for ( int i = 0 ; i < qrmqnbK ; ++ 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 < qrmqnbK ; ++ j ) { if ( food [ j ] [ i ] == 0 ) break ; } if ( j == qrmqnbK ) ++ ans ; } System . out . println ( ans ) ; } } import java . io . IOException ; import java . util . Scanner ; public class UryEsm { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int UryL = sc . nextInt ( ) ; long a , b , c , d , e ; a = 2 ; b = sc . nextLong ( ) ; c = b ; d = b ; e = b ; while ( a <= UryL ) { 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 XeyedgVjp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long XeyedgVnq = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = 0 ; int i = 1 ; while ( i <= b ) { if ( ( long ) XeyedgVnq * i % b == 0 ) { c = ( long ) XeyedgVnq * i ; break ; } else { i ++ ; } } System . out . println ( c ) ; sc . close ( ) ; } } import java . util . Scanner ; class emvrxlHnd { 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 EmvrxlKdaoz = c . length ; EmvrxlKdaoz > 0 ; EmvrxlKdaoz -- ) { reverse += c [ EmvrxlKdaoz - 1 ] ; } System . out . println ( reverse ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class jixN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Integer [ ] a = new Integer [ 10 ] ; for ( int JixHy = 0 ; JixHy < 10 ; JixHy ++ ) { a [ JixHy ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( a , Collections . reverseOrder ( ) ) ; for ( int JixHy = 0 ; JixHy < 3 ; JixHy ++ ) { System . out . println ( a [ JixHy ] ) ; } } } import java . util . Scanner ; public class JdrbryTdur { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int JdrbryYt = Integer . parseInt ( input . nextLine ( ) ) ; int W = Integer . parseInt ( input . nextLine ( ) ) ; int [ ] v = new int [ JdrbryYt ] ; for ( int i = 0 ; i < JdrbryYt ; 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 < JdrbryYt ; i ++ ) { System . out . println ( v [ i ] + 1 ) ; } System . exit ( 0 ) ; } } import java . util . Scanner ; public class FayRv { static String str ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; str = sc . next ( ) ; int fayTzre = str . length ( ) ; boolean [ ] dp = new boolean [ fayTzre + 1 ] ; dp [ 0 ] = true ; for ( int i = 5 ; i <= fayTzre ; 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 [ fayTzre ] ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class jkuansJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long JkuansItqp = sc . nextLong ( ) ; int count = 1 ; long money = 100 ; while ( true ) { money *= 1.01 ; if ( money >= JkuansItqp ) { System . out . println ( count ) ; return ; } count ++ ; } } } import java . util . * ; public class RqkqEjivpp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str1 = sc . nextLine ( ) ; String str2 = sc . nextLine ( ) ; boolean RqkqYye = 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 ) ) RqkqYye = true ; } if ( RqkqYye ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class BcwHiuw { private static class BcwHiuw { int BcwGh ; int to ; Range ( int BcwGh , int to ) { this . BcwGh = BcwGh ; 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 . BcwGh ; i < range . to ; i ++ ) { hs [ i ] += 1 ; } count ++ ; } } } } import java . util . * ; public class HmhkzgFbf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long HmhkzgD = sc . nextLong ( ) ; long bank = 100 ; long count = 0 ; for ( long i = bank ; i < HmhkzgD ; bank += bank / 100 , count ++ ) { if ( bank >= HmhkzgD ) { System . out . println ( count ) ; break ; } } } } import java . util . * ; public class BqmdmeBhbef { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BqmdmeX = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int res = BqmdmeX / b ; if ( res * b < BqmdmeX ) { ++ res ; } System . out . println ( res ) ; } } import java . util . Scanner ; public class KxxSf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] [ ] [ ] houses = new int [ 4 ] [ 3 ] [ 10 ] ; int kxxAcnu = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] [ ] a = new int [ kxxAcnu ] [ m ] ; int [ ] b = new int [ m ] ; int [ ] c = new int [ kxxAcnu ] ; for ( int i = 0 ; i < kxxAcnu ; 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 < kxxAcnu ; 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 ptcaH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PtcaGoh = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] queue = new int [ PtcaGoh ] [ m ] ; int [ ] vector = new int [ m ] ; int [ ] vectorAns = new int [ PtcaGoh ] ; 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 PbpeJrmp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pbpeRwa = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; double log ; log = Math . log10 ( pbpeRwa ) / Math . log10 ( K ) ; int ans = ( int ) Math . floor ( log ) + 1 ; System . out . println ( ans ) ; } } import java . util . * ; public class QmupnMz { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int qmupnKlv = 5 ; int [ ] array = new int [ qmupnKlv ] ; for ( int i = 0 ; i < qmupnKlv ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int tmp = 0 ; int tmp2 = 10 - ( array [ 0 ] % 10 ) ; for ( int i = 0 ; i < qmupnKlv ; 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 < qmupnKlv ; 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 qysvhhWg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . nextLine ( ) ; int QysvhhZfsdg = 0 ; String t ; while ( ! ( ( t = sc . next ( ) ) . equals ( " END_OF_TEXT " ) ) ) { if ( t . toLowerCase ( ) . equals ( w ) ) QysvhhZfsdg ++ ; } System . out . println ( QysvhhZfsdg ) ; } } import java . io . * ; public class KkvocMwcq { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = reader . readLine ( ) . split ( " " ) ; int kkvocLnmm = Integer . parseInt ( arr [ 0 ] ) ; int K = Integer . parseInt ( arr [ 1 ] ) ; int cnt = 1 ; while ( Math . pow ( K , cnt ) <= kkvocLnmm ) cnt ++ ; System . out . println ( cnt ) ; } } import java . util . * ; public class DmhseSee { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DmhseXan = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; double a = sc . nextInt ( ) ; double min = 1000000 ; int ans = 0 ; int [ ] h = new int [ DmhseXan ] ; for ( int i = 0 ; i < DmhseXan ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < DmhseXan ; 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 uqwicbMm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int UqwicbJug = scanner . nextInt ( ) ; int a = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int total = 0 ; for ( int i = 1 ; i <= UqwicbJug ; 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 snyFr { public void run ( java . io . InputStream in , java . io . PrintStream out ) { java . util . Scanner sc = new java . util . Scanner ( in ) ; int SnySrxyh , x ; int i , j , k , count ; for ( ; ; ) { SnySrxyh = sc . nextInt ( ) ; x = sc . nextInt ( ) ; if ( SnySrxyh == 0 && x == 0 ) break ; count = 0 ; for ( i = 1 ; i <= SnySrxyh ; i ++ ) { for ( j = i + 1 ; j <= SnySrxyh ; j ++ ) { if ( x - i - j > j && x - i - j <= SnySrxyh ) 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 rabmJav { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int RabmAirl = 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 [ RabmAirl ] ; for ( i = 0 ; i < RabmAirl ; 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 PkuyTxea { 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 pkuyKv = 0 ; pkuyKv < 8 ; pkuyKv ++ ) { int sum = x [ 0 ] ; for ( int j = 0 ; j < 3 ; j ++ ) { if ( ( 1 & ( pkuyKv >> 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 jtaicD { 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 jtaicD { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long JtaicHhwmu = in . nextLong ( ) , x = in . nextLong ( ) ; long count = 1 , sum = 0 ; for ( long i = 1 ; i <= JtaicHhwmu ; i ++ ) { long y = in . nextLong ( ) ; sum += y ; if ( sum <= x ) count ++ ; } out . println ( count ) ; } } } import java . util . Scanner ; public class HvbqDb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HvbqBxu = sc . nextInt ( ) ; int maxHigh = 0 ; int view = 0 ; for ( int i = 0 ; i < HvbqBxu ; i ++ ) { int High = sc . nextInt ( ) ; if ( maxHigh <= High ) { maxHigh = High ; view ++ ; } } System . out . println ( view ) ; } } import java . util . * ; public class YdkqTn { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int ydkqTtob = s . nextInt ( ) ; int [ ] check = { 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; String ans = " No " ; if ( ydkqTtob >= 10 ) { for ( int i = 0 ; i < check . length ; i ++ ) { if ( ydkqTtob % check [ i ] == 0 && ydkqTtob / check [ i ] < 10 ) { ans = " Yes " ; break ; } } } else { ans = " Yes " ; } System . out . println ( ans ) ; } } import java . util . * ; public class niyZt { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { int NiyOh = sc . nextInt ( ) ; int [ ] arr = new int [ NiyOh ] ; int [ ] check = new int [ NiyOh ] ; for ( int i = 0 ; i < NiyOh ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int res = 0 ; while ( ! Arrays . equals ( arr , check ) ) { int l = 0 ; int min = Integer . MAX_VALUE ; while ( l < NiyOh && arr [ l ] == 0 ) { l ++ ; } int cp = l ; while ( l < NiyOh && 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 OkiNa { public static void main ( String [ ] Args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int okiTbdq = s . length ( ) ; int flag = 0 ; for ( int i = 1 ; i <= okiTbdq ; 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 uahiNg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long UahiBsjch = sc . nextLong ( ) ; int i = 2 ; while ( true ) { if ( i == UahiBsjch ) { System . out . println ( i ) ; return ; } if ( UahiBsjch % i == 0 ) { UahiBsjch ++ ; i = 2 ; continue ; } else { i ++ ; } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class QejjCk { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int QejjX = Integer . valueOf ( br . readLine ( ) ) ; int z = Integer . valueOf ( br . readLine ( ) ) ; if ( QejjX == 1 ) { if ( z == 2 ) { System . out . print ( " 3 " ) ; } else if ( z == 3 ) { System . out . print ( " 2 " ) ; } } else if ( QejjX == 2 ) { if ( z == 1 ) { System . out . print ( " 3 " ) ; } else if ( z == 3 ) { System . out . print ( " 1 " ) ; } } else if ( QejjX == 3 ) { if ( z == 1 ) { System . out . print ( " 2 " ) ; } else if ( z == 2 ) { System . out . print ( " 1 " ) ; } } } } import java . util . Scanner ; public class VpntwcXrae { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int VpntwcC , col ; int [ ] matrix ; VpntwcC = scanner . nextInt ( ) ; col = scanner . nextInt ( ) ; matrix = new int [ col ] ; int in , sum ; for ( int rowi = 0 ; rowi < VpntwcC ; 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 HugMp { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; char hugIl = in . next ( ) . charAt ( 0 ) ; int integerInput = hugIl ; 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 PgoQmnz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pgoU = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int ans = 0 ; while ( pgoU > 0 ) { pgoU = pgoU - a ; ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; public class aokkAx { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int AokkHsh = sc . nextInt ( ) ; int [ ] a = new int [ AokkHsh ] ; for ( int i = 0 ; i < AokkHsh ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int count = 0 ; boolean flg = true ; while ( flg ) { for ( int i = 0 ; i < AokkHsh ; i ++ ) { if ( a [ i ] % 2 == 0 ) { a [ i ] /= 2 ; if ( i == AokkHsh - 1 ) count ++ ; } else { flg = false ; break ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class vfccL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VfccFbl = sc . nextInt ( ) ; int z = 0 ; if ( VfccFbl % 2 == 0 ) { z = VfccFbl / 2 ; } else { z = VfccFbl / 2 + 1 ; } System . out . print ( z ) ; } } import java . io . IOException ; import java . util . Scanner ; public class ZvenXj { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int ZvenJs = 1 ; int i = 0 ; while ( true ) { ZvenJs = sc . nextInt ( ) ; i ++ ; if ( ZvenJs == 0 ) { break ; } System . out . println ( " Case " + i + " : " + ZvenJs ) ; } } } import java . util . * ; public class CrsBbs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CrsCh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] p = s . toCharArray ( ) ; int flag = 0 ; for ( int i = 0 ; i < CrsCh ; i ++ ) { if ( p [ i ] < '0' || p [ i ] > '9' ) { flag = 1 ; } } if ( p [ CrsCh ] != '-' ) { flag = 1 ; } for ( int i = CrsCh + 1 ; i <= CrsCh + 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 jvfyhhUs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JvfyhhHx = sc . nextInt ( ) ; int X2 = sc . nextInt ( ) ; int X3 = sc . nextInt ( ) ; int X4 = sc . nextInt ( ) ; int X5 = sc . nextInt ( ) ; if ( JvfyhhHx == 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 jjlPic { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int JjlTk = s . nextInt ( ) ; int B = s . nextInt ( ) ; if ( 0 < JjlTk && JjlTk < 10 && 0 < B && B < 10 ) { System . out . println ( JjlTk * B ) ; } else { System . out . println ( - 1 ) ; } s . close ( ) ; } } import java . util . * ; public class mxrzypRv { public static void main ( String [ ] args ) { int MxrzypNqko = 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 ncnavA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double NcnavIctl = sc . nextDouble ( ) ; double calc1 = Math . pow ( NcnavIctl , 2 ) ; double calc2 = Math . pow ( NcnavIctl , 3 ) ; System . out . println ( ( int ) NcnavIctl + ( int ) calc1 + ( int ) calc2 ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class IhbyRglj { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int ihbyS = in . nextInt ( ) ; int t = in . nextInt ( ) ; int s = in . nextInt ( ) ; if ( t * s < ihbyS ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . * ; public class arbkQxb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ArbkBa = sc . nextInt ( ) ; boolean [ ] b = new boolean [ 1000001 ] ; b [ ArbkBa ] = true ; int i = 2 ; while ( true ) { if ( ArbkBa % 2 == 0 ) { ArbkBa /= 2 ; } else { ArbkBa = ArbkBa * 3 + 1 ; } if ( b [ ArbkBa ] ) { break ; } else { b [ ArbkBa ] = true ; } i ++ ; } System . out . println ( i ) ; } } import java . util . HashSet ; import java . util . Scanner ; class XsltwhNg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xsltwhH = 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 ( xsltwhH - hs . size ( ) ) ; } } import java . util . * ; public class QbmxMhs { public static void main ( String [ ] args ) { int qbmxMdh ; double tSurf , tA ; Scanner sc = new Scanner ( System . in ) ; qbmxMdh = sc . nextInt ( ) ; tSurf = sc . nextDouble ( ) ; tA = sc . nextDouble ( ) ; double [ ] ts = new double [ qbmxMdh ] ; int result = 1 ; double min = 0 ; for ( int i = 0 ; i < qbmxMdh ; 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 ZsgIcwiwr { public static void main ( String [ ] args ) { Scanner sc = null ; try { sc = new Scanner ( System . in ) ; int ZsgM = Integer . parseInt ( sc . nextLine ( ) ) ; int [ ] numBox = new int [ ZsgM ] ; 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 LnxxuaZcwe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] x = new int [ 100000 ] , y = new int [ 100000 ] ; int lnxxuaFs = 0 , a ; while ( true ) { x [ lnxxuaFs ] = sc . nextInt ( ) ; y [ lnxxuaFs ] = sc . nextInt ( ) ; if ( x [ lnxxuaFs ] == 0 && y [ lnxxuaFs ] == 0 ) break ; if ( x [ lnxxuaFs ] > y [ lnxxuaFs ] ) { a = x [ lnxxuaFs ] ; x [ lnxxuaFs ] = y [ lnxxuaFs ] ; y [ lnxxuaFs ] = a ; } lnxxuaFs ++ ; } for ( int j = 0 ; j < lnxxuaFs ; j ++ ) { System . out . println ( x [ j ] + " " + y [ j ] ) ; } } } import java . util . Scanner ; public class rqrE { public static void main ( String [ ] argc ) { Scanner sc = new Scanner ( System . in ) ; int RqrInxv = sc . nextInt ( ) ; int [ ] A = new int [ RqrInxv ] ; for ( int i = 0 ; i < RqrInxv ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int j = 0 ; j < RqrInxv ; j ++ ) { int min = j ; for ( int k = j ; k < RqrInxv ; 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 < RqrInxv ; m ++ ) { if ( m == RqrInxv - 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 qfmoP { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QfmoNspqe = 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 [ QfmoNspqe ] [ num ] ; for ( int i = 0 ; i < QfmoNspqe ; 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 gntAj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String GntRuwld = sc . next ( ) ; HashMap < String , String > map = new HashMap < > ( ) ; map . put ( " ARC " , " ABC " ) ; map . put ( " ABC " , " ARC " ) ; System . out . println ( map . get ( GntRuwld ) ) ; } } import java . util . Scanner ; public class MkjbxfPsu { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int mkjbxfFh = stdIn . nextInt ( ) ; int q = stdIn . nextInt ( ) ; int r = stdIn . nextInt ( ) ; int a = mkjbxfFh + q ; int b = q + r ; int c = mkjbxfFh + 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 PtkjUi { public static void main ( String [ ] args ) { int ptkjSiy , q , t ; int t_sum = 0 ; String pros ; Deque < String > name = new ArrayDeque < > ( ) ; Deque < Integer > time = new ArrayDeque < > ( ) ; Scanner sc = new Scanner ( System . in ) ; ptkjSiy = sc . nextInt ( ) ; q = sc . nextInt ( ) ; for ( int i = 0 ; i < ptkjSiy ; 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 EpvHpac { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int epvLg = sc . nextInt ( ) , f = 1 ; int [ ] a = new int [ epvLg ] ; for ( int i = 0 ; i < epvLg ; 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 IcdpbSwj { public static void main ( String [ ] args ) { char [ ] ch = " abcdefghijklmnopqrstuvwxyz " . toCharArray ( ) ; Scanner scan = new Scanner ( System . in ) ; long icdpbMstp = scan . nextLong ( ) ; StringBuilder sb = new StringBuilder ( ) ; int t ; for ( ; icdpbMstp > 0 ; icdpbMstp = ( icdpbMstp - 1 ) / 26 ) { t = ( int ) ( ( icdpbMstp - 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 uywkkpJe { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int UywkkpAlugr = 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 != UywkkpAlugr ) { 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 JptpGqv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jptpNb = sc . nextInt ( ) ; int [ ] a = new int [ jptpNb + 1 ] ; for ( int i = 1 ; i <= jptpNb ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int count = 0 ; boolean [ ] flag = new boolean [ jptpNb + 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 FtzzkgUr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long FtzzkgS = sc . nextLong ( ) ; long val = log2 ( FtzzkgS ) ; 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 SpenoCjv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long spenoLwzz = sc . nextLong ( ) ; long ans = 1 ; long count = 1 ; while ( spenoLwzz > 1 ) { spenoLwzz = spenoLwzz / 2 ; ans += Math . pow ( 2 , count ) ; count ++ ; } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; class XysTdt { public static void main ( String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; String xysB ; xysB = sc . next ( ) ; solve ( xysB ) ; } static void solve ( String xysB ) { System . out . println ( calc ( xysB ) ) ; } static int calc ( String xysB ) { switch ( xysB ) { 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 RsaybxXai { 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 NkgLsb { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int NkgFc = 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 ; } NkgFc = NkgFc - d ; if ( NkgFc <= 0 ) { System . out . println ( " No " ) ; flg = false ; } } } } import java . util . * ; public class AbjtbmZroa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String AbjtbmVd = sc . next ( ) ; if ( AbjtbmVd . equals ( " AAA " ) ) { System . out . println ( " No " ) ; } else if ( AbjtbmVd . equals ( " BBB " ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class tqnfAgp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long TqnfZa = sc . nextLong ( ) ; int ans = ( int ) Math . log10 ( TqnfZa ) + 1 ; for ( int i = 1 ; i <= Math . sqrt ( TqnfZa ) ; i ++ ) { if ( TqnfZa % i == 0 ) ans = ( int ) Math . min ( ans , Math . log10 ( TqnfZa / i ) + 1 ) ; } System . out . println ( ans ) ; } } import java . io . * ; public class davabzDis { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { int DavabzRipwz , sum = 0 ; try { String line = reader . readLine ( ) ; if ( line . equals ( " 0 " ) ) break ; for ( DavabzRipwz = 0 ; DavabzRipwz < line . length ( ) ; DavabzRipwz ++ ) { char c = line . charAt ( DavabzRipwz ) ; sum += Character . getNumericValue ( c ) ; } } catch ( IOException e ) { System . out . println ( e ) ; } System . out . println ( sum ) ; } } } import java . util . Scanner ; public class KngtyIdby { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KngtyL = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int count = 0 ; int n = 0 ; for ( int i = Math . max ( KngtyL , b ) ; i >= 1 ; i -- ) { if ( KngtyL % i == 0 && b % i == 0 ) { count ++ ; n = i ; if ( count >= k ) break ; } } System . out . println ( n ) ; } } import java . util . Scanner ; public class WlfUilv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WlfE = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ WlfE ] ; long [ ] dp = new long [ WlfE ] ; for ( int i = 0 ; i < WlfE ; i ++ ) { h [ i ] = sc . nextInt ( ) ; dp [ i ] = 9223372036854775807l ; } dp [ 0 ] = 0 ; for ( int i = 1 ; i < WlfE ; 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 [ WlfE - 1 ] ) ; } } import java . util . * ; public class GgldjPzxfyh { 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 GgldjZ = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; if ( ( GgldjZ == 0 ) && ( x == 0 ) ) { break ; } listN . add ( GgldjZ ) ; listX . add ( x ) ; } for ( int i = 0 ; i < listN . size ( ) ; i ++ ) { int GgldjZ = listN . get ( i ) ; int x = listX . get ( i ) ; int cnt = 0 ; for ( int a = 1 ; a <= GgldjZ ; a ++ ) { for ( int b = a + 1 ; b <= GgldjZ ; b ++ ) { for ( int c = b + 1 ; c <= GgldjZ ; c ++ ) { int sum = a + b + c ; if ( sum == x ) { cnt ++ ; } } } } System . out . println ( cnt ) ; } } } import java . util . * ; public class ElmeNlfsz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Long N = sc . nextLong ( ) ; int ElmeW = ( int ) Math . floor ( Math . sqrt ( ( double ) N ) ) ; for ( int i = ElmeW ; 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 QmuetuRmmuaw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long QmuetuH = scan . nextLong ( ) , m = scan . nextLong ( ) ; for ( int i = 0 ; i < m ; i ++ ) { QmuetuH -= scan . nextLong ( ) ; if ( QmuetuH < 0 ) { System . out . println ( - 1 ) ; scan . close ( ) ; return ; } } System . out . println ( QmuetuH ) ; scan . close ( ) ; return ; } } import java . util . Scanner ; public class AyrfbFoc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ayrfbV = sc . nextInt ( ) ; int [ ] [ ] D = new int [ ayrfbV ] [ 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 FvhNado { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int fvhG = scanner . nextInt ( ) ; final int k = scanner . nextInt ( ) ; double result = 0 ; for ( int i = 1 ; i <= fvhG ; 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 / fvhG ) ; } } import java . util . * ; import java . io . * ; public class DkrHuy { public static void main ( String [ ] args ) throws Exception { FastScanner fs = new FastScanner ( ) ; int DkrI = fs . nextInt ( ) ; if ( DkrI == 0 ) System . out . println ( 1 ) ; else System . out . println ( 0 ) ; } static class DkrHuy { 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 kjsOdu { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int KjsLany = stdIn . nextInt ( ) ; int t = stdIn . nextInt ( ) ; int s = stdIn . nextInt ( ) ; if ( KjsLany <= t * s ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class GlwIeo { public static void main ( String [ ] Args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = new String [ 3 ] ; for ( int glwQ = 0 ; glwQ < 3 ; glwQ ++ ) { s [ glwQ ] = 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 VfjyTyrq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int VfjyStg = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int tax8pricemin = ( int ) ( ( ( double ) VfjyStg ) / 0.08 ) ; int tax8pricemax = ( int ) ( ( ( double ) VfjyStg + 1 ) / 0.08 ) ; for ( int i = tax8pricemin ; i < tax8pricemax ; i ++ ) { int tax8 = ( int ) ( i * 0.08 ) ; int tax10 = ( int ) ( i * 0.1 ) ; if ( tax8 == VfjyStg && tax10 == b ) { System . out . println ( i ) ; System . exit ( 0 ) ; } } System . out . println ( - 1 ) ; } } import java . util . Scanner ; public class ehfhBtp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EhfhQhjzb = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int count = 0 ; while ( true ) { if ( ( EhfhQhjzb - 1 ) * count + 1 >= B ) { break ; } count += 1 ; } System . out . println ( count ) ; } } import java . math . BigInteger ; import java . util . Scanner ; public class ivuZz { public static void main ( String [ ] args ) { BigInteger MAX = new BigInteger ( " 1000000000000000000 " ) ; Scanner sc = new Scanner ( System . in ) ; int IvuLiwgx = sc . nextInt ( ) ; BigInteger [ ] s = new BigInteger [ IvuLiwgx ] ; BigInteger ans = BigInteger . ONE ; for ( int i = 0 ; i < IvuLiwgx ; i ++ ) { s [ i ] = sc . nextBigInteger ( ) ; if ( s [ i ] . compareTo ( BigInteger . ZERO ) == 0 ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } } for ( int i = 0 ; i < IvuLiwgx ; 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 oodL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char OodSfhc ; char [ ] ch = { 'A' , 'C' , 'G' , 'T' } ; int count = 0 ; int count_max = 0 ; boolean con ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { OodSfhc = s . charAt ( i ) ; con = true ; count ++ ; for ( int j = 0 ; j < 4 && con ; j ++ ) { if ( OodSfhc == 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 CrkuneCbqk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long CrkuneEd = sc . nextLong ( ) ; for ( int i = 0 ; i < Math . min ( CrkuneEd , 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 NizAx { public static int func ( int n ) { int nizGb = 0 ; if ( n % 2 == 0 ) { nizGb = n / 2 ; } else if ( n % 2 == 1 ) { nizGb = 3 * n + 1 ; } return nizGb ; } 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 AqnagmKs { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int aqnagmQww = in . nextInt ( ) ; int K = in . nextInt ( ) ; int [ ] h = new int [ aqnagmQww ] ; int count = 0 ; for ( int i = 0 ; i < aqnagmQww ; i ++ ) { h [ i ] = in . nextInt ( ) ; if ( h [ i ] >= K ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; class DkzkyzVmm { static PrintStream out = System . out ; static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int dkzkyzE = 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 <= dkzkyzE ) ; out . println ( ) ; } } import java . util . Scanner ; public class RneyqfAno { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str1 = sc . next ( ) ; String str2 = " 7 " ; int RneyqfKwm = str1 . indexOf ( str2 ) ; if ( RneyqfKwm != - 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class yhlHvq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int YhlYjln = 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 ( YhlYjln , 2 ) + Math . pow ( B , 2 ) - 2 * YhlYjln * 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 IbjXmzmnu { 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 IbjXmzmnu { int IbjHhu ; int M ; boolean [ ] a ; int mod = ( int ) ( 1e9 + 7 ) ; public void solve ( int testNumber , Scanner in , PrintWriter out ) { IbjHhu = in . nextInt ( ) ; M = in . nextInt ( ) ; a = new boolean [ IbjHhu + 1 ] ; Arrays . fill ( a , true ) ; for ( int i = 0 ; i < M ; i ++ ) { a [ in . nextInt ( ) ] = false ; } int [ ] dp = new int [ IbjHhu + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i <= IbjHhu ; i ++ ) { if ( a [ i ] ) { dp [ i ] = dp [ i - 1 ] ; if ( i - 2 >= 0 ) { dp [ i ] += dp [ i - 2 ] ; } dp [ i ] %= mod ; } } out . println ( dp [ IbjHhu ] ) ; } } } import java . util . Scanner ; import java . util . regex . * ; import java . math . * ; public class DwgbrYvgobe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DwgbrSeo = 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 ( DwgbrSeo == 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 chcExj { static class chcExj { 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 ChcIfzh = obj . nextInt ( ) , sn2 = obj . nextInt ( ) ; String t = obj . next ( ) ; if ( t . equals ( s1 ) ) ChcIfzh -- ; else sn2 -- ; System . out . println ( ChcIfzh + " " + sn2 ) ; } } import java . util . Scanner ; class YrypFdbt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YrypYm , X ; YrypYm = sc . nextInt ( ) ; X = sc . nextInt ( ) ; int count = X - YrypYm + 1 ; for ( int i = 0 ; i < ( 2 * YrypYm ) - 1 ; i ++ , count ++ ) System . out . print ( count + " " ) ; System . out . println ( ) ; } } import java . util . Scanner ; public class tzlqyZxe { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int TzlqyNr = sc . nextInt ( ) ; while ( true ) { if ( prime ( TzlqyNr ) ) { break ; } TzlqyNr ++ ; } System . out . println ( TzlqyNr ) ; sc . close ( ) ; } private boolean prime ( int TzlqyNr ) { if ( TzlqyNr == 0 || TzlqyNr == 1 ) { return false ; } if ( TzlqyNr == 2 ) return true ; if ( TzlqyNr % 2 == 0 ) return false ; for ( int i = 3 ; i * i <= TzlqyNr ; i += 2 ) { if ( TzlqyNr % i == 0 ) { return false ; } } return true ; } } import java . util . Scanner ; public class SljaMy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; sc . close ( ) ; int sljaKb = ( int ) 'A' - ( int ) 'a' ; for ( char moji : input . toCharArray ( ) ) { if ( 'a' <= moji && moji <= 'z' ) { System . out . print ( ( char ) ( ( int ) moji + sljaKb ) ) ; } else if ( 'A' <= moji && moji <= 'Z' ) { System . out . print ( ( char ) ( ( int ) moji - sljaKb ) ) ; } else { System . out . print ( moji ) ; } } System . out . println ( ) ; } } import java . util . Scanner ; public class NykUk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int NykBz = scan . nextInt ( ) ; int min = 0 ; int max = 0 ; long amount = 0 ; for ( int i = 0 ; i < NykBz ; 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 VxrdssRqa { 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 vxrdssEc = 0 ; vxrdssEc < splitWord . length - 1 ; vxrdssEc ++ ) { String rear = splitWord [ vxrdssEc ] ; String front = splitWord [ vxrdssEc + 1 ] ; if ( front . equals ( rear ) ) { return true ; } } return false ; } } import java . util . Scanner ; public class VznjafZcbvy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String VznjafEw = scan . nextLine ( ) ; String p = scan . nextLine ( ) ; VznjafEw += VznjafEw . substring ( 0 , VznjafEw . length ( ) - 1 ) ; if ( VznjafEw . indexOf ( p ) == - 1 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class QmzvsWe { 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 QmzvsUp = 0 ; QmzvsUp < s . length ( ) ; QmzvsUp ++ ) { for ( int j = 0 ; j < c . length ; j ++ ) { c [ j ] = s . charAt ( ( j + QmzvsUp ) % 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 JzcuFc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jzcuD = sc . nextInt ( ) ; int [ ] b = new int [ jzcuD - 1 ] ; int result = 0 ; int pre = 0 ; for ( int i = 0 ; i < jzcuD - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; if ( i == 0 ) result = result + b [ i ] ; if ( i > 0 ) { result = result + min ( pre , b [ i ] ) ; } if ( i == jzcuD - 2 ) result = result + b [ i ] ; pre = b [ i ] ; } System . out . println ( result ) ; } } import java . util . * ; public class NlxzlvKt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long nlxzlvWt = sc . nextLong ( ) ; long year = 0 ; double kingaku = 100 ; do { kingaku = kingaku * 1.01 ; kingaku = Math . floor ( kingaku ) ; year ++ ; } while ( kingaku < nlxzlvWt ) ; System . out . println ( year ) ; } } import java . util . Scanner ; public class IojZds { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; for ( int IojPed = 1 ; IojPed > 0 ; IojPed ++ ) { 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 TctVvf { 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 tctGuu = Integer . parseInt ( x [ 0 ] ) ; int b = Integer . parseInt ( x [ 1 ] ) ; int c = Integer . parseInt ( x [ 2 ] ) ; if ( b > tctGuu && 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 OarfKp { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner s = new Scanner ( System . in ) ; int oarfMwk = s . nextInt ( ) ; int K = s . nextInt ( ) ; Set set = new HashSet ( ) ; for ( int i = 1 ; i <= oarfMwk ; 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 fyjucLxq { public static void main ( String [ ] args ) { Scanner s = null ; try { s = new Scanner ( System . in ) ; String FyjucDd = s . nextLine ( ) ; System . out . println ( powBy3 ( Integer . parseInt ( FyjucDd ) ) ) ; } 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 nittvrPc { 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 NittvrCosc = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( S . charAt ( i ) == T . charAt ( i ) ) { NittvrCosc ++ ; } } out . println ( NittvrCosc ) ; } } import java . util . * ; import java . text . * ; public class OqkkBdg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oqkkItcq = sc . nextInt ( ) ; int count = 0 ; int a = 0 ; for ( int i = 1 ; i <= oqkkItcq ; i ++ ) { a = i % 2 ; if ( a == 1 ) { count += 1 ; } } double prob = ( double ) count / oqkkItcq ; System . out . println ( prob ) ; } } import java . util . Scanner ; public class MddzmdMjub { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mddzmdB = sc . nextInt ( ) ; int [ ] array = new int [ mddzmdB ] ; for ( int i = 0 ; i < mddzmdB ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } long min = 1000001 ; for ( int i = 0 ; i < mddzmdB ; i ++ ) { if ( min > array [ i ] ) { min = array [ i ] ; } } long max = - 1000001 ; for ( int i = 0 ; i < mddzmdB ; i ++ ) { if ( max < array [ i ] ) { max = array [ i ] ; } } long sum = 0 ; for ( int i = 0 ; i < mddzmdB ; i ++ ) { sum += array [ i ] ; } System . out . println ( min + " " + max + " " + sum ) ; } } import java . util . Scanner ; public class iofmpD { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int IofmpXpclu = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int s = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( IofmpXpclu > b ) { s += IofmpXpclu -- ; } else { s += b -- ; } } System . out . print ( s ) ; } } import java . util . Scanner ; class LtbEl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ltbO = scan . nextInt ( ) ; int [ ] num = new int [ ltbO ] ; int count ; for ( int c = 0 ; c < ltbO ; c ++ ) { num [ c ] = scan . nextInt ( ) ; } count = bubbleSort ( num , ltbO ) ; for ( int i = 0 ; i < ltbO ; i ++ ) { if ( i != ltbO - 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 JsjhJsjg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JsjhLm = sc . nextInt ( ) ; int g = JsjhLm / 2 ; double ans = ( double ) ( JsjhLm - g ) / JsjhLm ; out . println ( ans ) ; } } import java . util . Scanner ; class dqhxfvZo { private static String toString ( int [ ] numbers ) { StringBuilder ans = new StringBuilder ( ) . append ( numbers [ 0 ] ) ; for ( int DqhxfvOwirb = 1 ; DqhxfvOwirb < numbers . length ; DqhxfvOwirb ++ ) ans . append ( " " ) . append ( numbers [ DqhxfvOwirb ] ) ; 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 mqooG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MqooDco = 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 = ( MqooDco * MqooDco ) + ( num2 * num2 ) - ( 2 * MqooDco * num2 * Math . cos ( rad ) ) ; System . out . print ( Math . sqrt ( num3 ) ) ; } } import java . util . Scanner ; class QeggJizht { 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 QeggLc = 0 ; long a = num [ 0 ] ; long b = num [ 1 ] ; do { QeggLc = a % b ; a = b ; b = QeggLc ; } while ( QeggLc != 0 ) ; return a ; } private static long lcm ( long [ ] num ) { return ( num [ 0 ] * num [ 1 ] ) / gcd ( num ) ; } } import java . util . Scanner ; public class ffnG { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int FfnRfcb = input . nextInt ( ) ; int back , i , j = 1 ; while ( true ) { i = j * 1000 ; if ( i >= FfnRfcb ) { back = i - FfnRfcb ; break ; } j ++ ; } System . out . println ( back ) ; } } import java . util . Scanner ; public class MymsgpXbm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String mymsgpBdai = sc . next ( ) ; String t = sc . next ( ) ; String T1 = t . substring ( mymsgpBdai . length ( ) - 0 ) ; if ( t . equals ( mymsgpBdai + T1 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class okjdpnIko { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OkjdpnYka = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int value = OkjdpnYka + b + c ; int product = OkjdpnYka * b * c ; if ( value == 17 & product == 175 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class WhaTh { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int WhaQac = scanner . nextInt ( ) ; final int x = scanner . nextInt ( ) ; final int [ ] lengths = new int [ WhaQac ] ; for ( int i = 0 ; i < lengths . length ; i ++ ) { lengths [ i ] = scanner . nextInt ( ) ; } int i ; int distance = 0 ; for ( i = 0 ; i < WhaQac ; 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 KustlIvli { public static void main ( String [ ] args ) { try { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = reader . readLine ( ) ; int KustlL = Integer . parseInt ( s ) ; String t = reader . readLine ( ) ; String [ ] u = t . split ( " " ) ; int [ ] m = new int [ KustlL ] ; for ( int i = 0 ; i < KustlL ; i ++ ) { m [ i ] = Integer . parseInt ( u [ i ] ) ; } for ( int j = KustlL - 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 QpbEp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qpbMu = sc . nextInt ( ) ; int [ ] arrs = new int [ qpbMu + 1 ] ; for ( int i = 1 ; i <= qpbMu ; i ++ ) { arrs [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int i = 1 ; i <= qpbMu ; i ++ ) { result += Math . max ( arrs [ i ] - arrs [ i - 1 ] , 0 ) ; } System . out . println ( result ) ; } } import java . util . * ; public class edmeL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EdmeHflea = 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 < EdmeHflea ; 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 DoosXwbt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int doosZ = sc . nextInt ( ) ; double M = sc . nextInt ( ) ; int [ ] A = new int [ doosZ ] ; double sum = 0 ; for ( int i = 0 ; i < doosZ ; 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 pleekpWlo { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int PleekpLxlob = input . nextInt ( ) ; int X = input . nextInt ( ) ; int [ ] L = new int [ PleekpLxlob ] ; 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 LgxbqZy { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int LgxbqNbu = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int C = scanner . nextInt ( ) ; System . out . println ( Math . max ( 0 , C - ( LgxbqNbu - B ) ) ) ; } } import java . util . Scanner ; public class buiyroQtv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BuiyroZzfjw = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; int result = 0 ; for ( int i = 2 ; i < BuiyroZzfjw ; 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 IzkEze { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int izkZlce = 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 " ) ) { izkZlce ++ ; } else if ( i == 1 && izkZlce == 1 ) { break ; } } System . out . println ( izkZlce ) ; } } import java . util . * ; public class zgwxhbRnq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZgwxhbZu = 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 FrbwjSuo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int frbwjOxj = scan . nextInt ( ) ; int waza = scan . nextInt ( ) ; long [ ] hp = new long [ frbwjOxj ] ; for ( int i = 0 ; i < frbwjOxj ; i ++ ) { hp [ i ] = scan . nextInt ( ) ; } long sum = 0 ; Arrays . sort ( hp ) ; for ( int i = 0 ; i < frbwjOxj - waza ; i ++ ) { sum += hp [ i ] ; } System . out . println ( sum ) ; scan . close ( ) ; } } import java . util . * ; public class PzbmtoFqcx { private static final Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int pzbmtoX = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int d = pzbmtoX / b ; int r = pzbmtoX % b ; double f = ( double ) pzbmtoX / ( double ) b ; System . out . printf ( " %d %d %f \n " , d , r , f ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class WalgHvpt { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int WalgOr = sc . nextInt ( ) ; String [ ] S = new String [ WalgOr ] ; for ( int i = 0 ; i < WalgOr ; i ++ ) { S [ i ] = sc . next ( ) ; } HashSet < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < WalgOr ; i ++ ) { set . add ( S [ i ] ) ; } System . out . println ( set . size ( ) ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class IdzlqoQa { 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 IdzlqoJ = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( list . contains ( str [ i ] ) ) { IdzlqoJ ++ ; } else { list . add ( str [ i ] ) ; } } if ( list . size ( ) > 2 ) { System . out . println ( " No " ) ; } else { if ( IdzlqoJ == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . io . * ; import java . util . * ; public class RecmYqdp { public static void main ( String [ ] args ) throws IOException { Scanner scn = new Scanner ( System . in ) ; int recmO = scn . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= recmO ; i ++ ) { if ( i % 3 != 0 && i % 5 != 0 ) ans += i ; } System . out . println ( ans ) ; } static class RecmYqdp { 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 RgnbUylj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rgnbHnw = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( ( rgnbHnw + b + c ) == 17 && ( rgnbHnw * b * c ) == 175 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; class yiwucWnd { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YiwucIzh = sc . nextInt ( ) ; String [ ] S = new String [ YiwucIzh ] ; int ans = 1 ; for ( int i = 0 ; i < YiwucIzh ; i ++ ) { S [ i ] = sc . next ( ) ; } Arrays . sort ( S ) ; for ( int i = 1 ; i < YiwucIzh ; i ++ ) { if ( ! S [ i - 1 ] . equals ( S [ i ] ) ) { ans ++ ; } } System . out . print ( ans ) ; } } import java . util . Scanner ; public class JlajkRhqf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JlajkBkl = sc . nextInt ( ) ; int [ ] a = new int [ JlajkBkl ] ; for ( int i = 0 ; i < JlajkBkl ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } boolean f = true ; for ( int i = JlajkBkl - 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 DjyjXmd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String l1 = scan . nextLine ( ) ; scan . close ( ) ; int DjyjKyr = Integer . valueOf ( l1 ) ; double side = DjyjKyr / 3.0 ; System . out . println ( String . format ( " %.12f " , side * side * side ) ) ; } } import java . util . Scanner ; class buzM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] iro = new int [ 8 ] ; int BuzKjx = 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 { BuzKjx ++ ; } } int clr = 0 ; for ( int i = 0 ; i < 8 ; i ++ ) { if ( iro [ i ] > 0 ) { clr ++ ; } } System . out . println ( Math . max ( 1 , clr ) + " " + ( clr + BuzKjx ) ) ; } } import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; public class VpjFr { 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 VpjVe = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < VpjVe ; 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 OagAgfr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int OagWv = scanner . nextInt ( ) ; Integer [ ] a = new Integer [ OagWv ] ; boolean s = true ; int Alice = 0 ; int Bob = 0 ; for ( int i = 0 ; i < OagWv ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( a , Comparator . reverseOrder ( ) ) ; for ( int i = 0 ; i < OagWv ; 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 QvmcPpw { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int qvmcE = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; System . out . println ( Math . min ( qvmcE * A , B ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class WeznsoXn { 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 weznsoOyc = Integer . parseInt ( result [ 0 ] ) ; int num2 = Integer . parseInt ( result [ 1 ] ) ; int num3 = Integer . parseInt ( result [ 2 ] ) ; if ( weznsoOyc < num2 ) { if ( num2 < num3 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class KnjeAs { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int knjeBkgk = scanner . nextInt ( ) ; int input = scanner . nextInt ( ) ; String str = new Integer ( knjeBkgk ) . toString ( knjeBkgk , input ) ; System . out . println ( str . length ( ) ) ; } } import java . util . Scanner ; public class YpjvejZnf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ypjvejJ = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int [ ] num_road = new int [ ypjvejJ ] ; int [ ] a = new int [ M ] ; int [ ] b = new int [ M ] ; int i ; for ( i = 0 ; i < ypjvejJ ; 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 < ypjvejJ ; i ++ ) { System . out . println ( num_road [ i ] ) ; } } } import java . util . Scanner ; public class DrfgysGu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int drfgysJnqi = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = 0 ; if ( drfgysJnqi % X > 0 ) A = 1 ; System . out . println ( ( drfgysJnqi / X + A ) * T ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class OkuQxsa { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] string = br . readLine ( ) . split ( " " ) ; int okuMbe = Integer . parseInt ( string [ 0 ] ) ; int y = Integer . parseInt ( string [ 1 ] ) ; int tmp ; if ( okuMbe < y ) { tmp = okuMbe ; okuMbe = y ; y = tmp ; } int r = okuMbe % y ; while ( r != 0 ) { okuMbe = y ; y = r ; r = okuMbe % y ; } System . out . println ( y ) ; } } import java . io . * ; import java . util . * ; public class FrvqTjafz { 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 FrvqTjafz { public void solve ( String S ) { for ( int FrvqYq = 0 ; FrvqYq < 3 ; FrvqYq ++ ) { if ( S . charAt ( FrvqYq ) == S . charAt ( FrvqYq + 1 ) ) { System . out . println ( " Bad " ) ; return ; } } System . out . println ( " Good " ) ; } } import java . util . * ; public class jbjZwg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int JbjMj = Integer . parseInt ( str ) ; if ( ( JbjMj % 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 YxgmSad { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yxgmDpm = sc . nextInt ( ) ; boolean ans = false ; for ( int i = 0 ; i <= yxgmDpm / 7 ; i ++ ) { if ( ( yxgmDpm - i * 7 ) % 4 == 0 ) { ans = true ; break ; } } if ( ans == true ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class IigZmemx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; StringBuilder str = new StringBuilder ( ) ; int IigRgt = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { switch ( s . charAt ( i ) ) { case '0' : str . append ( '0' ) ; IigRgt ++ ; break ; case '1' : str . append ( '1' ) ; IigRgt ++ ; break ; case 'B' : if ( IigRgt == 0 ) { break ; } str . deleteCharAt ( IigRgt - 1 ) ; IigRgt -- ; break ; default : break ; } } System . out . println ( str . toString ( ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class sauRcx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SauWngo = Integer . parseInt ( sc . nextLine ( ) ) ; int [ ] point = new int [ 2 ] ; for ( int i = 0 ; i < SauWngo ; 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 hwulmKav { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HwulmRc = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( HwulmRc + HwulmRc * HwulmRc + HwulmRc * HwulmRc * HwulmRc ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class FzlNeu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int fzlFm = sc . nextInt ( ) ; List < Long > a = new ArrayList < Long > ( ) ; int fe = - 1 ; int count = 0 ; for ( int i = 0 ; i < fzlFm ; 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 YwiNg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ywiT = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; sc . close ( ) ; double prob = 0.0 ; for ( int i = 1 ; i <= ywiT ; i ++ ) { int points = i ; double diff = 1.0 / ywiT ; while ( points < k ) { diff *= 0.5 ; points *= 2 ; } prob += diff ; } System . out . println ( prob ) ; } } import java . util . Scanner ; public class wsqmG { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; long WsqmIu = scanner . nextLong ( ) ; if ( WsqmIu <= s . length ( ) ) { for ( int i = 0 ; i < WsqmIu ; 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 vjrJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] c = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; for ( int VjrXqcqt = 0 ; VjrXqcqt < c . length ; VjrXqcqt ++ ) { char a = c [ VjrXqcqt ] ; if ( VjrXqcqt % 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 OyfwfAgp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long oyfwfO = 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 ( ) ) { oyfwfO += map . get ( key ) * ( map . get ( key ) - 1 ) / 2 ; } System . out . println ( oyfwfO ) ; } } import java . util . Scanner ; public class JpghntWzkv { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { char [ ] S = sc . next ( ) . toCharArray ( ) ; int jpghntWsc = 0 ; for ( int i = 0 ; i < S . length ; i ++ ) { if ( S [ i ] == '+' ) { jpghntWsc ++ ; } else { jpghntWsc -- ; } } System . out . println ( jpghntWsc ) ; } } } import java . util . * ; public class NorttRmlj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int norttMt = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; double nearest = Double . MAX_VALUE ; int ans = 0 ; for ( int i = 1 ; i <= norttMt ; 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 gdpvuGvk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int GdpvuTe = 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 qhxQp { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; int QhxLql = 0 ; int z = 0 ; while ( s . charAt ( QhxLql ) != 'A' ) { QhxLql ++ ; } for ( int i = QhxLql + 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'Z' ) { z = i ; } } System . out . println ( z - QhxLql + 1 ) ; } } import java . util . Scanner ; public class QqgcgwFkw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qqgcgwEjq = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int T = scan . nextInt ( ) ; int times = T / qqgcgwEjq ; int ans = times * B ; System . out . println ( ans ) ; } } import java . util . * ; class MbfPh { public void yatary ( ) { Scanner sc = new Scanner ( System . in ) ; int mbfFh ; int x = sc . nextInt ( ) ; int [ ] num = new int [ x ] ; for ( mbfFh = 0 ; mbfFh < x ; mbfFh ++ ) { num [ mbfFh ] = sc . nextInt ( ) ; } for ( mbfFh = x - 1 ; mbfFh >= 0 ; mbfFh -- ) { if ( mbfFh != 0 ) { System . out . print ( num [ mbfFh ] + " " ) ; } else { System . out . println ( num [ mbfFh ] ) ; } } } public static void main ( String [ ] args ) { new Main ( ) . yatary ( ) ; } } import java . util . Scanner ; class IirehfMjmd { static class IirehfMjmd { int A [ ] , iirehfW ; Stack ( int size ) { A = new int [ size + 1 ] ; iirehfW = 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 iirehfW == 0 ; } boolean isFull ( ) { return iirehfW == A . length - 1 ; } void push ( int key ) { if ( isFull ( ) ) return ; A [ ++ iirehfW ] = key ; } int pop ( ) { if ( isEmpty ( ) ) return 0 ; return A [ iirehfW -- ] ; } } 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 brdpvK { 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 brdpvK { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int BrdpvIrfa = in . nextInt ( ) ; int b = in . nextInt ( ) ; int res = 0 ; for ( int i = BrdpvIrfa ; i <= b ; i ++ ) if ( i / 10000 == i % 10 && i / 10 % 10 == i / 1000 % 10 ) res ++ ; out . println ( res ) ; } } } import java . util . Scanner ; public class zsurK { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ZsurWtpnc = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] [ ] arrayA = new int [ ZsurWtpnc ] [ m ] ; int [ ] arrayB = new int [ m ] ; for ( int i = 0 ; i < ZsurWtpnc ; 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 < ZsurWtpnc ; 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 thpccClg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ThpccOkv = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] A = new int [ ThpccOkv ] ; for ( int i = 0 ; i < ThpccOkv ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } Arrays . parallelSort ( A ) ; for ( int i = 0 ; i < ThpccOkv ; i ++ ) { X -= A [ i ] ; } System . out . println ( ThpccOkv + X / A [ 0 ] ) ; } } import java . util . Scanner ; public class YnzwUsj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ynzwOm = scan . nextInt ( ) ; int [ ] b = new int [ ynzwOm ] ; int [ ] f = new int [ ynzwOm ] ; int [ ] r = new int [ ynzwOm ] ; int [ ] v = new int [ ynzwOm ] ; int [ ] [ ] [ ] num = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int i = 0 ; i < ynzwOm ; 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 WnssbpUilj { public static final int wnssbpAisr = 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 += wnssbpAisr ; } else if ( taro . compareTo ( hanako ) == 0 ) { taroPoint += EVEN_POINTS ; hanakoPoint += EVEN_POINTS ; } else { taroPoint += wnssbpAisr ; } } 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 VafjlvXxmbwn { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String input = sc . next ( ) ; String [ ] inputSplit = input . split ( " " ) ; int VafjlvN = 0 ; for ( int i = 0 ; i < inputSplit . length ; i ++ ) { if ( inputSplit [ i ] . equals ( " 0 " ) ) { VafjlvN ++ ; } } System . out . print ( Math . min ( VafjlvN , inputSplit . length - VafjlvN ) * 2 ) ; } } import java . util . Scanner ; public class plpsqnLf { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int PlpsqnHc = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; System . out . println ( ( ( PlpsqnHc == 5 && B == 5 && C == 7 ) || ( PlpsqnHc == 5 && B == 7 && C == 5 ) || ( PlpsqnHc == 7 && B == 5 && C == 5 ) ) ? " YES " : " NO " ) ; } } } import java . util . Scanner ; public class DkgvgoFn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dkgvgoUzad , x , ans ; while ( true ) { dkgvgoUzad = scan . nextInt ( ) ; x = scan . nextInt ( ) ; ans = 0 ; if ( dkgvgoUzad == 0 && x == 0 ) break ; for ( int i = 1 ; i <= dkgvgoUzad ; i ++ ) { for ( int j = i + 1 ; j <= dkgvgoUzad ; j ++ ) { for ( int k = j + 1 ; k <= dkgvgoUzad ; 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 SxoogNb { public static void main ( String [ ] args ) throws IOException { int SxoogC = 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 ) SxoogC ++ ; } System . out . println ( " " + SxoogC + " " ) ; } } import java . util . * ; public class HqogfQuyo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HqogfZ = sc . nextInt ( ) ; long [ ] A = new long [ HqogfZ + 1 ] ; long [ ] B = new long [ HqogfZ ] ; for ( int i = 0 ; i < HqogfZ + 1 ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < HqogfZ ; i ++ ) { B [ i ] = sc . nextLong ( ) ; } long sum = 0 ; for ( int i = 0 ; i < HqogfZ ; 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 ogsD { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int OgsKr = sc . nextInt ( ) ; int [ ] array = new int [ OgsKr ] ; for ( int i = 0 ; i < OgsKr ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int count = 0 ; Arrays . sort ( array ) ; int a = array [ OgsKr / 2 - 1 ] ; int b = array [ OgsKr / 2 ] ; if ( a == b ) { System . out . println ( 0 ) ; } else { System . out . println ( b - a ) ; } } } import java . util . * ; public class WyzmmZy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] str = line . split ( " " ) ; int wyzmmG = Integer . parseInt ( str [ 0 ] ) ; int y = Integer . parseInt ( str [ 1 ] ) ; int z = wyzmmG * y ; if ( z % 2 == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Scanner ; public class NskXtnt { public static void main ( String [ ] args ) { String s = ( new Scanner ( System . in ) ) . next ( ) ; char [ ] acgt = { 'A' , 'C' , 'G' , 'T' } ; int nskRlk = 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 ) { nskRlk = Math . max ( nskRlk , tmp1 ) ; tmp1 = 0 ; } } nskRlk = Math . max ( nskRlk , tmp1 ) ; System . out . println ( nskRlk ) ; } } import java . util . Scanner ; public class uwtpE { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int UwtpVf = 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 * UwtpVf ) + ( Bpizza * B ) ) ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class ExmxRrk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ExmxNpp = scan . nextInt ( ) ; ArrayList < Integer > result = new ArrayList < > ( ) ; for ( int i = 0 ; i < ExmxNpp ; i ++ ) { result . add ( 0 ) ; } for ( int i = 0 ; i < ExmxNpp - 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 HgtOblz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hgtYaig = sc . nextInt ( ) ; Map < String , Integer > m = new HashMap ( ) ; for ( int i = 0 ; i < hgtYaig ; 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 ThoyvyUda { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int thoyvyVet = 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 < thoyvyVet ; 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 NqsszCynb { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String nqsszPg = in . next ( ) ; if ( nqsszPg . equals ( " AAA " ) || nqsszPg . equals ( " BBB " ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; public class gaplYh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GaplGulwn = sc . nextInt ( ) ; int [ ] array = new int [ GaplGulwn ] ; int [ ] array_min = new int [ GaplGulwn ] ; int min = GaplGulwn + 1 ; for ( int i = 0 ; i < GaplGulwn ; i ++ ) { array [ i ] = sc . nextInt ( ) ; if ( min > array [ i ] ) { min = array [ i ] ; } array_min [ i ] = min ; } int count = 0 ; for ( int i = 0 ; i < GaplGulwn ; i ++ ) { if ( array_min [ i ] >= array [ i ] ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class vwlvzmX { public static int VwlvzmGxy = 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 EhgmJz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ehgmT = sc . nextInt ( ) ; int [ ] array = new int [ ehgmT ] ; for ( int i = 0 ; i < ehgmT ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int buff = 0 ; int count = 0 ; for ( int i = 0 ; i < ehgmT ; 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 LcxavsAbxs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LcxavsP = sc . nextInt ( ) ; int res = 1 ; for ( int i = 2 ; i * i <= LcxavsP ; i ++ ) { int p = i * i ; while ( p <= LcxavsP ) { res = Math . max ( res , p ) ; p *= i ; } } System . out . println ( res ) ; sc . close ( ) ; } } import java . util . * ; class TxdUscwt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String F = sc . nextLine ( ) ; String C = sc . nextLine ( ) ; int TxdHr = 0 ; for ( int i = 0 ; i < F . length ( ) ; i ++ ) { Character c1 = F . charAt ( i ) ; Character c2 = C . charAt ( i ) ; if ( c1 == c2 ) TxdHr ++ ; } System . out . println ( TxdHr ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class lypthyO { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String LypthyGgce = br . readLine ( ) ; if ( LypthyGgce . contains ( " RRR " ) ) { System . out . println ( " 3 " ) ; } else if ( LypthyGgce . contains ( " RR " ) ) { System . out . println ( " 2 " ) ; } else if ( LypthyGgce . contains ( " R " ) ) { System . out . println ( 1 ) ; } else { System . out . println ( 0 ) ; } } } import java . util . * ; public class erqoaD { int ErqoaRk = 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 ErqoaRk = 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 ; ErqoaRk ++ ; } } return ErqoaRk ; } } import java . util . Scanner ; public class GgdeTnp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long GgdeBom = Integer . parseInt ( scan . next ( ) ) ; long b = Integer . parseInt ( scan . next ( ) ) ; long mult = GgdeBom * b ; if ( GgdeBom < b ) { long tmp = GgdeBom ; GgdeBom = b ; b = tmp ; } long r = GgdeBom % b ; while ( r > 0 ) { GgdeBom = b ; b = r ; r = GgdeBom % b ; } System . out . println ( mult / b ) ; scan . close ( ) ; } } import java . util . * ; public class dsglFud { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long DsglYh = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long resultA = DsglYh * c ; resultA = resultA < DsglYh * d ? DsglYh * 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 CkpzjwAbzm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ckpzjwAsn = sc . nextInt ( ) ; double probability = ( double ) ( ckpzjwAsn - ( ckpzjwAsn / 2 ) ) ; System . out . print ( probability / 1.0 / ckpzjwAsn ) ; } } import java . util . Scanner ; public class TmipiLo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double tmipiFqd = sc . nextDouble ( ) ; double are = 0 ; double circ = 0 ; are = tmipiFqd * tmipiFqd * Math . PI ; circ = ( tmipiFqd + tmipiFqd ) * Math . PI ; ; System . out . printf ( " %f %f \n " , are , circ ) ; } } import java . util . HashMap ; import java . util . Scanner ; public class ZtwDex { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ztwVwv = scan . nextInt ( ) ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < ztwVwv - 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 < ztwVwv ; 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 xndBq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long XndLe = 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 ( XndLe < total ) { if ( XndLe >= blue ) { ans = blue ; } else if ( XndLe < blue ) { ans = XndLe ; } } else if ( XndLe >= total ) { div = XndLe / total ; mod = XndLe % 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 FoyHji { 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 foyYj = in . nextLong ( ) ; long rem = foyYj % 500 ; long total = ( foyYj - rem ) * 2 ; total += ( rem - ( rem % 5 ) ) ; out . println ( total ) ; out . close ( ) ; } static class FoyHji { 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 akpuS { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int AkpuLo = Integer . parseInt ( str [ 0 ] ) ; int a = Integer . parseInt ( str [ 1 ] ) ; br . close ( ) ; System . out . println ( ( AkpuLo + a - 1 ) / a ) ; } } import java . util . Scanner ; public class xbjkA { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int XbjkYqyvb = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int sum = XbjkYqyvb + f ; if ( XbjkYqyvb == - 1 && f == - 1 && r == - 1 ) break ; else if ( XbjkYqyvb == - 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 MjpfmqKzm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mjpfmqRhf = sc . nextInt ( ) ; Integer [ ] mochi = new Integer [ mjpfmqRhf ] ; int ans = 1 ; for ( int i = 0 ; i < mjpfmqRhf ; i ++ ) { mochi [ i ] = sc . nextInt ( ) ; } Arrays . sort ( mochi , Comparator . reverseOrder ( ) ) ; for ( int i = 0 ; i < mjpfmqRhf ; i ++ ) { if ( i != mjpfmqRhf - 1 ) { if ( mochi [ i ] > mochi [ i + 1 ] ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class TknPz { static int [ ] insertSort ( int [ ] x ) { int tknDxh , j ; for ( int i = 0 ; i < x . length ; i ++ ) { tknDxh = x [ i ] ; j = i - 1 ; while ( j >= 0 && x [ j ] > tknDxh ) { x [ j + 1 ] = x [ j ] ; j -- ; } x [ j + 1 ] = tknDxh ; 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 utveszZce { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UtveszBtenn = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int sum = 1 ; for ( int i = 0 ; i < UtveszBtenn ; i ++ ) { sum = sum * 100 ; } if ( N == 100 ) { System . out . println ( 101 * sum ) ; return ; } System . out . println ( N * sum ) ; } } import java . util . * ; public class JntnreGk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jntnreLgbh = sc . nextInt ( ) ; double [ ] v = new double [ jntnreLgbh ] ; 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 ZnyjDy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int znyjN = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '+' ) znyjN ++ ; if ( s . charAt ( i ) == '-' ) znyjN -- ; } System . out . println ( znyjN ) ; } } import java . util . * ; public class cbbxW { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String [ ] line = sc . nextLine ( ) . split ( " " ) ; int CbbxQo = Integer . parseInt ( line [ 0 ] ) ; int S = Integer . parseInt ( line [ 1 ] ) ; int ans = 0 ; for ( int x = 0 ; x <= CbbxQo ; x ++ ) { for ( int y = 0 ; y <= CbbxQo ; y ++ ) { int target = S - x - y ; if ( target >= 0 && target <= CbbxQo ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class XmqhZhp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xmqhJypy = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = 0 ; for ( int i = 0 ; i < ( b - xmqhJypy + 1 ) ; i ++ ) { String [ ] s = String . valueOf ( xmqhJypy + i ) . split ( " " ) ; String t = s [ 4 ] + s [ 3 ] + s [ 2 ] + s [ 1 ] + s [ 0 ] ; if ( String . valueOf ( xmqhJypy + 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 VcofrLie { 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 VcofrLie { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int VcofrK = Integer . parseInt ( in . next ( ) ) ; int b = Integer . parseInt ( in . next ( ) ) ; int c = Integer . parseInt ( in . next ( ) ) ; Set < Integer > s = new HashSet < > ( ) ; s . add ( VcofrK ) ; 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 LoudDipyfj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LoudHj = scan . nextInt ( ) ; int [ ] costs = new int [ LoudHj ] ; int [ ] cache = new int [ LoudHj ] ; for ( int i = 0 ; i < LoudHj ; 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 OvuZok { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ovuIqt = 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 ) ( ovuIqt * h ) / 2 ; int hukusu = 0 ; if ( ( double ) x == ( double ) ovuIqt / 2.0 && ( double ) y == ( double ) h / 2.0 ) { hukusu = 1 ; } System . out . println ( ans + " " + hukusu ) ; } } import java . util . * ; public class QpncvgAqgf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QpncvgGav = 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 rlhE { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int RlhGovk = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( s . length ( ) <= RlhGovk ) { System . out . println ( s ) ; } else { System . out . println ( s . subSequence ( 0 , RlhGovk ) + " ... " ) ; } } } } import java . util . Arrays ; import java . util . Scanner ; public class JmmdkJfik { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] A = new int [ 3 ] ; for ( int jmmdkQh = 0 ; jmmdkQh < 3 ; jmmdkQh ++ ) { A [ jmmdkQh ] = 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 HptpmPuaz { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; int hptpmDdj = s . nextInt ( ) ; int k = s . nextInt ( ) ; int [ ] a = new int [ hptpmDdj ] ; 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 IlutCcq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int IlutCi = sc . nextInt ( ) ; int [ ] a = new int [ IlutCi ] ; String ans = " YES " ; int cnt = 0 ; for ( int i = 0 ; i < IlutCi ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] b = Arrays . copyOf ( a , IlutCi ) ; Arrays . sort ( b ) ; for ( int i = 0 ; i < IlutCi ; 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 NjlAp { public static void main ( String [ ] args ) { final Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; final int njlQjga = in . next ( ) . trim ( ) . length ( ) ; final StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < njlQjga ; i ++ ) { sb . append ( " x " ) ; } System . out . println ( sb ) ; } } import java . util . Scanner ; public class QfoiTzfg { 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 QfoiM = p . length ( ) ; String doubleS = s + s ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { String word = doubleS . substring ( i , i + QfoiM ) ; if ( word . equals ( p ) ) { return true ; } } return false ; } } import java . io . ByteArrayInputStream ; import java . util . Scanner ; public class KvwRieza { private static boolean strcmp ( String s , int pos , String other ) { if ( pos >= other . length ( ) ) { int KvwA = other . length ( ) ; for ( int i = 0 ; i < KvwA ; i ++ ) { if ( s . charAt ( pos - i - 1 ) != other . charAt ( KvwA - 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 " ) ; } } import java . util . * ; public class advitJky { 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 advitkru = Integer . parseInt ( sc . next ( ) ) ; Arrays . sort ( v ) ; for ( int i = 0 ; i < advitkru ; i ++ ) { v [ 2 ] *= 2 ; } System . out . println ( v [ 0 ] + v [ 1 ] + v [ 2 ] ) ; } }