import java . util . * ; public class pWlvhcmrsG { 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 pWlvhcmrsG = Integer . parseInt ( sc . next ( ) ) ; Arrays . sort ( v ) ; for ( int i = 0 ; i < pWlvhcmrsG ; i ++ ) { v [ 2 ] *= 2 ; } System . out . println ( v [ 0 ] + v [ 1 ] + v [ 2 ] ) ; } } import java . util . Scanner ; public class uqOPBEfORO { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int uqOPBEfORO = scan . nextInt ( ) ; int first = uqOPBEfORO / 100 ; int last = uqOPBEfORO % 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 NGZtAyoJla { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NGZtAyoJla = sc . nextInt ( ) ; long [ ] a = new long [ NGZtAyoJla ] ; boolean isZero = false ; for ( int i = 0 ; i < NGZtAyoJla ; 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 = NGZtAyoJla - 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 bjukKjscaq { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int bjukKjscaq = cin . nextInt ( ) ; int [ ] list = new int [ bjukKjscaq ] ; for ( int i = 0 ; i < bjukKjscaq ; 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 vVsGRlXpND { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vVsGRlXpND = 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 ] + ( vVsGRlXpND - 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 ( vVsGRlXpND - Y ) ; } } import java . util . * ; class kFstBDcYcm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int kFstBDcYcm = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] line = scanner . nextLine ( ) . split ( " " , kFstBDcYcm ) ; int [ ] arr = new int [ kFstBDcYcm ] ; for ( int i = 0 ; i < kFstBDcYcm ; i ++ ) { arr [ i ] = Integer . parseInt ( line [ i ] ) ; } Arrays . sort ( arr ) ; int sum = 0 ; for ( int i = 0 ; i < kFstBDcYcm - 1 ; i ++ ) { sum += arr [ i ] ; } if ( arr [ kFstBDcYcm - 1 ] < sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class vFVrFzWIHk { 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 vFVrFzWIHk = 0 ; vFVrFzWIHk < 3 ; vFVrFzWIHk ++ ) { nums [ vFVrFzWIHk ] = sc . nextInt ( ) ; if ( nums [ vFVrFzWIHk ] == 5 ) { rep [ 0 ] ++ ; } else if ( nums [ vFVrFzWIHk ] == 7 ) { rep [ 1 ] ++ ; } } if ( rep [ 0 ] == 2 && rep [ 1 ] == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; class VTxdSCYMPp { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int VTxdSCYMPp = sc . nextInt ( ) ; int [ ] a = new int [ VTxdSCYMPp + 1 ] ; a [ 0 ] = 0 ; for ( int i = 1 ; i <= VTxdSCYMPp ; i ++ ) { a [ i ] = a [ i - 1 ] + sc . nextInt ( ) ; } int min = 10000000 ; for ( int t = 1 ; t < VTxdSCYMPp ; t ++ ) { min = Math . min ( Math . abs ( ( a [ t ] - a [ 0 ] ) - ( a [ VTxdSCYMPp ] - a [ t ] ) ) , min ) ; } System . out . println ( min ) ; } } import java . util . * ; public class XiwUvCMBPm { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { long XiwUvCMBPm = in . nextLong ( ) ; long b = in . nextLong ( ) ; long c = LCM ( XiwUvCMBPm , b ) ; long d = XiwUvCMBPm * b / c ; System . out . println ( c + " " + d ) ; } } static long LCM ( long XiwUvCMBPm , long b ) { if ( b == 0 ) { return XiwUvCMBPm ; } else { return LCM ( b , XiwUvCMBPm % b ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class OUDHbblAJq { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int OUDHbblAJq = Integer . parseInt ( br . readLine ( ) ) ; String [ ] strArray = br . readLine ( ) . split ( " " ) ; int [ ] array = new int [ OUDHbblAJq ] ; for ( int i = 0 ; i < OUDHbblAJq ; i ++ ) { array [ i ] = Integer . parseInt ( strArray [ i ] ) ; } int count = bubbleSor ( array , OUDHbblAJq ) ; printArray ( array ) ; System . out . println ( count ) ; } static int bubbleSor ( int [ ] array , int OUDHbblAJq ) { int flag = 1 ; int count = 0 ; while ( flag == 1 ) { flag = 0 ; for ( int j = OUDHbblAJq - 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 srHdHRJZli { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int srHdHRJZli = 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 ( srHdHRJZli > 0 ) { result += 1 ; srHdHRJZli -= 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 SlzNPRILGx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Deque < Integer > deq = new ArrayDeque < Integer > ( ) ; String str = " " ; int SlzNPRILGx = 0 , b = 0 ; while ( sc . hasNext ( ) ) { str = sc . next ( ) ; if ( str . equals ( " + " ) ) { SlzNPRILGx = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( SlzNPRILGx + b ) ; } else if ( str . equals ( " - " ) ) { SlzNPRILGx = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( b - SlzNPRILGx ) ; } else if ( str . equals ( " * " ) ) { SlzNPRILGx = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( SlzNPRILGx * b ) ; } else if ( str . equals ( " / " ) ) { SlzNPRILGx = deq . pollLast ( ) ; b = deq . pollLast ( ) ; deq . addLast ( b / SlzNPRILGx ) ; } 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 wNqMQCdVPI { 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 wNqMQCdVPI { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { int wNqMQCdVPI = in . nextInt ( ) ; int A = in . nextInt ( ) ; out . println ( ( int ) Math . ceil ( wNqMQCdVPI / ( double ) A ) ) ; } } static class wNqMQCdVPI { 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 asZqooTryo { public static void main ( String [ ] args ) { Scanner x = new Scanner ( System . in ) ; int asZqooTryo = x . nextInt ( ) ; int f = x . nextInt ( ) ; int r = x . nextInt ( ) ; int go = asZqooTryo + f ; while ( asZqooTryo != - 1 || f != - 1 || r != - 1 ) { if ( asZqooTryo == - 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 " ) ; } asZqooTryo = x . nextInt ( ) ; f = x . nextInt ( ) ; r = x . nextInt ( ) ; go = asZqooTryo + f ; } } } import java . util . Scanner ; public class lVUdNGjFfa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] nums = new int [ 11 ] ; for ( int lVUdNGjFfa = 0 ; lVUdNGjFfa < 3 ; lVUdNGjFfa ++ ) { 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 pjCtaIDGfe { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int pjCtaIDGfe = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int r = s * t - pjCtaIDGfe ; System . out . println ( r >= 0 ? " Yes " : " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class nWSMRQijLt { public Main ( ) { } static int nWSMRQijLt ; public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; nWSMRQijLt = Integer . parseInt ( str ) ; System . out . println ( ( int ) Math . pow ( nWSMRQijLt , 3 ) ) ; } } import java . util . * ; public class MmRjuCDqrW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MmRjuCDqrW = sc . nextInt ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; if ( MmRjuCDqrW >= s . length ) { for ( int i = 0 ; i < s . length ; i ++ ) { System . out . print ( s [ i ] ) ; } } else { for ( int i = 0 ; i < MmRjuCDqrW ; i ++ ) { System . out . print ( s [ i ] ) ; } System . out . print ( " ... " ) ; } } } import java . util . Scanner ; public class OPEOcFdoTC { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; long OPEOcFdoTC = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = lcm ( OPEOcFdoTC , b ) ; System . out . println ( ans ) ; sc . close ( ) ; } public long gcd ( long OPEOcFdoTC , long b ) { if ( b == 0 ) { return OPEOcFdoTC ; } long ans = gcd ( b , OPEOcFdoTC % b ) ; return ans ; } public long lcm ( long OPEOcFdoTC , long b ) { long g = gcd ( OPEOcFdoTC , b ) ; return OPEOcFdoTC * b / g ; } } import java . util . * ; public class NRmAaJQVDD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NRmAaJQVDD = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] num = new int [ 2 * NRmAaJQVDD ] ; int min = 1001 ; for ( int i = 0 ; i < 2 * NRmAaJQVDD ; i ++ ) { num [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < NRmAaJQVDD ; i ++ ) { if ( num [ 2 * i + 1 ] > T ) { num [ 2 * i ] = 1001 ; } } for ( int i = 0 ; i < NRmAaJQVDD ; 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 UBMwvRaXKk { private static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int UBMwvRaXKk ; while ( 0 > ( UBMwvRaXKk = scanner . nextInt ( ) ) || UBMwvRaXKk >= 86400 ) ; int hour = UBMwvRaXKk / 3600 ; int minute = ( UBMwvRaXKk - hour * 3600 ) / 60 ; int second = ( UBMwvRaXKk - hour * 3600 - minute * 60 ) ; System . out . println ( hour + " : " + minute + " : " + second ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class PwgXyOahBF { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int PwgXyOahBF = 0 ; String s = br . readLine ( ) ; String t = br . readLine ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) { PwgXyOahBF ++ ; } } System . out . println ( PwgXyOahBF ) ; } catch ( Exception e ) { System . out . println ( e ) ; } } } import java . io . * ; import java . util . * ; public class VhQVmDZACv { 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 VhQVmDZACv = 0 ; VhQVmDZACv < strings . length ; VhQVmDZACv ++ ) { if ( str . equals ( strings [ VhQVmDZACv ] ) ) { return 7 - VhQVmDZACv ; } } 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 CZHelBVlKF { 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 CZHelBVlKF = 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 ( " + " ) ) { CZHelBVlKF = ArrayA [ 0 ] + ArrayA [ 1 ] ; resultLine = resultLine + CZHelBVlKF + ( " \n " ) ; } else if ( op . equals ( " - " ) ) { CZHelBVlKF = ArrayA [ 0 ] - ArrayA [ 1 ] ; resultLine = resultLine + CZHelBVlKF + ( " \n " ) ; } else if ( op . equals ( " * " ) ) { CZHelBVlKF = ArrayA [ 0 ] * ArrayA [ 1 ] ; resultLine = resultLine + CZHelBVlKF + ( " \n " ) ; } else if ( op . equals ( " / " ) ) { CZHelBVlKF = ( ArrayA [ 0 ] / ArrayA [ 1 ] ) ; resultLine = resultLine + CZHelBVlKF + ( " \n " ) ; } else if ( op . equals ( " ? " ) ) { check = false ; } } System . out . print ( resultLine ) ; } } import java . util . * ; public class olRGEtslIp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int olRGEtslIp = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int a1 = olRGEtslIp + b ; int a2 = olRGEtslIp - b ; int a3 = olRGEtslIp * 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 iBoCOmPKcT { public static void main ( String [ ] args ) { int iBoCOmPKcT = 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 ] ; iBoCOmPKcT = 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 ( iBoCOmPKcT >= 0 && A [ iBoCOmPKcT ] > key ) { A [ iBoCOmPKcT + 1 ] = A [ iBoCOmPKcT ] ; iBoCOmPKcT -- ; } A [ iBoCOmPKcT + 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 VvUYVpfNOX { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int VvUYVpfNOX = 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 + VvUYVpfNOX ] ; 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 AKTTIYpHLL { 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 AKTTIYpHLL : w ) { if ( map . containsKey ( AKTTIYpHLL ) ) { map . put ( AKTTIYpHLL , map . get ( AKTTIYpHLL ) + 1 ) ; } else { map . put ( AKTTIYpHLL , 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 TuIEqycTmf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String w = scan . nextLine ( ) ; String [ ] wArray = new String [ w . length ( ) ] ; for ( int TuIEqycTmf = 0 ; TuIEqycTmf < w . length ( ) ; TuIEqycTmf ++ ) { wArray [ TuIEqycTmf ] = w . substring ( TuIEqycTmf , TuIEqycTmf + 1 ) ; } List < String > wList = new ArrayList < String > ( Arrays . asList ( wArray ) ) ; List < String > wHashList = new ArrayList < String > ( new HashSet < > ( wList ) ) ; int sum = 0 ; for ( int TuIEqycTmf = 0 ; TuIEqycTmf < wHashList . size ( ) ; TuIEqycTmf ++ ) { for ( int j = 0 ; j < w . length ( ) ; j ++ ) { if ( wHashList . get ( TuIEqycTmf ) . 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 GfzYgKgtyq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strArr = br . readLine ( ) . split ( " " ) ; double GfzYgKgtyq = Double . parseDouble ( strArr [ 0 ] ) ; double area = GfzYgKgtyq * GfzYgKgtyq * Math . PI ; double length = 2 * Math . PI * GfzYgKgtyq ; System . out . printf ( " %.6f %.6f \n " , area , length ) ; } } import java . io . InputStreamReader ; import java . io . BufferedReader ; import java . io . IOException ; class IlgbjvfHKz { 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 IlgbjvfHKz = Integer . parseInt ( strAry [ 0 ] ) ; int w = Integer . parseInt ( strAry [ 1 ] ) ; if ( IlgbjvfHKz == 0 && w == 0 ) { break ; } for ( int i = 1 ; i <= IlgbjvfHKz ; 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 gEycxOxjRO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gEycxOxjRO = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; String s = sc . next ( ) ; for ( int i = 0 ; i < gEycxOxjRO ; 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 XhqvDdKnud { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int XhqvDdKnud = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; double f = 1.0 * XhqvDdKnud / y ; BigDecimal g = new BigDecimal ( f ) ; g = g . setScale ( 5 , BigDecimal . ROUND_HALF_UP ) ; System . out . printf ( XhqvDdKnud / y + " " + XhqvDdKnud % y + " " + " %.5f " , g ) ; } } import java . util . * ; public class gatzNwaSeX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gatzNwaSeX = sc . nextInt ( ) ; int now = sc . nextInt ( ) ; int next = 0 ; int count = 0 ; int answer = 0 ; for ( int i = 0 ; i < gatzNwaSeX - 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 hFkaBwoEVY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hFkaBwoEVY = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; ArrayList < Integer > arrayList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < hFkaBwoEVY ; 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 AFXLIyqOYG { 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 AFXLIyqOYG = 0 ; AFXLIyqOYG < input . length - 1 ; AFXLIyqOYG ++ ) { if ( input [ AFXLIyqOYG ] . equals ( input [ AFXLIyqOYG + 1 ] ) ) { return Result . Bad ; } } return Result . Good ; } enum Result { Good , Bad } } import java . util . * ; class OfenOosIFe { Scanner sc ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { int OfenOosIFe = sc . nextInt ( ) ; int [ ] d = new int [ OfenOosIFe ] ; for ( int i = 0 ; i < OfenOosIFe ; i ++ ) d [ i ] = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < OfenOosIFe - 1 ; i ++ ) { for ( int j = i + 1 ; j < OfenOosIFe ; j ++ ) { sum += d [ i ] * d [ j ] ; } } System . out . println ( sum ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . * ; public class purkPZblYh { Scanner sc = new Scanner ( System . in ) ; int purkPZblYh , b , c , d , e , f , k , l , m , n , x , y , z ; int ans ; String [ ] S ; Main ( ) { n = sc . nextInt ( ) ; purkPZblYh = sc . nextInt ( ) ; b = sc . nextInt ( ) ; System . out . println ( Math . min ( purkPZblYh * n , b ) ) ; } public static void main ( String [ ] args ) { new Main ( ) ; } } import java . util . * ; public class rxDFMVrBOJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rxDFMVrBOJ = sc . nextInt ( ) ; int [ ] A = new int [ rxDFMVrBOJ ] ; for ( int i = 0 ; i < rxDFMVrBOJ ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int cnt = 0 , tmp = 0 ; for ( int i = 0 ; i < rxDFMVrBOJ - 1 ; i ++ ) { for ( int j = rxDFMVrBOJ - 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 < rxDFMVrBOJ ; i ++ ) { if ( i == rxDFMVrBOJ - 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 zYqJCieysX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zYqJCieysX = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; int diff = 1 ; char prev = s . charAt ( 0 ) ; for ( int i = 0 ; i < zYqJCieysX ; i ++ ) { if ( s . charAt ( i ) != prev ) { diff ++ ; } prev = s . charAt ( i ) ; } System . out . println ( diff ) ; } } import java . util . * ; public class eJmlOLpHSS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; String [ ] nums = input . split ( " " ) ; int eJmlOLpHSS = Integer . parseInt ( nums [ 0 ] ) ; int A = Integer . parseInt ( nums [ 1 ] ) ; int B = Integer . parseInt ( nums [ 2 ] ) ; System . out . println ( eJmlOLpHSS * A < B ? eJmlOLpHSS * A : B ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; class lpJlSSFLUn { public static long gcd ( long lpJlSSFLUn , long b ) { if ( b == 0 ) return lpJlSSFLUn ; return gcd ( b , lpJlSSFLUn % b ) ; } public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; long lpJlSSFLUn = s . nextLong ( ) ; long b = s . nextLong ( ) ; long k = gcd ( lpJlSSFLUn , b ) ; System . out . println ( ( lpJlSSFLUn * b ) / k ) ; } } import java . util . * ; public class hxLNLVpDPK { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int hxLNLVpDPK = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int count = 0 ; int compare = 0 ; for ( int i = hxLNLVpDPK ; 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 myxtLyMtKZ { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int myxtLyMtKZ = scanner . nextInt ( ) ; final int b = scanner . nextInt ( ) ; final int value = Integer . parseInt ( Integer . toString ( myxtLyMtKZ ) + 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 gpBBpndASi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gpBBpndASi = sc . nextInt ( ) ; String [ ] s = new String [ gpBBpndASi ] ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; long result = 0 ; for ( int i = 0 ; i < gpBBpndASi ; 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 iLGyLayZth { public static void main ( String [ ] args ) throws IOException { int iLGyLayZth ; 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 ) { iLGyLayZth = a ; a = b ; b = iLGyLayZth ; } if ( b > c ) { iLGyLayZth = b ; b = c ; c = iLGyLayZth ; } if ( a > b ) { iLGyLayZth = a ; a = b ; b = iLGyLayZth ; } System . out . println ( a + " " + b + " " + c ) ; } } import java . util . Scanner ; class GaeIeAwrHy { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long GaeIeAwrHy = scanner . nextLong ( ) ; long r = scanner . nextLong ( ) ; scanner . close ( ) ; int count = 0 ; while ( GaeIeAwrHy >= r ) { count += 1 ; GaeIeAwrHy = GaeIeAwrHy / r ; } System . out . println ( count + 1 ) ; } } import java . util . Scanner ; public class TSFJwPHCjQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long TSFJwPHCjQ = sc . nextLong ( ) ; long R = sc . nextLong ( ) ; final int divide = 2019 ; long ans = 1000000000 ; if ( R - TSFJwPHCjQ >= 2019 ) System . out . println ( 0 ) ; else { for ( long i = TSFJwPHCjQ ; 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 IvHGnoUvir { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final List < Integer > list = new ArrayList < > ( ) ; int IvHGnoUvir = sc . nextInt ( ) ; int s1 = 0 ; int s2 = 0 ; int min = 10001 ; for ( int i = 0 ; i < IvHGnoUvir ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } for ( int i = 0 ; i < IvHGnoUvir ; i ++ ) { for ( int j = 0 ; j < IvHGnoUvir ; 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 EIPrDzWdqj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] arg = sc . nextLine ( ) . split ( " " ) ; int EIPrDzWdqj = Integer . parseInt ( arg [ 0 ] ) ; String d = arg [ 1 ] ; int count = 0 ; for ( int i = 0 ; i < EIPrDzWdqj ; 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 uurOiROrWr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uurOiROrWr = 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 <= uurOiROrWr ; i ++ ) { al . add ( i ) ; } for ( int i = 0 ; i <= uurOiROrWr ; i ++ ) { for ( int j = 0 ; j <= uurOiROrWr ; j ++ ) { if ( al . contains ( s - i - j ) ) { count ++ ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; class VQjJCcnmNq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int VQjJCcnmNq = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int x = scanner . nextInt ( ) ; int y = scanner . nextInt ( ) ; int sum = 0 ; if ( VQjJCcnmNq + b < c * 2 ) { sum = VQjJCcnmNq * x + b * y ; System . out . println ( sum ) ; } else { while ( x >= 1 && y >= 1 ) { sum += c * 2 ; x -- ; y -- ; } int sum2 = sum ; sum += VQjJCcnmNq * x + b * y ; if ( VQjJCcnmNq > c * 2 || b > c * 2 ) { while ( x >= 1 || y >= 1 ) { sum2 += c * 2 ; x -- ; y -- ; } x = 0 ; y = 0 ; } sum2 += VQjJCcnmNq * 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 osEOmIlxbX { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int osEOmIlxbX = Integer . parseInt ( br . readLine ( ) ) ; String [ ] string = br . readLine ( ) . split ( " " ) ; int [ ] Progression = new int [ osEOmIlxbX ] ; for ( int i = 0 ; i < osEOmIlxbX ; i ++ ) { Progression [ i ] = Integer . parseInt ( string [ i ] ) ; } for ( int k = 0 ; k < osEOmIlxbX ; k ++ ) { System . out . print ( Progression [ k ] ) ; if ( k < osEOmIlxbX - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; int v ; for ( int i = 1 ; i < osEOmIlxbX ; 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 < osEOmIlxbX ; k ++ ) { System . out . print ( Progression [ k ] ) ; if ( k < osEOmIlxbX - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } } import java . util . * ; public class SfTqyRVGfc { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; double SfTqyRVGfc = 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 = ( SfTqyRVGfc * SfTqyRVGfc ) + ( B * B ) - 2 * SfTqyRVGfc * B * Math . cos ( Math . toRadians ( radian ) ) ; double ans = Math . sqrt ( result ) ; System . out . println ( ans ) ; } } public class GNEZiQHYxX { public static void main ( String [ ] args ) { java . util . Scanner scan = new java . util . Scanner ( System . in ) ; int GNEZiQHYxX = 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 < GNEZiQHYxX && GNEZiQHYxX <= 100 && 0 < H && H <= 100 ) { if ( GNEZiQHYxX >= ( 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 GFbRAwVDxN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GFbRAwVDxN = sc . nextInt ( ) ; long result = 0 ; for ( int i = 1 ; i <= GFbRAwVDxN ; i ++ ) { for ( int j = i ; j <= GFbRAwVDxN ; j ++ ) { for ( int k = j ; k <= GFbRAwVDxN ; 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 XFaIMhqAmF { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { final String s = reader . readLine ( ) ; int XFaIMhqAmF = 200001 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'A' ) { XFaIMhqAmF = 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 - XFaIMhqAmF + 1 ) ; } } } import java . util . * ; public class uIFwcLFORG { 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 uIFwcLFORG = 0 ; for ( int value : array ) uIFwcLFORG += value ; return uIFwcLFORG ; } 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 GpYcVmtToY { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int GpYcVmtToY = 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 [ GpYcVmtToY + 1 ] ; String find = " AC " ; for ( int i = 0 ; i < GpYcVmtToY ; 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 [ GpYcVmtToY + 1 ] ; for ( int i = 0 ; i < GpYcVmtToY ; 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 lyEdryiOJo { int lyEdryiOJo ; 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 ) { lyEdryiOJo = sc . nextInt ( ) ; d = new int [ lyEdryiOJo ] ; for ( int i = 0 ; i < lyEdryiOJo ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } } void solve ( ) { boolean [ ] cnt = new boolean [ 100 ] ; for ( int i = 0 ; i < lyEdryiOJo ; 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 QPLoLlnggE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QPLoLlnggE = sc . nextInt ( ) ; int b = 0 ; int [ ] d = new int [ QPLoLlnggE ] ; int [ ] e = new int [ QPLoLlnggE ] ; for ( int i = 0 ; i < QPLoLlnggE ; i ++ ) { d [ i ] = sc . nextInt ( ) ; d [ i ] -- ; e [ d [ i ] ] = i + 1 ; } for ( int i = 0 ; i < QPLoLlnggE ; i ++ ) { System . out . print ( e [ i ] + " " ) ; } } } import java . util . * ; class qcjwIALBRP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int qcjwIALBRP = 0 ; qcjwIALBRP < 3 ; qcjwIALBRP ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { c [ qcjwIALBRP ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] d = new int [ 3 ] [ 2 ] ; for ( int qcjwIALBRP = 0 ; qcjwIALBRP < 3 ; qcjwIALBRP ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { d [ qcjwIALBRP ] [ j ] = c [ qcjwIALBRP ] [ j + 1 ] - c [ qcjwIALBRP ] [ 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 xPJpVLhHQu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xPJpVLhHQu = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( W >= xPJpVLhHQu ) System . out . println ( " unsafe " ) ; else System . out . println ( " safe " ) ; } } import java . util . * ; public class oUoODZeLqg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oUoODZeLqg = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; boolean zero = false ; if ( oUoODZeLqg - R >= 2019 ) zero = true ; for ( int i = oUoODZeLqg ; i < R ; i ++ ) { if ( i % 2019 == 0 ) { zero = true ; break ; } } oUoODZeLqg = oUoODZeLqg % 2019 ; R = R % 2019 ; int min = 2017 * 2018 ; if ( ! zero ) { for ( int i = oUoODZeLqg ; 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 keMxygPKXK { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int keMxygPKXK = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; int d = 0 ; ArrayList < ArrayList < Integer > > arraylist = new ArrayList < ArrayList < Integer > > ( keMxygPKXK ) ; for ( int i = 0 ; i < keMxygPKXK ; 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 < keMxygPKXK ; i ++ ) { if ( arraylist . get ( i ) . size ( ) == 0 ) { count += 1 ; } } System . out . println ( count ) ; } } import java . util . * ; public class zlGdvxJiax { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zlGdvxJiax = sc . nextInt ( ) ; int [ ] arr = new int [ zlGdvxJiax ] ; 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 awhBWdVLFR { static String blackjack ( int awhBWdVLFR , int a2 , int a3 ) { if ( awhBWdVLFR + 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 awhBWdVLFR = Integer . parseInt ( sc . next ( ) ) ; int a2 = Integer . parseInt ( sc . next ( ) ) ; int a3 = Integer . parseInt ( sc . next ( ) ) ; out . println ( blackjack ( awhBWdVLFR , a2 , a3 ) ) ; out . flush ( ) ; } } import java . util . * ; public class WbvZnmxqfH { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String WbvZnmxqfH = scan . nextLine ( ) ; scan . close ( ) ; switch ( WbvZnmxqfH . charAt ( WbvZnmxqfH . 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 znqeWezeHu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int znqeWezeHu = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ znqeWezeHu ] ; for ( int i = 0 ; i < znqeWezeHu ; 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 WxRuwOvFtm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String WxRuwOvFtm = sc . next ( ) ; String str2 = WxRuwOvFtm . toLowerCase ( ) ; if ( WxRuwOvFtm . 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 MUvOnMUrQw { 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 IqszTNUhrL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IqszTNUhrL = Integer . parseInt ( sc . next ( ) ) ; Map < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 1 ; i <= IqszTNUhrL ; i ++ ) { map . put ( Integer . parseInt ( sc . next ( ) ) , i ) ; } StringBuilder builder = new StringBuilder ( ) ; for ( int i = 1 ; i <= IqszTNUhrL ; i ++ ) { builder . append ( map . get ( i ) ) . append ( " " ) ; } System . out . println ( builder . toString ( ) ) ; } } import java . util . Scanner ; public class DPOPrQOUnG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long DPOPrQOUnG = 0 ; long answer = 0 ; double limit = 0.0 ; DPOPrQOUnG = scan . nextLong ( ) ; answer = DPOPrQOUnG ; limit = Math . sqrt ( DPOPrQOUnG ) ; for ( int i = 1 ; i <= limit ; i ++ ) { if ( DPOPrQOUnG % i == 0 && ( DPOPrQOUnG / i ) + i - 2 < answer ) { answer = ( DPOPrQOUnG / i ) + i - 2 ; } } System . out . println ( answer ) ; } } import java . util . Scanner ; class dyXjbxBwUZ { public static final String SEVEN = " 7 " ; public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dyXjbxBwUZ = scan . nextInt ( ) ; scan . close ( ) ; String numN = String . valueOf ( dyXjbxBwUZ ) ; 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 cyxLLaCeBM { 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 cyxLLaCeBM = charStr . length - 1 ; cyxLLaCeBM > - 1 ; cyxLLaCeBM -- ) rvsStr . append ( charStr [ cyxLLaCeBM ] ) ; System . out . println ( rvsStr ) ; } } } import java . util . Scanner ; class UGdMZWwpLO { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int UGdMZWwpLO ; int i = 1 ; while ( true ) { UGdMZWwpLO = scan . nextInt ( ) ; ; if ( UGdMZWwpLO != 0 ) { System . out . println ( " Case " + " " + i + " : " + " " + UGdMZWwpLO ) ; i ++ ; } else { break ; } } } } import java . util . Scanner ; class kLHsWcrtcU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kLHsWcrtcU = 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 AVgWsifkvN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AVgWsifkvN = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] l = new int [ AVgWsifkvN ] ; int d = 0 ; int i = 0 ; for ( int cnt = 0 ; cnt < AVgWsifkvN ; cnt ++ ) { l [ cnt ] = sc . nextInt ( ) ; d += l [ cnt ] ; if ( d > x ) { i = cnt + 1 ; break ; } else { i = AVgWsifkvN + 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 gdeGCyhYYa { static Scanner sc = new Scanner ( in ) ; public static void main ( String [ ] args ) { int gdeGCyhYYa = sc . nextInt ( ) ; int [ ] d = new int [ gdeGCyhYYa ] ; int ans = 0 ; for ( int i = 0 ; i < gdeGCyhYYa ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; ans = max ( 0 , d [ gdeGCyhYYa / 2 ] - d [ gdeGCyhYYa / 2 - 1 ] ) ; out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class sSXLEYFEXi { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int sSXLEYFEXi = Integer . parseInt ( br . readLine ( ) ) ; String [ ] tmpArray = br . readLine ( ) . split ( " " ) ; int [ ] input = new int [ sSXLEYFEXi ] ; for ( int i = 0 ; i < sSXLEYFEXi ; i ++ ) { input [ sSXLEYFEXi - i - 1 ] = Integer . parseInt ( tmpArray [ i ] ) ; } System . out . print ( input [ 0 ] ) ; for ( int i = 1 ; i < sSXLEYFEXi ; i ++ ) { System . out . print ( " " + input [ i ] ) ; } System . out . println ( ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class XLmHAZOQYs { 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 XLmHAZOQYs = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( ss [ i ] == 'A' || ss [ i ] == 'C' || ss [ i ] == 'G' || ss [ i ] == 'T' ) { XLmHAZOQYs ++ ; } else { ans . add ( XLmHAZOQYs ) ; XLmHAZOQYs = 0 ; } } ans . add ( XLmHAZOQYs ) ; Collections . sort ( ans , Collections . reverseOrder ( ) ) ; System . out . println ( ans . get ( 0 ) ) ; } } import java . util . * ; public class NELhCDPuAr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; LinkedList < Integer > ll = new LinkedList < > ( ) ; int NELhCDPuAr = 999 ; int x = 999 ; int cnt = 0 ; while ( NELhCDPuAr != 0 || x != 0 ) { NELhCDPuAr = sc . nextInt ( ) ; x = sc . nextInt ( ) ; int ans = 0 ; if ( NELhCDPuAr == 0 && x == 0 ) { break ; } else { cnt ++ ; for ( int i = 1 ; i <= NELhCDPuAr ; 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 BMAKBWqXZC { static final int BMAKBWqXZC = 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 MFsHDYMHZI { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int MFsHDYMHZI = stdIn . nextInt ( ) ; int y = stdIn . nextInt ( ) ; int z = stdIn . nextInt ( ) ; int temp ; if ( MFsHDYMHZI > y ) { temp = MFsHDYMHZI ; MFsHDYMHZI = y ; y = temp ; } if ( MFsHDYMHZI > z ) { temp = MFsHDYMHZI ; MFsHDYMHZI = z ; z = temp ; } if ( y > z ) { temp = z ; z = y ; y = temp ; } System . out . printf ( " %d %d %d \n " , MFsHDYMHZI , y , z ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class DGuRMlgXyU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DGuRMlgXyU = Integer . parseInt ( sc . next ( ) ) ; ArrayList < String > shiritoriList = new ArrayList < > ( ) ; for ( int i = 0 ; i < DGuRMlgXyU ; 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 oqOyeGzsDu { 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 oqOyeGzsDu = 0 ; oqOyeGzsDu < s . length ( ) ; oqOyeGzsDu ++ ) { int countval = s . toLowerCase ( ) . codePointAt ( oqOyeGzsDu ) - 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 HlgHJuDcJF { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String fst = br . readLine ( ) ; int HlgHJuDcJF = Integer . parseInt ( fst ) ; if ( HlgHJuDcJF == 0 ) { break ; } String line = br . readLine ( ) ; String [ ] str = line . split ( " " ) ; double [ ] s = new double [ str . length ] ; for ( int j = 0 ; j < HlgHJuDcJF ; j ++ ) { s [ j ] = Double . parseDouble ( str [ j ] ) ; } double sum = 0.0 ; for ( int j = 0 ; j < HlgHJuDcJF ; j ++ ) { sum += s [ j ] ; } double num = HlgHJuDcJF ; double avr = sum / num ; double a = 0.0 ; for ( int j = 0 ; j < HlgHJuDcJF ; 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 GMflvRHmRa { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int GMflvRHmRa = in . nextInt ( ) ; Integer [ ] nam = new Integer [ GMflvRHmRa ] ; int max1 = 0 ; int max2 = 0 ; for ( int i = 0 ; i < GMflvRHmRa ; 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 < GMflvRHmRa ; i ++ ) { if ( nam2 [ i ] != max1 ) { System . out . println ( max1 ) ; } else { System . out . println ( max2 ) ; } } } } import java . util . * ; public class COrWUszizR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int COrWUszizR = Integer . parseInt ( sc . next ( ) ) ; int L = Integer . parseInt ( sc . next ( ) ) ; int [ ] appleValue = new int [ COrWUszizR ] ; int sum = 0 ; int a = 0 ; int min = 9999 ; for ( int i = 0 ; i < COrWUszizR ; 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 CNNLUZTtYi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long CNNLUZTtYi = sc . nextLong ( ) ; long min = ( long ) 999999999999.0 ; for ( long i = 1 ; i <= Math . sqrt ( CNNLUZTtYi ) ; i ++ ) if ( CNNLUZTtYi % i == 0 && min > ( i - 1 ) + ( CNNLUZTtYi / i ) - 1 ) min = ( i - 1 ) + ( CNNLUZTtYi / i ) - 1 ; System . out . println ( min ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class elTogojjqH { 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 elTogojjqH = Integer . parseInt ( st . nextToken ( ) ) ; String op = st . nextToken ( ) ; int b = Integer . parseInt ( st . nextToken ( ) ) ; int ans = 0 ; if ( op . equals ( " + " ) ) { ans = elTogojjqH + b ; System . out . println ( ans ) ; } else if ( op . equals ( " - " ) ) { ans = elTogojjqH - b ; System . out . println ( ans ) ; } else if ( op . equals ( " * " ) ) { ans = elTogojjqH * b ; System . out . println ( ans ) ; } else if ( op . equals ( " / " ) ) { ans = elTogojjqH / b ; System . out . println ( ans ) ; } else if ( op . equals ( " ? " ) ) { break ; } } } } import java . util . * ; public class jTZQLZjPsK { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jTZQLZjPsK = Integer . parseInt ( scan . next ( ) ) ; int [ ] lst = new int [ jTZQLZjPsK ] ; int ans = 0 ; for ( int i = 0 ; i < jTZQLZjPsK ; i ++ ) { lst [ i ] = Integer . parseInt ( scan . next ( ) ) ; } for ( int i = 0 ; i < jTZQLZjPsK - 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 suZCsKUSWK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long suZCsKUSWK = sc . nextLong ( ) ; suZCsKUSWK -- ; String result = " " ; String alp = " abcdefghijklmnopqrstuvwxyz " ; while ( true ) { long syou = suZCsKUSWK / alp . length ( ) ; long mod = suZCsKUSWK % alp . length ( ) ; String tmp = alp . substring ( ( int ) mod , ( int ) mod + 1 ) ; result = tmp + result ; suZCsKUSWK = syou - 1 ; if ( syou == 0 ) { break ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class mbcQXzmqGH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int mbcQXzmqGH = 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 ( mbcQXzmqGH + B , 2 * C ) * min + mbcQXzmqGH * ( X - min ) + B * ( Y - min ) , max * 2 * C ) ) ; } } import java . util . Scanner ; public class XshyYxidWa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XshyYxidWa = sc . nextInt ( ) ; int c = 0 ; int prev = 0 ; int max = 0 ; for ( int i = 0 ; i < XshyYxidWa ; 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 uDYbCudTOE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uDYbCudTOE = 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 ( uDYbCudTOE == Aval && B == Bval ) { System . out . println ( i ) ; System . exit ( 0 ) ; } } System . out . println ( - 1 ) ; sc . close ( ) ; } } import java . util . * ; class tJZlwJendr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tJZlwJendr = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Ans = 0 ; int Max = Math . max ( tJZlwJendr , B ) ; Max = Math . max ( Max , C ) ; double pow = Math . pow ( 2 , K ) ; if ( Max == tJZlwJendr ) { Ans = ( tJZlwJendr * ( int ) pow ) + B + C ; } else if ( Max == B ) { Ans = ( B * ( ( int ) pow ) ) + tJZlwJendr + C ; } else { Ans = ( C * ( ( int ) pow ) ) + tJZlwJendr + B ; } System . out . println ( Ans ) ; } } import java . util . Scanner ; public class pOFcblPItH { 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 pOFcblPItH { static void solve ( ) { final Scanner sc = new Scanner ( System . in ) ; final int pOFcblPItH = sc . nextInt ( ) ; final int d = sc . nextInt ( ) ; final int res = calc ( pOFcblPItH , d ) ; System . out . println ( res ) ; } static int calc ( final int pOFcblPItH , final int d ) { final int max = ( 2 * d + 1 ) ; int res = pOFcblPItH / max ; if ( pOFcblPItH % max != 0 ) { res += 1 ; } return res ; } } class pOFcblPItH { 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 UfnIZypzNp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UfnIZypzNp = sc . nextInt ( ) ; int migi = UfnIZypzNp % 100 ; int hidari = ( UfnIZypzNp - 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 jAJXzrfFTe { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int jAJXzrfFTe = scn . nextInt ( ) ; int a = jAJXzrfFTe / 100 ; int b = ( jAJXzrfFTe % 100 ) / 10 ; int c = jAJXzrfFTe % 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 UqCqKqsuIz { 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 UqCqKqsuIz = 0 , size = list . size ( ) ; UqCqKqsuIz < size ; UqCqKqsuIz ++ ) { System . out . println ( list . get ( UqCqKqsuIz ) ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class kdtAoCFxPI { static int [ ] h ; static int [ ] dp ; public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int kdtAoCFxPI = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; h = new int [ kdtAoCFxPI ] ; dp = new int [ kdtAoCFxPI ] ; for ( int i = 0 ; i < kdtAoCFxPI ; i ++ ) h [ i ] = scan . nextInt ( ) ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < kdtAoCFxPI ; 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 [ kdtAoCFxPI - 1 ] ) ; } } import java . util . Scanner ; public class dWUWJKkLab { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int dWUWJKkLab = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int c = stdIn . nextInt ( ) ; int d = stdIn . nextInt ( ) ; if ( c >= b || dWUWJKkLab >= d ) System . out . println ( 0 ) ; else if ( ( dWUWJKkLab <= c && b >= d ) || ( c <= dWUWJKkLab && d >= b ) ) System . out . println ( ( b - dWUWJKkLab ) < ( d - c ) ? b - dWUWJKkLab : d - c ) ; else System . out . println ( ( b > c && c >= dWUWJKkLab ) ? b - c : d - dWUWJKkLab ) ; } } 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 whOfqeqsVR { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int whOfqeqsVR = Integer . parseInt ( scanner . nextLine ( ) ) ; String [ ] tmp = scanner . nextLine ( ) . split ( " " ) ; int [ ] list = new int [ whOfqeqsVR ] ; int ans = 0 ; for ( int i = 0 ; i < whOfqeqsVR ; i ++ ) { list [ i ] = Integer . parseInt ( tmp [ i ] ) ; } for ( int i = 0 ; i < whOfqeqsVR ; i ++ ) { int r = i ; int min = Integer . MAX_VALUE ; while ( list [ i ] != 0 ) { while ( r < whOfqeqsVR && 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 jWhGQdzYfT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jWhGQdzYfT = sc . nextInt ( ) ; int [ ] h = new int [ jWhGQdzYfT ] ; for ( int i = 0 ; i < jWhGQdzYfT ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int sum = 0 ; boolean flag = true ; while ( flag ) { flag = false ; boolean ed = false ; for ( int i = 0 ; i < jWhGQdzYfT ; 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 WpMCrgcmao { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WpMCrgcmao = sc . nextInt ( ) ; long max = 0L ; int Bi = 0 ; int save = 0 ; for ( int i = 0 ; i < WpMCrgcmao ; i ++ ) { if ( i == WpMCrgcmao - 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 nHebklQnCl { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int nHebklQnCl = sc . nextInt ( ) ; int [ ] array = new int [ nHebklQnCl ] ; for ( int i = 0 ; i < nHebklQnCl ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int i = 0 ; i < nHebklQnCl ; 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 ehdTxiMAZw { public static void main ( String [ ] args ) { int [ ] arr = new int [ 5 ] ; Scanner sc = new Scanner ( System . in ) ; for ( int ehdTxiMAZw = 0 ; ehdTxiMAZw < 5 ; ehdTxiMAZw ++ ) { arr [ ehdTxiMAZw ] = sc . nextInt ( ) ; if ( arr [ ehdTxiMAZw ] == 0 ) System . out . println ( ehdTxiMAZw + 1 ) ; } } } import java . util . * ; public class OsOforBbTc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long OsOforBbTc = sc . nextLong ( ) ; HashMap < Long , Long > map = new HashMap < > ( ) ; long res = dfs ( OsOforBbTc , map ) ; System . out . println ( res ) ; } public static long dfs ( long OsOforBbTc , HashMap < Long , Long > map ) { long ans = 1 ; if ( OsOforBbTc <= 1 ) return ans ; if ( map . get ( OsOforBbTc ) != null ) return map . get ( OsOforBbTc ) ; long cur = dfs ( OsOforBbTc / 2 , map ) ; ans += 2 * cur ; map . put ( OsOforBbTc , ans ) ; return ans ; } } import java . util . * ; public class MgZfVgxgvB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MgZfVgxgvB = sc . nextInt ( ) ; Integer [ ] p = new Integer [ MgZfVgxgvB ] ; for ( int i = 0 ; i < MgZfVgxgvB ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Integer [ ] p_ = p . clone ( ) ; Arrays . sort ( p ) ; int count = 0 ; for ( int i = 0 ; i < MgZfVgxgvB ; 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 QpklDGPECz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QpklDGPECz = sc . nextInt ( ) ; String [ ] str = new String [ QpklDGPECz ] ; for ( int i = 0 ; i < QpklDGPECz ; i ++ ) { str [ i ] = sc . next ( ) ; } int acCount = 0 ; int waCount = 0 ; int tleCount = 0 ; int reCount = 0 ; for ( int j = 0 ; j < QpklDGPECz ; 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 QBnTMbpQTL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QBnTMbpQTL = 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 ) { QBnTMbpQTL = 1 ; b = 1 ; break ; } } } if ( b == 1 ) { break ; } } if ( QBnTMbpQTL == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class tDjLmPZNfk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tDjLmPZNfk = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int tmp ; if ( tDjLmPZNfk > b ) { tmp = tDjLmPZNfk ; tDjLmPZNfk = b ; b = tmp ; } if ( b > c ) { tmp = b ; b = c ; c = tmp ; } if ( tDjLmPZNfk > b ) { tmp = tDjLmPZNfk ; tDjLmPZNfk = b ; b = tmp ; } System . out . println ( tDjLmPZNfk + " " + b + " " + c ) ; } } import java . util . * ; public class gXtIlsXsMg { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; int gXtIlsXsMg = kb . nextInt ( ) , k = kb . nextInt ( ) ; int [ ] h = new int [ gXtIlsXsMg ] ; for ( int i = 0 ; i < gXtIlsXsMg ; i ++ ) { h [ i ] = kb . nextInt ( ) ; } int [ ] dp = new int [ gXtIlsXsMg ] ; boolean [ ] visited = new boolean [ gXtIlsXsMg ] ; dp [ 0 ] = 0 ; visited [ 0 ] = true ; for ( int i = 1 ; i < gXtIlsXsMg ; 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 [ gXtIlsXsMg - 1 ] ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class ipogCjEFFa { 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 ipogCjEFFa = 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 ) ) { ipogCjEFFa = true ; break ; } } if ( ipogCjEFFa ) { 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 gUwSiYQYjX { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int gUwSiYQYjX = Integer . parseInt ( scan . next ( ) ) ; List < String > list = new ArrayList < > ( ) ; String W = scan . next ( ) ; list . add ( W ) ; String preW ; for ( int i = 1 ; i < gUwSiYQYjX ; 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 hEaFkQPRCo { int hEaFkQPRCo , s ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; hEaFkQPRCo = sc . nextInt ( ) ; s = sc . nextInt ( ) ; solve ( ) ; } void solve ( ) { long count = 0 ; for ( int x = 0 ; x <= hEaFkQPRCo ; x ++ ) { for ( int y = 0 ; y <= hEaFkQPRCo ; y ++ ) { int z = s - x - y ; if ( z >= 0 && z <= hEaFkQPRCo ) { count ++ ; } } } System . out . println ( count ) ; } static class hEaFkQPRCo { 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 XAiCevctdl { private static double XAiCevctdl ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; XAiCevctdl = stdIn . nextDouble ( ) ; double Pi = Math . PI ; System . out . printf ( " %.6f %.6f \n " , ( XAiCevctdl * XAiCevctdl * Pi ) , ( 2 * Pi * XAiCevctdl ) ) ; } } import java . util . Scanner ; public class tpXrGXDdXl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tpXrGXDdXl = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int count = tpXrGXDdXl / x ; int answer = 0 ; if ( tpXrGXDdXl % 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 ZWKzIHONxe { private void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] charArray = S . toCharArray ( ) ; List < Integer > counts = new ArrayList < Integer > ( ) ; int ZWKzIHONxe = 0 ; for ( int i = 0 ; i < charArray . length ; i ++ ) { if ( charArray [ i ] == 'A' || charArray [ i ] == 'C' || charArray [ i ] == 'G' || charArray [ i ] == 'T' ) { ZWKzIHONxe ++ ; if ( i == charArray . length - 1 ) { counts . add ( ZWKzIHONxe ) ; } } else { if ( ZWKzIHONxe != 0 ) { counts . add ( ZWKzIHONxe ) ; ZWKzIHONxe = 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 bXhVajIdat { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bXhVajIdat = sc . nextInt ( ) ; int max_first = 0 ; int max_second = 0 ; int [ ] a = new int [ bXhVajIdat ] ; for ( int i = 0 ; i < bXhVajIdat ; ++ 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 GkFKAkxQPk { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int GkFKAkxQPk , b , c ; while ( true ) { GkFKAkxQPk = input . nextInt ( ) ; b = input . nextInt ( ) ; c = input . nextInt ( ) ; if ( GkFKAkxQPk == - 1 && b == - 1 && c == - 1 ) break ; else { if ( GkFKAkxQPk == - 1 || b == - 1 ) System . out . println ( " F " ) ; else if ( GkFKAkxQPk + b < 30 ) System . out . println ( " F " ) ; else if ( GkFKAkxQPk + b < 50 ) { if ( c == - 1 ) { System . out . println ( " D " ) ; } else { if ( c >= 50 ) System . out . println ( " C " ) ; else System . out . println ( " D " ) ; } } else if ( GkFKAkxQPk + b < 65 ) System . out . println ( " C " ) ; else if ( GkFKAkxQPk + b < 80 ) System . out . println ( " B " ) ; else if ( GkFKAkxQPk + b >= 80 ) System . out . println ( " A " ) ; } } } } import java . util . * ; import java . io . * ; public class WoYvwqswTu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long WoYvwqswTu = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long div = WoYvwqswTu / ( a + b ) ; long rem = WoYvwqswTu % ( a + b ) ; long sum = div * a ; sum += Math . min ( rem , a ) ; System . out . println ( sum ) ; } } import java . io . * ; public class ZARrbzqDkR { 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 ZARrbzqDkR = s . length ( ) ; boolean ok = checkKaibun ( s ) ; ok &= checkKaibun ( s . substring ( 0 , ( ZARrbzqDkR - 1 ) / 2 ) ) ; ok &= checkKaibun ( s . substring ( ( ZARrbzqDkR + 1 ) / 2 ) ) ; System . out . println ( ok ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class YKIgmWMrOH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YKIgmWMrOH , B , C , X , Y ; YKIgmWMrOH = sc . nextInt ( ) ; B = sc . nextInt ( ) ; C = sc . nextInt ( ) ; X = sc . nextInt ( ) ; Y = sc . nextInt ( ) ; int min = YKIgmWMrOH * X + B * Y ; if ( X > Y ) { if ( C * 2 * X < min ) { min = C * 2 * X ; } if ( C * 2 * Y + ( X - Y ) * YKIgmWMrOH < min ) { min = C * 2 * Y + ( X - Y ) * YKIgmWMrOH ; } } 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 jrLlOnnBMB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jrLlOnnBMB = sc . nextInt ( ) ; int larger = jrLlOnnBMB / 500 ; int smaller = jrLlOnnBMB - larger * 500 ; int yens = smaller / 5 ; System . out . println ( ( larger * 1000 ) + ( yens * 5 ) ) ; } } import java . io . IOException ; import java . util . Scanner ; public class XEkaNuFgYf { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int XEkaNuFgYf = sc . nextInt ( ) ; int [ ] a = new int [ XEkaNuFgYf ] ; for ( int b = 0 ; b < XEkaNuFgYf ; ++ b ) { a [ b ] = sc . nextInt ( ) ; } for ( int b = XEkaNuFgYf - 1 ; b >= 0 ; -- b ) { if ( b != 0 ) { System . out . print ( a [ b ] + " " ) ; } else { System . out . println ( a [ b ] ) ; } } } } import java . util . * ; public class qhsgpBFwvc { public static void main ( String [ ] args ) { String alphabet = " ABCDEFGHIJKLMNOPQRSTUVWXYZ " ; Scanner sc = new Scanner ( System . in ) ; int qhsgpBFwvc = 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 + qhsgpBFwvc ) % alphabet . length ( ) , ( ( j + qhsgpBFwvc ) % alphabet . length ( ) ) + 1 ) ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class vAPpjCEqJy { void run ( ) { Scanner scan = new Scanner ( System . in ) ; int vAPpjCEqJy = scan . nextInt ( ) ; int prime = 0 ; for ( int i = 0 ; i < vAPpjCEqJy ; 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 YQLYVCYBzc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YQLYVCYBzc = sc . nextInt ( ) ; int [ ] b = new int [ YQLYVCYBzc ] ; for ( int i = 0 ; i < YQLYVCYBzc ; i ++ ) { int m = sc . nextInt ( ) ; b [ i ] = m ; } int w ; for ( int h = 0 ; h < ( YQLYVCYBzc / 2 ) ; h ++ ) { w = b [ h ] ; b [ h ] = b [ YQLYVCYBzc - 1 - h ] ; b [ YQLYVCYBzc - 1 - h ] = w ; } for ( int j = 0 ; j < YQLYVCYBzc - 1 ; j ++ ) { System . out . print ( b [ j ] + " " ) ; } System . out . print ( b [ YQLYVCYBzc - 1 ] ) ; System . out . println ( " " ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; class ixlQwqCeiP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ixlQwqCeiP = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; System . out . println ( ixlQwqCeiP * b ) ; } } import java . io . * ; import java . util . * ; class vXBEamxzIb { public static void main ( String [ ] args ) { solve ( ) ; } public static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; for ( int vXBEamxzIb = 0 ; vXBEamxzIb < s . length ( ) ; vXBEamxzIb ++ ) { if ( vXBEamxzIb == 3 ) { System . out . print ( 8 ) ; } else { System . out . print ( s . charAt ( vXBEamxzIb ) ) ; } } System . out . println ( ) ; } } import java . util . Scanner ; import java . util . * ; class Utxnragktr { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int Utxnragktr = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int [ ] sort = { Utxnragktr , 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 snExKsGEKc { 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 snExKsGEKc : array ) { if ( map . containsKey ( snExKsGEKc ) ) { map . put ( snExKsGEKc , map . get ( snExKsGEKc ) + 1 ) ; } } System . out . println ( map . get ( '1' ) ) ; } } } import java . util . Scanner ; public class lbdCAKoqWn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int lbdCAKoqWn = Integer . parseInt ( scanner . next ( ) ) ; System . out . println ( lbdCAKoqWn * lbdCAKoqWn * lbdCAKoqWn ) ; } } import java . util . * ; public class nAiEbZIaKr { public static void main ( String [ ] arg ) { Scanner scan = new Scanner ( System . in ) ; int nAiEbZIaKr = scan . nextInt ( ) ; int [ ] p = new int [ nAiEbZIaKr ] ; int check = 0 ; for ( int i = 0 ; i < nAiEbZIaKr ; 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 UgMedHZpWc { public static void main ( String [ ] args ) throws IOException { new ABC133 ( ) . c ( ) ; } } class UgMedHZpWc { void c ( ) { long UgMedHZpWc , R ; long M = 2019L ; Scanner in = new Scanner ( System . in ) ; UgMedHZpWc = in . nextLong ( ) ; R = in . nextLong ( ) ; int ans = 2018 ; long maxI = ( long ) Math . min ( R , UgMedHZpWc + M ) ; for ( long i = UgMedHZpWc ; 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 Ixloduaggb { 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 Ixloduaggb = Integer . parseInt ( a + b ) ; double number = Math . sqrt ( Ixloduaggb ) ; if ( number == Math . floor ( number ) ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } out . close ( ) ; } } import java . util . Scanner ; public class CVQuCEVfPM { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int CVQuCEVfPM = scan . nextInt ( ) ; int [ ] a = new int [ CVQuCEVfPM ] ; for ( int i = 0 ; i < CVQuCEVfPM ; 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 < CVQuCEVfPM ; i ++ ) { a [ i ] /= 2 ; } count ++ ; } System . out . println ( count ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class HGiMcZhRug { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str ; while ( ! ( ( str = br . readLine ( ) ) . equals ( " - " ) ) ) { int HGiMcZhRug = Integer . parseInt ( br . readLine ( ) ) ; int [ ] arrH = new int [ HGiMcZhRug ] ; for ( int i = 0 ; i < HGiMcZhRug ; i ++ ) { arrH [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } shuff ( str , arrH , HGiMcZhRug ) ; } } 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 zRQPWjumdb { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int zRQPWjumdb = 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 < zRQPWjumdb ; 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 TTHDwRZqDR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long TTHDwRZqDR = sc . nextLong ( ) ; int ans = 0 ; for ( int i = 0 ; i < TTHDwRZqDR ; i ++ ) { if ( s . charAt ( i ) == '1' ) { if ( i + 1 == TTHDwRZqDR ) { ans = i ; break ; } } else { ans = i ; break ; } } System . out . println ( s . charAt ( ans ) ) ; } } import java . util . * ; public class siyyuGdqmk { public static void main ( String [ ] args ) { final String RESULT_YES = " Yes " ; final String RESULT_NO = " No " ; Scanner sc = new Scanner ( System . in ) ; int siyyuGdqmk = sc . nextInt ( ) ; int locationCode = sc . nextInt ( ) ; String val = sc . next ( ) ; boolean result = false ; if ( val . matches ( " [0-9] { " + siyyuGdqmk + " } -[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 NsJSgCxMCq { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String readStr ; int NsJSgCxMCq = 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 vcHanlnAtO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vcHanlnAtO = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; Set < Integer > ans1 = new TreeSet < > ( ) ; for ( int i = 1 ; i <= vcHanlnAtO ; i ++ ) { if ( vcHanlnAtO % 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 qFulTsrMff { 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 qFulTsrMff = Integer . parseInt ( array_of_li_col [ 0 ] ) ; int column = Integer . parseInt ( array_of_li_col [ 1 ] ) ; int [ ] [ ] matrix_array_A = new int [ qFulTsrMff ] [ column ] ; int [ ] vector_array_b = new int [ column ] ; for ( int line_A = 0 ; line_A < qFulTsrMff ; 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 < qFulTsrMff ; 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 BESwdvEPAA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int BESwdvEPAA = Integer . parseInt ( a + b ) ; for ( int i = 1 ; i < 400 ; i ++ ) { if ( i * i == BESwdvEPAA ) { 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 mbeBNoXSIf { 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 mbeBNoXSIf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = 0 ; c += Main . combination ( mbeBNoXSIf , 2 ) ; c += Main . combination ( b , 2 ) ; System . out . println ( c ) ; } } import java . util . Scanner ; public class mZIjUobuRU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mZIjUobuRU = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long x1 = mZIjUobuRU * c ; long x2 = mZIjUobuRU * 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 zyKteKralk { 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 zyKteKralk { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int zyKteKralk = in . nextInt ( ) ; int b = in . nextInt ( ) ; out . println ( zyKteKralk * b % 2 == 1 ? " Odd " : " Even " ) ; } } static class zyKteKralk { 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 KBrAJanfXW { public static void main ( String [ ] args ) { FastScanner scanner = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int KBrAJanfXW = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; out . println ( Math . max ( c - ( KBrAJanfXW - b ) , 0 ) ) ; out . flush ( ) ; } public static class KBrAJanfXW { 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 wrNHVBTeAo { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int wrNHVBTeAo = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( wrNHVBTeAo + b <= c * 2 ) { System . out . println ( wrNHVBTeAo * x + b * y ) ; return ; } int tmp = Math . min ( x , y ) ; int tmp2 = c * tmp * 2 ; int tmp3 = wrNHVBTeAo * ( 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 WCDCixJpyM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WCDCixJpyM = sc . nextInt ( ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; char [ ] s = new char [ WCDCixJpyM ] ; char [ ] t = new char [ WCDCixJpyM ] ; int i ; int m ; char [ ] b = new char [ 2 * WCDCixJpyM ] ; for ( i = 0 ; i < WCDCixJpyM ; i ++ ) { s [ i ] = S . charAt ( i ) ; } for ( i = 0 ; i < WCDCixJpyM ; i ++ ) { t [ i ] = T . charAt ( i ) ; } for ( i = 0 , m = 0 ; i < WCDCixJpyM ; i ++ , m = m + 2 ) { b [ m ] = s [ i ] ; } for ( i = 0 , m = 1 ; i < WCDCixJpyM ; i ++ , m = m + 2 ) { b [ m ] = t [ i ] ; } String str = String . valueOf ( b ) ; System . out . println ( str ) ; } } import java . util . Scanner ; public class jahmmvIPlF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double jahmmvIPlF = 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 = jahmmvIPlF * Math . cos ( ht ) ; double hy = jahmmvIPlF * 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 pWdBQdSyfY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pWdBQdSyfY = sc . nextInt ( ) ; for ( int i = 1 ; i <= 10 ; i ++ ) { if ( ( pWdBQdSyfY - 1000 * i ) <= 0 ) { System . out . println ( ( pWdBQdSyfY - 1000 * i ) * - 1 ) ; break ; } } } } import java . util . * ; public class KiPXgZiMFy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KiPXgZiMFy = sc . nextInt ( ) ; int [ ] h = new int [ KiPXgZiMFy ] ; for ( int i = 0 ; i < KiPXgZiMFy ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int [ ] q = new int [ KiPXgZiMFy ] ; Arrays . fill ( q , 0 ) ; q [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < KiPXgZiMFy ; 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 [ KiPXgZiMFy - 1 ] ) ; } } import java . util . * ; public class hoNaZoHrOF { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double hoNaZoHrOF = scan . nextInt ( ) ; System . out . println ( 2 * Math . PI * hoNaZoHrOF ) ; scan . close ( ) ; return ; } } import java . util . * ; public class JNiqjbVySx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JNiqjbVySx = sc . nextInt ( ) ; int syainj = sc . nextInt ( ) ; System . out . println ( JNiqjbVySx * syainj ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class RsUpbucQWh { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int RsUpbucQWh = Integer . parseInt ( str [ 0 ] ) ; int a = Integer . parseInt ( str [ 1 ] ) ; System . out . println ( ( RsUpbucQWh + a - 1 ) / a ) ; } } import java . util . Scanner ; public class yfcabVBGJI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yfcabVBGJI = sc . nextInt ( ) ; String S = sc . next ( ) ; int count = 0 ; for ( int i = 0 ; i < yfcabVBGJI - 2 ; i ++ ) { if ( S . substring ( i , i + 3 ) . equals ( " ABC " ) ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class cWbsulTEDj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String buff = " " ; int cWbsulTEDj = 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 < cWbsulTEDj ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < cWbsulTEDj - 1 ; i ++ ) { for ( int j = i + 1 ; j < cWbsulTEDj ; j ++ ) { count += array [ i ] * array [ j ] ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class kvODOinpLN { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int kvODOinpLN = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int T = scanner . nextInt ( ) ; int ans = T / kvODOinpLN * B ; System . out . println ( ans ) ; scanner . close ( ) ; } } import java . util . Scanner ; public class mrvsleFqcO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] chars = sc . next ( ) . toCharArray ( ) ; for ( char mrvsleFqcO : chars ) { if ( mrvsleFqcO == '1' ) { System . out . print ( 9 ) ; } else if ( mrvsleFqcO == '9' ) { System . out . print ( 1 ) ; } else { System . out . println ( mrvsleFqcO ) ; } } System . out . println ( ) ; } } import java . util . Scanner ; public class dtgLCedaLc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dtgLCedaLc = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; if ( dtgLCedaLc <= ( 2 * D + 1 ) ) { System . out . println ( 1 ) ; } else { int num = 0 ; while ( dtgLCedaLc > 0 ) { dtgLCedaLc -= ( 2 * D + 1 ) ; num ++ ; } System . out . println ( num ) ; } } } import java . util . * ; public class LycUmIDuxP { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int LycUmIDuxP = sc . nextInt ( ) ; int leg = sc . nextInt ( ) ; if ( leg % 2 == 1 ) { System . out . println ( " No " ) ; } else if ( leg < 2 * LycUmIDuxP ) { System . out . println ( " No " ) ; } else if ( leg > 4 * LycUmIDuxP ) { 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 iKlGDoqaXg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iKlGDoqaXg = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( Math . max ( Math . max ( iKlGDoqaXg + b , iKlGDoqaXg - b ) , iKlGDoqaXg * b ) ) ; } } import java . util . * ; class tOTjMtspip { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tOTjMtspip = sc . nextInt ( ) , count = 0 ; for ( int i = 0 ; i < tOTjMtspip ; i ++ ) { if ( sc . nextInt ( ) == count + 1 ) { count ++ ; } } System . out . println ( count == 0 ? - 1 : tOTjMtspip - count ) ; } } import java . util . Scanner ; public class iKTWZEXcvz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iKTWZEXcvz = sc . nextInt ( ) ; int [ ] arrayA = new int [ iKTWZEXcvz ] ; 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 vwqakqpJpD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vwqakqpJpD = sc . nextInt ( ) ; int [ ] w = new int [ vwqakqpJpD ] ; for ( int i = 0 ; i < vwqakqpJpD ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } int min = 1000000000 ; for ( int i = 0 ; i < vwqakqpJpD ; i ++ ) { int s1 = 0 ; int s2 = 0 ; for ( int j = 0 ; j <= i ; j ++ ) { s1 += w [ j ] ; } for ( int k = i + 1 ; k <= vwqakqpJpD - 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 JCfgSxxcJf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JCfgSxxcJf , M ; JCfgSxxcJf = sc . nextInt ( ) ; M = sc . nextInt ( ) ; int [ ] broken = new int [ JCfgSxxcJf + 1 ] ; for ( int i = 0 ; i < M ; i ++ ) { int a = sc . nextInt ( ) ; broken [ a ] = 1 ; } int [ ] dp = new int [ JCfgSxxcJf + 2 ] ; dp [ JCfgSxxcJf ] = 1 ; for ( int i = JCfgSxxcJf - 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 BrYiuZekXE { 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 BrYiuZekXE = num . length ( ) ; System . out . println ( BrYiuZekXE ) ; } } import java . util . LinkedHashSet ; import java . util . Scanner ; import java . util . Set ; public class FiyReEokMd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FiyReEokMd = sc . nextInt ( ) ; int [ ] numbers = new int [ FiyReEokMd ] ; for ( int i = 0 ; i < FiyReEokMd ; 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 LuQTKCzRtz { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; int LuQTKCzRtz = scan . nextInt ( ) ; double sum = 0 ; for ( int i = 0 ; i < LuQTKCzRtz && scan . hasNextInt ( ) ; i ++ ) { sum += ( 1 / ( double ) scan . nextInt ( ) ) ; } System . out . println ( 1 / sum ) ; } } import java . util . * ; public class PTPqQCkGZq { public static void main ( String [ ] args ) { int PTPqQCkGZq = 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 ) PTPqQCkGZq = 1 ; System . out . println ( max_area + " " + PTPqQCkGZq ) ; } } import java . util . * ; public class tILtrfWSwA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tILtrfWSwA = sc . nextInt ( ) ; int [ ] nums = new int [ tILtrfWSwA ] ; for ( int i = 0 ; i < tILtrfWSwA ; i ++ ) { nums [ i ] = sc . nextInt ( ) ; } int output = 0 ; flag2 : while ( true ) { for ( int i = 0 ; i < tILtrfWSwA ; i ++ ) { if ( nums [ i ] > 0 ) { output ++ ; for ( int j = 0 ; j < tILtrfWSwA - 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 OveIHABzHU { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String str = in . nextLine ( ) ; char OveIHABzHU ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { OveIHABzHU = str . charAt ( i ) ; if ( Character . isUpperCase ( OveIHABzHU ) ) System . out . print ( Character . toLowerCase ( OveIHABzHU ) ) ; else System . out . print ( Character . toUpperCase ( OveIHABzHU ) ) ; } System . out . println ( ) ; } } import java . util . * ; public class xTdwTwkWxK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xTdwTwkWxK = sc . nextInt ( ) ; int bInt = sc . nextInt ( ) ; int seki = xTdwTwkWxK * 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 VOxMUAIIcE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VOxMUAIIcE = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; int max = 0 ; for ( int i = 0 ; i < VOxMUAIIcE ; 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 YFTeqzrCDx { public static void main ( String [ ] args ) { Scanner t = new Scanner ( System . in ) ; String S = t . nextLine ( ) ; int YFTeqzrCDx = 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 FOihmXaCXF { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; List < Integer > heightsOfMountain = new ArrayList < Integer > ( ) ; String FOihmXaCXF = null ; while ( ( FOihmXaCXF = br . readLine ( ) ) != null ) { heightsOfMountain . add ( Integer . valueOf ( FOihmXaCXF ) ) ; } 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 xZqZfBmHaP { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int xZqZfBmHaP = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char ss = s . charAt ( i ) ; char tt = t . charAt ( i ) ; if ( ss != tt ) xZqZfBmHaP ++ ; } System . out . println ( xZqZfBmHaP ) ; } } import java . util . Scanner ; public class xhkJjHWMqQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; int xhkJjHWMqQ = input . length ( ) ; String [ ] n = new String [ 30 ] ; for ( int i = 0 ; i < xhkJjHWMqQ ; i ++ ) { n [ i ] = input . substring ( i , i + 1 ) ; } for ( int i = ( xhkJjHWMqQ - 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 QVNLGHoQxJ { final static Long MAX = 1000000000000000000L ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QVNLGHoQxJ = sc . nextInt ( ) ; sc . nextLine ( ) ; List < Long > l = new ArrayList < Long > ( ) ; for ( int i = 0 ; i < QVNLGHoQxJ ; 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 LQJUsYNGMD { static boolean solve ( int LQJUsYNGMD , int t , int s ) { if ( s * t >= LQJUsYNGMD ) return true ; else return false ; } public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int LQJUsYNGMD , t , s ; LQJUsYNGMD = stdIn . nextInt ( ) ; t = stdIn . nextInt ( ) ; s = stdIn . nextInt ( ) ; boolean result = solve ( LQJUsYNGMD , t , s ) ; if ( result ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; stdIn . close ( ) ; } } import java . util . * ; public class KJDNOXaepj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; long KJDNOXaepj = sc . nextLong ( ) ; int i = 0 ; while ( i < S . length ( ) && S . charAt ( i ) == '1' ) { i ++ ; } if ( i == S . length ( ) || KJDNOXaepj <= 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 hwxVjYHEsy { 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 hwxVjYHEsy , W ; while ( true ) { hwxVjYHEsy = sc . nextInt ( ) ; W = sc . nextInt ( ) ; if ( hwxVjYHEsy == 0 && W == 0 ) break ; height . add ( hwxVjYHEsy ) ; 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 ZNqLpZZsTP { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int ZNqLpZZsTP = sc . nextInt ( ) ; int [ ] arr = new int [ ZNqLpZZsTP ] ; int [ ] dp = new int [ ZNqLpZZsTP ] ; for ( int i = 0 ; i < ZNqLpZZsTP ; i ++ ) arr [ i ] = sc . nextInt ( ) ; Arrays . fill ( dp , 0 ) ; if ( ZNqLpZZsTP == 1 ) { System . out . println ( arr [ 0 ] ) ; return ; } dp [ 1 ] = Math . abs ( arr [ 1 ] - arr [ 0 ] ) ; for ( int i = 2 ; i < ZNqLpZZsTP ; 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 [ ZNqLpZZsTP - 1 ] ) ; return ; } } import java . util . * ; class PzwyhdMvfE { public static void main ( String [ ] args ) { int PzwyhdMvfE = 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 ] ) { PzwyhdMvfE ++ ; } else if ( a [ 0 ] == a [ 2 ] && a [ 1 ] == a [ 3 ] ) { PzwyhdMvfE ++ ; } else if ( a [ 0 ] == a [ 3 ] && a [ 1 ] == a [ 2 ] ) { PzwyhdMvfE ++ ; } System . out . print ( ans [ PzwyhdMvfE ] ) ; } } import java . util . * ; import java . io . * ; public class OxeuswKAoH { 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 OxeuswKAoH = s . length ( ) ; int m = t . length ( ) ; int gg = m ; for ( int i = 0 ; i <= OxeuswKAoH - 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 tYjPtLlftu { public static int tYjPtLlftu = 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 jjAMpwUrVI { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int jjAMpwUrVI = 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 <= jjAMpwUrVI ; 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 BEbTHEUPEv { 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 AhtuRTsVwy { 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 AhtuRTsVwy = Integer . parseInt ( br . readLine ( ) ) ; System . out . println ( ( int ) Math . pow ( AhtuRTsVwy , 3 ) ) ; } } import java . util . * ; public class hAKxcwSIcH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hAKxcwSIcH = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int ans = 0 ; ans = ( hAKxcwSIcH + ( d * 2 + 1 ) - 1 ) / ( d * 2 + 1 ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class NSAglIAVQh { public static void main ( String [ ] args ) throws Exception { try ( Scanner sc = new Scanner ( System . in ) ) { int NSAglIAVQh = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int L_MAX = 0 ; int R_MIN = NSAglIAVQh + 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 xyKfVSSUAN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xyKfVSSUAN = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int hitNum = ( int ) Math . ceil ( ( double ) xyKfVSSUAN / A ) ; System . out . print ( hitNum ) ; } } import java . util . * ; class INNynOuTMZ { Scanner sc ; String s ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { s = sc . next ( ) ; for ( int INNynOuTMZ = 0 ; INNynOuTMZ < s . length ( ) ; INNynOuTMZ ++ ) { char c = s . charAt ( INNynOuTMZ ) ; if ( ( INNynOuTMZ % 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 hCuXPHSQnd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int hCuXPHSQnd = sc . nextInt ( ) , d [ ] = new int [ hCuXPHSQnd + 1 ] ; for ( int i = 0 ; i < hCuXPHSQnd ; ++ i ) d [ i ] = sc . nextInt ( ) ; sc . close ( ) ; d [ hCuXPHSQnd ] = 1000 ; Arrays . sort ( d ) ; int ans = 0 ; for ( int i = 0 ; i < hCuXPHSQnd ; ++ i ) { if ( d [ i ] != d [ i + 1 ] ) ++ ans ; } System . out . println ( ans ) ; } } import java . util . * ; public class HwhHCAaMhR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HwhHCAaMhR = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int count = 0 ; for ( int i = HwhHCAaMhR ; 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 pgDNAUQxaQ { public static void main ( String [ ] args ) { Scanner Str = new Scanner ( System . in ) ; int pgDNAUQxaQ = Integer . parseInt ( Str . next ( ) ) ; int b = Integer . parseInt ( Str . next ( ) ) ; if ( Math . floor ( pgDNAUQxaQ / 10 ) + Math . floor ( b / 10 ) == 0 ) { System . out . println ( pgDNAUQxaQ * b ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . * ; public class sCNiMVktGf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sCNiMVktGf = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= sCNiMVktGf ; 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 bywsTEbTXh { 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 bywsTEbTXh = 0 ; bywsTEbTXh < s . length ; bywsTEbTXh ++ ) que . addLast ( s [ bywsTEbTXh ] ) ; while ( true ) { StringBuilder sb = new StringBuilder ( ) ; for ( int bywsTEbTXh = 0 ; bywsTEbTXh < 5 ; bywsTEbTXh ++ ) 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 QsItMAYvci { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; final int QsItMAYvci = Integer . parseInt ( sc . next ( ) ) ; long [ ] a = new long [ QsItMAYvci + 1 ] ; long [ ] b = new long [ QsItMAYvci ] ; for ( int i = 0 ; i < QsItMAYvci + 1 ; i ++ ) { a [ i ] = Long . parseLong ( sc . next ( ) ) ; } for ( int i = 0 ; i < QsItMAYvci ; i ++ ) { b [ i ] = Long . parseLong ( sc . next ( ) ) ; } long ans = 0 ; for ( int i = 0 ; i < QsItMAYvci ; 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 TqqGrZEAhe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TqqGrZEAhe = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; String ans = " " ; int max = TqqGrZEAhe * 5000 ; if ( TqqGrZEAhe * 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 <= ( TqqGrZEAhe - i ) ; j ++ ) { int value = sum ; value += j * 5000 ; int k = TqqGrZEAhe - ( 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 LWYuafwxol { public static void main ( String [ ] args ) { int LWYuafwxol , 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 ( LWYuafwxol = 0 ; LWYuafwxol < n ; LWYuafwxol ++ ) array [ LWYuafwxol ] = 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 GLuvFoPfJT { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int GLuvFoPfJT = Integer . parseInt ( in . readLine ( ) ) ; int ans = 0 ; while ( GLuvFoPfJT >= 5 ) { if ( GLuvFoPfJT >= 500 ) { ans += 1000 * ( GLuvFoPfJT / 500 ) ; GLuvFoPfJT %= 500 ; } else { ans += 5 * ( GLuvFoPfJT / 5 ) ; GLuvFoPfJT %= 5 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class NRjSMHgFSH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NRjSMHgFSH = sc . nextInt ( ) ; int cnt = 1 ; while ( true ) { if ( NRjSMHgFSH == 1 || NRjSMHgFSH == 2 || NRjSMHgFSH == 4 ) { System . out . println ( cnt + 3 ) ; return ; } if ( NRjSMHgFSH % 2 == 0 ) NRjSMHgFSH /= 2 ; else NRjSMHgFSH = NRjSMHgFSH * 3 + 1 ; cnt ++ ; } } } import java . util . Scanner ; public class lLuDxHJgGO { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] ar = scanner . nextLine ( ) . split ( " " ) ; for ( int lLuDxHJgGO = 0 ; lLuDxHJgGO < ar . length ; lLuDxHJgGO ++ ) { if ( Integer . parseInt ( ar [ lLuDxHJgGO ] ) == 0 ) { System . out . println ( lLuDxHJgGO + 1 ) ; } } } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class HjRKxEbuob { public static void main ( String [ ] args ) { solve ( System . in , System . out ) ; } static void solve ( InputStream is , PrintStream os ) { Scanner sc = new Scanner ( is ) ; int HjRKxEbuob = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < HjRKxEbuob ; i ++ ) { int h = sc . nextInt ( ) ; if ( k <= h ) ans ++ ; } os . println ( ans ) ; } } import java . util . Scanner ; public class dcDJBNBmUj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dcDJBNBmUj = sc . nextInt ( ) ; int [ ] h = new int [ dcDJBNBmUj ] ; int count = 0 ; for ( int i = 0 ; i < dcDJBNBmUj ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int a = 0 ; int b = 0 ; L : while ( a <= dcDJBNBmUj - 1 && b <= dcDJBNBmUj - 1 ) { if ( h [ a ] == 0 ) { a ++ ; continue ; } b = a ; while ( b <= dcDJBNBmUj - 1 ) { if ( h [ b ] != 0 && b != dcDJBNBmUj - 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 VaZCrfXJZr { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int VaZCrfXJZr = 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 [ VaZCrfXJZr ] ; int [ ] pe = new int [ VaZCrfXJZr ] ; 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 OYYacyfzPu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OYYacyfzPu = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= OYYacyfzPu ; i ++ ) { int digCount = digCount ( i ) ; if ( digCount % 2 != 0 ) { ans ++ ; } } System . out . println ( ans ) ; } static int digCount ( int OYYacyfzPu ) { int res = 0 ; while ( OYYacyfzPu > 0 ) { res ++ ; OYYacyfzPu /= 10 ; } return res ; } } import java . util . Scanner ; public class JfxrCpwVsi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JfxrCpwVsi = sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; System . out . println ( e - JfxrCpwVsi > k ? " :( " : " Yay! " ) ; } } import java . util . Scanner ; public class AuUyyfEvTq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AuUyyfEvTq = sc . nextInt ( ) ; long [ ] a = new long [ AuUyyfEvTq + 1 ] ; long [ ] b = new long [ AuUyyfEvTq ] ; for ( int i = 0 ; i < AuUyyfEvTq + 1 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < AuUyyfEvTq ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } long fii1 = 0 ; long sum = 0 ; for ( int i = 0 ; i < AuUyyfEvTq ; 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 DYojjEwkaU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DYojjEwkaU , b , c ; DYojjEwkaU = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; System . out . println ( c + " " + DYojjEwkaU + " " + b ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class jBiuuSexQc { 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 jBiuuSexQc = 0 ; for ( int i = 0 ; i < tiles . length ( ) ; i ++ ) { if ( tile != tiles . charAt ( i ) ) jBiuuSexQc ++ ; tile = tile == '0' ? '1' : '0' ; } return jBiuuSexQc ; } } import java . util . Scanner ; class JuUnFwfcWP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JuUnFwfcWP = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] A = new int [ JuUnFwfcWP ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < JuUnFwfcWP ; 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 < JuUnFwfcWP ; 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 NLTYXoXnQx { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int NLTYXoXnQx = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; System . out . println ( Math . max ( 0 , C - ( NLTYXoXnQx - B ) ) ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } } import java . util . * ; public class fEIHkyjISt { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int fEIHkyjISt = sc . nextInt ( ) ; int [ ] [ ] array = new int [ fEIHkyjISt ] [ 2 ] ; for ( int i = 0 ; i < fEIHkyjISt ; i ++ ) { array [ i ] [ 0 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < fEIHkyjISt ; i ++ ) { array [ i ] [ 1 ] = sc . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < fEIHkyjISt ; i ++ ) { int s = array [ i ] [ 0 ] - array [ i ] [ 1 ] ; if ( s > 0 ) { sum += s ; } } System . out . println ( sum ) ; } } import java . util . * ; public class hnzgRjAWQO { Scanner sc ; public static void main ( String [ ] args ) { new Main ( ) . execute ( ) ; } public void execute ( ) { this . sc = new Scanner ( System . in ) ; int hnzgRjAWQO = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < hnzgRjAWQO ; 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 uqdamXalHp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long uqdamXalHp = sc . nextInt ( ) ; long n = sc . nextInt ( ) ; long k = 0 ; boolean stop = false ; if ( uqdamXalHp < n ) { k = uqdamXalHp ; } else { k = n ; } for ( ; k >= 1 && stop == false ; k -- ) { if ( n % k == 0 && uqdamXalHp % k == 0 ) { stop = true ; } } long l = n * uqdamXalHp / ( 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 YukCntocQa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YukCntocQa = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < YukCntocQa ; 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 tjqCpBNJUA { 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 tjqCpBNJUA { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int tjqCpBNJUA = in . nextInt ( ) ; int b = in . nextInt ( ) ; out . print ( tjqCpBNJUA * b % 2 == 0 ? " Even " : " Odd " ) ; } } static class tjqCpBNJUA 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 ffRZEIFbJV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ffRZEIFbJV = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int C = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int a = ffRZEIFbJV ; 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 ( ffRZEIFbJV + b + C , ffRZEIFbJV + B + c ) ) ) ; } } import java . util . Scanner ; public class wyeABssDIC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wyeABssDIC = 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 [ wyeABssDIC + 1 ] ; int [ ] waA = new int [ wyeABssDIC + 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 eaKpBwGamM { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; try { while ( true ) { String line = sc . next ( ) ; if ( line . equals ( " - " ) ) { break ; } int eaKpBwGamM = sc . nextInt ( ) ; for ( int i = 0 ; i < eaKpBwGamM ; 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 bNxpJsLNlp { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int bNxpJsLNlp = stdIn . nextInt ( ) ; for ( int n = 1 ; bNxpJsLNlp != 0 ; n ++ ) { System . out . println ( " Case " + n + " : " + bNxpJsLNlp ) ; bNxpJsLNlp = stdIn . nextInt ( ) ; } } } import java . util . * ; public class aoAKtFVRjR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aoAKtFVRjR = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int plus = aoAKtFVRjR + B ; int minus = aoAKtFVRjR - B ; int kakeru = aoAKtFVRjR * 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 cPZPGfpQoL { 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 cPZPGfpQoL = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( gcd ( cPZPGfpQoL , b ) ) ; } } import java . util . Scanner ; public class jrUEzkKUfS { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int jrUEzkKUfS = scanner . nextInt ( ) ; int [ ] h = new int [ jrUEzkKUfS ] ; int [ ] curH = new int [ jrUEzkKUfS ] ; for ( int i = 0 ; i < jrUEzkKUfS ; i ++ ) { h [ i ] = scanner . nextInt ( ) ; } int count = 0 ; outer : while ( true ) { int start = 0 , end = 0 ; for ( start = 0 ; start < jrUEzkKUfS ; start ++ ) { if ( curH [ start ] < h [ start ] ) { break ; } } if ( start >= jrUEzkKUfS ) { break ; } count ++ ; int i ; for ( i = start ; i < jrUEzkKUfS ; i ++ ) { if ( curH [ i ] < h [ i ] ) { curH [ i ] ++ ; } else { break ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class NYlUFehbpZ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int NYlUFehbpZ = Integer . parseInt ( scan . next ( ) ) ; int x = 0 ; int y = 0 ; int t = 0 ; boolean possible = true ; for ( int i = 0 ; i < NYlUFehbpZ ; ++ 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 BSsKwplnOa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BSsKwplnOa = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; if ( BSsKwplnOa == 0 ) { BSsKwplnOa = 1 ; } else if ( BSsKwplnOa == 1 ) { BSsKwplnOa = 100 ; } else { BSsKwplnOa = 10000 ; } for ( int i = 1 ; i <= b ; i ++ ) { ans = BSsKwplnOa * i ; if ( i >= 100 ) { ans = BSsKwplnOa * ( i + 1 ) ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; public class ILHMLooAYU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ILHMLooAYU = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a % ILHMLooAYU == 0 || b % ILHMLooAYU == 0 ) { System . out . println ( " OK " ) ; return ; } int rem = a % ILHMLooAYU ; int temp = a - rem ; temp += ILHMLooAYU ; for ( int i = temp ; i < b ; i += ILHMLooAYU ) { if ( temp > a ) { System . out . println ( " OK " ) ; return ; } } System . out . println ( " NG " ) ; } } import java . io . IOException ; import java . util . * ; public class lFvGvzwGYq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lFvGvzwGYq = sc . nextInt ( ) ; int [ ] s = new int [ lFvGvzwGYq ] ; for ( int i = 0 ; i < lFvGvzwGYq ; 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 = lFvGvzwGYq - 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 ojHaQKPFPi { public static void main ( String [ ] args ) { Scanner sn = new Scanner ( System . in ) ; int ojHaQKPFPi = sn . nextInt ( ) ; int b = sn . nextInt ( ) ; int c = sn . nextInt ( ) ; int co = 0 ; for ( int i = ojHaQKPFPi ; i <= b ; i ++ ) { if ( c % i != 0 ) { continue ; } co ++ ; } System . out . println ( co ) ; } } import java . util . * ; public class TGqogqZRAS { 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 TGqogqZRAS = 0 ; int ans = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( Y [ i ] . equals ( " # " ) ) { TGqogqZRAS ++ ; ans = ( TGqogqZRAS > ans ) ? TGqogqZRAS : ans ; if ( TGqogqZRAS == S . length ( ) ) { ans = TGqogqZRAS ; } } else { ans = ( TGqogqZRAS > ans ) ? TGqogqZRAS : ans ; TGqogqZRAS = 0 ; } } System . out . println ( ans ) ; keyboard . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class sjgFvFyROy { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String sjgFvFyROy = br . readLine ( ) ; char [ ] ch = sjgFvFyROy . 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 VLQilGIMNu { void run ( ) { Scanner scan = new Scanner ( System . in ) ; int VLQilGIMNu = scan . nextInt ( ) ; int [ ] a = new int [ 100 ] ; for ( int i = 0 ; i < VLQilGIMNu ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } System . out . print ( a [ VLQilGIMNu - 1 ] ) ; for ( int i = VLQilGIMNu - 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 uaAcOSKzOS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uaAcOSKzOS = sc . nextInt ( ) ; int [ ] H = new int [ uaAcOSKzOS ] ; 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 FrELXaxelb { static DecimalFormat df = new DecimalFormat ( " 0.0000000000000000000 " ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int FrELXaxelb = sc . nextInt ( ) ; String op = sc . next ( ) ; int b = sc . nextInt ( ) ; if ( op . equals ( " ? " ) ) break ; if ( op . equals ( " + " ) ) System . out . println ( FrELXaxelb + b ) ; else if ( op . equals ( " - " ) ) System . out . println ( FrELXaxelb - b ) ; else if ( op . equals ( " * " ) ) System . out . println ( FrELXaxelb * b ) ; else System . out . println ( FrELXaxelb / b ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class UjfnhcmlmH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int UjfnhcmlmH = sc . nextInt ( ) , a = sc . nextInt ( ) , b = sc . nextInt ( ) ; if ( a % UjfnhcmlmH == 0 || b % UjfnhcmlmH == 0 ) { System . out . println ( " OK " ) ; } else { if ( b / UjfnhcmlmH - a / UjfnhcmlmH == 0 ) { System . out . println ( " NG " ) ; } else { System . out . println ( " OK " ) ; } } } } import java . util . * ; public class tjVXCgpBQb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tjVXCgpBQb = scan . nextInt ( ) ; HashMap < Integer , Integer > a = new HashMap < Integer , Integer > ( ) ; int [ ] b = new int [ tjVXCgpBQb ] ; for ( int i = 0 ; i < tjVXCgpBQb ; i ++ ) { int t = scan . nextInt ( ) ; a . put ( t , i + 1 ) ; b [ i ] = t ; } Arrays . sort ( b ) ; for ( int j = 0 ; j < tjVXCgpBQb - 1 ; j ++ ) { System . out . print ( a . get ( b [ j ] ) + " " ) ; } System . out . println ( a . get ( b [ tjVXCgpBQb - 1 ] ) ) ; } } import java . util . * ; public class rluwBIbspH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rluwBIbspH = sc . nextInt ( ) ; if ( rluwBIbspH >= 100 && rluwBIbspH < 112 ) { System . out . println ( 111 ) ; } else if ( rluwBIbspH >= 112 && rluwBIbspH <= 222 ) { System . out . println ( 222 ) ; } else if ( rluwBIbspH > 222 && rluwBIbspH <= 333 ) { System . out . println ( 333 ) ; } else if ( rluwBIbspH > 333 && rluwBIbspH <= 444 ) { System . out . println ( 444 ) ; } else if ( rluwBIbspH > 444 && rluwBIbspH <= 555 ) { System . out . println ( 555 ) ; } else if ( rluwBIbspH > 555 && rluwBIbspH <= 666 ) { System . out . println ( 666 ) ; } else if ( rluwBIbspH > 666 && rluwBIbspH <= 777 ) { System . out . println ( 777 ) ; } else if ( rluwBIbspH > 777 && rluwBIbspH <= 888 ) { System . out . println ( 888 ) ; } else if ( rluwBIbspH > 888 && rluwBIbspH <= 999 ) { System . out . println ( 999 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class ycsEqolMzw { static int ycsEqolMzw ; 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+ " ) ; ycsEqolMzw = Integer . parseInt ( word [ 0 ] ) ; B = Integer . parseInt ( word [ 1 ] ) ; System . out . println ( ycsEqolMzw * B ) ; br . close ( ) ; } } import java . util . Scanner ; import static java . lang . Math . ceil ; class DgzXUzHjju { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int DgzXUzHjju = input . nextInt ( ) ; int b = input . nextInt ( ) ; System . out . println ( ( int ) ceil ( ( 1.0 * DgzXUzHjju ) / ( 1.0 * b ) ) ) ; } } import java . util . * ; public class OFhGNcPwwi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int OFhGNcPwwi = scanner . nextInt ( ) ; Integer [ ] d = new Integer [ OFhGNcPwwi ] ; int s = 1 ; for ( int i = 0 ; i < OFhGNcPwwi ; i ++ ) { d [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( d , Comparator . reverseOrder ( ) ) ; for ( int i = 0 ; i < OFhGNcPwwi - 1 ; i ++ ) { if ( d [ i ] > d [ i + 1 ] ) s ++ ; } System . out . println ( s ) ; } } import java . util . * ; public class uvukaKvIfb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uvukaKvIfb = sc . nextInt ( ) ; int [ ] x = new int [ uvukaKvIfb ] ; int [ ] y = new int [ uvukaKvIfb + 1 ] ; for ( int i = 0 ; i < uvukaKvIfb ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ x [ i ] ] = i + 1 ; } for ( int i = 1 ; i <= uvukaKvIfb ; i ++ ) System . out . print ( y [ i ] + " " ) ; } } import java . io . StringReader ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; class pIwGRenvFK { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int pIwGRenvFK = 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 / pIwGRenvFK ; if ( ( pointSum % pIwGRenvFK ) > ( ( double ) pIwGRenvFK / 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 hvRJJRWMTU { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int hvRJJRWMTU = 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 ( hvRJJRWMTU > sum ? " No " : " Yes " ) ; } } import java . util . Scanner ; import java . util . Date ; class OAsQfvQfRJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OAsQfvQfRJ , b , c , m , n ; while ( sc . hasNext ( ) ) { OAsQfvQfRJ = sc . nextInt ( ) ; b = sc . nextInt ( ) ; m = OAsQfvQfRJ ; 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 , OAsQfvQfRJ / m * b ) ; } } } import java . util . Scanner ; public class EAyCUYRQjb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EAyCUYRQjb = 0 ; while ( sc . hasNext ( ) ) { String s = sc . next ( ) ; if ( s . equals ( " 0 " ) ) { break ; } EAyCUYRQjb = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; int digit = c - '0' ; EAyCUYRQjb += digit ; } System . out . printf ( " %d \n " , EAyCUYRQjb ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class rrQfFmQMLC { 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 rrQfFmQMLC = 0 ; rrQfFmQMLC < s . length ( ) ; rrQfFmQMLC ++ ) { C [ rrQfFmQMLC ] = s . charAt ( rrQfFmQMLC ) ; } for ( int rrQfFmQMLC = 0 ; rrQfFmQMLC < s . length ( ) ; rrQfFmQMLC ++ ) { if ( C [ rrQfFmQMLC ] == '1' ) { c . add ( '1' ) ; } if ( C [ rrQfFmQMLC ] == '0' ) { c . add ( '0' ) ; } if ( C [ rrQfFmQMLC ] == 'B' && c . size ( ) > 0 ) { c . remove ( c . size ( ) - 1 ) ; } } for ( int rrQfFmQMLC = 0 ; rrQfFmQMLC < c . size ( ) ; rrQfFmQMLC ++ ) { System . out . print ( c . get ( rrQfFmQMLC ) ) ; } } } import java . util . * ; public class UtvNsRWqyr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UtvNsRWqyr = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { UtvNsRWqyr -= sc . nextInt ( ) ; } System . out . println ( UtvNsRWqyr >= 0 ? UtvNsRWqyr : - 1 ) ; } } import java . util . Scanner ; public class BcRqPiBFqu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String [ ] strArray = scan . nextLine ( ) . split ( " " ) ; int BcRqPiBFqu = Integer . parseInt ( strArray [ 0 ] ) ; int A = Integer . parseInt ( strArray [ 1 ] ) ; int lastCount = 0 ; for ( int i = 1 ; BcRqPiBFqu > 0 ; i ++ ) { BcRqPiBFqu = BcRqPiBFqu - A ; lastCount = i ; } System . out . println ( lastCount ) ; } } import java . util . * ; class VrtzyaPGjG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VrtzyaPGjG = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; for ( int i = VrtzyaPGjG ; 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 kXeHDnHSiS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kXeHDnHSiS = sc . nextInt ( ) ; System . out . println ( Math . ceil ( kXeHDnHSiS / 2d ) / ( double ) kXeHDnHSiS ) ; } } import java . util . Scanner ; public class HYWpHJsAla { public static void main ( String [ ] args ) { int HYWpHJsAla , 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 ] ) { HYWpHJsAla = next [ 1 ] ; next [ 1 ] = next [ 0 ] ; next [ 0 ] = HYWpHJsAla ; } 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 LpcksAbDEV { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LpcksAbDEV = scan . nextInt ( ) ; int i ; for ( i = 1 ; i <= LpcksAbDEV ; i ++ ) { if ( i > LpcksAbDEV ) 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 BOwdUNVJxK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; int BOwdUNVJxK = sc . nextInt ( ) ; int [ ] a = new int [ BOwdUNVJxK ] ; for ( int i = 0 ; i < BOwdUNVJxK ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int t = a [ BOwdUNVJxK - 1 ] ; int max = 0 , cnt = 0 ; for ( int i = BOwdUNVJxK - 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 AlAgGtoDIW { private static final Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int AlAgGtoDIW = scanner . nextInt ( ) ; boolean canReach = true ; int prevT = 0 ; int prevX = 0 ; int prevY = 0 ; for ( int i = 0 ; i < AlAgGtoDIW ; 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 lhvFSiOWDx { 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 lhvFSiOWDx = scan . nextInt ( ) ; for ( int d = 0 ; d < lhvFSiOWDx ; d ++ ) { sum [ d ] = 0 ; } int b = scan . nextInt ( ) ; for ( int c = 0 ; c < lhvFSiOWDx ; 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 < lhvFSiOWDx ; c ++ ) { for ( int d = 0 ; d < b ; d ++ ) { sum [ c ] += h [ c ] [ d ] * m [ d ] ; } } for ( int c = 0 ; c < lhvFSiOWDx ; c ++ ) { System . out . println ( sum [ c ] ) ; } } } import java . util . * ; public class QHBKbdxuzx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QHBKbdxuzx = sc . nextInt ( ) ; int [ ] A = new int [ QHBKbdxuzx ] ; for ( int i = 0 ; i < QHBKbdxuzx ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } long [ ] L = new long [ QHBKbdxuzx ] ; for ( int i = 1 ; i < QHBKbdxuzx ; 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 < QHBKbdxuzx ; 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 KzRPODuqlm { 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 KzRPODuqlm { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int KzRPODuqlm = in . next ( ) . length ( ) ; String s = " " ; for ( int i = 0 ; i < KzRPODuqlm ; i ++ ) { s += 'x' ; } out . print ( s ) ; } } } import java . util . * ; public class enWHPdiBcT { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int enWHPdiBcT = 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 ( enWHPdiBcT ) ; return ; } for ( int i = 0 ; i < n ; i ++ ) { int countm = 0 ; int countp = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( enWHPdiBcT - i != p [ j ] ) { countm ++ ; } if ( enWHPdiBcT + i != p [ j ] ) { countp ++ ; } } if ( countm == n ) { System . out . println ( enWHPdiBcT - i ) ; return ; } else if ( countp == n ) { System . out . println ( enWHPdiBcT + i ) ; return ; } } System . out . println ( enWHPdiBcT - 1 ) ; } } import java . util . Scanner ; public class ZnMXwRvCjm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int ZnMXwRvCjm = 0 ; ZnMXwRvCjm += s . charAt ( 0 ) == '1' ? 1 : 0 ; ZnMXwRvCjm += s . charAt ( 1 ) == '1' ? 1 : 0 ; ZnMXwRvCjm += s . charAt ( 2 ) == '1' ? 1 : 0 ; System . out . println ( ZnMXwRvCjm ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class YMPpSCwNyH { 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 YMPpSCwNyH = Integer . parseInt ( depth_width [ 0 ] ) ; int width = Integer . parseInt ( depth_width [ 1 ] ) ; ; int perimeter = YMPpSCwNyH * 2 + width * 2 ; int area = YMPpSCwNyH * width ; System . out . println ( area + " " + perimeter ) ; } } import java . io . PrintStream ; import java . util . Scanner ; public class vMycjCMTYA { static final PrintStream out = System . out ; static Scanner sc = new Scanner ( System . in ) ; static final long vMycjCMTYA = 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 TXtkOgmVBp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int TXtkOgmVBp = 0 ; TXtkOgmVBp < s . length ( ) ; TXtkOgmVBp ++ ) { if ( TXtkOgmVBp % 2 == 0 ) { sb . append ( '0' ) ; } else { sb . append ( '1' ) ; } } String zero = sb . toString ( ) ; sb = new StringBuffer ( ) ; for ( int TXtkOgmVBp = 0 ; TXtkOgmVBp < s . length ( ) ; TXtkOgmVBp ++ ) { if ( TXtkOgmVBp % 2 == 1 ) { sb . append ( '0' ) ; } else { sb . append ( '1' ) ; } } String one = sb . toString ( ) ; int z = 0 ; int o = 0 ; for ( int TXtkOgmVBp = 0 ; TXtkOgmVBp < s . length ( ) ; TXtkOgmVBp ++ ) { if ( s . charAt ( TXtkOgmVBp ) == zero . charAt ( TXtkOgmVBp ) ) { z ++ ; } else { o ++ ; } } System . out . println ( Math . min ( z , o ) ) ; } } import java . io . * ; class AJgjwKICON { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int AJgjwKICON = Integer . parseInt ( br . readLine ( ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; long min = 1000000 ; long max = - 1000000 ; long sum = 0 ; for ( int i = 0 ; i < AJgjwKICON ; 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 CXPRlrSFyT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CXPRlrSFyT = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = new Main ( ) . gcd ( Math . max ( CXPRlrSFyT , b ) , Math . min ( CXPRlrSFyT , 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 QJIcyBFRiX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QJIcyBFRiX = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; int Q = sc . nextInt ( ) ; long lim = K - Q ; int [ ] winCon = new int [ QJIcyBFRiX + 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 XKJgBRGAFh { int XKJgBRGAFh , y ; public void suzuki ( ) { Scanner sc = new Scanner ( System . in ) ; XKJgBRGAFh = sc . nextInt ( ) ; y = sc . nextInt ( ) ; while ( XKJgBRGAFh != 0 || y != 0 ) { if ( XKJgBRGAFh > y ) { System . out . println ( y + " " + XKJgBRGAFh ) ; } else { System . out . println ( XKJgBRGAFh + " " + y ) ; } XKJgBRGAFh = sc . nextInt ( ) ; y = sc . nextInt ( ) ; } } public static void main ( String [ ] args ) { new Main ( ) . suzuki ( ) ; } } import java . util . Scanner ; public class YSQYEthqjZ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . nextLine ( ) ; int YSQYEthqjZ = Integer . parseInt ( str ) ; for ( int i = 1 ; i < 10 ; i ++ ) { if ( YSQYEthqjZ % i == 0 & YSQYEthqjZ / i < 10 ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . * ; public class MFlqUapkEG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MFlqUapkEG = 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 ztWzdWJhVg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ztWzdWJhVg = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < ztWzdWJhVg ; 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 RdOMCAeqcb { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int RdOMCAeqcb = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < RdOMCAeqcb ; 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 BhxEvTctvP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BhxEvTctvP = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long out = BhxEvTctvP ; long a1 = BhxEvTctvP ; long b1 = b ; while ( ! ( out % BhxEvTctvP == 0 && out % b == 0 ) ) { out = a1 > b1 ? a1 : b1 ; if ( a1 < out ) { a1 += BhxEvTctvP ; } if ( b1 < out ) { b1 += b ; } } System . out . println ( out ) ; } } import java . util . Scanner ; public class RSxUakgvqK { 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 RSxUakgvqK = 0 ; RSxUakgvqK < you . length ; RSxUakgvqK ++ ) { if ( s . equals ( you [ RSxUakgvqK ] ) ) { System . out . print ( 7 - RSxUakgvqK ) ; 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 sPOboehCpa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sPOboehCpa = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int ans = getKth ( getGcd ( sPOboehCpa , b ) , k ) ; System . out . println ( ans ) ; } static int getGcd ( int sPOboehCpa , int b ) { if ( sPOboehCpa == 0 ) { return b ; } return getGcd ( b % sPOboehCpa , sPOboehCpa ) ; } 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 AwIcVWiSGS { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int AwIcVWiSGS = 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 PBWmdqozzg { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int PBWmdqozzg = 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 = PBWmdqozzg - aArray [ n - 1 ] + aArray [ 0 ] ; pq . add ( dist ) ; } else { pq . add ( aArray [ i ] - aArray [ i - 1 ] ) ; } } int max = pq . poll ( ) ; System . out . println ( PBWmdqozzg - max ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class YHBXodYMBD { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int YHBXodYMBD = Integer . parseInt ( str [ 0 ] ) , y = Integer . parseInt ( str [ 1 ] ) , rest ; if ( YHBXodYMBD < y ) { int temp = YHBXodYMBD ; YHBXodYMBD = y ; y = temp ; } do { rest = YHBXodYMBD % y ; YHBXodYMBD = y ; y = rest ; } while ( y != 0 ) ; System . out . println ( YHBXodYMBD ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . text . DecimalFormat ; public class AhfOjyfgEY { 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 AhfOjyfgEY = Integer . parseInt ( arrStr [ 0 ] ) ; long b = Integer . parseInt ( arrStr [ 1 ] ) ; long d = AhfOjyfgEY / b ; long r = AhfOjyfgEY % b ; double f = ( double ) AhfOjyfgEY / 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 jKryPwCmZB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jKryPwCmZB = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= jKryPwCmZB ; i ++ ) { double tmp = 1.0 / jKryPwCmZB ; int now = i ; while ( now < K ) { now *= 2 ; tmp /= 2 ; } ans += tmp ; } System . out . println ( ans ) ; } } import java . io . * ; class WpNqvYiRpw { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = buf . readLine ( ) ; int WpNqvYiRpw = Integer . parseInt ( s ) ; int res = WpNqvYiRpw * WpNqvYiRpw * WpNqvYiRpw ; System . out . println ( res ) ; } } import java . util . * ; public class eXYfjAzIqL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eXYfjAzIqL = sc . nextInt ( ) ; int [ ] A = new int [ eXYfjAzIqL ] ; for ( int i = 0 ; i < eXYfjAzIqL ; i ++ ) { A [ sc . nextInt ( ) - 1 ] = i + 1 ; } for ( int j = 0 ; j < eXYfjAzIqL ; j ++ ) { System . out . print ( A [ j ] + " " ) ; } } } import java . util . * ; public class vJWVASWePq { 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 yhGqXalkEr { 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 yhGqXalkEr = 0 ; for ( int i = 0 ; i <= 2 ; i ++ ) { if ( Slist [ i ] . equals ( Tlist [ i ] ) ) { yhGqXalkEr ++ ; } } System . out . println ( yhGqXalkEr ) ; } } import java . util . * ; class GQPyNlEwLV { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int GQPyNlEwLV = in . nextInt ( ) ; int [ ] s = new int [ GQPyNlEwLV ] ; for ( int i = 0 ; i < GQPyNlEwLV ; 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 JntDabeQxQ { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int JntDabeQxQ = 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 AaAdqhLjVX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AaAdqhLjVX = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = Integer . valueOf ( String . valueOf ( AaAdqhLjVX ) + 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 lXQNnvloGG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int lXQNnvloGG = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int i = 0 ; int sum = 0 ; if ( k >= lXQNnvloGG ) { sum += lXQNnvloGG ; k = k - lXQNnvloGG ; } 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 nHUcFBmrjO { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int nHUcFBmrjO , x , x1 , x2 , x3 ; int counter ; while ( true ) { counter = 0 ; nHUcFBmrjO = scanner . nextInt ( ) ; x = scanner . nextInt ( ) ; if ( nHUcFBmrjO == 0 && x == 0 ) break ; for ( int i = 1 ; i <= nHUcFBmrjO ; i ++ ) { x1 = x ; x1 -= i ; if ( x1 > 1 ) { for ( int j = i + 1 ; j <= nHUcFBmrjO ; j ++ ) { x2 = x1 ; x2 -= j ; if ( x2 > 0 ) { for ( int k = j + 1 ; k <= nHUcFBmrjO ; k ++ ) { x3 = x2 ; x3 -= k ; if ( x3 == 0 ) counter ++ ; } } } } } System . out . println ( counter ) ; } } } import java . util . * ; class LlznqXfKmM { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] argv ) { int LlznqXfKmM = scan . nextInt ( ) ; int n1 = LlznqXfKmM % 10 ; int n2 = ( LlznqXfKmM % 100 - n1 ) / 10 ; int n3 = ( LlznqXfKmM - n1 - n1 ) / 100 ; if ( n3 == 9 ) { LlznqXfKmM = 999 ; System . out . println ( LlznqXfKmM ) ; return ; } if ( n1 > n3 || n2 > n3 ) { n3 += 1 ; } LlznqXfKmM = n3 * 100 + n3 * 10 + n3 ; System . out . println ( LlznqXfKmM ) ; } } import java . util . * ; public class dhhGBQeKyE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dhhGBQeKyE = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ dhhGBQeKyE + 1 ] ; for ( int i = 1 ; i <= dhhGBQeKyE ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int [ ] b = new int [ dhhGBQeKyE + 1 ] ; b [ 0 ] = 1 ; int i = 1 ; int ans = - 1 ; while ( i <= dhhGBQeKyE ) { 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 fhpbdsjDhh { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int fhpbdsjDhh = sc . nextInt ( ) ; int m = 1 ; Set < Integer > used = new HashSet < > ( ) ; for ( ; ! used . contains ( fhpbdsjDhh ) ; m ++ ) { used . add ( fhpbdsjDhh ) ; if ( fhpbdsjDhh % 2 == 0 ) { fhpbdsjDhh /= 2 ; } else { fhpbdsjDhh = fhpbdsjDhh * 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 WGXyNHiRLP { final static int WGXyNHiRLP = 2 ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] num = new int [ WGXyNHiRLP + 1 ] ; for ( int i = 0 ; i <= WGXyNHiRLP ; 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 zLEDUyAtZc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; char [ ] cs = sc . next ( ) . toCharArray ( ) ; for ( char zLEDUyAtZc : cs ) { switch ( zLEDUyAtZc ) { case '1' : sb . append ( zLEDUyAtZc ) ; break ; case '0' : sb . append ( zLEDUyAtZc ) ; break ; case 'B' : if ( sb . length ( ) > 0 ) { sb . deleteCharAt ( sb . length ( ) - 1 ) ; } break ; } } System . out . println ( sb ) ; } } import java . util . Scanner ; public class lUkCuqtBCX { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int lUkCuqtBCX = 0 , A2 = 0 , A3 = 0 , result = 0 ; lUkCuqtBCX = input . nextInt ( ) ; A2 = input . nextInt ( ) ; A3 = input . nextInt ( ) ; if ( 1 <= lUkCuqtBCX && lUkCuqtBCX <= 13 && 1 <= A2 && A2 <= 13 && 1 <= A3 && A3 <= 13 ) { if ( lUkCuqtBCX + A2 + A3 == 22 || lUkCuqtBCX + A2 + A3 > 22 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } } else { } } } import java . io . * ; import java . util . * ; class XCGCljsGUL { 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 XCGCljsGUL = Integer . parseInt ( buf [ 0 ] ) ; int m = Integer . parseInt ( buf [ 1 ] ) ; ArrayList < Integer > matrix = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < XCGCljsGUL ; 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 < XCGCljsGUL ; 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 < XCGCljsGUL ; i ++ ) { System . out . println ( answer . get ( i ) ) ; } } } import java . util . * ; import java . lang . * ; public class VJEWevgIhV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VJEWevgIhV , 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 ( VJEWevgIhV = 0 ; VJEWevgIhV < n ; VJEWevgIhV ++ ) { a [ VJEWevgIhV ] = sc . nextInt ( ) ; s = s + a [ VJEWevgIhV ] ; } 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 IpfZsKIVca { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; long IpfZsKIVca = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextInt ( ) ; long d = sc . nextInt ( ) ; long x = b - IpfZsKIVca + 1 - ( ( b / c ) - ( IpfZsKIVca / c ) + ( b / d ) - ( IpfZsKIVca / d ) - ( ( b / ( lcm ( c , d ) ) ) - ( IpfZsKIVca / ( lcm ( c , d ) ) ) ) ) ; if ( IpfZsKIVca % c == 0 ) x -- ; if ( IpfZsKIVca % d == 0 ) x -- ; if ( IpfZsKIVca % ( lcm ( c , d ) ) == 0 ) x ++ ; System . out . println ( x ) ; } static long gcd ( long IpfZsKIVca , long b ) { if ( IpfZsKIVca == 0 ) return b ; else return gcd ( b % IpfZsKIVca , IpfZsKIVca ) ; } static long lcm ( long IpfZsKIVca , long b ) { return ( IpfZsKIVca * b ) / gcd ( IpfZsKIVca , b ) ; } } import java . util . * ; public class UkmXGzQvtf { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } long UkmXGzQvtf ; long k ; long res ; public void run ( ) { Scanner sc = new Scanner ( System . in ) ; UkmXGzQvtf = sc . nextLong ( ) ; k = sc . nextLong ( ) ; sc . close ( ) ; solve ( ) ; } private void solve ( ) { a ( UkmXGzQvtf % 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 kZIkuqDXLh { 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 kZIkuqDXLh = 0 ; kZIkuqDXLh < 4 ; kZIkuqDXLh ++ ) { if ( map . containsKey ( s [ kZIkuqDXLh ] ) ) { map . put ( s [ kZIkuqDXLh ] , map . get ( s [ kZIkuqDXLh ] ) + 1 ) ; } else { map . put ( s [ kZIkuqDXLh ] , 1 ) ; } } String ans = " Yes " ; for ( int kZIkuqDXLh = 0 ; kZIkuqDXLh < 4 ; kZIkuqDXLh ++ ) { if ( map . get ( s [ kZIkuqDXLh ] ) == 2 ) { continue ; } else { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class lyEfnhPhsm { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int lyEfnhPhsm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( lyEfnhPhsm >= 0 && lyEfnhPhsm <= 100 ) { if ( b >= 0 && b <= 100 ) { if ( c >= 0 && c <= 100 ) { if ( lyEfnhPhsm < b && b < c ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } } } } import java . util . * ; import java . math . BigDecimal ; public class LqXluAWdau { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long LqXluAWdau = sc . nextLong ( ) ; BigDecimal x = BigDecimal . valueOf ( LqXluAWdau ) ; 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 EhLNsMKETT { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long EhLNsMKETT = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = EhLNsMKETT / ( a + b ) ; long d = EhLNsMKETT % ( 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 zbzklXthzA { static class zbzklXthzA { 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 zbzklXthzA = ob . nextInt ( ) , a = ob . nextInt ( ) , b = ob . nextInt ( ) ; int ans = ( a - ( a % zbzklXthzA ) ) + zbzklXthzA ; if ( ans >= a && ans <= b || a % zbzklXthzA == 0 ) { System . out . println ( " OK " ) ; return ; } System . out . println ( " NG " ) ; } } import java . util . Scanner ; public class qtnwlGXeiE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long qtnwlGXeiE = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( k == 0 ) { System . out . println ( qtnwlGXeiE + " " + b ) ; return ; } if ( qtnwlGXeiE >= k ) { System . out . println ( qtnwlGXeiE - k + " " + b ) ; return ; } k -= qtnwlGXeiE ; 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 AUKZSgHcaj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AUKZSgHcaj = sc . nextInt ( ) ; String [ ] array = new String [ AUKZSgHcaj ] ; for ( int i = 0 ; i < AUKZSgHcaj ; 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 < AUKZSgHcaj ; 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 == AUKZSgHcaj - 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 ezWumbyeOG { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ezWumbyeOG , count = 1 ; String s ; ezWumbyeOG = sc . nextInt ( ) ; s = sc . next ( ) ; for ( int i = 0 ; i < ezWumbyeOG - 1 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i + 1 ) ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class syOsJPYFhp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int syOsJPYFhp = 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 ( syOsJPYFhp - sum < 0 ? - 1 : syOsJPYFhp - sum ) ; sc . close ( ) ; } } import java . util . Scanner ; public class WLamVHNyut { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int WLamVHNyut = scan . nextInt ( ) ; int odd , even ; if ( WLamVHNyut % 2 == 1 ) { odd = WLamVHNyut / 2 + 1 ; even = WLamVHNyut / 2 ; } else { odd = WLamVHNyut / 2 ; even = WLamVHNyut / 2 ; } if ( WLamVHNyut == 1 ) { System . out . println ( 1 ) ; } else { double ans = ( double ) odd / ( double ) WLamVHNyut ; System . out . println ( ans ) ; } } } import java . util . Scanner ; public class ggFKsZUhyA { public static void main ( String [ ] args ) { long ggFKsZUhyA ; try ( Scanner sc = new Scanner ( System . in ) ) { ggFKsZUhyA = sc . nextLong ( ) ; } double c = ( double ) ggFKsZUhyA / 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 YxqvgmJDyk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String YxqvgmJDyk = sc . next ( ) ; String result = " Heisei " ; if ( YxqvgmJDyk . compareTo ( " 2019/04/30 " ) > 0 ) result = " TBD " ; System . out . println ( result ) ; } } import java . util . * ; public class pmPlwwnWmW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pmPlwwnWmW = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = pmPlwwnWmW + B ; int c = ( pmPlwwnWmW + 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 DRSQvcTvjP { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int DRSQvcTvjP = in . nextInt ( ) ; int [ ] a = new int [ 100 ] ; for ( int i = 0 ; i < DRSQvcTvjP ; i ++ ) { int val = in . nextInt ( ) ; a [ i ] = val ; } for ( int i = 1 ; i < DRSQvcTvjP ; i ++ ) { output ( a , DRSQvcTvjP ) ; 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 , DRSQvcTvjP ) ; } static void output ( int [ ] a , int DRSQvcTvjP ) { for ( int i = 0 ; i < DRSQvcTvjP - 1 ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } System . out . println ( a [ DRSQvcTvjP - 1 ] ) ; } } import java . util . * ; class MbHLxCLBMJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MbHLxCLBMJ = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] d = new int [ 3 ] ; d [ 0 ] = MbHLxCLBMJ ; 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 XMHwFTCAcV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XMHwFTCAcV = sc . nextInt ( ) ; int [ ] A ; A = new int [ XMHwFTCAcV ] ; for ( int i = 0 ; i < XMHwFTCAcV ; i ++ ) A [ i ] = sc . nextInt ( ) ; Arrays . sort ( A ) ; boolean ans = true ; for ( int i = 0 ; i < XMHwFTCAcV - 1 ; i ++ ) if ( A [ i ] == A [ i + 1 ] ) ans = false ; System . out . println ( ans ? " YES " : " NO " ) ; } } import java . util . * ; class WbBYtNyqqg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WbBYtNyqqg = sc . nextInt ( ) ; int [ ] nums = new int [ WbBYtNyqqg ] ; for ( int i = 0 ; i < WbBYtNyqqg ; i ++ ) nums [ i ] = sc . nextInt ( ) ; for ( int i = 1 ; i < WbBYtNyqqg ; 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 NJxWryZGTf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NJxWryZGTf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( NJxWryZGTf != 1 && b != 1 ) { System . out . println ( 1 ) ; } else if ( NJxWryZGTf != 2 && b != 2 ) { System . out . println ( 2 ) ; } else { System . out . println ( 3 ) ; } } } import java . util . Scanner ; public class XBbNTHCtEC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XBbNTHCtEC = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; sc . close ( ) ; if ( ( double ) XBbNTHCtEC / T <= S ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; public class cPKcJOfPfU { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int cPKcJOfPfU = s . nextInt ( ) ; int b = s . nextInt ( ) ; int c = s . nextInt ( ) ; int d = s . nextInt ( ) ; int start ; int end ; if ( cPKcJOfPfU < c ) { start = c ; } else { start = cPKcJOfPfU ; } 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 zyNYTnCTqS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zyNYTnCTqS = sc . nextInt ( ) ; String sura = sc . next ( ) ; ArrayList < Character > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < zyNYTnCTqS ; 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 vuSFqXdnxm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vuSFqXdnxm = sc . nextInt ( ) ; int [ ] A = new int [ vuSFqXdnxm ] ; int ans = 0 ; for ( int i = 0 ; i < vuSFqXdnxm ; 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 nYxajPROVr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long nYxajPROVr = sc . nextLong ( ) ; double m = sc . nextLong ( ) ; long result = ( long ) Math . round ( m * 100 ) ; result = result * nYxajPROVr / 100 ; System . out . println ( result ) ; } } import java . util . * ; public class wFhYLmAERl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; String [ ] S1 = S . split ( " / " , 0 ) ; int wFhYLmAERl , month , day ; wFhYLmAERl = 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 cJdxQGkUoy { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int cJdxQGkUoy = 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 ) == cJdxQGkUoy ) { x = true ; } } } if ( x ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class hhAkaqAAHG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hhAkaqAAHG = sc . nextInt ( ) ; int [ ] ary = new int [ hhAkaqAAHG ] ; for ( int i = 0 ; i < hhAkaqAAHG ; i ++ ) { ary [ i ] = sc . nextInt ( ) ; } boolean flag = true ; int numSwap = 0 ; while ( flag ) { flag = false ; for ( int i = hhAkaqAAHG - 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 < hhAkaqAAHG ; i ++ ) { System . out . print ( ary [ i ] ) ; if ( i < hhAkaqAAHG - 1 ) { System . out . print ( " " ) ; } } System . out . println ( " " ) ; System . out . println ( numSwap ) ; } } import java . util . * ; public class SgGqNkQAPV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SgGqNkQAPV = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int start = Math . max ( SgGqNkQAPV , C ) ; int end = Math . min ( B , D ) ; int reult = end - start ; System . out . println ( reult < 0 ? 0 : reult ) ; } } import java . util . * ; public class mHVqrSmvMg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mHVqrSmvMg = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] alpha = new int [ mHVqrSmvMg ] ; int i , j ; for ( i = 0 ; i < mHVqrSmvMg ; 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 lARqbbjkPk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lARqbbjkPk = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; list . add ( lARqbbjkPk ) ; while ( true ) { if ( lARqbbjkPk % 2 == 0 ) { lARqbbjkPk /= 2 ; } else { lARqbbjkPk = lARqbbjkPk * 3 + 1 ; } if ( list . contains ( lARqbbjkPk ) ) { list . add ( lARqbbjkPk ) ; System . out . println ( list . size ( ) ) ; break ; } else { list . add ( lARqbbjkPk ) ; } } } } import java . util . Scanner ; public class NfgzDNLYBH { 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 NfgzDNLYBH = Integer . parseInt ( String . valueOf ( sA ) ) ; int b = Integer . parseInt ( String . valueOf ( sB ) ) ; if ( NfgzDNLYBH == 0 && b == 0 ) { answer = " NA " ; } else if ( NfgzDNLYBH == 0 ) { if ( b <= 12 ) { answer = " YYMM " ; } else { answer = " NA " ; } } else if ( b == 0 ) { if ( NfgzDNLYBH <= 12 ) { answer = " MMYY " ; } else { answer = " NA " ; } } else if ( NfgzDNLYBH <= 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 DetdaUhZqr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String moji = sc . nextLine ( ) ; char [ ] chmoji = new char [ moji . length ( ) ] ; for ( int DetdaUhZqr = 0 ; DetdaUhZqr < moji . length ( ) ; DetdaUhZqr ++ ) { chmoji [ DetdaUhZqr ] = moji . charAt ( DetdaUhZqr ) ; boolean kekka = Character . isUpperCase ( chmoji [ DetdaUhZqr ] ) ; if ( kekka == true ) { chmoji [ DetdaUhZqr ] = Character . toLowerCase ( chmoji [ DetdaUhZqr ] ) ; } else { chmoji [ DetdaUhZqr ] = Character . toUpperCase ( chmoji [ DetdaUhZqr ] ) ; } System . out . print ( chmoji [ DetdaUhZqr ] ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class kzVytofjDx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kzVytofjDx = sc . nextInt ( ) ; for ( int i = 0 ; i < kzVytofjDx ; 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 diOkrzdJJP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int diOkrzdJJP = 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 ; } diOkrzdJJP -= D ; if ( diOkrzdJJP <= 0 ) { System . out . println ( " No " ) ; break ; } } } } import java . util . Scanner ; public class IqNwSwrwtd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IqNwSwrwtd = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i <= IqNwSwrwtd ; 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 kVUYeYnjMv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kVUYeYnjMv = sc . nextInt ( ) ; int [ ] list = new int [ kVUYeYnjMv - 1 ] ; for ( int i = 0 ; i < kVUYeYnjMv - 1 ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } int ans = 0 ; int lastV = 0 ; for ( int i = 0 ; i < kVUYeYnjMv - 1 ; i ++ ) { if ( i == 0 ) { ans += list [ i ] ; } else if ( list [ i ] > lastV ) { ans += lastV ; } else { ans += list [ i ] ; } if ( i == kVUYeYnjMv - 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 MqJenSsxBQ { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strArr = br . readLine ( ) . split ( " " ) ; long MqJenSsxBQ = Long . valueOf ( strArr [ 0 ] ) ; long b = Long . valueOf ( strArr [ 1 ] ) ; System . out . println ( gcd ( MqJenSsxBQ , b ) ) ; } private static long gcd ( long MqJenSsxBQ , long b ) { long r = MqJenSsxBQ % b ; if ( r == 0 ) return b ; else return gcd ( b , MqJenSsxBQ % b ) ; } } import java . util . Scanner ; public class PIXWLgddPg { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String line = sc . nextLine ( ) ; String answer = " " ; for ( int PIXWLgddPg = 0 ; PIXWLgddPg < line . length ( ) ; PIXWLgddPg ++ ) { char ch = line . charAt ( PIXWLgddPg ) ; if ( Character . isLowerCase ( ch ) ) answer = answer + Character . toUpperCase ( ch ) ; else answer = answer + Character . toLowerCase ( ch ) ; } System . out . println ( answer ) ; } } } import java . util . * ; public class msLvsEPxbn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int msLvsEPxbn = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; if ( S . length ( ) <= msLvsEPxbn ) System . out . println ( S ) ; else System . out . println ( S . substring ( 0 , msLvsEPxbn ) + " ... " ) ; } } import java . util . Scanner ; class VcSTwDGlpJ { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int VcSTwDGlpJ = in . nextInt ( ) ; int Taro = 0 ; int Hanako = 0 ; while ( VcSTwDGlpJ != 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 ; } VcSTwDGlpJ -- ; } System . out . println ( Taro + " " + Hanako ) ; } } import java . util . Scanner ; public class nRdUYMQWQN { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; for ( int nRdUYMQWQN = 0 ; nRdUYMQWQN < 3000 ; nRdUYMQWQN ++ ) { 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 YpQhhLOQiZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YpQhhLOQiZ = sc . nextInt ( ) ; int min = 200000 ; int cnt = 0 ; for ( int i = 0 ; i < YpQhhLOQiZ ; 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 JrYyQFJWXS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long JrYyQFJWXS = sc . nextLong ( ) ; Set < Long > numSet = new HashSet < > ( ) ; boolean hasSame = false ; for ( int i = 0 ; i < JrYyQFJWXS ; 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 VzDCpqBTcH { public static void main ( String [ ] args ) { solve ( ) ; } private static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; char [ ] sCode = sc . next ( ) . toCharArray ( ) ; boolean VzDCpqBTcH = false ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( sCode [ i ] == sCode [ i + 1 ] ) { VzDCpqBTcH = true ; break ; } } if ( VzDCpqBTcH ) { System . out . print ( " Bad " ) ; } else System . out . print ( " Good " ) ; } } import java . util . * ; public class LxmKeKOdDa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String LxmKeKOdDa = sc . next ( ) ; if ( LxmKeKOdDa . contentEquals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } if ( LxmKeKOdDa . equals ( " ARC " ) ) { System . out . println ( " ABC " ) ; } } } import java . math . * ; import java . util . * ; public class DRLVuNEFwe { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int [ ] hills = new int [ 10 ] ; for ( int DRLVuNEFwe = 0 ; DRLVuNEFwe < 10 ; DRLVuNEFwe ++ ) { hills [ DRLVuNEFwe ] = in . nextInt ( ) * - 1 ; } Arrays . sort ( hills ) ; for ( int DRLVuNEFwe = 0 ; DRLVuNEFwe < 3 ; DRLVuNEFwe ++ ) { System . out . println ( hills [ DRLVuNEFwe ] * - 1 ) ; } } } import java . util . Scanner ; public class uQwDnkGJlk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int uQwDnkGJlk = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= uQwDnkGJlk - 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 HqDtdiZMsA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HqDtdiZMsA = sc . nextInt ( ) ; ArrayList < Integer > A = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < HqDtdiZMsA ; i ++ ) A . add ( sc . nextInt ( ) ) ; ArrayList < Integer > output = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < HqDtdiZMsA ; i ++ ) output . add ( 0 ) ; for ( int i = 0 ; i < HqDtdiZMsA ; i ++ ) { int AIndex = A . get ( i ) - 1 ; output . set ( AIndex , i + 1 ) ; } for ( int i = 0 ; i < HqDtdiZMsA ; i ++ ) { System . out . print ( output . get ( i ) + " " ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class BSqcvyqcHC { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int BSqcvyqcHC = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 1 ] ) ; int c = Integer . parseInt ( str [ 2 ] ) ; System . out . println ( ( ( BSqcvyqcHC == b ) && ( b != c ) ) || ( ( b == c ) && ( c != BSqcvyqcHC ) ) || ( ( c == BSqcvyqcHC ) && ( BSqcvyqcHC != b ) ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class lmWHlZJAON { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lmWHlZJAON = Integer . parseInt ( sc . next ( ) ) ; int [ ] p = new int [ lmWHlZJAON ] ; for ( int i = 0 ; i < lmWHlZJAON ; i ++ ) { p [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int cnt = 0 ; for ( int i = 1 ; i < lmWHlZJAON - 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 MhzhiMwLHT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MhzhiMwLHT = 0 ; int sum = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { int x = sc . nextInt ( ) ; MhzhiMwLHT = Math . MhzhiMwLHT ( MhzhiMwLHT , x ) ; sum += x ; } System . out . println ( sum - MhzhiMwLHT ) ; } } import java . util . * ; public class dztJZhDYbt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int dztJZhDYbt = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int saisi = sc . nextInt ( ) ; int c = dztJZhDYbt + b ; if ( dztJZhDYbt == - 1 && b == - 1 && saisi == - 1 ) { break ; } if ( dztJZhDYbt == - 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 umksVgZlFo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int umksVgZlFo = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; solve ( umksVgZlFo , 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 vTtPQySltN { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int vTtPQySltN = 0 ; int o = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '0' ) { vTtPQySltN ++ ; } else { o ++ ; } } int r = Math . min ( vTtPQySltN , o ) * 2 ; System . out . print ( r ) ; } } import java . util . Scanner ; public class jJRXQcQfbS { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int jJRXQcQfbS = scanner . nextInt ( ) ; String S = scanner . next ( ) ; String [ ] S1 = S . split ( " " ) ; if ( jJRXQcQfbS >= S1 . length ) { for ( int j = 0 ; j < S1 . length ; j ++ ) { System . out . print ( S1 [ j ] ) ; } } else { for ( int j = 0 ; j < jJRXQcQfbS ; j ++ ) { System . out . print ( S1 [ j ] ) ; } System . out . println ( " ... " ) ; } } } import java . util . Scanner ; public class CgCEoWksej { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int CgCEoWksej = s . length ( ) ; int [ ] A = new int [ CgCEoWksej ] ; int [ ] B = new int [ CgCEoWksej ] ; int i ; for ( i = 0 ; i < CgCEoWksej ; i ++ ) { A [ i ] = i % 2 ; B [ i ] = ( i + 1 ) % 2 ; } int tempA = 0 ; int tempB = 0 ; int intS ; for ( i = 0 ; i < CgCEoWksej ; 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 ehfaTbTqnw { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ehfaTbTqnw = in . nextInt ( ) ; int ac = 0 ; int wa = 0 ; int tle = 0 ; int re = 0 ; for ( int i = 0 ; i <= ehfaTbTqnw ; ++ 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 CgOylZErif { public static void main ( String [ ] argv ) { Scanner scanner = new Scanner ( System . in ) ; String line = scanner . nextLine ( ) ; String [ ] mn = line . split ( " " ) ; int CgOylZErif = Integer . parseInt ( mn [ 0 ] ) ; int n = Integer . parseInt ( mn [ 1 ] ) ; int ans = CgOylZErif * ( CgOylZErif - 1 ) / 2 + n * ( n - 1 ) / 2 ; System . out . println ( ans ) ; } } import java . io . IOException ; import java . util . Scanner ; public class KGoPUijDDN { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int KGoPUijDDN = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( KGoPUijDDN == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < KGoPUijDDN ; 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 yBrkZncWac { 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 yBrkZncWac = 0 ; String ans = " " ; while ( true ) { switch ( C [ yBrkZncWac ] [ t [ yBrkZncWac ] ] ) { case 'a' : t [ yBrkZncWac ] ++ ; yBrkZncWac = 0 ; break ; case 'b' : t [ yBrkZncWac ] ++ ; yBrkZncWac = 1 ; break ; case 'c' : t [ yBrkZncWac ] ++ ; yBrkZncWac = 2 ; break ; } if ( t [ 0 ] == Sa . length ( ) && yBrkZncWac == 0 ) { ans = " A " ; break ; } if ( t [ 1 ] == Sb . length ( ) && yBrkZncWac == 1 ) { ans = " B " ; break ; } if ( t [ 2 ] == Sc . length ( ) && yBrkZncWac == 2 ) { ans = " C " ; break ; } } System . out . println ( ans ) ; scanner . close ( ) ; } } import java . util . * ; public class npYXkMpyRE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int npYXkMpyRE = 0 ; int steps2 = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { if ( s . charAt ( i ) != '1' ) npYXkMpyRE ++ ; else steps2 ++ ; } else { if ( s . charAt ( i ) != '1' ) steps2 ++ ; else npYXkMpyRE ++ ; } } System . out . println ( Math . min ( npYXkMpyRE , steps2 ) ) ; } } import java . util . Scanner ; public class AiZiBvjLWK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long AiZiBvjLWK = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; sc . close ( ) ; if ( AiZiBvjLWK < c ) { c -= AiZiBvjLWK ; AiZiBvjLWK = 0 ; if ( b < c ) { b = 0 ; } else { b -= c ; } } else { AiZiBvjLWK -= c ; } System . out . println ( AiZiBvjLWK + " " + b ) ; } } import java . util . * ; public class QktQJYciLp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QktQJYciLp = sc . nextInt ( ) ; int [ ] A = new int [ QktQJYciLp ] ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < QktQJYciLp ; i ++ ) { A [ i ] = sc . nextInt ( ) ; list . add ( A [ i ] ) ; } Collections . sort ( list ) ; for ( int i = 0 ; i < QktQJYciLp ; i ++ ) { if ( A [ i ] == list . get ( QktQJYciLp - 1 ) ) { System . out . println ( list . get ( QktQJYciLp - 2 ) ) ; } else { System . out . println ( list . get ( QktQJYciLp - 1 ) ) ; } } } } import java . util . Scanner ; public class gnHJxmQwIS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gnHJxmQwIS = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i < gnHJxmQwIS ; 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 gyVNcAjYNW { private static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static void main ( String [ ] args ) throws IOException { getLine ( ) ; List < String > strings = getStrOnLine ( ) ; int gyVNcAjYNW = bubbleSort ( strings ) ; String out = String . join ( " " , strings ) ; System . out . println ( out ) ; System . out . println ( gyVNcAjYNW ) ; } private static int bubbleSort ( List < String > list ) { boolean flag = true ; int gyVNcAjYNW = 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 ) ; gyVNcAjYNW ++ ; flag = true ; } } } return gyVNcAjYNW ; } 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 ociYxwiQfn { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int ociYxwiQfn = sc . nextInt ( ) ; String S = sc . next ( ) ; char [ ] C = S . toCharArray ( ) ; char x = C [ 0 ] ; for ( int i = 1 ; i < ociYxwiQfn ; i ++ ) { if ( C [ i ] == x ) { C [ i ] = 0 ; } else { x = C [ i ] ; } } int ans = 0 ; for ( int i = 0 ; i < ociYxwiQfn ; i ++ ) { if ( C [ i ] != 0 ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class gzyeytKsOt { public static void main ( String [ ] gg ) { Scanner sc = new Scanner ( System . in ) ; int gzyeytKsOt = sc . nextInt ( ) ; String s = sc . next ( ) ; int counter = 0 ; int i = 0 ; while ( i < gzyeytKsOt - 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 sAlBKzqpHc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sAlBKzqpHc = sc . nextInt ( ) ; long [ ] nums = new long [ sAlBKzqpHc ] ; for ( int i = 0 ; i < sAlBKzqpHc ; 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 < sAlBKzqpHc ; 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 AoJIPpigED { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int AoJIPpigED = scan . nextInt ( ) ; boolean [ ] [ ] cards = new boolean [ 4 ] [ 13 ] ; for ( int i = 0 ; i < AoJIPpigED ; 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 lWNHsUrRma { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lWNHsUrRma = Integer . parseInt ( sc . nextLine ( ) ) ; boolean okFlag = true ; int prePosX = 0 ; int prePosY = 0 ; int preTime = 0 ; for ( int i = 1 ; i <= lWNHsUrRma ; 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 LRchPTNXPs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LRchPTNXPs = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int cnt = 0 ; int plug = 1 ; for ( ; ; ) { if ( plug >= b ) break ; plug = plug + LRchPTNXPs - 1 ; cnt ++ ; } out . println ( cnt ) ; } } import java . util . * ; public class ZBKWgPVaFW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZBKWgPVaFW = sc . nextInt ( ) ; int tA = sc . nextInt ( ) ; int aH = sc . nextInt ( ) ; int aA = sc . nextInt ( ) ; int tCount = 0 ; while ( ZBKWgPVaFW > 0 ) { ZBKWgPVaFW -= 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 JZEjyqcwum { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = sc . next ( ) . split ( " " ) ; for ( int JZEjyqcwum = 0 ; JZEjyqcwum < s . length ; JZEjyqcwum ++ ) { if ( s [ JZEjyqcwum ] . equals ( " 1 " ) ) s [ JZEjyqcwum ] = " 9 " ; else if ( s [ JZEjyqcwum ] . equals ( " 9 " ) ) s [ JZEjyqcwum ] = " 1 " ; System . out . print ( s [ JZEjyqcwum ] ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; public class ILqEeYyTMG { 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 ILqEeYyTMG = Integer . valueOf ( arr01 [ 0 ] ) ; String [ ] arr_result = new String [ ILqEeYyTMG ] ; Arrays . fill ( arr_result , " 0 " ) ; for ( int i = ILqEeYyTMG - 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 DpPecKHCuL { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int DpPecKHCuL = Integer . parseInt ( br . readLine ( ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < DpPecKHCuL ; i ++ ) { if ( i == DpPecKHCuL - 1 ) { System . out . println ( str [ DpPecKHCuL - i - 1 ] ) ; } else { System . out . print ( str [ DpPecKHCuL - i - 1 ] + " " ) ; } } } } import java . util . Scanner ; public class ADvqqnVWzO { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int ADvqqnVWzO = s . nextInt ( ) ; int ones = ADvqqnVWzO % 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 PcDrWdkTzN { Scanner sc = new Scanner ( System . in ) ; void run ( ) { int PcDrWdkTzN = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] ret = new int [ PcDrWdkTzN + 1 ] ; for ( int i = 0 ; i < PcDrWdkTzN + 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 < PcDrWdkTzN + 1 ; i ++ ) { System . out . println ( ret [ i ] ) ; } } public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . run ( ) ; } } import java . util . * ; public class GBomnRTgqK { 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 GBomnRTgqK = 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 ) ) { GBomnRTgqK ++ ; } } return GBomnRTgqK ; } } import java . util . Arrays ; import java . util . Scanner ; public class GRckmkBlcF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GRckmkBlcF = sc . nextInt ( ) ; int [ ] d = new int [ GRckmkBlcF ] ; int mid = 0 ; int max = 0 ; int min = 100000 ; for ( int i = 0 ; i < GRckmkBlcF ; 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 [ GRckmkBlcF / 2 - 1 ] ; int count = 0 ; System . out . println ( e [ GRckmkBlcF / 2 ] - e [ GRckmkBlcF / 2 - 1 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class fddipJMbNr { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String str = br . readLine ( ) ; int fddipJMbNr = 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 < fddipJMbNr ; 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 NrgyCtiuTQ { public static int gcd ( int a , int b , int c ) { int NrgyCtiuTQ = Math . min ( a , Math . min ( b , c ) ) ; for ( int i = NrgyCtiuTQ ; 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 TyJNiEYyzx { Scanner sc = new Scanner ( System . in ) ; void doIt ( ) { sB ( ) ; } void sB ( ) { int TyJNiEYyzx = sc . nextInt ( ) ; int L ; int max = 0 ; int sum = 0 ; for ( int i = 0 ; i < TyJNiEYyzx ; 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 ETtOOytaHk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ETtOOytaHk = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; for ( int i = 1 ; i < 10000 ; i ++ ) { if ( ( int ) Math . floor ( i * 0.08 ) == ETtOOytaHk && ( 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 vKqqYAJEkA { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = reader . readLine ( ) ; int vKqqYAJEkA = Integer . parseInt ( str ) ; long sum = 0 ; for ( int i = 1 ; i <= vKqqYAJEkA ; i ++ ) { if ( i % 3 == 0 || i % 5 == 0 ) continue ; sum += i ; } System . out . print ( sum ) ; } } import java . io . * ; public class uStdmdueSj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String in = br . readLine ( ) ; double uStdmdueSj = Math . pow ( Integer . parseInt ( in ) , 3 ) ; System . out . println ( ( int ) uStdmdueSj ) ; br . close ( ) ; } } import java . util . Scanner ; public class mFViEsrlMz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mFViEsrlMz , wid , cnt_wid ; while ( true ) { mFViEsrlMz = scan . nextInt ( ) ; wid = scan . nextInt ( ) ; if ( mFViEsrlMz == 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 < mFViEsrlMz - 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 FltQJdLzFo { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int FltQJdLzFo = scanner . nextInt ( ) ; int tarop = 0 ; int hanakop = 0 ; String tarow ; String hanakow ; for ( int i = 0 ; i < FltQJdLzFo ; 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 OcIRHYBYSU { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String [ ] SSplit = S . split ( " " ) ; int OcIRHYBYSU = 0 ; for ( int i = 0 ; i < SSplit . length / 2 ; i ++ ) { if ( ! SSplit [ i ] . equals ( SSplit [ SSplit . length - i - 1 ] ) ) { OcIRHYBYSU ++ ; } } System . out . print ( OcIRHYBYSU ) ; } } import java . text . * ; import java . util . * ; public class cMZGlBtyeV { 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 cMZGlBtyeV = date1 . compareTo ( date2 ) ; if ( cMZGlBtyeV > 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 TeFJfPuBde { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String str = br . readLine ( ) ; String [ ] strArr = str . split ( " " ) ; int TeFJfPuBde = Integer . parseInt ( strArr [ 0 ] ) ; int m = Integer . parseInt ( strArr [ 1 ] ) ; String [ ] [ ] a = new String [ TeFJfPuBde ] [ m ] ; String [ ] b = new String [ m ] ; for ( int i = 0 ; i < TeFJfPuBde ; 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 < TeFJfPuBde ; 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 CiYKWFAfMS { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int CiYKWFAfMS = sc . nextInt ( ) ; int [ ] li = new int [ CiYKWFAfMS ] ; for ( int i = 1 ; i <= CiYKWFAfMS ; i ++ ) { li [ sc . nextInt ( ) - 1 ] = i ; } int i = 0 ; for ( int k : li ) { if ( i != CiYKWFAfMS - 1 ) { System . out . print ( li [ i ] + " " ) ; } else { System . out . println ( li [ i ] ) ; } i ++ ; } } } import java . util . Scanner ; public class RIVSHWbAxV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String RIVSHWbAxV = sc . next ( ) ; String S = " Sunny " ; String C = " Cloudy " ; String R = " Rainy " ; if ( RIVSHWbAxV . equals ( S ) ) { System . out . println ( C ) ; } else if ( RIVSHWbAxV . equals ( C ) ) { System . out . println ( R ) ; } else { System . out . println ( S ) ; } } } import java . util . * ; public class wgfaDYcqKc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int wgfaDYcqKc = 0 ; wgfaDYcqKc < 3 ; wgfaDYcqKc ++ ) { a [ wgfaDYcqKc ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int wgfaDYcqKc = 0 ; wgfaDYcqKc < 2 ; wgfaDYcqKc ++ ) { System . out . print ( a [ wgfaDYcqKc ] + " " ) ; } System . out . println ( a [ 2 ] ) ; } } import java . util . Scanner ; public class AXsalDyltH { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int AXsalDyltH = scan . nextInt ( ) ; String op = scan . next ( ) ; int b = scan . nextInt ( ) ; if ( op . equals ( " ? " ) ) { break ; } switch ( op ) { case " + " : System . out . println ( AXsalDyltH + b ) ; break ; case " - " : System . out . println ( AXsalDyltH - b ) ; break ; case " * " : System . out . println ( AXsalDyltH * b ) ; break ; case " / " : System . out . println ( AXsalDyltH / b ) ; break ; } } scan . close ( ) ; } } import java . io . PrintWriter ; import java . util . Scanner ; class QGfXBhNnwF { 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 QGfXBhNnwF = Integer . parseInt ( sc . next ( ) ) ; final int f = Integer . parseInt ( sc . next ( ) ) ; final int r = Integer . parseInt ( sc . next ( ) ) ; if ( QGfXBhNnwF == - 1 && f == - 1 && r == - 1 ) break ; if ( QGfXBhNnwF == - 1 || f == - 1 ) out . println ( 'F' ) ; else if ( QGfXBhNnwF + f >= 80 ) out . println ( 'A' ) ; else if ( QGfXBhNnwF + f >= 65 ) out . println ( 'B' ) ; else if ( QGfXBhNnwF + f >= 50 ) out . println ( 'C' ) ; else if ( QGfXBhNnwF + 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 zXyZvSIhtX { public static void main ( String [ ] args ) { int zXyZvSIhtX ; int [ ] A ; try ( Scanner sc = new Scanner ( System . in ) ) { zXyZvSIhtX = sc . nextInt ( ) ; A = new int [ zXyZvSIhtX ] ; for ( int i = 0 ; i < zXyZvSIhtX ; 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 puepoHbwqg { 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 puepoHbwqg = Integer . parseInt ( temp ) ; if ( puepoHbwqg >= 1 && puepoHbwqg <= 31 ) { a = a . replace ( " 2017 " , " 2018 " ) ; System . out . println ( a ) ; } } } } } import java . util . Scanner ; public class nQHPPBCOOq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; try { int nQHPPBCOOq = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( " a " + ( nQHPPBCOOq == b ? " == " : ( nQHPPBCOOq < b ? " < " : " > " ) ) + " b " ) ; } finally { sc . close ( ) ; } } } import java . util . Scanner ; public class fYRBsyNqhi { public static void select_Sort ( int n , int [ ] A ) { int fYRBsyNqhi = 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 ) { fYRBsyNqhi = A [ j ] ; mini = j ; } if ( fYRBsyNqhi > A [ j ] ) { fYRBsyNqhi = 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 ThcoKterqK { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = input . readLine ( ) ; int ThcoKterqK = 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 PjIqFvHsHn { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int PjIqFvHsHn = s . nextInt ( ) ; long sum = 0 ; for ( int i = 0 ; i < PjIqFvHsHn ; i ++ ) { if ( ( i + 1 ) % 3 != 0 ) { if ( ( i + 1 ) % 5 != 0 ) { sum = sum + ( i + 1 ) ; } } } System . out . println ( sum ) ; } } import java . util . * ; class GlbnhxZCJV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; boolean [ ] a = new boolean [ 3 ] ; for ( int GlbnhxZCJV = 0 ; GlbnhxZCJV < 2 ; GlbnhxZCJV ++ ) { a [ sc . nextInt ( ) - 1 ] = true ; } for ( int GlbnhxZCJV = 0 ; GlbnhxZCJV < 3 ; GlbnhxZCJV ++ ) { if ( ! a [ GlbnhxZCJV ] ) System . out . println ( GlbnhxZCJV + 1 ) ; } } } import java . util . * ; public class EGHUBjAnfg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EGHUBjAnfg = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int t = scan . nextInt ( ) ; System . out . println ( b * ( t / EGHUBjAnfg ) ) ; scan . close ( ) ; } } import java . util . Scanner ; public class VKaebamrEW { public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int VKaebamrEW , b , seki , syu ; VKaebamrEW = sc . nextInt ( ) ; b = sc . nextInt ( ) ; seki = VKaebamrEW * b ; syu = ( VKaebamrEW * 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 yzlcBDZRDc { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String yzlcBDZRDc = sc . next ( ) ; String [ ] S2 = yzlcBDZRDc . 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 OAvVxYzJue { 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 OAvVxYzJue = 0 ; OAvVxYzJue < s . length ; OAvVxYzJue ++ ) { sb . append ( s [ s . length - 1 - OAvVxYzJue ] ) ; } System . out . println ( sb ) ; } catch ( Exception ex ) { System . exit ( 0 ) ; } } } import java . util . Scanner ; public class HDuIHjHLHY { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int HDuIHjHLHY = scan . nextInt ( ) ; switch ( HDuIHjHLHY % 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 AjTkfPQeaU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AjTkfPQeaU = sc . nextInt ( ) ; for ( int i = 1 ; i <= AjTkfPQeaU ; 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 aHkgrwHlDi { 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 aHkgrwHlDi { } class aHkgrwHlDi { } void solveA ( Scanner sc ) { int aHkgrwHlDi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( Math . max ( c - ( aHkgrwHlDi - b ) , 0 ) ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class jRUEVgzACN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jRUEVgzACN = sc . nextInt ( ) , count = 0 ; for ( int i = 1 ; i <= jRUEVgzACN ; i += 2 ) { if ( divisorEnum ( i ) . size ( ) == 8 ) count ++ ; } System . out . println ( count ) ; } public static List < Long > divisorEnum ( long jRUEVgzACN ) { List < Long > l = new ArrayList < > ( ) ; for ( long i = 1 ; i <= Math . sqrt ( jRUEVgzACN ) ; i ++ ) { if ( jRUEVgzACN % i == 0 ) { l . add ( i ) ; if ( i != Math . sqrt ( jRUEVgzACN ) ) l . add ( jRUEVgzACN / i ) ; } } l . sort ( null ) ; return l ; } } import java . util . Scanner ; public class gAWUqCITlO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gAWUqCITlO = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] d = new int [ gAWUqCITlO + 1 ] ; d [ 0 ] = 0 ; int j ; int bound = 1 ; for ( j = 1 ; j <= gAWUqCITlO ; 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 UxNTaljPxZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UxNTaljPxZ = Integer . parseInt ( sc . next ( ) ) ; int [ ] X = new int [ UxNTaljPxZ ] ; int minSum = 2000000 ; int sum = 0 ; for ( int i = 0 ; i < UxNTaljPxZ ; i ++ ) { X [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( X ) ; for ( int i = X [ 0 ] ; i <= X [ UxNTaljPxZ - 1 ] ; i ++ ) { for ( int j = 0 ; j < UxNTaljPxZ ; 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 nJDUCjUNVa { public static void main ( String [ ] args ) { new Solver ( ) . run ( ) ; } } class nJDUCjUNVa { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int nJDUCjUNVa = sc . nextInt ( ) ; int [ ] A = new int [ nJDUCjUNVa ] ; int top1 = 0 ; int idx1 = 0 ; for ( int i = 0 ; i < nJDUCjUNVa ; i ++ ) { A [ i ] = sc . nextInt ( ) ; if ( top1 < A [ i ] ) { top1 = A [ i ] ; idx1 = i ; } } int top2 = 0 ; for ( int i = 0 ; i < nJDUCjUNVa ; i ++ ) { if ( i != idx1 && top2 < A [ i ] ) { top2 = A [ i ] ; } } long max = Integer . MIN_VALUE ; for ( int i = 0 ; i < nJDUCjUNVa ; i ++ ) { if ( A [ i ] == top1 ) { System . out . println ( top2 ) ; } else { System . out . println ( top1 ) ; } } return ; } } import java . util . * ; public class wYXizNSSqX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wYXizNSSqX = sc . nextInt ( ) ; int [ ] H = new int [ wYXizNSSqX ] ; for ( int i = 0 ; i < wYXizNSSqX ; i ++ ) H [ i ] = sc . nextInt ( ) ; int maxMove = 0 ; int currentMove = 0 ; for ( int i = 0 ; i < wYXizNSSqX - 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 OfFUlrSoTR { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; for ( ; ; ) { int OfFUlrSoTR = stdIn . nextInt ( ) ; int w = stdIn . nextInt ( ) ; if ( OfFUlrSoTR == 0 && w == 0 ) break ; for ( int i = 0 ; i < OfFUlrSoTR ; 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 lCIhXLyxNl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lCIhXLyxNl = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] answerArr = new int [ M ] ; int answer = 0 ; Arrays . fill ( answerArr , 0 ) ; for ( int i = 0 ; i < lCIhXLyxNl ; 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 ] == lCIhXLyxNl ) { answer ++ ; } } System . out . println ( answer ) ; } } import java . util . * ; public class cvnoLOhBTq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cvnoLOhBTq = 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 ) ) { cvnoLOhBTq = cvnoLOhBTq + 1 ; } wk = 0 ; } } System . out . println ( cvnoLOhBTq ) ; } } import java . util . Scanner ; public class BEzXhRFFVd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BEzXhRFFVd = sc . nextInt ( ) ; int [ ] arr = new int [ BEzXhRFFVd ] ; boolean flg = true ; int count = 0 ; for ( int i = 0 ; i < BEzXhRFFVd ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } while ( flg ) { boolean existOdd = false ; for ( int i = 0 ; i < BEzXhRFFVd ; i ++ ) { if ( arr [ i ] % 2 != 0 ) { flg = false ; } } if ( ! flg ) break ; for ( int j = 0 ; j < BEzXhRFFVd ; j ++ ) { arr [ j ] = arr [ j ] / 2 ; } count ++ ; } System . out . println ( count ) ; } } import java . util . * ; import java . util . Scanner ; public class IASKkkUnqc { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String IASKkkUnqc = sc . next ( ) ; char [ ] b = new char [ 4 ] ; b [ 0 ] = IASKkkUnqc . charAt ( 0 ) ; b [ 1 ] = IASKkkUnqc . charAt ( 1 ) ; b [ 2 ] = IASKkkUnqc . charAt ( 2 ) ; b [ 3 ] = IASKkkUnqc . 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 ymsFnWKNnx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ymsFnWKNnx = Integer . parseInt ( sc . nextLine ( ) ) ; List < Integer > nums = new ArrayList < > ( ) ; for ( int i = 0 ; i < ymsFnWKNnx ; i ++ ) { nums . add ( sc . nextInt ( ) ) ; } Collections . sort ( nums ) ; int n1 = nums . get ( ymsFnWKNnx / 2 - 1 ) ; int n2 = nums . get ( ymsFnWKNnx / 2 ) ; System . out . println ( n2 - n1 ) ; } } import java . util . * ; import java . io . * ; public class OQmDsthGhq { static StringTokenizer st ; static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static void main ( String [ ] args ) throws IOException { int OQmDsthGhq = nextInt ( ) ; HashSet < String > kinds = new HashSet < > ( ) ; for ( int x = 0 ; x < OQmDsthGhq ; 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 dUnuPvyMlT { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int dUnuPvyMlT = stdIn . nextInt ( ) ; int x = stdIn . nextInt ( ) ; int [ ] l = new int [ dUnuPvyMlT ] ; for ( int i = 0 ; i < dUnuPvyMlT ; i ++ ) { l [ i ] = stdIn . nextInt ( ) ; } int counter = 1 ; long zahyou = 0 ; for ( int i = 0 ; i < dUnuPvyMlT ; i ++ ) { zahyou += l [ i ] ; if ( x < zahyou ) { break ; } else { counter ++ ; } } System . out . println ( counter ) ; } } import java . util . * ; public class VjnFbflrSS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VjnFbflrSS = sc . nextInt ( ) ; int over = sc . nextInt ( ) ; int outlet = 1 ; int ans = 0 ; while ( outlet < over ) { -- outlet ; outlet += VjnFbflrSS ; ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; public class RNFstHtQax { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RNFstHtQax = sc . nextInt ( ) ; int [ ] v = new int [ RNFstHtQax ] ; int [ ] c = new int [ RNFstHtQax ] ; for ( int i = 0 ; i < RNFstHtQax ; i ++ ) { v [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < RNFstHtQax ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int i = 0 ; i < RNFstHtQax ; i ++ ) { if ( v [ i ] > c [ i ] ) { result += v [ i ] - c [ i ] ; } } System . out . println ( result ) ; } } import java . util . Scanner ; class brjYTiQMLA { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String c = scan . next ( ) , str = " " ; for ( int brjYTiQMLA = 0 ; brjYTiQMLA < c . length ( ) ; brjYTiQMLA ++ ) { str = c . substring ( brjYTiQMLA , brjYTiQMLA + 1 ) + str ; } System . out . println ( str ) ; } } import java . util . * ; public class UidbBfNTzy { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String S = s . nextLine ( ) ; int UidbBfNTzy = 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' ) { UidbBfNTzy ++ ; if ( ans < UidbBfNTzy ) { ans = UidbBfNTzy ; } } else { UidbBfNTzy = 0 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class NASVeNvcRM { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int NASVeNvcRM = scan . nextInt ( ) ; if ( NASVeNvcRM == 0 ) { break ; } double [ ] s = new double [ NASVeNvcRM ] ; int i = 0 ; double sum = 0 ; double sumHensa = 0 ; double ans = 0 ; for ( i = 0 ; i < NASVeNvcRM ; i ++ ) { s [ i ] = scan . nextDouble ( ) ; sum += s [ i ] ; } double average = ( double ) sum / NASVeNvcRM ; for ( i = 0 ; i < NASVeNvcRM ; i ++ ) { sumHensa += ( s [ i ] - average ) * ( s [ i ] - average ) ; } ans = Math . sqrt ( ( double ) sumHensa / NASVeNvcRM ) ; 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 OiHdVShagM { public static void main ( String [ ] args ) { int OiHdVShagM = in . NI ( ) ; if ( OiHdVShagM % 2 == 0 ) out . println ( OiHdVShagM / 2 ) ; else out . println ( OiHdVShagM / 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 OiHdVShagM { 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 lqiFyRQqKZ { 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 lqiFyRQqKZ = Integer . parseInt ( br . readLine ( ) ) ; int b = Integer . parseInt ( br . readLine ( ) ) ; int x = 1 ^ 2 ^ 3 ; x ^= lqiFyRQqKZ ; x ^= b ; pw . println ( x ) ; pw . flush ( ) ; pw . close ( ) ; } } import java . util . Scanner ; public class IbufxjFbfO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IbufxjFbfO = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int ab = Math . min ( IbufxjFbfO + b , c * 2 ) ; int ans = Math . min ( x , y ) * ab ; if ( x > y ) { ans += ( x - y ) * Math . min ( IbufxjFbfO , c * 2 ) ; } else { ans += ( y - x ) * Math . min ( b , c * 2 ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class BYUuqMkjWQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int BYUuqMkjWQ = sc . nextInt ( ) ; String strA = sc . next ( ) ; int b = sc . nextInt ( ) ; if ( strA == " ? " ) { break ; } switch ( strA ) { case " + " : System . out . println ( BYUuqMkjWQ + b ) ; break ; case " - " : System . out . println ( BYUuqMkjWQ - b ) ; break ; case " * " : System . out . println ( BYUuqMkjWQ * b ) ; break ; case " / " : System . out . println ( BYUuqMkjWQ / 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 YZbvvKpqDc { 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 YZbvvKpqDc { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int YZbvvKpqDc = Integer . parseInt ( in . next ( ) ) ; int K = Integer . parseInt ( in . next ( ) ) ; Integer [ ] H = new Integer [ YZbvvKpqDc ] ; long ans = 0 ; for ( int i = 0 ; i < YZbvvKpqDc ; i ++ ) { H [ i ] = Integer . valueOf ( in . next ( ) ) ; ans += H [ i ] ; } Arrays . sort ( H , Collections . reverseOrder ( ) ) ; if ( K > YZbvvKpqDc ) K = YZbvvKpqDc ; 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 ARLDQOrjou { 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 ARLDQOrjou = 0 ; ARLDQOrjou < N . length ( ) ; ARLDQOrjou ++ ) { int tmp = ( int ) ( N . charAt ( ARLDQOrjou ) - '0' ) ; cubes [ tmp ] += 1 ; } System . out . println ( Math . min ( cubes [ 0 ] , cubes [ 1 ] ) * 2 ) ; } } import java . util . Scanner ; public class uoFEncvsdf { 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 uoFEncvsdf = true ; int len = s . length ( ) ; for ( int i = 0 ; i <= len / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( len - 1 - i ) ) { uoFEncvsdf = false ; break ; } } return uoFEncvsdf ; } } import java . util . Scanner ; public class KuotNlwFsG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KuotNlwFsG = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( KuotNlwFsG < 10 ) { if ( b < 10 ) { System . out . println ( KuotNlwFsG * b ) ; } else { System . out . println ( - 1 ) ; } } else { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; public class nHxjcapmqN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nHxjcapmqN = sc . nextInt ( ) ; int [ ] [ ] A = new int [ nHxjcapmqN + 1 ] [ 3 ] ; for ( int i = 1 ; i <= nHxjcapmqN ; 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 <= nHxjcapmqN ; 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 == nHxjcapmqN ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class wsEeBaoRtL { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; double wsEeBaoRtL = scn . nextDouble ( ) ; scn . close ( ) ; double ans = 2 * wsEeBaoRtL * 3.1415926535 ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class qTsPyLwVnI { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qTsPyLwVnI = scan . nextInt ( ) ; int zone = scan . nextInt ( ) ; int pos = 0 ; int count = 1 ; for ( int i = 0 ; i < qTsPyLwVnI ; i ++ ) { pos += scan . nextInt ( ) ; if ( pos <= zone ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class yNJZAyIfNt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; if ( s . charAt ( 0 ) == 'A' ) { int yNJZAyIfNt = 0 ; int index = 0 ; for ( int j = 2 ; j < s . length ( ) - 1 ; j ++ ) { if ( s . charAt ( j ) == 'C' ) { yNJZAyIfNt ++ ; index = j ; } } if ( yNJZAyIfNt == 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 DiaZNdgwSV { static final long DiaZNdgwSV = 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 DiaZNdgwSV { 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 iCtMCOvcBP { public static void main ( String [ ] args ) throws Exception { String inputNameA ; String inputNameB ; int iCtMCOvcBP ; 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 ( " " ) ; iCtMCOvcBP = Integer . parseInt ( editInputNum [ 0 ] ) ; numberOfB = Integer . parseInt ( editInputNum [ 1 ] ) ; if ( inputNameA . equals ( choiceName ) ) { iCtMCOvcBP -- ; } else if ( inputNameB . equals ( choiceName ) ) { numberOfB -- ; } System . out . println ( iCtMCOvcBP + " " + numberOfB ) ; } } import java . util . Scanner ; public class gOVwOAlaPG { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; int [ ] x = new int [ 20000 ] ; x [ 0 ] = kb . nextInt ( ) ; int gOVwOAlaPG = 0 ; int i = 0 ; while ( x [ gOVwOAlaPG ] != 0 ) { gOVwOAlaPG ++ ; x [ gOVwOAlaPG ] = kb . nextInt ( ) ; } while ( x [ i ] != 0 ) { System . out . printf ( " Case %d: %d \n " , i + 1 , x [ i ] ) ; i ++ ; } } } import java . util . * ; public class lHmTXHeAHN { public static void main ( String [ ] args ) { int [ ] arr = new int [ 100 ] ; Scanner sc = new Scanner ( System . in ) ; int lHmTXHeAHN = sc . nextInt ( ) ; for ( int i = 0 ; i < lHmTXHeAHN ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } for ( int j = lHmTXHeAHN - 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 tVypYImlDs { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] numbers = br . readLine ( ) . split ( " " ) ; int tVypYImlDs = Integer . parseInt ( numbers [ 0 ] ) ; int x = Integer . parseInt ( numbers [ 1 ] ) ; String [ ] length = br . readLine ( ) . split ( " " ) ; int [ ] len = new int [ tVypYImlDs ] ; for ( int i = 0 ; i < tVypYImlDs ; i ++ ) { len [ i ] = Integer . parseInt ( length [ i ] ) ; } int [ ] bounces = new int [ tVypYImlDs + 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 LZTJFElpyG { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String str = in . nextLine ( ) ; in . close ( ) ; int LZTJFElpyG = 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 ( LZTJFElpyG < count ) LZTJFElpyG = count ; count = 0 ; } } if ( LZTJFElpyG < count ) LZTJFElpyG = count ; System . out . println ( LZTJFElpyG ) ; } } import java . util . Scanner ; public class sHzeXLbbhI { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String t = scan . next ( ) ; int sHzeXLbbhI = 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 ++ ; } } sHzeXLbbhI = Math . min ( sHzeXLbbhI , diff ) ; } System . out . println ( sHzeXLbbhI ) ; } } import java . util . Scanner ; public class ygTMEQoGqG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ygTMEQoGqG = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] A = new int [ ygTMEQoGqG ] ; for ( int i = 0 ; i < ygTMEQoGqG ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < ygTMEQoGqG ; 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 zUKRXHzeUn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zUKRXHzeUn = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < zUKRXHzeUn ; 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 IIliLkwUSW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IIliLkwUSW = 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 == IIliLkwUSW && 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 NsSkdxypgB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NsSkdxypgB = sc . nextInt ( ) ; int [ ] cities = new int [ NsSkdxypgB + 1 ] ; int [ ] savers = new int [ NsSkdxypgB ] ; for ( int i = 0 ; i <= NsSkdxypgB ; i ++ ) cities [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < NsSkdxypgB ; i ++ ) savers [ i ] = sc . nextInt ( ) ; double ans = 0 ; for ( int i = 0 ; i < NsSkdxypgB ; 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 sDnlNcWDRa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sDnlNcWDRa = sc . nextInt ( ) ; int [ ] v = new int [ sDnlNcWDRa ] ; int sum = 0 ; for ( int i = 0 ; i < sDnlNcWDRa ; ++ i ) { v [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < sDnlNcWDRa ; ++ i ) { int c = sc . nextInt ( ) ; sum = ( v [ i ] > c ) ? sum + v [ i ] - c : sum ; } System . out . println ( sum ) ; } } import java . util . * ; public class omRqupvQIO { private static final Scanner sc = new Scanner ( System . in ) ; private void solve ( ) { int omRqupvQIO = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < omRqupvQIO ; ++ i ) { set . add ( sc . next ( ) ) ; } System . out . println ( set . size ( ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . * ; public class qtOKJmvsYU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qtOKJmvsYU = 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 < qtOKJmvsYU - 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 lKACocQsXd { 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 lKACocQsXd = 0 ; int sb = 0 ; int sc = 0 ; char next = 'a' ; boolean flag = true ; char winner = 0 ; while ( flag ) { switch ( next ) { case 'a' : if ( lKACocQsXd == SA . length ( ) ) { flag = false ; winner = 'A' ; } else { next = SA . charAt ( lKACocQsXd ) ; lKACocQsXd ++ ; } 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 VQhwtANPkv { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { solve ( sc ) ; } } static void solve ( Scanner sc ) { int VQhwtANPkv = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; if ( d <= VQhwtANPkv || b <= c ) { System . out . println ( 0 ) ; return ; } if ( c <= VQhwtANPkv ) { if ( d <= b ) { System . out . println ( d - VQhwtANPkv ) ; } else { System . out . println ( b - VQhwtANPkv ) ; } } else if ( c < b ) { if ( d <= b ) { System . out . println ( d - c ) ; } else { System . out . println ( b - c ) ; } } } } import java . util . Scanner ; class hDonajUbHt { public static void main ( String [ ] args ) { int hDonajUbHt = 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 ) ) hDonajUbHt ++ ; temp = sc . next ( ) ; } System . out . println ( hDonajUbHt ) ; } } import java . util . Scanner ; import java . math . BigDecimal ; public class femysZwzSM { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double femysZwzSM = scan . nextDouble ( ) ; final double CIRCLERATE = 3.141592653589 ; double s = CIRCLERATE * femysZwzSM * femysZwzSM ; double l = 2 * CIRCLERATE * femysZwzSM ; 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 FutsZgjTDK { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; Map < String , Integer > count = new HashMap < > ( ) ; int FutsZgjTDK = in . nextInt ( ) ; long res = 0 ; for ( int i = 0 ; i < FutsZgjTDK ; 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 BouhliqakD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BouhliqakD = sc . nextInt ( ) ; int [ ] list = new int [ BouhliqakD ] ; for ( int i = 0 ; i < BouhliqakD ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } int count = 0 ; int Max = 0 ; for ( int i = 1 ; i < BouhliqakD ; 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 FPesyIHKqJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FPesyIHKqJ = 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 = FPesyIHKqJ ; 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 BHvZrkQhwz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BHvZrkQhwz = sc . nextInt ( ) ; int [ ] stoneHeights = new int [ BHvZrkQhwz ] ; for ( int i = 0 ; i < BHvZrkQhwz ; i ++ ) { stoneHeights [ i ] = sc . nextInt ( ) ; } int [ ] minCostForStones = new int [ BHvZrkQhwz ] ; Arrays . fill ( minCostForStones , Integer . MAX_VALUE ) ; minCostForStones [ 0 ] = 0 ; for ( int i = 0 ; i < BHvZrkQhwz ; i ++ ) { for ( int j = i + 1 ; j < i + 3 ; j ++ ) { if ( j < BHvZrkQhwz ) { minCostForStones [ j ] = Math . min ( minCostForStones [ j ] , minCostForStones [ i ] + Math . abs ( stoneHeights [ j ] - stoneHeights [ i ] ) ) ; } } } System . out . println ( minCostForStones [ BHvZrkQhwz - 1 ] ) ; } } import java . util . Scanner ; public class wqsxMcoCgn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wqsxMcoCgn = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = Integer . parseInt ( String . valueOf ( wqsxMcoCgn ) + 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 YQWhfetGQU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YQWhfetGQU = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int temp1 = b ; b = YQWhfetGQU ; YQWhfetGQU = temp1 ; int temp = c ; c = YQWhfetGQU ; YQWhfetGQU = temp ; System . out . print ( YQWhfetGQU + " " + b + " " + c ) ; } } import java . io . * ; import java . util . * ; class PttYAufCIG { 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 PttYAufCIG : c_array ) { if ( 'a' <= PttYAufCIG && PttYAufCIG <= 'z' ) array [ PttYAufCIG - 'a' ] ++ ; else if ( 'A' <= PttYAufCIG && PttYAufCIG <= 'Z' ) array [ PttYAufCIG - 'A' ] ++ ; } } while ( true ) ; for ( int i = 0 ; i < 26 ; i ++ ) { System . out . println ( ( char ) ( 'a' + i ) + " : " + array [ i ] ) ; } } } import java . util . * ; public class XxtxEUIuZr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XxtxEUIuZr = sc . nextInt ( ) ; int b = XxtxEUIuZr ; int ans = 0 ; while ( XxtxEUIuZr > 0 ) { ans += XxtxEUIuZr % 10 ; XxtxEUIuZr /= 10 ; } System . out . println ( b % ans == 0 ? " Yes " : " No " ) ; } } import java . awt . * ; import java . awt . geom . * ; import java . io . * ; import java . util . * ; class JkiCVjWMEV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] list = new int [ 3 ] ; for ( int JkiCVjWMEV = 0 ; JkiCVjWMEV < 3 ; JkiCVjWMEV ++ ) { list [ JkiCVjWMEV ] = sc . nextInt ( ) ; } Arrays . sort ( list ) ; System . out . print ( list [ 0 ] ) ; for ( int JkiCVjWMEV = 1 ; JkiCVjWMEV < 3 ; JkiCVjWMEV ++ ) { System . out . print ( " " + list [ JkiCVjWMEV ] ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class uIvDhFrpHc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String uIvDhFrpHc = sc . next ( ) ; String b = sc . next ( ) ; String c = sc . next ( ) ; String next = uIvDhFrpHc . substring ( 0 , 1 ) ; uIvDhFrpHc = uIvDhFrpHc . substring ( 1 , uIvDhFrpHc . length ( ) ) ; for ( ; ; ) { if ( next . equals ( " a " ) ) { if ( uIvDhFrpHc . isEmpty ( ) ) { System . out . println ( " A " ) ; return ; } next = uIvDhFrpHc . substring ( 0 , 1 ) ; uIvDhFrpHc = uIvDhFrpHc . substring ( 1 , uIvDhFrpHc . 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 UbZkTRscDd { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; double UbZkTRscDd = stdIn . nextDouble ( ) ; double H = stdIn . nextDouble ( ) ; double x = stdIn . nextDouble ( ) ; double y = stdIn . nextDouble ( ) ; System . out . println ( UbZkTRscDd * H / 2 ) ; if ( x == UbZkTRscDd / 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 uFSUUYaYWM { public static void main ( String [ ] args ) { Integer [ ] input = readInput ( ) ; int uFSUUYaYWM = input [ 0 ] ; int b = input [ 1 ] ; if ( uFSUUYaYWM < b ) { System . out . println ( " a < b " ) ; } else if ( uFSUUYaYWM > 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 REaSIfuCKE { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; int REaSIfuCKE = Integer . parseInt ( line ) ; int tarouScore = 0 ; int hanakoScore = 0 ; for ( int i = 0 ; i < REaSIfuCKE ; 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 aYqNqqAtYl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; try { int aYqNqqAtYl , H , x , y , r ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; String [ ] strAry = str . split ( " " ) ; aYqNqqAtYl = 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 <= aYqNqqAtYl && 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 TVbyxsuBlG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long TVbyxsuBlG = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = TVbyxsuBlG / ( a + b ) ; long m = TVbyxsuBlG - 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 oyPAlbOnXB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oyPAlbOnXB = 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 < oyPAlbOnXB ; 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 rXudGNBGKe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rXudGNBGKe = sc . nextInt ( ) ; long [ ] monster = new long [ rXudGNBGKe + 1 ] ; long [ ] brave = new long [ rXudGNBGKe ] ; long anser = 0 ; for ( int i = 0 ; i < rXudGNBGKe + 1 ; i ++ ) { monster [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < rXudGNBGKe ; 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 ZovpyHsTHH { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int ZovpyHsTHH = s . nextInt ( ) ; int y = s . nextInt ( ) ; int flag = 0 ; for ( int i = 0 ; i <= ZovpyHsTHH ; i ++ ) { if ( i * 2 + ( ZovpyHsTHH - 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 ZYdqSgSkRq { public static void main ( String [ ] args ) { InputReader in = new InputReader ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int ZYdqSgSkRq = in . nextInt ( ) ; int y = in . nextInt ( ) ; int z = in . nextInt ( ) ; int p = ZYdqSgSkRq ; System . out . println ( z + " " + ZYdqSgSkRq + " " + y ) ; } static class ZYdqSgSkRq { 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 kbzxtdPupf { 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 kbzxtdPupf = Integer . parseInt ( numberStr [ 0 ] ) ; int sum = Integer . parseInt ( numberStr [ 1 ] ) ; if ( ( kbzxtdPupf == 0 ) && ( sum == 0 ) ) { break ; } int set = 0 ; for ( int oneNum = 1 ; oneNum <= kbzxtdPupf - 2 ; oneNum ++ ) { for ( int twoNum = oneNum + 1 ; twoNum <= kbzxtdPupf + 1 ; twoNum ++ ) { for ( int threeNum = twoNum + 1 ; threeNum <= kbzxtdPupf ; 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 PkyehoYBcl { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int PkyehoYBcl = sc . nextInt ( ) ; int max = sc . nextInt ( ) ; int count = 1 ; for ( int i = 0 ; i < PkyehoYBcl - 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 dfuujAVKCH { public static void main ( String [ ] args ) { int dfuujAVKCH = 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 ++ ) { dfuujAVKCH = dfuujAVKCH + 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 ++ ) { dfuujAVKCH = dfuujAVKCH + c [ CN . get ( l ) - 1 ] ; } System . out . println ( dfuujAVKCH ) ; } } import java . util . * ; public class QfcCzaIaPj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QfcCzaIaPj = scan . nextInt ( ) ; if ( QfcCzaIaPj % 10 == 7 || QfcCzaIaPj % 100 - QfcCzaIaPj % 10 == 70 || QfcCzaIaPj % 1000 - QfcCzaIaPj % 100 == 700 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; return ; } } import java . util . * ; public class DgITmdYniU { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int DgITmdYniU ; DgITmdYniU = in . nextInt ( ) ; int a , b , i , num ; a = in . nextInt ( ) ; b = in . nextInt ( ) ; num = a ; for ( i = num ; i <= b ; i ++ , num ++ ) { if ( i % DgITmdYniU == 0 ) { System . out . println ( " OK " ) ; System . exit ( 0 ) ; } } System . out . println ( " NG " ) ; } } import java . util . Scanner ; public class JqQqJAusLq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JqQqJAusLq = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( 6 - JqQqJAusLq - b ) ; } } import java . util . Scanner ; public class rWcEcqbBrP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rWcEcqbBrP = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int tmp = 9999 ; int min = 9999 ; int [ ] ci = new int [ rWcEcqbBrP ] ; int [ ] ti = new int [ rWcEcqbBrP ] ; int i = 0 ; for ( i = 0 ; i < rWcEcqbBrP ; 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 HqaQkaCMfe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HqaQkaCMfe = 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 < HqaQkaCMfe ; 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 xDlawXtXCK { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double xDlawXtXCK = 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 DJmMNCeXMj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long DJmMNCeXMj = 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 ] >= DJmMNCeXMj ) 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 eMNnnTiYyQ { private static final Scanner scn = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int eMNnnTiYyQ = scn . nextInt ( ) , b = scn . nextInt ( ) , c = scn . nextInt ( ) ; System . out . println ( eMNnnTiYyQ < b && b < c ? " Yes " : " No " ) ; } } import java . util . * ; class iGieOtMoxL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iGieOtMoxL = sc . nextInt ( ) ; if ( iGieOtMoxL < 0 ) { System . out . println ( " NA " ) ; return ; } if ( iGieOtMoxL % 100 < 13 && iGieOtMoxL % 100 != 0 ) { if ( iGieOtMoxL / 100 < 13 && iGieOtMoxL / 100 != 0 ) { System . out . println ( " AMBIGUOUS " ) ; return ; } System . out . println ( " YYMM " ) ; return ; } if ( iGieOtMoxL / 100 < 13 && iGieOtMoxL / 100 != 0 ) { System . out . println ( " MMYY " ) ; return ; } System . out . println ( " NA " ) ; } } import java . util . * ; import java . math . * ; public class PuMGziAIzO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long PuMGziAIzO = 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 ) ( PuMGziAIzO * B / 100 ) ; System . out . println ( res ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class SYAwpXynYD { public static void main ( String [ ] args ) { Scanner a = new Scanner ( System . in ) ; int [ ] numbers = new int [ 3 ] ; for ( int SYAwpXynYD = 0 ; SYAwpXynYD < 3 ; SYAwpXynYD ++ ) { numbers [ SYAwpXynYD ] = 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 wdoboZFjHz { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int wdoboZFjHz = Integer . parseInt ( br . readLine ( ) ) ; for ( int f = 0 ; f < wdoboZFjHz ; 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 DbxlMDCBlg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int DbxlMDCBlg = scan . nextInt ( ) ; int [ ] a = new int [ DbxlMDCBlg ] ; for ( int i = 0 ; i < DbxlMDCBlg ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; Arrays . sort ( a ) ; int check = 0 ; for ( int i = 0 ; i < DbxlMDCBlg ; i ++ ) { for ( int j = i + 1 ; j < DbxlMDCBlg ; 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 tsVQBZTsge { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tsVQBZTsge = sc . nextInt ( ) ; String str = sc . next ( ) ; char [ ] c = str . toCharArray ( ) ; int count = 0 ; if ( tsVQBZTsge % 2 == 0 ) { for ( int i = 0 ; i < tsVQBZTsge / 2 ; i ++ ) { if ( c [ i ] == c [ tsVQBZTsge / 2 + i ] ) { count ++ ; } } if ( count == tsVQBZTsge / 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class EcxmwHEOvV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long EcxmwHEOvV = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; if ( EcxmwHEOvV >= 0 ) { if ( d >= 0 ) { System . out . println ( b * d ) ; } else { System . out . println ( d * EcxmwHEOvV ) ; } } else if ( b < 0 ) { if ( c >= 0 ) { System . out . println ( b * c ) ; } else { System . out . println ( c * EcxmwHEOvV ) ; } } else { if ( d < 0 ) { System . out . println ( c * EcxmwHEOvV ) ; } else if ( c >= 0 ) { System . out . println ( b * d ) ; } else { if ( EcxmwHEOvV * c > b * d ) { System . out . println ( EcxmwHEOvV * c ) ; } else { System . out . println ( b * d ) ; } } } } } import java . util . Scanner ; public class SjqeCyPAtV { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final StringBuilder S1 = new StringBuilder ( sc . next ( ) ) ; final int SjqeCyPAtV = S1 . length ( ) ; final StringBuilder S2 = new StringBuilder ( S1 . substring ( 0 , ( SjqeCyPAtV - 1 ) / 2 ) ) ; final StringBuilder S3 = new StringBuilder ( S1 . substring ( ( SjqeCyPAtV + 3 ) / 2 - 1 , SjqeCyPAtV ) ) ; 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 NFsFLOyhHP { 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 NFsFLOyhHP = Integer . parseInt ( split [ 0 ] ) ; int N = Integer . parseInt ( split [ 1 ] ) ; info = br . readLine ( ) ; String [ ] A = info . split ( " " ) ; for ( int i = 0 ; i < N ; i ++ ) { NFsFLOyhHP = NFsFLOyhHP - Integer . parseInt ( A [ i ] ) ; } if ( NFsFLOyhHP <= 0 ) { System . out . println ( " Yes " ) ; } else System . out . println ( " No " ) ; } } import java . math . * ; import java . util . * ; import java . io . * ; import java . lang . * ; public class OIXUmghDhj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OIXUmghDhj = sc . nextInt ( ) ; if ( isPrime ( OIXUmghDhj ) ) { System . out . println ( OIXUmghDhj ) ; } else { while ( ! isPrime ( OIXUmghDhj ) ) { OIXUmghDhj ++ ; } System . out . println ( OIXUmghDhj ) ; } } 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 FhWEACMrfb { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] parts = br . readLine ( ) . split ( " " ) ; int FhWEACMrfb = Integer . parseInt ( parts [ 0 ] ) ; int A = Integer . parseInt ( parts [ 1 ] ) ; int a = FhWEACMrfb % A ; if ( a == 0 ) { System . out . println ( FhWEACMrfb / A ) ; } else { System . out . println ( FhWEACMrfb / A + 1 ) ; } } } import java . util . Scanner ; public class NXwfmIcBaM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NXwfmIcBaM = Integer . parseInt ( sc . nextLine ( ) ) ; sc . close ( ) ; int ans = 0 ; if ( NXwfmIcBaM < 10 ) { ans = NXwfmIcBaM ; } else if ( NXwfmIcBaM < 100 ) { ans = 9 ; } else if ( NXwfmIcBaM < 1000 ) { ans = NXwfmIcBaM - 99 + 9 ; } else if ( NXwfmIcBaM < 10000 ) { ans = 999 - 99 + 9 ; } else if ( NXwfmIcBaM < 100000 ) { ans = NXwfmIcBaM - 9999 + 999 - 99 + 9 ; } else if ( NXwfmIcBaM < 1000000 ) { ans = 99999 - 9999 + 999 - 99 + 9 ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class soMdPazlIa { 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 soMdPazlIa = list . get ( 0 ) ; int sum = list . get ( 1 ) ; int i = 0 ; if ( sum == 1 ) { System . out . print ( 0 ) ; } else if ( soMdPazlIa >= sum ) { System . out . print ( 1 ) ; } else { sum = sum - soMdPazlIa ; i ++ ; soMdPazlIa -- ; while ( true ) { sum = sum - soMdPazlIa ; i ++ ; if ( sum < 1 ) { System . out . print ( i ) ; break ; } } } } } import java . util . Scanner ; public class AMbHIEntwq { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int AMbHIEntwq ; double [ ] b = new double [ 1111 ] ; double av ; double sum ; while ( true ) { AMbHIEntwq = input . nextInt ( ) ; if ( AMbHIEntwq == 0 ) break ; else { sum = 0 ; av = 0 ; for ( int i = 0 ; i < AMbHIEntwq ; i ++ ) { b [ i ] = input . nextDouble ( ) ; av += b [ i ] ; } av /= AMbHIEntwq ; for ( int i = 0 ; i < AMbHIEntwq ; i ++ ) { sum += ( b [ i ] - av ) * ( b [ i ] - av ) / AMbHIEntwq ; } System . out . println ( Math . sqrt ( sum ) ) ; } } input . close ( ) ; } } import java . util . * ; class RgyXnxstBy { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int RgyXnxstBy = 1 , x = 1 ; while ( x > 0 ) { x = scanner . nextInt ( ) ; if ( x == 0 ) { break ; } System . out . println ( " Case " + RgyXnxstBy + " : " + x ) ; RgyXnxstBy ++ ; } } } import java . util . * ; public class FJjHuTRyTi { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int FJjHuTRyTi = input . nextInt ( ) ; int h = ( FJjHuTRyTi / 500 ) * 1000 ; int f = ( ( FJjHuTRyTi % 500 ) / 5 ) * 5 ; System . out . println ( h + f ) ; } } import java . util . * ; public class XqIDPPJeZs { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { boolean XqIDPPJeZs = true ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( a >= b ) { XqIDPPJeZs = false ; } int c = sc . nextInt ( ) ; if ( b >= c ) { XqIDPPJeZs = false ; } System . out . println ( XqIDPPJeZs == true ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class WEgqZXtooF { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String WEgqZXtooF = input . nextLine ( ) ; if ( WEgqZXtooF . equals ( " SUN " ) ) { System . out . println ( " 7 " ) ; } else if ( WEgqZXtooF . equals ( " MON " ) ) { System . out . println ( " 6 " ) ; } else if ( WEgqZXtooF . equals ( " TUE " ) ) { System . out . println ( " 5 " ) ; } else if ( WEgqZXtooF . equals ( " WED " ) ) { System . out . println ( " 4 " ) ; } else if ( WEgqZXtooF . equals ( " THU " ) ) { System . out . println ( " 3 " ) ; } else if ( WEgqZXtooF . equals ( " FRI " ) ) { System . out . println ( " 2 " ) ; } else if ( WEgqZXtooF . equals ( " SAT " ) ) { System . out . println ( " 1 " ) ; } } } import java . util . Scanner ; public class FZyDwOfaBa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String FZyDwOfaBa = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; String t = sb . append ( FZyDwOfaBa ) . 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 XscVOdXVsi { 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 XscVOdXVsi = 0 ; XscVOdXVsi < 10 ; XscVOdXVsi ++ ) input . add ( Integer . parseInt ( br . readLine ( ) ) ) ; Collections . sort ( input , Collections . reverseOrder ( ) ) ; for ( int XscVOdXVsi = 0 ; XscVOdXVsi < 3 ; XscVOdXVsi ++ ) System . out . println ( input . get ( XscVOdXVsi ) ) ; } } import java . util . Scanner ; public class JdJrtyjJCn { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; while ( true ) { String word = input . nextLine ( ) ; if ( word . equals ( " - " ) ) break ; int JdJrtyjJCn = input . nextInt ( ) ; for ( int i = 0 ; i < JdJrtyjJCn ; 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 PzhMEaZYhd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PzhMEaZYhd = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int judge = 0 ; while ( PzhMEaZYhd >= 0 && Y >= 0 ) { if ( Y / 4 == PzhMEaZYhd && Y % 4 == 0 ) { judge = 1 ; break ; } PzhMEaZYhd = PzhMEaZYhd - 1 ; Y = Y - 2 ; } if ( judge == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class mIWwUMmVZc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] list = scanner . next ( ) . split ( " " ) ; int mIWwUMmVZc = 0 ; for ( String s : list ) { if ( Integer . parseInt ( s ) == 1 ) { mIWwUMmVZc ++ ; } } System . out . println ( mIWwUMmVZc ) ; scanner . close ( ) ; } } import java . util . * ; public class yfHcoKebCk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] ss = new String [ 4 ] ; for ( int yfHcoKebCk = 0 ; yfHcoKebCk < 4 ; yfHcoKebCk ++ ) { ss [ yfHcoKebCk ] = s . substring ( yfHcoKebCk , yfHcoKebCk + 1 ) ; } for ( int yfHcoKebCk = 0 ; yfHcoKebCk < 3 ; yfHcoKebCk ++ ) { if ( ss [ yfHcoKebCk ] . equals ( ss [ yfHcoKebCk + 1 ] ) ) { System . out . println ( " Bad " ) ; return ; } } System . out . println ( " Good " ) ; } } import java . util . * ; public class TwCDUQLZjN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TwCDUQLZjN = 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 ( TwCDUQLZjN ) ; } else { for ( int i = 0 ; i < a . length ; i ++ ) { if ( min <= ( int ) Math . abs ( TwCDUQLZjN - a [ i ] ) ) { System . out . println ( a [ i - 1 ] ) ; break ; } else { min = ( int ) Math . abs ( TwCDUQLZjN - a [ i ] ) ; } } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class yhsdJbQetE { public static void main ( String [ ] args ) throws IOException , Exception { BufferedReader st = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] data1 = getIntArry ( st ) ; int yhsdJbQetE = data1 [ 0 ] ; int k = data1 [ 1 ] ; int [ ] data2 = getIntArry ( st ) ; int ans = 0 ; for ( int i = 0 ; i < yhsdJbQetE ; 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 uDUdiWOOuN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uDUdiWOOuN = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( ( B + uDUdiWOOuN - 3 ) / ( uDUdiWOOuN - 1 ) ) ; } } import java . util . Scanner ; public class QOkxCTNZHO { public static void main ( String [ ] args ) { Scanner kbd = new Scanner ( System . in ) ; int QOkxCTNZHO = kbd . nextInt ( ) ; int d = kbd . nextInt ( ) ; int num = 0 ; for ( int i = 0 ; i < QOkxCTNZHO ; 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 HGKiPZvQNu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int HGKiPZvQNu = s . length ; char [ ] t = sc . next ( ) . toCharArray ( ) ; int tlen = t . length ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < HGKiPZvQNu - 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 HvrpGovCNs { 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 HvrpGovCNs = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int ans = 0 ; while ( HvrpGovCNs >= K ) { HvrpGovCNs /= K ; ans ++ ; } if ( HvrpGovCNs != 0 ) ans ++ ; os . println ( ans ) ; } } import java . util . Scanner ; import java . lang . Math ; class jMHWuKdaPh { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int jMHWuKdaPh = Integer . parseInt ( stdIn . next ( ) ) ; if ( jMHWuKdaPh != 2 && jMHWuKdaPh % 2 == 0 ) jMHWuKdaPh ++ ; while ( true ) { int i ; double sqrtNum = Math . sqrt ( jMHWuKdaPh ) ; for ( i = 3 ; i <= sqrtNum ; i += 2 ) { if ( jMHWuKdaPh % i == 0 ) break ; } if ( i > sqrtNum ) break ; jMHWuKdaPh += 2 ; } System . out . println ( jMHWuKdaPh ) ; } } import java . util . Scanner ; public class MEymUBgdLB { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int MEymUBgdLB = 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 ofrbLIVMhu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ofrbLIVMhu = scan . nextInt ( ) ; int [ ] A = new int [ ofrbLIVMhu ] ; for ( int i = 0 ; i < ofrbLIVMhu ; i ++ ) { A [ i ] = scan . nextInt ( ) ; } double c = 0 ; Arrays . sort ( A ) ; c = ( A [ 0 ] + A [ 1 ] ) / 2.0 ; for ( int i = 2 ; i < ofrbLIVMhu ; i ++ ) { c = ( c + A [ i ] ) / 2.0 ; } System . out . println ( c ) ; } } import java . util . * ; import java . io . * ; import java . nio . charset . StandardCharsets ; public class bXSZUGvUQK { 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 bXSZUGvUQK = new String ( str ) ; System . out . println ( bXSZUGvUQK ) ; } } import java . util . * ; class LvKOivxkPh { 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 LvKOivxkPh = ss [ ss . length - 1 ] ; if ( LvKOivxkPh == '2' || LvKOivxkPh == '4' || LvKOivxkPh == '5' || LvKOivxkPh == '7' || LvKOivxkPh == '9' ) { System . out . println ( " hon " ) ; } else if ( LvKOivxkPh == '0' || LvKOivxkPh == '1' || LvKOivxkPh == '6' || LvKOivxkPh == '8' ) { System . out . println ( " pon " ) ; } else { System . out . println ( " bon " ) ; } } } import java . io . * ; import java . util . * ; public class lapjoQKtgB { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int lapjoQKtgB = 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 QJmXntwpLb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Double r = Double . parseDouble ( sc . next ( ) ) ; double QJmXntwpLb = Math . PI ; double s = r * r * QJmXntwpLb ; double l = 2 * r * QJmXntwpLb ; System . out . printf ( " %.6f " , s ) ; System . out . print ( " " ) ; System . out . printf ( " %.6f \n " , l ) ; } } import java . util . * ; class wbYIEeyzjJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wbYIEeyzjJ = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] array = { 1 , 2 , 3 } ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( ( array [ i ] == wbYIEeyzjJ ) || ( 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 oJDGvaISUZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oJDGvaISUZ = 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 pBjOIsbgtP { static char [ ] xx = new char [ ] { 'S' , 'H' , 'C' , 'D' } ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pBjOIsbgtP = sc . nextInt ( ) ; boolean [ ] [ ] l = new boolean [ 4 ] [ 13 ] ; for ( int i = 0 ; i < pBjOIsbgtP ; 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 eKPdpBpgew { 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 eKPdpBpgew = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; if ( eKPdpBpgew > 2019 || ( eKPdpBpgew <= 2019 && m > 4 ) ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } } } import java . util . Scanner ; public class fdjwgXbhJY { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String [ ] t = s . split ( " " ) ; for ( int fdjwgXbhJY = 0 ; fdjwgXbhJY < t . length ; fdjwgXbhJY ++ ) { t [ fdjwgXbhJY ] = " x " ; } String u = String . join ( " " , t ) ; System . out . println ( u ) ; } } import java . util . * ; public class HVLxnHdyQw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String HVLxnHdyQw = sc . next ( ) ; if ( " SAT " . equals ( HVLxnHdyQw ) ) { System . out . println ( " 1 " ) ; } else if ( " FRI " . equals ( HVLxnHdyQw ) ) { System . out . println ( " 2 " ) ; } else if ( " THU " . equals ( HVLxnHdyQw ) ) { System . out . println ( " 3 " ) ; } else if ( " WED " . equals ( HVLxnHdyQw ) ) { System . out . println ( " 4 " ) ; } else if ( " TUE " . equals ( HVLxnHdyQw ) ) { System . out . println ( " 5 " ) ; } else if ( " MON " . equals ( HVLxnHdyQw ) ) { System . out . println ( " 6 " ) ; } else if ( " SUN " . equals ( HVLxnHdyQw ) ) { 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 WJWWsgEqVL { 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 WJWWsgEqVL = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int H = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; double ax = WJWWsgEqVL * Math . cos ( Math . toRadians ( 90 - 30 * H - M / 2.0 ) ) ; double ay = WJWWsgEqVL * 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 FPgeZieHul { public static void main ( String [ ] args ) { try ( final Scanner sc = new Scanner ( System . in ) ) { Resolver resolver = new Resolver ( sc ) ; resolver . resolve ( ) ; } } private static class FPgeZieHul { private final int FPgeZieHul , b , t ; private Resolver ( final Scanner sc ) { this . FPgeZieHul = sc . nextInt ( ) ; this . b = sc . nextInt ( ) ; this . t = sc . nextInt ( ) ; } private void resolve ( ) { int k = t / FPgeZieHul ; System . out . println ( b * k ) ; } } } import java . util . Scanner ; class mryaxpuSAF { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int mryaxpuSAF , c , a [ ] [ ] = new int [ 101 ] [ 101 ] , i , j ; mryaxpuSAF = stdIn . nextInt ( ) ; c = stdIn . nextInt ( ) ; for ( i = 0 ; i < mryaxpuSAF ; 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 < mryaxpuSAF ; j ++ ) a [ mryaxpuSAF ] [ i ] += a [ j ] [ i ] ; a [ mryaxpuSAF ] [ c ] += a [ mryaxpuSAF ] [ i ] ; } for ( i = 0 ; i <= mryaxpuSAF ; 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 WbPIHdMlMU { public static void main ( String [ ] args ) { boolean WbPIHdMlMU = 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 ( WbPIHdMlMU == 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 ( ) ; WbPIHdMlMU = true ; } } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class OilKrUZVjB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String nyu = sc . next ( ) ; int OilKrUZVjB = 0 , mem = 0 , leng ; leng = nyu . length ( ) ; for ( int i = 0 ; i < leng ; i ++ ) { char top = nyu . charAt ( i ) ; switch ( top ) { case 'A' : OilKrUZVjB += 1 ; break ; case 'C' : OilKrUZVjB += 1 ; break ; case 'G' : OilKrUZVjB += 1 ; break ; case 'T' : OilKrUZVjB += 1 ; break ; default : if ( OilKrUZVjB > mem ) { mem = OilKrUZVjB ; OilKrUZVjB = 0 ; } } } if ( OilKrUZVjB > mem ) { mem = OilKrUZVjB ; } System . out . println ( mem ) ; } } import java . util . * ; public class zYcrGaPyGH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zYcrGaPyGH = sc . nextInt ( ) , T = sc . nextInt ( ) ; int [ ] c = new int [ zYcrGaPyGH ] ; int [ ] t = new int [ zYcrGaPyGH ] ; for ( int i = 0 ; i < zYcrGaPyGH ; i ++ ) { c [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; } int ans = INF ; boolean exist = false ; for ( int i = 0 ; i < zYcrGaPyGH ; 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 EWjUMgbbdJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; long EWjUMgbbdJ = 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 >= EWjUMgbbdJ ) { int cnt1 = 0 ; for ( int i = 0 ; i < l ; i ++ ) { if ( num [ i ] == 1 ) { cnt1 ++ ; } else { break ; } } if ( cnt1 >= EWjUMgbbdJ ) { 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 MXAVHyKZPU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MXAVHyKZPU = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ m ] ; boolean [ ] jdg = new boolean [ MXAVHyKZPU + 1 ] ; long [ ] Dp = new long [ MXAVHyKZPU + 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 <= MXAVHyKZPU ; 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 [ MXAVHyKZPU ] ) ; } } import java . util . * ; public class yYoXqAxuUy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yYoXqAxuUy , i , answer ; int sum = 0 ; int temp_a = 0 ; int temp_b = 0 ; yYoXqAxuUy = Integer . parseInt ( sc . next ( ) ) ; int [ ] weight = new int [ yYoXqAxuUy ] ; for ( i = 0 ; i < yYoXqAxuUy ; i ++ ) { weight [ i ] = Integer . parseInt ( sc . next ( ) ) ; sum += weight [ i ] ; } for ( i = 0 ; i < yYoXqAxuUy ; 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 ptkPDPnmlo { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int ptkPDPnmlo = scanner . nextInt ( ) ; int max = Integer . MAX_VALUE ; for ( int i = 0 ; i < ptkPDPnmlo ; i ++ ) { max = Math . min ( max , Integer . numberOfTrailingZeros ( scanner . nextInt ( ) ) ) ; } System . out . println ( max ) ; } } import java . util . Scanner ; public class nMgYqyEDMt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; boolean nMgYqyEDMt = 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 nyFJYwptpw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int nyFJYwptpw = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( '0' == s . charAt ( i ) ) nyFJYwptpw ++ ; } System . out . println ( 2 * Math . min ( s . length ( ) - nyFJYwptpw , nyFJYwptpw ) ) ; } } import java . util . Scanner ; public class ShpSrYoLnv { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int ShpSrYoLnv = s . nextInt ( ) ; int [ ] ds = new int [ ShpSrYoLnv ] ; int sum = 0 ; for ( int i = 0 ; i < ShpSrYoLnv ; 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 dSmiWioxdc { static String str ; static int dSmiWioxdc , zeroC , oneC ; static int [ ] A ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; str = sc . next ( ) ; dSmiWioxdc = str . length ( ) ; A = new int [ dSmiWioxdc ] ; for ( int i = 0 ; i < dSmiWioxdc ; i ++ ) { A [ i ] = Character . getNumericValue ( str . charAt ( i ) ) ; if ( A [ i ] == 0 ) { zeroC ++ ; } else { oneC ++ ; } } System . out . println ( dSmiWioxdc - ( Math . abs ( zeroC - oneC ) ) ) ; } } import java . util . * ; class hEThtUSkwu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hEThtUSkwu = 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 ) + ( hEThtUSkwu * ( X - Y ) ) ; price2 = C * 2 * X ; } else { price1 = ( C * 2 * X ) + ( B * ( Y - X ) ) ; price2 = C * 2 * Y ; } int price3 = hEThtUSkwu * X + B * Y ; int ans = Math . min ( price1 , price2 ) ; ans = Math . min ( ans , price3 ) ; System . out . println ( + ans ) ; } } import java . util . * ; public class coOcBdxgqV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int coOcBdxgqV = sc . nextInt ( ) ; int [ ] H = new int [ coOcBdxgqV ] ; for ( int i = 0 ; i < coOcBdxgqV ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; boolean out = false ; H [ 0 ] -- ; for ( int i = 0 ; i < coOcBdxgqV - 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 QeHUdIrsKz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long QeHUdIrsKz = sc . nextLong ( ) ; long ans = Long . MAX_VALUE / 2 ; for ( int i = 1 ; ( long ) i * i <= QeHUdIrsKz ; i ++ ) { if ( QeHUdIrsKz % i == 0 ) { long a = i ; long b = QeHUdIrsKz / 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 kdbPdwvIcX { public static void main ( String [ ] args ) { int kdbPdwvIcX ; int endNum ; int answer = 0 ; Scanner sc = new Scanner ( System . in ) ; kdbPdwvIcX = sc . nextInt ( ) ; endNum = sc . nextInt ( ) ; for ( int i = kdbPdwvIcX ; 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 ByxjYdQTzv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ByxjYdQTzv = sc . nextInt ( ) ; int [ ] b = new int [ ByxjYdQTzv ] ; 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 BEislVkzqz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long BEislVkzqz = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( BEislVkzqz % k < k - ( BEislVkzqz % k ) ) k = BEislVkzqz % k ; else k = k - ( BEislVkzqz % k ) ; System . out . println ( k ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class lFUCjFoReq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lFUCjFoReq = sc . nextInt ( ) , K = sc . nextInt ( ) ; double [ ] dp = new double [ K + 1 ] ; Arrays . fill ( dp , 0 ) ; for ( int i = 1 ; i <= Math . min ( lFUCjFoReq , K ) ; ++ i ) dp [ i ] = 1.0 / lFUCjFoReq ; dp [ K ] += ( double ) Math . max ( 0 , lFUCjFoReq - K ) / lFUCjFoReq ; 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 GqFPcTzhtu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int GqFPcTzhtu = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int min = 0 ; int count = 0 ; if ( GqFPcTzhtu < B ) { min = GqFPcTzhtu ; } else { min = B ; } for ( int i = min ; i >= 1 ; i -- ) { if ( GqFPcTzhtu % i == 0 && B % i == 0 ) { count ++ ; if ( count == K ) { System . out . println ( i ) ; break ; } } } scan . close ( ) ; } } import java . util . * ; public class wUJABfaNnZ { 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 wUJABfaNnZ = 0 ; wUJABfaNnZ < Q ; wUJABfaNnZ ++ ) { l [ wUJABfaNnZ ] = sc . nextInt ( ) ; r [ wUJABfaNnZ ] = sc . nextInt ( ) ; } int [ ] a = new int [ N ] ; int count = 0 ; for ( int wUJABfaNnZ = 1 ; wUJABfaNnZ < N ; wUJABfaNnZ ++ ) { if ( S . charAt ( wUJABfaNnZ - 1 ) == 'A' && S . charAt ( wUJABfaNnZ ) == 'C' ) { count ++ ; a [ wUJABfaNnZ ] = count ; } else { a [ wUJABfaNnZ ] = count ; } } for ( int wUJABfaNnZ = 0 ; wUJABfaNnZ < Q ; wUJABfaNnZ ++ ) { System . out . println ( a [ r [ wUJABfaNnZ ] - 1 ] - a [ l [ wUJABfaNnZ ] - 1 ] ) ; } } } import java . util . Scanner ; public class xhFCAMqeIK { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xhFCAMqeIK = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int C = 0 ; C = xhFCAMqeIK * B ; System . out . println ( C ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class uJgiGdGeQI { private static int uJgiGdGeQI = 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 . uJgiGdGeQI ) ; } public static void me ( int [ ] nums ) { int min = Integer . MAX_VALUE ; for ( int num : nums ) { min = num < min ? num : min ; } Main . uJgiGdGeQI += 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 EwRMCpEFKa { public static void main ( String [ ] args ) throws Exception { boolean EwRMCpEFKa = 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 ZOPCfQhoQg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String w = scan . nextLine ( ) ; int ZOPCfQhoQg = 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 ) ) { ZOPCfQhoQg ++ ; } } } System . out . println ( ZOPCfQhoQg ) ; } } import java . util . * ; import java . lang . * ; public class CBkVpgaNoc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; int [ ] a = new int [ n . length ( ) + 1 ] ; int CBkVpgaNoc = 0 ; for ( int i = 0 ; i < n . length ( ) ; i ++ ) { a [ i ] = n . charAt ( i ) - '0' ; } for ( int i = 0 ; i < n . length ( ) ; i ++ ) { CBkVpgaNoc = CBkVpgaNoc + a [ i ] ; } if ( CBkVpgaNoc % 9 == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class hZyIVYnAgS { Scanner sc ; int hZyIVYnAgS , 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 { hZyIVYnAgS = sc . nextInt ( ) ; b = sc . nextInt ( ) ; int k = ( hZyIVYnAgS + b ) / 2 ; if ( k * 2 != hZyIVYnAgS + 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 BwfGcNbEpu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BwfGcNbEpu = 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 ++ ) { BwfGcNbEpu -= A [ i ] ; } if ( BwfGcNbEpu <= 0 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; import java . util . Collections ; import java . util . ArrayList ; public class oOOmGuTwpT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oOOmGuTwpT = 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 gBCdyNgGHY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char gBCdyNgGHY = sc . next ( ) . trim ( ) . charAt ( 0 ) ; StringBuilder sb = new StringBuilder ( ) ; if ( gBCdyNgGHY >= 'A' && gBCdyNgGHY <= 'Z' ) sb . append ( 'A' + " \n " ) ; else if ( gBCdyNgGHY >= 'a' && gBCdyNgGHY <= 'z' ) sb . append ( 'a' + " \n " ) ; sc . close ( ) ; System . out . println ( sb ) ; } } import java . util . * ; public class vYpEeEqNld { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] nums = new int [ 3 ] ; for ( int vYpEeEqNld = 0 ; vYpEeEqNld < 3 ; vYpEeEqNld ++ ) nums [ vYpEeEqNld ] = sc . nextInt ( ) ; Arrays . sort ( nums ) ; int cost = 0 ; for ( int vYpEeEqNld = 1 ; vYpEeEqNld < 3 ; vYpEeEqNld ++ ) cost += nums [ vYpEeEqNld ] - nums [ vYpEeEqNld - 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 yCExgKpHog { static class yCExgKpHog { 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 yCExgKpHog = 1 ; long ans = 0 , mod = 1000000007 ; while ( yCExgKpHog -- > 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 NMtOUbjteK { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner stdin = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ ] ; for ( int NMtOUbjteK = 0 ; NMtOUbjteK < 3 ; NMtOUbjteK ++ ) { c [ NMtOUbjteK ] = new int [ 3 ] ; for ( int j = 0 ; j < 3 ; j ++ ) { c [ NMtOUbjteK ] [ 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 njwRsxtTFO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int njwRsxtTFO = Integer . parseInt ( sc . next ( ) ) ; int [ ] l = new int [ njwRsxtTFO ] ; for ( int i = 0 ; i < njwRsxtTFO ; 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 PfJnvGcMpz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long PfJnvGcMpz = sc . nextLong ( ) ; sc . close ( ) ; long p = 1 ; long sum = 0 ; for ( int i = 0 ; i < PfJnvGcMpz ; i ++ ) { if ( p % 5 == 0 || p % 3 == 0 ) { p ++ ; continue ; } else { sum += p ; p ++ ; } } System . out . println ( sum ) ; } } import java . util . * ; public class mSphegtLDt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long mSphegtLDt = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long ans1 = Math . max ( mSphegtLDt , b ) * Math . max ( c , d ) ; long ans2 = Math . min ( mSphegtLDt , b ) * Math . max ( c , d ) ; long ans3 = Math . max ( mSphegtLDt , b ) * Math . min ( c , d ) ; long ans4 = Math . min ( mSphegtLDt , 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 whNzNftBnQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long whNzNftBnQ = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; if ( whNzNftBnQ - c < 0 && whNzNftBnQ + b >= c ) { System . out . println ( " 0 " + ( b - ( c - whNzNftBnQ ) ) ) ; } else if ( whNzNftBnQ + b <= c ) { System . out . println ( " 0 0 " ) ; } else { System . out . println ( whNzNftBnQ - c + " " + b ) ; } } } import java . util . Scanner ; public class rlontUaQYS { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int rlontUaQYS = sc . nextInt ( ) ; int c = 0 ; for ( int i = 0 ; i < rlontUaQYS ; i ++ ) { if ( PNcheck ( sc . nextInt ( ) ) ) c ++ ; } System . out . println ( c ) ; } static boolean PNcheck ( int rlontUaQYS ) { if ( rlontUaQYS == 2 ) return true ; if ( ( rlontUaQYS % 2 ) == 0 ) return false ; for ( int i = 3 ; i * i <= rlontUaQYS ; i = i + 2 ) { if ( ( rlontUaQYS % i ) == 0 ) return false ; } return true ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; class xxQQzrQZEo { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static String S , T ; static int xxQQzrQZEo = 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 ) { xxQQzrQZEo ++ ; } } System . out . println ( xxQQzrQZEo ) ; } } import java . util . * ; public class shTArMCFbp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double shTArMCFbp = scanner . nextDouble ( ) ; System . out . println ( String . format ( " %.6f " , Math . pow ( shTArMCFbp / 3 , 3 ) ) ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class jMatJQYbLT { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int jMatJQYbLT = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; sc . close ( ) ; R = Math . min ( jMatJQYbLT + 2019 , R ) ; int ans = Integer . MAX_VALUE ; for ( int x = jMatJQYbLT ; 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 HioCvhUBpE { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int HioCvhUBpE = scn . nextInt ( ) ; int d = scn . nextInt ( ) ; int [ ] [ ] dot = new int [ HioCvhUBpE ] [ d ] ; int answer = 0 ; for ( int i = 0 ; i < HioCvhUBpE ; i ++ ) { for ( int j = 0 ; j < d ; j ++ ) { dot [ i ] [ j ] = scn . nextInt ( ) ; } } for ( int i = 0 ; i < HioCvhUBpE ; i ++ ) { for ( int j = i + 1 ; j < HioCvhUBpE ; 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 NTOWgJfyhg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String NTOWgJfyhg = sc . next ( ) ; if ( NTOWgJfyhg . 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 KEHIOvhXaY { 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 KEHIOvhXaY = 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 AFqdWgKDjP { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int AFqdWgKDjP = scn . nextInt ( ) ; int a = scn . nextInt ( ) ; int b = scn . nextInt ( ) ; for ( ; a <= b ; a ++ ) { if ( a % AFqdWgKDjP == 0 ) { System . out . printf ( " OK \n " ) ; return ; } } System . out . printf ( " NG \n " ) ; } } import java . util . * ; class DVpCUrsQee { public Main ( ) { int DVpCUrsQee ; String S ; HashMap < String , Integer > HM = new HashMap < String , Integer > ( ) ; Scanner scanner = new Scanner ( System . in ) ; DVpCUrsQee = scanner . nextInt ( ) ; for ( int i = 0 ; i < DVpCUrsQee ; 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 RroGZuHSDb { 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 RroGZuHSDb = Integer . parseInt ( line [ 0 ] ) ; int q = Integer . parseInt ( line [ 1 ] ) ; Queue < String [ ] > queue = new ArrayDeque < String [ ] > ( ) ; for ( int i = 0 ; i < RroGZuHSDb ; 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 GwMsNYaAEW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GwMsNYaAEW = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] A = new int [ GwMsNYaAEW ] ; 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 < GwMsNYaAEW ; i ++ ) { if ( 0 < A [ i ] + K - Q ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } } out . flush ( ) ; } } import java . util . Scanner ; public class IvXCqOnFUj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] country = new int [ sc . nextInt ( ) ] ; int IvXCqOnFUj = sc . nextInt ( ) ; for ( int i = 0 ; i < IvXCqOnFUj ; 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 czsQxgMZit { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int czsQxgMZit = Integer . parseInt ( sc . next ( ) ) ; int [ ] d = new int [ czsQxgMZit ] ; for ( int i = 0 ; i < czsQxgMZit ; i ++ ) { d [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int sum = 0 ; for ( int i = 0 ; i < czsQxgMZit - 1 ; i ++ ) { for ( int j = i + 1 ; j < czsQxgMZit ; j ++ ) { sum += d [ i ] * d [ j ] ; } } System . out . println ( sum ) ; } } import java . util . * ; public class RPnxVHsHUl { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int RPnxVHsHUl = s . nextInt ( ) ; int [ ] An = new int [ RPnxVHsHUl ] ; int ans = 0 ; for ( int i = 0 ; i < RPnxVHsHUl ; i ++ ) { An [ i ] = s . nextInt ( ) ; } Arrays . sort ( An ) ; ans = An [ RPnxVHsHUl - 1 ] - An [ 0 ] ; System . out . print ( ans ) ; } } import java . util . Scanner ; public class QyXPMWZCkZ { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; boolean QyXPMWZCkZ = scanner . QyXPMWZCkZ ( ) ; 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 SjTVafuzfb { 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 SjTVafuzfb = Integer . parseInt ( s . substring ( 0 , 2 ) ) ; int a2 = Integer . parseInt ( s . substring ( 2 , 4 ) ) ; boolean m1 = false ; if ( 1 <= SjTVafuzfb && SjTVafuzfb <= 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 sIhhmyiBMP { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner scanner = new Scanner ( System . in ) ; int sIhhmyiBMP = scanner . nextInt ( ) ; String s = scanner . next ( ) ; System . out . println ( rotN ( sIhhmyiBMP , s ) ) ; } private static String rotN ( int sIhhmyiBMP , String s ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { sb . append ( rot ( sIhhmyiBMP , s . charAt ( i ) ) ) ; } return sb . toString ( ) ; } private static char rot ( int sIhhmyiBMP , char ch ) { int code = ( int ) ch - 'A' ; return ( char ) ( ( ( code + sIhhmyiBMP ) % 26 ) + 'A' ) ; } } import java . util . * ; public class DkWVGUfzFc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; List < Integer > primes = primeList ( 200 ) ; int DkWVGUfzFc = 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 <= DkWVGUfzFc ; 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 YMdYFwrYDi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double YMdYFwrYDi = sc . nextDouble ( ) ; double h = sc . nextDouble ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; double s = YMdYFwrYDi * h / 2.0 ; int e ; if ( x == YMdYFwrYDi / 2 && y == h / 2 && YMdYFwrYDi % 2 == 0 && h % 2 == 0 ) { e = 1 ; } else { e = 0 ; } System . out . println ( s ) ; System . out . println ( e ) ; } } public class HHygkpKFhp { protected static String calc ( String input ) { final int HHygkpKFhp = Integer . parseInt ( input ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i <= HHygkpKFhp ; 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 gphitOsMmh { 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 gphitOsMmh = Integer . parseInt ( ab [ 0 ] ) ; int b = Integer . parseInt ( ab [ 1 ] ) ; if ( gphitOsMmh < b ) System . out . println ( " a < b " ) ; if ( gphitOsMmh > b ) System . out . println ( " a > b " ) ; if ( gphitOsMmh == b ) System . out . println ( " a == b " ) ; } } import java . util . * ; public class QtQYPvdHQC { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int QtQYPvdHQC = sc . nextInt ( ) ; int leg = sc . nextInt ( ) ; for ( int i = 0 ; i < QtQYPvdHQC + 1 ; i ++ ) { if ( ( i * 2 + ( QtQYPvdHQC - i ) * 4 ) == leg ) { System . out . println ( " Yes " ) ; System . exit ( 0 ) ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; class MuhpGiWAIN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MuhpGiWAIN = sc . nextInt ( ) ; int [ ] [ ] A = new int [ 2 ] [ MuhpGiWAIN ] ; int [ ] sum = new int [ MuhpGiWAIN ] ; int x = 0 , y = 0 , collect = 0 , max = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < MuhpGiWAIN ; j ++ ) { A [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int j = 0 ; j < MuhpGiWAIN ; j ++ ) { for ( int i = 0 ; i < MuhpGiWAIN ; 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 kuXaHQcNCK { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int kuXaHQcNCK = Integer . parseInt ( sc . next ( ) ) ; int cnt = 0 ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 1 ; i <= kuXaHQcNCK ; i ++ ) { if ( i % 2 != 0 ) { for ( int j = 1 ; j <= kuXaHQcNCK ; 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 TghtykLQse { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int TghtykLQse = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String u = sc . next ( ) ; if ( s . equals ( u ) ) { System . out . println ( ( TghtykLQse - 1 ) + " " + b ) ; } else if ( t . contains ( u ) ) { System . out . println ( TghtykLQse + " " + ( b - 1 ) ) ; } sc . close ( ) ; } } import java . util . * ; import java . lang . * ; public class yHvCsRruGa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yHvCsRruGa = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < 40 ; i ++ ) { if ( yHvCsRruGa >= K ) { count ++ ; yHvCsRruGa = yHvCsRruGa / K ; } else { break ; } } System . out . println ( count + 1 ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class VisiauugAv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String VisiauugAv = sc . next ( ) ; if ( VisiauugAv . equals ( " Sunny " ) ) System . out . println ( " Cloudy " ) ; else if ( VisiauugAv . equals ( " Cloudy " ) ) System . out . println ( " Rainy " ) ; else if ( VisiauugAv . equals ( " Rainy " ) ) System . out . println ( " Sunny " ) ; } } import java . util . * ; public class PgekUghEzL { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int PgekUghEzL = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; String ans = " " ; if ( y % 2 != 0 ) { ans = " No " ; } else { if ( ( y / 2 ) >= PgekUghEzL && PgekUghEzL >= ( ( y / 4 ) + ( y % 4 / 2 ) ) ) { ans = " Yes " ; } else { ans = " No " ; } } System . out . println ( ans ) ; } } } import java . util . * ; class AyLuiMrwZS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AyLuiMrwZS = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int count = 0 ; do { count ++ ; AyLuiMrwZS -= a ; if ( AyLuiMrwZS <= 0 ) { System . out . println ( count ) ; } } while ( AyLuiMrwZS > 0 ) ; } } import java . util . * ; class GJhEQRSCaK { long GJhEQRSCaK ; long a = 0 ; long b = 0 ; final long START_DISTANCE_FROM_ORIGIN = 2 ; public Problem ( long GJhEQRSCaK ) { this . GJhEQRSCaK = GJhEQRSCaK ; } public void solve ( ) { for ( long i = 1 ; i * i <= GJhEQRSCaK ; i ++ ) if ( GJhEQRSCaK % i == 0 ) update ( i ) ; } private void update ( long i ) { a = i ; b = GJhEQRSCaK / i ; } public void show ( ) { System . out . println ( a + b - START_DISTANCE_FROM_ORIGIN ) ; } } public class GJhEQRSCaK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long GJhEQRSCaK = sc . nextLong ( ) ; Problem p = new Problem ( GJhEQRSCaK ) ; p . solve ( ) ; p . show ( ) ; } } import java . util . * ; public class nFGLXwPiVV { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; final int nFGLXwPiVV = scan . nextInt ( ) ; String [ ] words = new String [ nFGLXwPiVV ] ; for ( int i = 0 ; i < nFGLXwPiVV ; 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 < nFGLXwPiVV ; 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 plSQqFVCux { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String num = sc . next ( ) ; String [ ] splitNum = num . split ( " " , 0 ) ; int plSQqFVCux = Integer . parseInt ( num ) ; int N = 0 ; for ( int i = 0 ; i < num . length ( ) ; i ++ ) { N += Integer . parseInt ( splitNum [ i ] ) ; } System . out . println ( plSQqFVCux % N == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class ZwXNFLcUfH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int ZwXNFLcUfH = 0 ; ZwXNFLcUfH < 3 ; ZwXNFLcUfH ++ ) { a [ ZwXNFLcUfH ] = 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 avTuUBJqSI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int avTuUBJqSI = sc . nextInt ( ) , n = sc . nextInt ( ) , a , b , z ; int [ ] amida = new int [ avTuUBJqSI ] ; for ( int i = 0 ; i < avTuUBJqSI ; 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 < avTuUBJqSI ; i ++ ) System . out . println ( amida [ i ] ) ; sc . close ( ) ; } } import java . util . * ; public class gaoHwAwaWY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gaoHwAwaWY = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int ans = 0 ; int sum = 0 ; for ( int i = 0 ; i <= gaoHwAwaWY ; i ++ ) { for ( int j = 0 ; j <= gaoHwAwaWY ; j ++ ) { sum = S - ( i + j ) ; if ( 0 <= sum && sum <= gaoHwAwaWY ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class cjtxOiSZcZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cjtxOiSZcZ = sc . nextInt ( ) ; int [ ] b = new int [ cjtxOiSZcZ - 1 ] ; int sum = 0 ; for ( int i = 0 ; i < cjtxOiSZcZ - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } sum += b [ 0 ] ; for ( int i = 1 ; i < cjtxOiSZcZ - 1 ; i ++ ) { sum += min ( b [ i - 1 ] , b [ i ] ) ; } sum += b [ cjtxOiSZcZ - 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 dzNLgXlvmd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int dzNLgXlvmd = scanner . nextInt ( ) ; int [ ] arr = new int [ dzNLgXlvmd ] ; for ( int i = 0 ; i < dzNLgXlvmd ; 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 zCswnKiwkM { 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 zCswnKiwkM = str . split ( " " ) . length ; if ( zCswnKiwkM > 0 ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } } import java . util . * ; import java . io . * ; import java . math . BigDecimal ; public class lfsnVIgzuV { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int lfsnVIgzuV = fs . nextInt ( ) ; double y = ( double ) lfsnVIgzuV / 3 ; BigDecimal x = BigDecimal . valueOf ( y ) ; BigDecimal ans = x . multiply ( x ) ; ans = ans . multiply ( x ) ; System . out . printf ( " %.12f " , ans ) ; } static class lfsnVIgzuV { 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 uywvIYEpIf { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int uywvIYEpIf = 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 = uywvIYEpIf - sum + first ; if ( saigo > max ) { max = saigo ; } System . out . println ( uywvIYEpIf - max ) ; } } import java . util . * ; public class rQWQfrZhFJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rQWQfrZhFJ = 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 PAzpMYppxQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PAzpMYppxQ = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; int left = Math . max ( X - ( PAzpMYppxQ - 1 ) , - 1000000 ) ; int right = Math . min ( X + ( PAzpMYppxQ - 1 ) , 1000000 ) ; for ( int i = left ; i <= right ; i ++ ) { sb . append ( i ) ; sb . append ( " " ) ; } System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; class EJeJZDaBDP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EJeJZDaBDP = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; double A = ( t - a ) * 1000 / 6.0 ; double [ ] h = new double [ EJeJZDaBDP ] ; for ( int i = 0 ; i < EJeJZDaBDP ; i ++ ) { h [ i ] = Math . abs ( sc . nextInt ( ) - A ) ; } int idx = 0 ; for ( int i = 1 ; i < EJeJZDaBDP ; i ++ ) { if ( h [ i ] < h [ idx ] ) { idx = i ; } } System . out . println ( idx + 1 ) ; } } import java . util . Scanner ; public class hXaKPvAjDJ { public static void main ( String [ ] args ) { Scanner in = new java . util . Scanner ( System . in ) ; int hXaKPvAjDJ = in . nextInt ( ) ; int N = in . nextInt ( ) ; if ( hXaKPvAjDJ == 0 ) { if ( N == 100 ) { System . out . print ( N + 1 ) ; } else { System . out . print ( N ) ; } } else if ( hXaKPvAjDJ == 1 ) { if ( N == 100 ) { System . out . print ( 100 * ( N + 1 ) ) ; } else { System . out . print ( 100 * N ) ; } } else if ( hXaKPvAjDJ == 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 TGbbxFtPIw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; boolean TGbbxFtPIw = false ; for ( int i = 1 ; i < n . length ( ) ; i ++ ) { if ( n . charAt ( i ) > n . charAt ( 0 ) ) { TGbbxFtPIw = true ; break ; } } String ans = " " ; if ( TGbbxFtPIw ) { 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 KjRdTeUZZx { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String h = sc . nextLine ( ) ; String s = sc . nextLine ( ) ; int KjRdTeUZZx = Integer . parseInt ( h ) ; int len = String . valueOf ( s ) . length ( ) ; if ( len <= KjRdTeUZZx ) { System . out . println ( s ) ; } else { for ( int i = 0 ; i < KjRdTeUZZx ; i ++ ) { System . out . print ( s . charAt ( i ) ) ; } System . out . print ( " ... " ) ; } } } import java . util . Scanner ; class UNXoaASuXt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UNXoaASuXt = sc . nextInt ( ) ; double x ; if ( UNXoaASuXt % 2 == 0 ) x = 1.0 / 2.0 ; else x = ( double ) ( UNXoaASuXt / 2 + 1 ) / ( double ) UNXoaASuXt ; System . out . println ( x ) ; } } import java . util . Scanner ; public class NxAMteshTE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NxAMteshTE = sc . nextInt ( ) ; int [ ] r = new int [ NxAMteshTE ] ; int maxv = - 999999999 ; for ( int i = 0 ; i < r . length ; i ++ ) { r [ i ] = sc . nextInt ( ) ; } int minv = r [ 0 ] ; for ( int i = 1 ; i < NxAMteshTE ; 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 bxupcjMbnM { public static void main ( String [ ] args ) { try { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String sStr = stdReader . readLine ( ) ; String [ ] inputStr = sStr . split ( " " ) ; int bxupcjMbnM = 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 ( bxupcjMbnM >= 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 WhRtBFGApp { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int WhRtBFGApp , side , area , circum ; WhRtBFGApp = sc . nextInt ( ) ; side = sc . nextInt ( ) ; area = WhRtBFGApp * side ; circum = ( WhRtBFGApp + side ) * 2 ; System . out . println ( area + " " + circum ) ; } } import java . util . * ; public class DLRxnPTMND { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long DLRxnPTMND = 0 ; while ( s . length ( ) > 0 ) { DLRxnPTMND += Integer . parseInt ( s . substring ( 0 , 1 ) ) ; s = s . substring ( 1 ) ; } System . out . println ( DLRxnPTMND % 9 == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class feHPGgCIDf { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int feHPGgCIDf , B , T ; feHPGgCIDf = sc . nextInt ( ) ; B = sc . nextInt ( ) ; T = sc . nextInt ( ) ; int sum = 0 ; for ( int time = 1 ; time <= T ; time ++ ) { if ( time % feHPGgCIDf == 0 ) { sum += B ; } } System . out . println ( sum ) ; } catch ( Exception e ) { } } } import java . util . * ; class bAohPnJijd { public static void main ( String [ ] args ) { Scanner obj = new Scanner ( System . in ) ; int bAohPnJijd = obj . nextInt ( ) ; int m = obj . nextInt ( ) ; int [ ] a = new int [ bAohPnJijd ] ; for ( int i = 0 ; i < bAohPnJijd ; 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 nAwHQDoYTR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nAwHQDoYTR = sc . nextInt ( ) ; int [ ] a = new int [ nAwHQDoYTR ] ; int max = 0 ; int m = 0 ; for ( int i = 0 ; i < nAwHQDoYTR ; 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 hrkovUdtaw { Scanner scan = new Scanner ( System . in ) ; void compute ( ) { int hrkovUdtaw = scan . nextInt ( ) ; int D = scan . nextInt ( ) ; double x = ( double ) hrkovUdtaw / ( double ) ( 2 * D + 1 ) ; int y = hrkovUdtaw / ( 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 depDDAJhKN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int depDDAJhKN = sc . nextInt ( ) ; double [ ] data = new double [ 1000 ] ; int v ; double temp ; double lenkin ; for ( int i = 0 ; i < depDDAJhKN ; i ++ ) { v = sc . nextInt ( ) ; data [ i ] = v ; } for ( int i = 0 ; i < depDDAJhKN ; i ++ ) { for ( int j = i + 1 ; j < depDDAJhKN ; 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 < depDDAJhKN ; i ++ ) { lenkin = ( lenkin + data [ i ] ) / 2 ; } System . out . println ( lenkin ) ; } } import java . util . * ; public class cCZqdaRwtN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cCZqdaRwtN = 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 > cCZqdaRwtN ) { break ; } if ( max < exp ) { max = ( int ) exp ; } } } System . out . println ( max ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class fLIZSlQCFF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fLIZSlQCFF = Integer . parseInt ( sc . next ( ) ) ; int [ ] l = new int [ fLIZSlQCFF ] ; for ( int i = 0 ; i < fLIZSlQCFF ; i ++ ) { l [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( l ) ; int x = 0 ; for ( int i = 0 ; i < fLIZSlQCFF - 1 ; i ++ ) { x += l [ i ] ; } if ( l [ fLIZSlQCFF - 1 ] < x ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class jZEzqRgkVN { public static void main ( String [ ] args ) { int jZEzqRgkVN , k = 0 ; int [ ] A = new int [ 100 ] ; Scanner stdIn = new Scanner ( System . in ) ; jZEzqRgkVN = stdIn . nextInt ( ) ; for ( int i = 0 ; i < jZEzqRgkVN ; i ++ ) { A [ i ] = stdIn . nextInt ( ) ; } k = bubbleSort ( jZEzqRgkVN , A ) ; trace ( jZEzqRgkVN , A , k ) ; } public static void trace ( int jZEzqRgkVN , int [ ] A , int k ) { for ( int i = 0 ; i < jZEzqRgkVN ; i ++ ) { if ( i > 0 ) System . out . print ( " " ) ; System . out . print ( A [ i ] ) ; } System . out . println ( ) ; System . out . println ( k ) ; } public static int bubbleSort ( int jZEzqRgkVN , int [ ] A ) { int k = 0 ; for ( int i = 0 ; i < jZEzqRgkVN - 1 ; i ++ ) { for ( int j = jZEzqRgkVN - 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 nFWSeRVoKR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nFWSeRVoKR = sc . nextInt ( ) ; Integer [ ] p = new Integer [ nFWSeRVoKR ] ; for ( int i = 0 ; i < nFWSeRVoKR ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int i = 1 ; i < nFWSeRVoKR - 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 bDVQnjCQcq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bDVQnjCQcq = sc . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= bDVQnjCQcq ; i ++ ) { for ( int j = 1 ; j <= bDVQnjCQcq ; j ++ ) { for ( int t = 1 ; t <= bDVQnjCQcq ; 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 gURorTapqs { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String gURorTapqs = in . nextLine ( ) ; char [ ] array = gURorTapqs . toCharArray ( ) ; array [ 3 ] = '8' ; System . out . println ( array ) ; } } import java . util . * ; public class dvcqTjLMfE { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int dvcqTjLMfE = sc . nextInt ( ) ; long [ ] H = new long [ dvcqTjLMfE ] ; int counter = 0 ; int countMax = 0 ; for ( int i = 0 ; i < dvcqTjLMfE ; 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 COtvppqVAE { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int COtvppqVAE = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; scan . close ( ) ; if ( ( 1 <= COtvppqVAE && COtvppqVAE < 10 ) && ( 1 <= b && b < 10 ) ) System . out . println ( COtvppqVAE * b ) ; else System . out . println ( - 1 ) ; } } import java . util . Scanner ; class wmPwEMSvBA { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int wmPwEMSvBA , a , b ; wmPwEMSvBA = sc . nextInt ( ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; int sum = 0 , ans = 0 ; for ( int i = 0 ; i <= wmPwEMSvBA ; 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 JvMkgkisHf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String y = sc . next ( ) ; String j = sc . next ( ) ; int JvMkgkisHf = 0 ; for ( int i = 0 ; i < y . length ( ) ; i ++ ) { if ( y . charAt ( i ) == j . charAt ( i ) ) { JvMkgkisHf += 1 ; } } System . out . println ( JvMkgkisHf ) ; } } import java . util . * ; public class piJTHkDjuT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ans = " No " ; String s = sc . next ( ) ; String t = sc . next ( ) ; int piJTHkDjuT = s . length ( ) ; int temp = 0 ; int count = 0 ; for ( int i = 0 ; i < piJTHkDjuT ; i ++ ) { for ( int j = 0 ; j < piJTHkDjuT ; j ++ ) { if ( s . charAt ( j ) != t . charAt ( ( j + temp ) % piJTHkDjuT ) ) { temp ++ ; count = 0 ; break ; } else { count ++ ; } } if ( count == piJTHkDjuT ) { ans = " Yes " ; break ; } } System . out . println ( ans ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class XHhZpKHvJI { 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 XHhZpKHvJI = false ; while ( sc . hasNextLine ( ) ) { word = sc . nextLine ( ) ; if ( ! wordSet . add ( word ) ) { XHhZpKHvJI = true ; break ; } if ( prevWord != null ) { boolean chained = ( prevWord . charAt ( prevWord . length ( ) - 1 ) == word . charAt ( 0 ) ) ; if ( ! chained ) { XHhZpKHvJI = true ; break ; } } prevWord = word ; } System . out . println ( XHhZpKHvJI ? " No " : " Yes " ) ; } } import java . util . * ; public class AKbLxIZnYa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AKbLxIZnYa = Integer . parseInt ( sc . nextLine ( ) ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < AKbLxIZnYa ; 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 < AKbLxIZnYa ; i ++ ) { check = false ; if ( i == 0 ) { t = list . get ( i ) ; count ++ ; continue ; } u = list . get ( i ) ; if ( t . equals ( u ) && i < AKbLxIZnYa - 1 ) { count ++ ; } else if ( t . equals ( u ) && i == AKbLxIZnYa - 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 dIKkcBGPvF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dIKkcBGPvF = sc . nextInt ( ) ; int ans = dIKkcBGPvF % 1000 ; if ( ans != 0 ) { ans = 1000 - ans ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class AdJczXCNec { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int AdJczXCNec = scan . nextInt ( ) ; int [ ] a = new int [ AdJczXCNec ] ; int [ ] b = new int [ AdJczXCNec ] ; int [ ] c = new int [ AdJczXCNec ] ; for ( int i = 0 ; i < AdJczXCNec ; i ++ ) { a [ i ] = scan . nextInt ( ) - 1 ; } for ( int i = 0 ; i < AdJczXCNec ; i ++ ) { b [ i ] = scan . nextInt ( ) ; } for ( int i = 1 ; i < AdJczXCNec ; i ++ ) { c [ i ] = scan . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < AdJczXCNec ; 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 LaMHtuixvY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int LaMHtuixvY = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '+' ) { LaMHtuixvY = LaMHtuixvY + 1 ; } else { LaMHtuixvY = LaMHtuixvY - 1 ; } } System . out . println ( LaMHtuixvY ) ; } } import java . io . * ; public class XOQDHiZqqp { 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 XOQDHiZqqp = Integer . parseInt ( ra [ 0 ] ) ; int y = Integer . parseInt ( ra [ 1 ] ) ; int d , r ; String f = String . format ( " %.5f " , ( double ) XOQDHiZqqp / ( double ) y ) ; d = XOQDHiZqqp / y ; y = XOQDHiZqqp % y ; System . out . printf ( d + " " + y + " " + f ) ; } } import java . util . Scanner ; public class bybqpWKjgY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bybqpWKjgY = sc . nextInt ( ) ; int [ ] a = new int [ bybqpWKjgY ] ; int j = 1 ; for ( int i = 0 ; i < bybqpWKjgY ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( j == a [ i ] ) { j ++ ; } } if ( j == 1 ) { System . out . println ( - 1 ) ; return ; } System . out . println ( bybqpWKjgY - j + 1 ) ; } } import java . util . Scanner ; public class IOhHFSIRNj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int IOhHFSIRNj = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( IOhHFSIRNj == 0 && W == 0 ) break ; for ( int i = 1 ; i <= IOhHFSIRNj ; i ++ ) { if ( i == 1 || i == IOhHFSIRNj ) { 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 vYdAUXWzjE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int vYdAUXWzjE = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( vYdAUXWzjE == 0 && W == 0 ) break ; for ( int i = 1 ; i <= vYdAUXWzjE ; 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 JnciafWbOk { public static void main ( String [ ] args ) { int JnciafWbOk , 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 ( JnciafWbOk = 0 ; JnciafWbOk < n ; JnciafWbOk ++ ) array [ JnciafWbOk ] = 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 LeZoeKnqkB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LeZoeKnqkB = sc . nextInt ( ) ; int be = sc . nextInt ( ) ; int ans = 0 ; boolean check1 = false , check2 = false ; for ( int i = 1 ; i < LeZoeKnqkB ; 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 UzBwhnBfAN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UzBwhnBfAN = sc . nextInt ( ) ; int [ ] a = new int [ UzBwhnBfAN ] ; for ( int i = 0 ; i < UzBwhnBfAN ; ++ 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 < UzBwhnBfAN ; ++ i ) { if ( t == a [ i ] ) { an = 1 ; break ; } t = a [ i ] ; } System . out . println ( ans [ an ] ) ; } } import java . io . * ; import java . util . * ; public class nioEkGXynE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nioEkGXynE = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ nioEkGXynE ] ; 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 < nioEkGXynE ; 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 < nioEkGXynE ; i ++ ) { System . out . println ( a [ i ] ) ; } } } import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class RrmYxDbDAJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int RrmYxDbDAJ = sc . nextInt ( ) ; int [ ] [ ] a = new int [ 2 ] [ RrmYxDbDAJ + 1 ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 1 ; j <= RrmYxDbDAJ ; j ++ ) { a [ i ] [ j ] = a [ i ] [ j - 1 ] + sc . nextInt ( ) ; } } int ans = 0 ; for ( int i = 1 ; i <= RrmYxDbDAJ ; i ++ ) { for ( int j = 1 ; j <= RrmYxDbDAJ ; j ++ ) { ans = max ( ans , a [ 0 ] [ i ] + ( a [ 1 ] [ RrmYxDbDAJ ] - a [ 1 ] [ i - 1 ] ) ) ; } } out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class iMFokvHkaD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iMFokvHkaD = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int count = 0 ; for ( int i = iMFokvHkaD ; 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 GEhLldsmhT { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int GEhLldsmhT = scan . nextInt ( ) ; int [ ] num = new int [ GEhLldsmhT ] ; boolean t ; int count = 0 ; for ( int i = 0 ; i < GEhLldsmhT ; 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 KoTavfVyuP { public static void main ( String [ ] args ) { int KoTavfVyuP , point1 = 0 , point2 = 0 ; String card1 , card2 ; Scanner sc = new Scanner ( System . in ) ; KoTavfVyuP = sc . nextInt ( ) ; for ( int i = 0 ; i < KoTavfVyuP ; 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 nSuyLtghqG { public static void main ( String ... args ) { int nSuyLtghqG = new java . util . Scanner ( System . in ) . nextInt ( ) ; int sum = nSuyLtghqG * nSuyLtghqG * nSuyLtghqG ; System . out . println ( sum ) ; } } import java . io . * ; import java . util . Scanner ; public class CoQcsMduLb { public static void main ( String [ ] args ) { int CoQcsMduLb ; 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 ( CoQcsMduLb = i + 1 ; CoQcsMduLb < 10 ; CoQcsMduLb ++ ) if ( height [ i ] > height [ CoQcsMduLb ] ) { int temp = height [ i ] ; height [ i ] = height [ CoQcsMduLb ] ; height [ CoQcsMduLb ] = 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 gVPNSxTWDn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long gVPNSxTWDn = sc . nextInt ( ) ; long a = gVPNSxTWDn / 500 ; gVPNSxTWDn %= 500 ; long b = gVPNSxTWDn / 5 ; System . out . println ( 1000 * a + ( 5 * b ) ) ; } } import java . util . Scanner ; public class weWpCfHCqq { public static void main ( String [ ] args ) { Scanner Ahmad = new Scanner ( System . in ) ; int weWpCfHCqq , y ; weWpCfHCqq = Ahmad . nextInt ( ) ; y = Ahmad . nextInt ( ) ; if ( ( weWpCfHCqq + y ) % 2 == 0 ) { System . out . println ( ( weWpCfHCqq + y ) / 2 ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . io . IOException ; import java . util . Scanner ; class mhhfGJzxgz { public static void main ( String [ ] args ) throws IOException { Scanner scane = new Scanner ( System . in ) ; int mhhfGJzxgz = 0 , f = 0 , r = 0 ; int sum = 0 ; mhhfGJzxgz = scane . nextInt ( ) ; f = scane . nextInt ( ) ; r = scane . nextInt ( ) ; while ( ( mhhfGJzxgz + f + r ) != - 3 ) { sum = mhhfGJzxgz + f ; if ( mhhfGJzxgz == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } if ( ( mhhfGJzxgz != - 1 && f != - 1 ) && sum >= 80 ) { System . out . println ( " A " ) ; } else if ( ( mhhfGJzxgz != - 1 && f != - 1 ) && sum < 80 && sum >= 65 ) { System . out . println ( " B " ) ; } else if ( ( mhhfGJzxgz != - 1 && f != - 1 ) && sum < 65 && sum >= 50 ) { System . out . println ( " C " ) ; } else if ( ( mhhfGJzxgz != - 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 " ) ; } mhhfGJzxgz = scane . nextInt ( ) ; f = scane . nextInt ( ) ; r = scane . nextInt ( ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class uJUnlVDbrU { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; char uJUnlVDbrU ; StringBuilder build = new StringBuilder ( ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { uJUnlVDbrU = str . charAt ( i ) ; if ( Character . isLowerCase ( uJUnlVDbrU ) ) { build . append ( Character . toUpperCase ( uJUnlVDbrU ) ) ; } else { build . append ( Character . toLowerCase ( uJUnlVDbrU ) ) ; } } System . out . print ( build . toString ( ) + " \n " ) ; } } import java . util . * ; public class UCejhohDfe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Queue < String > name_queue = new ArrayDeque < > ( ) ; Queue < Integer > queue = new ArrayDeque < > ( ) ; int UCejhohDfe = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; for ( int i = 0 ; i < UCejhohDfe ; 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 qfYPsuysCt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qfYPsuysCt = sc . nextInt ( ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; String ans = " " ; for ( int i = 0 ; i < qfYPsuysCt ; i ++ ) { ans = ans + s1 . charAt ( i ) + s2 . charAt ( i ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class rJLPERDmhm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String input = scanner . nextLine ( ) ; String [ ] inputs = input . split ( " " ) ; int rJLPERDmhm = Integer . parseInt ( inputs [ 0 ] ) ; int x = Integer . parseInt ( inputs [ 1 ] ) ; String lineStr = scanner . nextLine ( ) ; String [ ] lines = lineStr . split ( " " ) ; int [ ] line = new int [ rJLPERDmhm ] ; for ( int i = 0 ; i < rJLPERDmhm ; i ++ ) { line [ i ] = Integer . parseInt ( lines [ i ] ) ; } int answer = 1 ; int distance = 0 ; for ( int i = 0 ; i < rJLPERDmhm ; i ++ ) { distance = distance + line [ i ] ; if ( distance > x ) { break ; } answer ++ ; } System . out . println ( answer ) ; scanner . close ( ) ; } } import java . util . Scanner ; public class VaGtHfHhph { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int VaGtHfHhph = scan . nextInt ( ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int ans = VaGtHfHhph * a ; if ( ans < b ) { System . out . println ( ans ) ; } else { System . out . println ( b ) ; } } } import java . util . Scanner ; import java . util . Arrays ; public class fHUTBcJzGd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fHUTBcJzGd = sc . nextInt ( ) ; int [ ] b = new int [ fHUTBcJzGd ] ; 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 FfPizwobKx { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; String FfPizwobKx = scan . next ( ) ; switch ( FfPizwobKx ) { 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 uXnSeDZzDg { 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 uXnSeDZzDg = list . get ( 0 ) ; int B = list . get ( 1 ) ; if ( ( uXnSeDZzDg == 1 && B == 2 ) || ( uXnSeDZzDg == 2 && B == 1 ) ) System . out . println ( 3 ) ; else if ( ( uXnSeDZzDg == 1 && B == 3 ) || ( uXnSeDZzDg == 3 && B == 1 ) ) System . out . println ( 2 ) ; else if ( ( uXnSeDZzDg == 2 && B == 3 ) || ( uXnSeDZzDg == 3 && B == 2 ) ) System . out . println ( 1 ) ; } } import java . util . Scanner ; public class wrytFeqzjn { public static int wrytFeqzjn = 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 ( wrytFeqzjn != 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 [ wrytFeqzjn ++ ] ; } public static int intDequeue ( ) { return queue2 [ head2 ++ ] ; } } import java . util . Scanner ; public class ePnaLVMaZx { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ePnaLVMaZx = scanner . nextInt ( ) ; int [ ] a = new int [ ePnaLVMaZx ] ; int count = 0 ; int v = 1 ; int flg = 0 ; for ( int i = 0 ; i < ePnaLVMaZx ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < ePnaLVMaZx ; i ++ ) { v = a [ v - 1 ] ; count ++ ; if ( v == 2 ) { System . out . println ( count ) ; count = 0 ; break ; } } if ( count == ePnaLVMaZx ) { System . out . println ( - 1 ) ; } } } import java . util . * ; import java . io . * ; public class SswmRONSKp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter ou = new PrintWriter ( System . out ) ; int SswmRONSKp = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int [ ] s = new int [ SswmRONSKp ] ; int i ; Arrays . fill ( s , k - q ) ; for ( i = 0 ; i < q ; i ++ ) { s [ Integer . parseInt ( sc . next ( ) ) - 1 ] ++ ; } for ( i = 0 ; i < SswmRONSKp ; i ++ ) { if ( s [ i ] > 0 ) ou . print ( " Yes \n " ) ; else ou . print ( " No \n " ) ; } ou . flush ( ) ; } } import java . util . * ; public class hoqlzWjgKm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int hoqlzWjgKm = S . length ( ) ; int tmp = 0 ; String [ ] part = new String [ hoqlzWjgKm * ( hoqlzWjgKm + 1 ) / 2 ] ; for ( int i = 0 ; i < hoqlzWjgKm ; i ++ ) { for ( int j = i ; j < hoqlzWjgKm ; 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 QeyIAsAeiQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QeyIAsAeiQ = Integer . valueOf ( sc . next ( ) ) ; int b = Integer . valueOf ( sc . next ( ) ) ; int t = Integer . valueOf ( sc . next ( ) ) ; System . out . println ( t / QeyIAsAeiQ * b ) ; } } import java . util . Scanner ; public class SucOUvLejq { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { long SucOUvLejq = ( 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 > SucOUvLejq || ans < 0 ) { isOver = true ; } } if ( isOver ) { System . out . println ( " -1 " ) ; } else { System . out . println ( ans ) ; } } } } import java . util . Scanner ; public class tIJVBWtiOx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tIJVBWtiOx = sc . nextInt ( ) ; int ans = 0 ; int [ ] array = new int [ tIJVBWtiOx ] ; for ( int i = 0 ; i < tIJVBWtiOx ; 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 eJAzpKgEXx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int eJAzpKgEXx = s . length ( ) ; int m = t . length ( ) ; int count = 0 ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < eJAzpKgEXx - 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 gkCojUQsed { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; double gkCojUQsed = s . nextDouble ( ) ; double n = s . nextDouble ( ) ; double m = 0 ; for ( int i = 0 ; i < n ; i ++ ) { m += s . nextDouble ( ) ; } if ( m >= gkCojUQsed ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; public class YxCVzEHZpI { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int YxCVzEHZpI = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i < YxCVzEHZpI ; 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 WCkifSnDOX { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = input . readLine ( ) ; String answer = " " ; for ( int WCkifSnDOX = 0 ; WCkifSnDOX < str . length ( ) ; WCkifSnDOX ++ ) { if ( String . valueOf ( str . charAt ( WCkifSnDOX ) ) . equals ( " B " ) && answer . length ( ) != 0 ) { answer = answer . substring ( 0 , answer . length ( ) - 1 ) ; } else if ( String . valueOf ( str . charAt ( WCkifSnDOX ) ) . equals ( " 0 " ) || String . valueOf ( str . charAt ( WCkifSnDOX ) ) . equals ( " 1 " ) ) { answer = answer + str . charAt ( WCkifSnDOX ) ; } } System . out . println ( answer ) ; } } import java . util . * ; public class YbYoDJlxis { 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 YbYoDJlxis = 1 ; int bIndex = 0 ; int cIndex = 0 ; char tmp = a . charAt ( 0 ) ; while ( true ) { switch ( tmp ) { case 'a' : if ( a . length ( ) == YbYoDJlxis ) { System . out . println ( " A " ) ; System . exit ( 0 ) ; } tmp = a . charAt ( YbYoDJlxis ++ ) ; 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 QvmpnIxFHz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QvmpnIxFHz = 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 < QvmpnIxFHz ; i ++ ) { ans = ans + Sarray [ i ] ; ans = ans + Tarray [ i ] ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class ateBRSrQam { 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 LicYKfdMTP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String t = sc . nextLine ( ) ; int LicYKfdMTP = 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 ++ ; } LicYKfdMTP = Math . LicYKfdMTP ( LicYKfdMTP , tot ) ; } } System . out . println ( LicYKfdMTP ) ; } } import java . util . Scanner ; public class QlThdkPpSg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QlThdkPpSg = 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 ) ; } QlThdkPpSg ++ ; } } } import java . util . Scanner ; public class HvkszxMRrz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String HvkszxMRrz = sc . next ( ) ; if ( ( HvkszxMRrz . charAt ( 0 ) == HvkszxMRrz . charAt ( 1 ) ) || ( HvkszxMRrz . charAt ( 1 ) == HvkszxMRrz . charAt ( 2 ) ) || ( HvkszxMRrz . charAt ( 2 ) == HvkszxMRrz . charAt ( 3 ) ) ) { System . out . println ( " Bad " ) ; } else { System . out . println ( " Good " ) ; } } } import java . util . Scanner ; public class EyWWvOpIBi { public static void main ( String [ ] args ) { int EyWWvOpIBi = 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 [ EyWWvOpIBi ++ ] = 2 ; prime [ EyWWvOpIBi ++ ] = 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 [ EyWWvOpIBi ++ ] = 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 aCKhBXEnPP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aCKhBXEnPP = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( b == 1 ) { System . out . println ( 0 ) ; return ; } if ( b <= aCKhBXEnPP ) { System . out . println ( 1 ) ; return ; } int sum = 0 ; for ( int i = 1 ; ; i ++ ) { sum += aCKhBXEnPP ; if ( sum >= b ) { System . out . println ( i ) ; return ; } sum -= 1 ; } } } import java . util . Scanner ; public class iFAYXdJmgM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iFAYXdJmgM = Integer . parseInt ( sc . next ( ) ) ; int kR = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int [ ] np = new int [ iFAYXdJmgM ] ; 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 < iFAYXdJmgM ; j ++ ) { if ( kR - q + np [ j ] > 0 ) { sb . append ( " Yes " ) ; } else { sb . append ( " No " ) ; } if ( j < iFAYXdJmgM - 1 ) { sb . append ( " \n " ) ; } } System . out . println ( sb ) ; sc . close ( ) ; } } import java . util . * ; public class fISejoGzGG { static public void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fISejoGzGG = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] sunuke = new int [ fISejoGzGG ] ; for ( int i = 0 ; i < fISejoGzGG ; 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 < fISejoGzGG ; h ++ ) { if ( sunuke [ h ] == 0 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; public class tugXHEGUNs { public static int solve ( int n , int k , int [ ] arr ) { int [ ] dp = new int [ n ] ; for ( int tugXHEGUNs = 1 ; tugXHEGUNs < n ; tugXHEGUNs ++ ) { int ans = Integer . MAX_VALUE ; for ( int j = tugXHEGUNs - 1 ; j >= 0 && ( tugXHEGUNs - j ) <= k ; j -- ) { int diff = Math . abs ( arr [ tugXHEGUNs ] - arr [ j ] ) ; ans = Math . min ( ans , diff + dp [ j ] ) ; } dp [ tugXHEGUNs ] = 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 tugXHEGUNs = 0 ; tugXHEGUNs < n ; tugXHEGUNs ++ ) { arr [ tugXHEGUNs ] = 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 GELGHDJYSa { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String GELGHDJYSa = br . readLine ( ) ; String [ ] str2 = GELGHDJYSa . 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 rRntrNsdTU { public static void main ( String [ ] s ) { long rRntrNsdTU = 1 , a = 101 , o = new java . util . Scanner ( System . in ) . nextLong ( ) ; for ( ; a < o ; rRntrNsdTU ++ ) a += a / 100 ; System . out . print ( rRntrNsdTU ) ; } } import java . io . * ; class VZHKurXqcK { 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 VZHKurXqcK = 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 ( VZHKurXqcK >= ( 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 dBjacRHjwh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String H = sc . next ( ) ; int dBjacRHjwh = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String U = sc . next ( ) ; if ( U . equals ( S ) ) { dBjacRHjwh -- ; } else if ( U . equals ( H ) ) { B -- ; } System . out . println ( dBjacRHjwh ) ; System . out . println ( B ) ; } } import java . util . Scanner ; public class JpuDYgWsVW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JpuDYgWsVW = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int c = 0 ; for ( int x = 0 ; x <= JpuDYgWsVW ; x ++ ) { for ( int y = 0 ; y <= JpuDYgWsVW ; y ++ ) { int z = S - x - y ; if ( 0 <= z && z <= JpuDYgWsVW ) { c += 1 ; } } } System . out . println ( c ) ; } } import java . util . Scanner ; public class PlTbZizcUY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PlTbZizcUY , T , A ; PlTbZizcUY = sc . nextInt ( ) ; T = sc . nextInt ( ) ; A = sc . nextInt ( ) ; int [ ] H = new int [ PlTbZizcUY ] ; double max = 99999 ; int ans = 0 ; for ( int i = 0 ; i < PlTbZizcUY ; 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 XQrjMkpzsw { 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 XQrjMkpzsw = Integer . parseInt ( br . readLine ( ) ) ; if ( XQrjMkpzsw == 0 ) break ; int [ ] s = new int [ XQrjMkpzsw ] ; String [ ] dataset = br . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < XQrjMkpzsw ; i ++ ) { s [ i ] = Integer . parseInt ( dataset [ i ] ) ; } int goukei = 0 ; for ( int i : s ) { goukei += i ; } double m = ( double ) goukei / ( double ) XQrjMkpzsw ; double alfa2 = 0.0 ; for ( int i : s ) { alfa2 += ( i - m ) * ( i - m ) ; } alfa2 = alfa2 / XQrjMkpzsw ; double alfa = Math . sqrt ( alfa2 ) ; System . out . println ( alfa ) ; } } } import java . util . * ; import java . io . * ; public class mXERwSDzwx { public static void main ( String [ ] args ) throws Exception { FastReader s = new FastReader ( ) ; int mXERwSDzwx = s . nextInt ( ) ; long sum = 0 ; int max = Integer . MIN_VALUE ; int [ ] arr = new int [ mXERwSDzwx ] ; for ( int i = 0 ; i < mXERwSDzwx ; 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 mXERwSDzwx { 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 DyFZHETKlo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DyFZHETKlo = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( Math . max ( Math . max ( DyFZHETKlo + b , DyFZHETKlo - b ) , DyFZHETKlo * b ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class nfUvUFMZjK { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int nfUvUFMZjK = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; int min = 2018 ; if ( R - nfUvUFMZjK > 2019 ) { System . out . print ( 0 ) ; } else { int LMod = Math . floorMod ( nfUvUFMZjK , 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 evnUQvBlfk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; int evnUQvBlfk = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { evnUQvBlfk += ( Math . pow ( 10 , i ) * ( s . charAt ( 3 - i ) - 48 ) ) ; } evnUQvBlfk *= 10000 ; evnUQvBlfk += ( s . charAt ( 5 ) - 48 ) * 1000 ; evnUQvBlfk += ( s . charAt ( 6 ) - 48 ) * 100 ; evnUQvBlfk += ( s . charAt ( 8 ) - 48 ) * 10 ; evnUQvBlfk += s . charAt ( 9 ) - 48 ; if ( evnUQvBlfk < 20190431 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . Scanner ; public class FggWYTgOHB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FggWYTgOHB = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int sum = 0 ; for ( int x = FggWYTgOHB ; x <= b ; x ++ ) { if ( c % x == 0 ) { sum ++ ; } } System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . Scanner ; public class KNXgjPuYqg { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int KNXgjPuYqg = stdIn . nextInt ( ) ; int [ ] a = new int [ KNXgjPuYqg ] ; for ( int i = 0 ; i < KNXgjPuYqg ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; } long ans = 0 ; for ( int i = 1 ; i < KNXgjPuYqg ; 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 usKrsEssMr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int usKrsEssMr = sc . nextInt ( ) ; int [ ] A = new int [ usKrsEssMr ] ; for ( int i = 0 ; i < usKrsEssMr ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } bubbleSort ( A , usKrsEssMr ) ; } public static void bubbleSort ( int [ ] A , int usKrsEssMr ) { int flag = 1 , count = 0 ; while ( flag == 1 ) { flag = 0 ; int i = 0 ; for ( int j = i ; j < usKrsEssMr - 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 < usKrsEssMr ; i ++ ) { System . out . print ( A [ i ] ) ; if ( i != usKrsEssMr - 1 ) System . out . print ( " " ) ; } System . out . printf ( " \n %d \n " , count ) ; } } import java . util . Scanner ; class YAARUdukXu { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long YAARUdukXu , 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 ( ) ; } YAARUdukXu = a [ 0 ] [ 0 ] ; for ( i = 0 ; i < t ; i ++ ) YAARUdukXu = YAARUdukXu + a [ i ] [ 1 ] ; max = YAARUdukXu ; for ( i = 1 ; i < t ; i ++ ) { YAARUdukXu = YAARUdukXu - a [ i - 1 ] [ 1 ] + a [ i ] [ 0 ] ; if ( YAARUdukXu > max ) max = YAARUdukXu ; } System . out . println ( max ) ; } } import java . util . * ; public class NMtyzWPVqJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NMtyzWPVqJ = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int cnt = 0 ; while ( true ) { if ( NMtyzWPVqJ > k ) { cnt += k ; k = 0 ; break ; } else { cnt += NMtyzWPVqJ ; k -= NMtyzWPVqJ ; } 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 LiIEjoYeDA { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long LiIEjoYeDA = scan . nextLong ( ) ; long moveCnt = ( long ) Math . pow ( 10 , 18 ) ; for ( long i = 1 ; i * i <= LiIEjoYeDA ; i ++ ) { if ( LiIEjoYeDA % i != 0 ) continue ; long j = LiIEjoYeDA / i ; if ( moveCnt > i + j - 2 ) { moveCnt = i + j - 2 ; } } System . out . println ( moveCnt ) ; } } import java . util . Scanner ; public class tAPDnuTFne { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tAPDnuTFne = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] A = new int [ tAPDnuTFne ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < tAPDnuTFne ; 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 [ tAPDnuTFne ] ; for ( int i = 0 ; i < tAPDnuTFne ; 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 SeKljBTwaY { static int SeKljBTwaY ; 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 MuaFLxJoln { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MuaFLxJoln = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ MuaFLxJoln ] ; for ( int i = 0 ; i < MuaFLxJoln ; i ++ ) { A [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; Arrays . sort ( A ) ; System . out . println ( Math . abs ( A [ 0 ] - A [ MuaFLxJoln - 1 ] ) ) ; } } import java . util . Scanner ; public class CNcMfeZtzS { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; StringBuilder out ; int CNcMfeZtzS = sc . nextInt ( ) ; int [ ] a = new int [ CNcMfeZtzS ] ; 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 kCqDyrXPPN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int kCqDyrXPPN = 0 ; int h = 0 ; int t = s . length ( ) - 1 ; while ( h < t ) { if ( s . charAt ( h ) != s . charAt ( t ) ) { kCqDyrXPPN += 1 ; } h += 1 ; t -= 1 ; } System . kCqDyrXPPN . println ( kCqDyrXPPN ) ; } } import java . util . Scanner ; public class xVEKukYHwM { 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 xVEKukYHwM = Integer . parseInt ( S . substring ( 0 , 2 ) ) ; int back = Integer . parseInt ( S . substring ( 2 , 4 ) ) ; if ( isMonth ( xVEKukYHwM ) ) { 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 YKtMhnEwJr { public static void main ( String [ ] args ) throws Exception { InputStreamReader r = new InputStreamReader ( System . in ) ; long YKtMhnEwJr = nextInt ( r ) ; long B = nextInt ( r ) ; long ans = YKtMhnEwJr > B ? calcLCM ( YKtMhnEwJr , B ) : calcLCM ( B , YKtMhnEwJr ) ; 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 RYHSQGFTJN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; int RYHSQGFTJN = 0 ; int one = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '0' ) { RYHSQGFTJN ++ ; } else { one ++ ; } } System . out . println ( 2 * Math . min ( RYHSQGFTJN , one ) ) ; } } import java . util . * ; public class mlJDhOlZFP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mlJDhOlZFP = sc . nextInt ( ) ; int height = sc . nextInt ( ) ; int [ ] fh = new int [ mlJDhOlZFP ] ; int count = 0 ; for ( int i = 0 ; i < mlJDhOlZFP ; i ++ ) { fh [ i ] = sc . nextInt ( ) ; if ( fh [ i ] >= height ) { count ++ ; } } System . out . println ( count ) ; } } import java . io . * ; import java . util . * ; public class gQeFRclBaF { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int gQeFRclBaF = in . nextInt ( ) ; int x = in . nextInt ( ) ; int t = in . nextInt ( ) ; System . out . println ( ( int ) Math . ceil ( 1.0 * gQeFRclBaF / x ) * t ) ; } } class gQeFRclBaF { 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 DuBVKqSdgr { 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 DuBVKqSdgr = Integer . parseInt ( arrStr [ 0 ] ) ; int w = Integer . parseInt ( arrStr [ 1 ] ) ; if ( DuBVKqSdgr == 0 && w == 0 ) { break ; } boolean iKisu = false ; for ( int i = 0 ; i < DuBVKqSdgr ; 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 rXveTjXKOO { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int rXveTjXKOO ; rXveTjXKOO = in . nextInt ( ) ; System . out . println ( rXveTjXKOO * rXveTjXKOO * rXveTjXKOO ) ; } } import java . util . Scanner ; public class hfyIjviXCu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hfyIjviXCu = sc . nextInt ( ) ; sc . nextLine ( ) ; String S = sc . next ( ) ; System . out . println ( solve ( hfyIjviXCu , 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 YBSqGqTBum { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; String YBSqGqTBum = kb . next ( ) ; String j = kb . next ( ) ; kb . close ( ) ; String k = " 123 " . replace ( YBSqGqTBum , " " ) ; 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 ddPrPzLrSo { 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 ddPrPzLrSo { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int ddPrPzLrSo = in . nextInt ( ) ; int sum = 0 ; int tmp = ddPrPzLrSo ; while ( tmp > 0 ) { sum += tmp % 10 ; tmp /= 10 ; } out . println ( ddPrPzLrSo % sum == 0 ? " Yes " : " No " ) ; } } static class ddPrPzLrSo { 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 lmXmyVBKHv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lmXmyVBKHv = sc . nextInt ( ) ; int yoko = sc . nextInt ( ) ; int men ; int syu ; men = lmXmyVBKHv * yoko ; syu = lmXmyVBKHv * 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 xaIGtIQELy { 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 xaIGtIQELy = 0 ; xaIGtIQELy < b . length ; xaIGtIQELy ++ ) { word . add ( b [ xaIGtIQELy ] ) ; rev_word . add ( b [ xaIGtIQELy ] ) ; } 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 SMLUdcLUwr { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String s = stdIn . next ( ) ; int SMLUdcLUwr = s . indexOf ( " 7 " ) ; if ( SMLUdcLUwr == - 1 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . * ; import java . util . Map . Entry ; class CwbmEUkVSR { static int CwbmEUkVSR = ( 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 MaanOVTnPm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int [ ] [ ] c = new int [ 3 ] [ 3 ] ; for ( int MaanOVTnPm = 0 ; MaanOVTnPm < 3 ; MaanOVTnPm ++ ) { c [ MaanOVTnPm ] [ 0 ] = Integer . parseInt ( scanner . next ( ) ) ; c [ MaanOVTnPm ] [ 1 ] = Integer . parseInt ( scanner . next ( ) ) ; c [ MaanOVTnPm ] [ 2 ] = Integer . parseInt ( scanner . next ( ) ) ; } scanner . close ( ) ; for ( int MaanOVTnPm = 0 ; MaanOVTnPm < c . length ; MaanOVTnPm ++ ) { int min = Integer . MAX_VALUE ; for ( int j = 0 ; j < c [ MaanOVTnPm ] . length ; j ++ ) { int num = c [ MaanOVTnPm ] [ j ] ; if ( min > num ) { min = num ; } } for ( int j = 0 ; j < c [ MaanOVTnPm ] . length ; j ++ ) { c [ MaanOVTnPm ] [ j ] -= min ; } } for ( int MaanOVTnPm = 0 ; MaanOVTnPm < c . length ; MaanOVTnPm ++ ) { if ( c [ 0 ] [ MaanOVTnPm ] != c [ 1 ] [ MaanOVTnPm ] || c [ 1 ] [ MaanOVTnPm ] != c [ 2 ] [ MaanOVTnPm ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class cCLZHzznhP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double cCLZHzznhP = sc . nextDouble ( ) ; double r = cCLZHzznhP * 2 * 3.14 ; System . out . println ( r ) ; } } import java . util . Scanner ; class zhpkBACVyT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zhpkBACVyT = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int cnt = 0 ; int z ; for ( int i = 0 ; i <= zhpkBACVyT ; 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 whFFbPpkcd { public static void main ( String [ ] args ) { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int whFFbPpkcd , b , c ; String [ ] arange = null ; try { arange = in . readLine ( ) . split ( " " , 0 ) ; } catch ( Exception e ) { } whFFbPpkcd = Integer . parseInt ( arange [ 0 ] ) ; b = Integer . parseInt ( arange [ 1 ] ) ; c = Integer . parseInt ( arange [ 2 ] ) ; if ( whFFbPpkcd <= b && whFFbPpkcd <= c ) { if ( b < c ) System . out . println ( whFFbPpkcd + " " + b + " " + c ) ; else System . out . println ( whFFbPpkcd + " " + c + " " + b ) ; } else if ( b <= whFFbPpkcd && b <= c ) { if ( whFFbPpkcd < c ) System . out . println ( b + " " + whFFbPpkcd + " " + c ) ; else System . out . println ( b + " " + c + " " + whFFbPpkcd ) ; } else { if ( whFFbPpkcd < b ) System . out . println ( c + " " + whFFbPpkcd + " " + b ) ; else System . out . println ( c + " " + b + " " + whFFbPpkcd ) ; } } } import java . util . Scanner ; class jukbPCqJiv { public void fun ( ) { Scanner sc = new Scanner ( System . in ) ; int jukbPCqJiv = 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 ) { jukbPCqJiv = jukbPCqJiv - a [ i ] ; i ++ ; } if ( jukbPCqJiv <= 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 iIbzpJdNpH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; char iIbzpJdNpH ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { iIbzpJdNpH = s . charAt ( i ) ; if ( iIbzpJdNpH >= 'A' && iIbzpJdNpH <= 'Z' ) { iIbzpJdNpH += 'a' - 'A' ; } else if ( iIbzpJdNpH >= 'a' && iIbzpJdNpH <= 'z' ) { iIbzpJdNpH += 'A' - 'a' ; } System . out . print ( iIbzpJdNpH ) ; } System . out . println ( " " ) ; sc . close ( ) ; } } import java . util . * ; public class YGvKwmstGU { 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 YGvKwmstGU = Integer . parseInt ( Ss ) ; if ( YGvKwmstGU <= 20190430 ) System . out . println ( " Heisei " ) ; else System . out . println ( " TBD " ) ; } } import java . util . * ; public class XXzximnHSQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XXzximnHSQ = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; for ( int i = x - XXzximnHSQ + 1 ; i <= x + XXzximnHSQ - 1 ; i ++ ) { System . out . print ( i ) ; if ( i < x + XXzximnHSQ - 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 QZfofkYJsy { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int QZfofkYJsy = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; String res = " TLE " ; int minCost = Integer . MAX_VALUE ; for ( int i = 0 ; i < QZfofkYJsy ; 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 QZfofkYJsy { 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 KJxJxkwTXR { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int KJxJxkwTXR = Integer . parseInt ( br . readLine ( ) ) ; String [ ] inputData = br . readLine ( ) . split ( " " ) ; Integer [ ] number = new Integer [ KJxJxkwTXR ] ; 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 biWXTGUqRC { public static void main ( String [ ] args ) { Main mainObj = new Main ( ) ; mainObj . exec ( ) ; } public void exec ( ) { Scanner sc = new Scanner ( System . in ) ; int biWXTGUqRC = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; sc . close ( ) ; if ( ! inRange ( biWXTGUqRC ) || ! inRange ( b ) ) { System . out . println ( - 1 ) ; return ; } System . out . println ( biWXTGUqRC * b ) ; } boolean inRange ( int biWXTGUqRC ) { if ( biWXTGUqRC >= 1 && biWXTGUqRC <= 9 ) { return true ; } else { return false ; } } } import java . util . * ; class drmrIBkLoL { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int drmrIBkLoL = sc . nextInt ( ) ; double [ ] v = new double [ drmrIBkLoL ] ; for ( int i = 0 ; i < drmrIBkLoL ; i ++ ) { v [ i ] = sc . nextDouble ( ) ; } Arrays . sort ( v ) ; for ( int i = 0 ; i < drmrIBkLoL - 1 ; i ++ ) { v [ i + 1 ] = ( v [ i ] + v [ i + 1 ] ) / 2d ; } System . out . println ( v [ drmrIBkLoL - 1 ] ) ; sc . close ( ) ; } } import java . util . Scanner ; import java . util . Collections ; import java . util . List ; import java . util . ArrayList ; public class AjRqMcJzaz { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; int AjRqMcJzaz = 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 LudJYvJxiS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String LudJYvJxiS = sc . next ( ) ; System . out . println ( LudJYvJxiS . charAt ( 2 ) == LudJYvJxiS . charAt ( 3 ) && LudJYvJxiS . charAt ( 4 ) == LudJYvJxiS . charAt ( 5 ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class hwfazqsEaA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String sub ; int hwfazqsEaA = - 1 ; sub = s . substring ( s . indexOf ( " A " ) , s . lastIndexOf ( " Z " ) + 1 ) ; hwfazqsEaA = sub . length ( ) ; System . out . println ( hwfazqsEaA ) ; } } import java . util . * ; public class uPyBPVUZTJ { public static void main ( String [ ] args ) { Scanner sn = new Scanner ( System . in ) ; int uPyBPVUZTJ = sn . nextInt ( ) ; int B = sn . nextInt ( ) ; int C = sn . nextInt ( ) ; if ( ( uPyBPVUZTJ == B && uPyBPVUZTJ != C ) || ( uPyBPVUZTJ == C && uPyBPVUZTJ != B ) || ( B == C && B != uPyBPVUZTJ ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; public class zxqPAKktoy { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int zxqPAKktoy = in . nextInt ( ) ; if ( zxqPAKktoy % 1000 == 0 ) { System . out . println ( " 0 " ) ; } else { int a = ( zxqPAKktoy / 1000 ) + 1 ; System . out . println ( ( a * 1000 ) - zxqPAKktoy ) ; } } } import java . util . Scanner ; public class CBVbFxDAZO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CBVbFxDAZO = sc . nextInt ( ) ; int [ ] ans = new int [ CBVbFxDAZO + 1 ] ; for ( int i = 1 ; i < CBVbFxDAZO ; i ++ ) { int a = sc . nextInt ( ) ; ans [ a ] ++ ; } for ( int i = 1 ; i <= CBVbFxDAZO ; i ++ ) { System . out . println ( ans [ i ] ) ; } } } import java . util . Scanner ; public class zjSYkhiaCu { 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 zjSYkhiaCu = Integer . parseInt ( monthS ) ; int day = Integer . parseInt ( dayS ) ; if ( zjSYkhiaCu <= 4 && day <= 30 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class xrXCLjwOXg { public static void main ( String [ ] args ) { Scanner tan = new Scanner ( System . in ) ; while ( tan . hasNext ( ) ) { int xrXCLjwOXg , k , sum = 0 ; xrXCLjwOXg = tan . nextInt ( ) ; k = tan . nextInt ( ) ; int [ ] a = new int [ xrXCLjwOXg ] ; for ( int i = 0 ; i < xrXCLjwOXg ; 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 reJTUzTmwM { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int reJTUzTmwM = 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 ] = ( ( reJTUzTmwM - 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 ( reJTUzTmwM - max ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . * ; import java . math . * ; import java . util . * ; class nsxcXbwFdh { 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 nsxcXbwFdh = 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 >= nsxcXbwFdh ) { break ; } } nsxcXbwFdh = Math . nsxcXbwFdh ( nsxcXbwFdh , count ) ; } System . out . print ( nsxcXbwFdh ) ; } } import java . util . Scanner ; public class qQIJFDawvn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qQIJFDawvn = sc . nextInt ( ) , n = sc . nextInt ( ) ; int sum = 0 , count = 0 , flag = 0 , max = - 999999 , min = 99999 ; if ( qQIJFDawvn == 0 ) { if ( n != 100 ) System . out . println ( n ) ; else System . out . println ( n + 1 ) ; } else if ( qQIJFDawvn == 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 xtiQQtKwSh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xtiQQtKwSh = sc . nextInt ( ) ; int max = 0 ; int num = 0 ; for ( int i = 0 ; i < xtiQQtKwSh ; 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 PPYTibbFwF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PPYTibbFwF = 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 djRSNMPuWG { 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 khkkqJBlWX { 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 khkkqJBlWX = 0 ; int i ; int length = str . length ( ) ; for ( i = 2 ; i < length - 1 ; i ++ ) { if ( str . charAt ( i ) == 'C' ) { khkkqJBlWX ++ ; } if ( khkkqJBlWX > 1 ) { System . out . println ( " WA " ) ; return ; } } if ( khkkqJBlWX == 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 qjAIakrbUf { 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 qjAIakrbUf = 0 ; qjAIakrbUf < S . length ( ) ; qjAIakrbUf ++ ) { String U = S . substring ( qjAIakrbUf , S . length ( ) ) + S . substring ( 0 , qjAIakrbUf ) ; if ( T . equals ( U ) ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . * ; public class tZwiAuUIdD { public static double tZwiAuUIdD = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double x = sc . nextInt ( ) ; if ( ( x % 2 ) == 0 ) { tZwiAuUIdD = ( ( x / 2 ) / x ) ; } else { if ( x == 1 ) { tZwiAuUIdD = 1 ; } else { tZwiAuUIdD = ( ( ( ( x - 1 ) / 2 ) + 1 ) / x ) ; } } System . out . println ( String . format ( " %.10f " , tZwiAuUIdD ) ) ; } } import java . util . * ; class oiPRSvLGuO { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { char oiPRSvLGuO = scan . next ( ) . charAt ( 0 ) ; if ( oiPRSvLGuO >= 'A' && oiPRSvLGuO <= 'Z' ) { System . out . println ( " A " ) ; } else if ( oiPRSvLGuO >= 'a' && oiPRSvLGuO <= 'z' ) { System . out . println ( " a " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class VqqXhtcEmQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VqqXhtcEmQ = sc . nextInt ( ) ; int [ ] p = new int [ VqqXhtcEmQ ] ; int [ ] q = new int [ VqqXhtcEmQ ] ; int replaceCnt = 0 ; String result = " YES " ; for ( int i = 0 ; i < VqqXhtcEmQ ; i ++ ) { p [ i ] = sc . nextInt ( ) ; q [ i ] = p [ i ] ; } Arrays . sort ( q ) ; for ( int i = 0 ; i < VqqXhtcEmQ ; 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 JfBnTmlqXc { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int JfBnTmlqXc = Integer . valueOf ( br . readLine ( ) ) ; String [ ] z = br . readLine ( ) . split ( " " ) ; String nums1 = z [ 0 ] ; String nums2 = z [ 1 ] ; for ( int i = 0 ; i < JfBnTmlqXc ; i ++ ) { System . out . print ( nums1 . charAt ( i ) ) ; System . out . print ( nums2 . charAt ( i ) ) ; } } } import java . util . * ; import java . lang . * ; public class BlFKEXOKhA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BlFKEXOKhA = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; String [ ] ac = new String [ BlFKEXOKhA + 1 ] ; int [ ] wa = new int [ BlFKEXOKhA + 1 ] ; for ( int i = 0 ; i < BlFKEXOKhA + 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 < BlFKEXOKhA + 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 yNaPODtAvM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yNaPODtAvM = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += sc . nextInt ( ) ; } System . out . print ( yNaPODtAvM <= sum ? " Yes " : " No " ) ; } } import java . util . * ; public class TtCiHmvjaZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int TtCiHmvjaZ = 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 > TtCiHmvjaZ ) TtCiHmvjaZ = tmp ; } System . out . println ( TtCiHmvjaZ ) ; } } import java . util . Scanner ; class JLJcouUDUP { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int JLJcouUDUP = scanner . nextInt ( ) ; int a ; int [ ] order = new int [ JLJcouUDUP ] ; for ( int i = 0 ; i < JLJcouUDUP ; 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 qYxgekaNdy { 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 qYxgekaNdy { public void solve ( int testNumber , Scanner in , PrintWriter out ) { boolean qYxgekaNdy = 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 ) { qYxgekaNdy = qYxgekaNdy && ( a [ i ] % 3 == 0 || a [ i ] % 5 == 0 ) ; } } out . println ( qYxgekaNdy ? " APPROVED " : " DENIED " ) ; } } } import java . util . Scanner ; import java . util . List ; import java . util . ArrayList ; import java . util . Map ; import java . util . HashMap ; class MDGbPQwgGP { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int MDGbPQwgGP = scanner . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < MDGbPQwgGP ; 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 xHLxDuRmsZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xHLxDuRmsZ = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ xHLxDuRmsZ + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ sc . nextInt ( ) ] ++ ; } long [ ] cmb = new long [ xHLxDuRmsZ + 1 ] ; cmb [ 0 ] = 1 ; cmb [ 1 ] = a [ 1 ] ^ 1 ; final long mod = 1_000_000_007 ; for ( int i = 2 ; i <= xHLxDuRmsZ ; i ++ ) { cmb [ i ] = ( a [ i ] ^ 1 ) * ( cmb [ i - 2 ] + cmb [ i - 1 ] ) % mod ; } System . out . println ( cmb [ xHLxDuRmsZ ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class OTbTRyqJTm { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; br . readLine ( ) ; int OTbTRyqJTm = 0 ; String str ; while ( ( str = br . readLine ( ) ) != null ) { if ( isPrime ( Long . valueOf ( str ) ) ) OTbTRyqJTm ++ ; } System . out . println ( OTbTRyqJTm ) ; } 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 ZfWDttEKRb { 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 ZfWDttEKRb = num . ZfWDttEKRb ( ) ; int sum = 0 ; for ( int i = 0 ; i < ZfWDttEKRb ; i ++ ) x [ i ] = num . charAt ( i ) - '0' ; for ( int i = 0 ; i < ZfWDttEKRb ; 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 XKJLGhOemp { 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 XKJLGhOemp { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String s = in . next ( ) ; int XKJLGhOemp = s . charAt ( 0 ) ; char ans = ( char ) ++ XKJLGhOemp ; out . println ( ans ) ; } } } import java . util . Scanner ; public class GMgjbBzZCw { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String GMgjbBzZCw = scanner . nextLine ( ) ; System . out . println ( ( GMgjbBzZCw . equals ( " ABC " ) ) ? " ARC " : " ABC " ) ; } } import java . util . * ; public class hAhyCEVIYR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hAhyCEVIYR = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; sc . close ( ) ; int cnt = 0 ; if ( hAhyCEVIYR >= 2 ) { cnt += hAhyCEVIYR * ( hAhyCEVIYR - 1 ) / 2 ; } if ( m >= 2 ) { cnt += m * ( m - 1 ) / 2 ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class afVlEGVWFv { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String ns = s . nextLine ( ) ; String str = s . nextLine ( ) ; int afVlEGVWFv = Integer . parseInt ( ns ) ; int [ ] arr = new int [ afVlEGVWFv + 1 ] ; arr [ 0 ] = 0 ; String [ ] sss = str . split ( " \\ s " ) ; for ( int i = 1 ; i <= afVlEGVWFv ; i ++ ) { arr [ i ] = Integer . parseInt ( sss [ i - 1 ] ) ; } int [ ] a = new int [ afVlEGVWFv + 1 ] ; a [ 0 ] = 0 ; for ( int i = 1 ; i <= afVlEGVWFv ; i ++ ) { a [ ( arr [ i ] ) ] = i ; } for ( int i = 1 ; i <= afVlEGVWFv ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } } } import java . util . Scanner ; public class ZuMllKZBmK { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int ZuMllKZBmK = sc . nextInt ( ) ; int [ ] rate = new int [ 8 ] ; int red = 0 ; for ( int i = 0 ; i < ZuMllKZBmK ; 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 EORHznsdGK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EORHznsdGK = Integer . parseInt ( sc . next ( ) ) ; ArrayList < Integer > nums = new ArrayList < Integer > ( EORHznsdGK ) ; for ( int i = 0 ; i < EORHznsdGK ; 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 == EORHznsdGK - 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 jxlBOfGdvE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; sc . next ( ) ; int jxlBOfGdvE = 1 ; char [ ] str = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; for ( int i = 0 ; i < str . length - 1 ; i ++ ) { if ( str [ i ] != str [ i + 1 ] ) ++ jxlBOfGdvE ; } System . out . println ( jxlBOfGdvE ) ; } } import java . util . Scanner ; public class EhuDJgFVfi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String EhuDJgFVfi = sc . nextLine ( ) ; sc . close ( ) ; String s2 = EhuDJgFVfi . replace ( " 0 " , " " ) ; System . out . println ( s2 . length ( ) ) ; } } import java . util . * ; class VOuJyeHLHv { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int VOuJyeHLHv = sc . nextInt ( ) ; long [ ] A = new long [ VOuJyeHLHv ] ; for ( int i = 0 ; i < VOuJyeHLHv ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } Arrays . sort ( A ) ; long ans = 1 ; for ( int i = 0 ; i < VOuJyeHLHv ; 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 hOpSzKbzwF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int hOpSzKbzwF = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( hOpSzKbzwF == 0 && W == 0 ) { break ; } for ( int x = 0 ; x < hOpSzKbzwF ; x ++ ) { for ( int y = 0 ; y < W ; y ++ ) { if ( x == 0 || y == 0 || x == hOpSzKbzwF - 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 ulUoaJyUou { 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 ulUoaJyUou { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int ulUoaJyUou = in . nextInt ( ) ; int [ ] h = new int [ ulUoaJyUou ] ; for ( int i = 0 ; i < ulUoaJyUou ; i ++ ) { h [ i ] = in . nextInt ( ) ; } long result = 0 ; int i = 0 ; while ( i < ulUoaJyUou ) { if ( h [ i ] == 0 ) { i ++ ; continue ; } int v = 1 ; result += 1 ; h [ i ] -= v ; for ( int j = i + 1 ; j < ulUoaJyUou ; 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 NJxZjdUdiM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NJxZjdUdiM = 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 ( NJxZjdUdiM , 2 ) + Math . pow ( b , 2 ) - 2 * NJxZjdUdiM * 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 ZJNiQuqZRA { 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 ZJNiQuqZRA = 0 ; ZJNiQuqZRA < inStr . length ( ) ; ZJNiQuqZRA ++ ) { if ( target . charAt ( 0 ) == ring . charAt ( ZJNiQuqZRA ) ) { if ( target . equals ( ring . substring ( ZJNiQuqZRA , ZJNiQuqZRA + target . length ( ) ) ) ) { result = " Yes " ; break ; } } } System . out . println ( result ) ; } } } import java . util . Scanner ; public class sxVTFuoPMn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sxVTFuoPMn , B ; sxVTFuoPMn = sc . nextInt ( ) ; B = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( solve ( sxVTFuoPMn , 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 ZAivnoOnmi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZAivnoOnmi = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int taxi = sc . nextInt ( ) ; int train , ans ; train = ZAivnoOnmi * a ; if ( train >= taxi ) { System . out . println ( taxi ) ; } else { System . out . println ( train ) ; } } } import java . util . Scanner ; public class meuwghvYXs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { long meuwghvYXs = sc . nextLong ( ) ; long n = sc . nextLong ( ) ; System . out . printf ( " %d %d \n " , gcd ( meuwghvYXs , n ) , lcm ( meuwghvYXs , 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 kKjpgcJAEI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kKjpgcJAEI = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int d ; int A ; int [ ] people = new int [ kKjpgcJAEI ] ; for ( int i = 0 ; i < kKjpgcJAEI ; 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 < kKjpgcJAEI ; i ++ ) { if ( people [ i ] == 0 ) res ++ ; } System . out . println ( res ) ; } } import java . util . * ; class vnnAxjAofA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vnnAxjAofA = sc . nextInt ( ) ; System . out . println ( vnnAxjAofA / 3600 + " : " + vnnAxjAofA % 3600 / 60 + " : " + vnnAxjAofA % 3600 % 60 ) ; } } import java . util . * ; public class JeFDwqiVWb { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String N = input . next ( ) ; int JeFDwqiVWb = N . charAt ( N . length ( ) - 1 ) - 48 ; if ( JeFDwqiVWb == 3 ) { System . out . print ( " bon " ) ; } else if ( JeFDwqiVWb == 0 || JeFDwqiVWb == 1 || JeFDwqiVWb == 6 || JeFDwqiVWb == 8 ) { System . out . print ( " pon " ) ; } else { System . out . print ( " hon " ) ; } } } import java . util . Scanner ; public class ZtsFEeaXkj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ZtsFEeaXkj = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int [ ] l = new int [ ZtsFEeaXkj ] ; for ( int i = 0 ; i < ZtsFEeaXkj ; i ++ ) { l [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; int d = 0 ; int cnt = 1 ; for ( int i = 0 ; i < ZtsFEeaXkj ; i ++ ) { d = d + l [ i ] ; if ( d <= x ) cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . * ; class ZenSRePJsN { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; for ( ; ; ) { int ZenSRePJsN = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( ZenSRePJsN == 0 && b == 0 ) break ; System . out . println ( " " + Math . min ( ZenSRePJsN , b ) + " " + Math . max ( ZenSRePJsN , b ) ) ; } } } import java . util . * ; class mIRiJvKQcr { Scanner sc ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { String mIRiJvKQcr = sc . next ( ) ; switch ( mIRiJvKQcr ) { 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 eeUhaemkph { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eeUhaemkph = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; long S , L ; long Ri = 1 ; if ( eeUhaemkph > B ) { L = eeUhaemkph ; S = B ; } else { L = B ; S = eeUhaemkph ; } 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 bxYrdGfcsl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bxYrdGfcsl = sc . nextInt ( ) ; int rest = bxYrdGfcsl % 7 ; for ( int i = 0 ; i < 25 ; i ++ ) { for ( int j = 0 ; j < 14 ; j ++ ) { if ( i * 4 + j * 7 == bxYrdGfcsl ) { System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } } import java . util . * ; public class LTVndoakYq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LTVndoakYq = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] b = new int [ LTVndoakYq ] ; 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 NhfIwtagqT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NhfIwtagqT = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int keypress = ( B < D ? B : D ) - ( NhfIwtagqT > C ? NhfIwtagqT : C ) ; System . out . println ( keypress > 0 ? keypress : 0 ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; class XXMxOjjtAs { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String input = br . readLine ( ) ; int XXMxOjjtAs = 0 ; if ( input . contains ( " A " ) ) { XXMxOjjtAs ++ ; } if ( input . contains ( " B " ) ) { XXMxOjjtAs ++ ; } if ( XXMxOjjtAs == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class ooqRPBraTz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ooqRPBraTz = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = ooqRPBraTz ; int ans = 1 ; while ( sum < b ) { ans ++ ; sum += ooqRPBraTz - 1 ; } if ( b == 1 ) ans = 0 ; System . out . print ( ans ) ; } } import java . util . * ; public class psKrdgpjTU { 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 psKrdgpjTU = 0 ; for ( int i = 0 ; i < s_arr . length ; i ++ ) { if ( s_arr [ i ] . equals ( t_arr [ i ] ) ) { psKrdgpjTU ++ ; } } System . out . println ( psKrdgpjTU ) ; } } import java . util . Scanner ; public class XBKTclHxHj { public static void main ( String ... args ) { Scanner scanner = new Scanner ( System . in ) ; int XBKTclHxHj = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; System . out . println ( lcm ( XBKTclHxHj , 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 bDNkJpoKVq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bDNkJpoKVq = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( bDNkJpoKVq <= 9 && B <= 9 ) { System . out . println ( bDNkJpoKVq * B ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . Scanner ; public class hSEEqCunpd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; long hSEEqCunpd = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { hSEEqCunpd += s . charAt ( i ) - '0' ; } if ( hSEEqCunpd % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class lmayWWZAko { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final String EOT = " END_OF_TEXT " ; String w , t ; int lmayWWZAko = 0 ; w = sc . next ( ) ; while ( true ) { t = sc . next ( ) ; if ( t . equals ( EOT ) ) { break ; } if ( t . equalsIgnoreCase ( w ) ) { lmayWWZAko ++ ; } } System . out . println ( lmayWWZAko ) ; } } import java . util . Scanner ; public class eLpGCwwpud { public static void main ( String [ ] args ) { int eLpGCwwpud = 0 ; Scanner sc = new Scanner ( System . in ) ; eLpGCwwpud = sc . nextInt ( ) ; eLpGCwwpud += sc . nextInt ( ) ; eLpGCwwpud += sc . nextInt ( ) ; if ( eLpGCwwpud > 21 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } } } import java . util . * ; public class xmEaiVomIh { Scanner sc = new Scanner ( System . in ) ; final int xmEaiVomIh = ( 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 jnYEsaunEk { public static void main ( String [ ] args ) throws Exception { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; double jnYEsaunEk = Double . parseDouble ( br . readLine ( ) ) ; double countOdd = Math . round ( jnYEsaunEk / 2 ) ; BigDecimal result = new BigDecimal ( countOdd / jnYEsaunEk ) ; 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 RUxlmesVYB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RUxlmesVYB = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; ArrayList < Integer > d = new ArrayList < Integer > ( ) ; for ( int i = Math . max ( RUxlmesVYB , B ) ; i >= 1 ; i -- ) { if ( RUxlmesVYB % 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 hokwScVJVj { 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 hokwScVJVj = Integer . parseInt ( line [ 0 ] ) ; int w = Integer . parseInt ( line [ 1 ] ) ; if ( hokwScVJVj == 0 && w == 0 ) break ; for ( int i = 0 ; i < hokwScVJVj ; 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 XyhvRoogvV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XyhvRoogvV = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; if ( XyhvRoogvV != 1 && M != 1 ) { System . out . print ( 1 ) ; } else if ( XyhvRoogvV != 2 && M != 2 ) { System . out . print ( 2 ) ; } else if ( XyhvRoogvV != 3 && M != 3 ) { System . out . print ( 3 ) ; } return ; } } import java . util . Scanner ; public class vVivXcFqdo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vVivXcFqdo = Integer . parseInt ( sc . next ( ) ) ; int ans = 1 ; int count = 0 ; for ( int i = 1 ; i <= vVivXcFqdo ; 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 tEnaPPUBzo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tEnaPPUBzo = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; ArrayList < Integer > divisor = new ArrayList < Integer > ( ) ; for ( int i = tEnaPPUBzo ; i > 0 ; i -- ) { if ( tEnaPPUBzo % i == 0 && b % i == 0 ) { divisor . add ( i ) ; } } System . out . println ( divisor . get ( k - 1 ) ) ; } } import java . util . * ; class iLrlltutfR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iLrlltutfR = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = 0 ; int T = iLrlltutfR * A ; if ( T < B ) { ans = T ; } else { ans = B ; } System . out . println ( ans ) ; } } import java . io . PrintWriter ; import java . util . * ; public class jUbWTifsOC { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int jUbWTifsOC = Integer . parseInt ( stdin . next ( ) ) ; int [ ] H = new int [ jUbWTifsOC ] ; int flag ; if ( jUbWTifsOC == 1 ) { flag = 1 ; } else { flag = 0 ; } for ( int i = 0 ; i < jUbWTifsOC ; i ++ ) { H [ i ] = Integer . parseInt ( stdin . next ( ) ) ; } for ( int i = jUbWTifsOC - 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 < jUbWTifsOC - 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 MAbGXyhTii { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MAbGXyhTii = Integer . parseInt ( sc . next ( ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; out . print ( ( int ) ( MAbGXyhTii + Math . pow ( MAbGXyhTii , 2 ) + Math . pow ( MAbGXyhTii , 3 ) ) ) ; out . flush ( ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class NgfjppCWzS { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int NgfjppCWzS = scan . nextInt ( ) ; int [ ] arr = new int [ NgfjppCWzS ] ; for ( int i = 0 ; i < NgfjppCWzS ; i ++ ) arr [ i ] = scan . nextInt ( ) ; for ( int i = 0 ; i < NgfjppCWzS ; 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 < NgfjppCWzS ; j ++ ) System . out . print ( ( j == 0 ? " " : " " ) + arr [ j ] ) ; System . out . println ( ) ; } } } import java . util . * ; public class TSidmczvWH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] array = new int [ 3 ] ; int TSidmczvWH = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } Arrays . sort ( array ) ; TSidmczvWH = array [ 0 ] + array [ 1 ] ; System . out . println ( TSidmczvWH ) ; } } import java . util . Scanner ; public class UEZRcBSUqO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long UEZRcBSUqO = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; b = Math . max ( Math . min ( UEZRcBSUqO + b - k , b ) , 0 ) ; UEZRcBSUqO = Math . max ( UEZRcBSUqO - k , 0 ) ; System . out . println ( UEZRcBSUqO + " " + b ) ; sc . close ( ) ; } } import java . util . Scanner ; public class coLcKhIfJo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int coLcKhIfJo = sc . nextInt ( ) ; if ( coLcKhIfJo == 10 ) { System . out . println ( s . length ( ) ) ; } else { long n = 0 ; while ( Math . pow ( coLcKhIfJo , n ) < Long . valueOf ( s ) + 1 ) { n ++ ; } System . out . println ( n ) ; } } } import java . util . * ; import java . math . BigDecimal ; public class QoZxRcztAZ { 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 zwAPBtHGAd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zwAPBtHGAd = 0 ; int W = 0 ; boolean flg = true ; while ( true ) { zwAPBtHGAd = sc . nextInt ( ) ; W = sc . nextInt ( ) ; if ( zwAPBtHGAd == 0 && W == 0 ) { break ; } for ( int i = 1 ; i <= zwAPBtHGAd ; 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 lriftZesSk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lriftZesSk = sc . nextInt ( ) ; if ( lriftZesSk % 2 == 0 ) { System . out . println ( " 0.5000000000 " ) ; } else { int s = lriftZesSk / 2 + 1 ; double ans = ( double ) s / lriftZesSk ; System . out . println ( String . format ( " %.10f " , ans ) ) ; } } } import java . util . Scanner ; public class ZULHzdDJTh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder answer = new StringBuilder ( ) ; int ZULHzdDJTh = sc . nextInt ( ) ; int i = 1 ; if ( ZULHzdDJTh >= 3 && ZULHzdDJTh <= 10000 ) { while ( i <= ZULHzdDJTh ) { 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 QHDBBmBoJu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QHDBBmBoJu = sc . nextInt ( ) ; int ans = 0 ; for ( int a = 1 ; a <= QHDBBmBoJu ; a ++ ) { for ( int b = 1 ; b <= QHDBBmBoJu ; b ++ ) { for ( int c = 1 ; c <= QHDBBmBoJu ; 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 ZLwwkaDAub { 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 ZLwwkaDAub { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String ZLwwkaDAub = in . next ( ) ; if ( ZLwwkaDAub . charAt ( 0 ) == 'A' && ZLwwkaDAub . charAt ( 1 ) == 'A' && ZLwwkaDAub . charAt ( 2 ) == 'A' ) { out . println ( " No " ) ; return ; } if ( ZLwwkaDAub . charAt ( 0 ) == 'B' && ZLwwkaDAub . charAt ( 1 ) == 'B' && ZLwwkaDAub . charAt ( 2 ) == 'B' ) { out . println ( " No " ) ; return ; } out . println ( " Yes " ) ; } } } import java . util . * ; class RocOupAQio { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RocOupAQio = sc . nextInt ( ) ; int [ ] [ ] a = new int [ 2 ] [ RocOupAQio ] ; for ( int i = 0 ; i < RocOupAQio ; i ++ ) { a [ 0 ] [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < RocOupAQio ; i ++ ) { a [ 1 ] [ i ] = sc . nextInt ( ) ; } int x = 0 ; int y = 0 ; int max = 0 ; for ( int i = 0 ; i < RocOupAQio ; i ++ ) { x += a [ 0 ] [ i ] ; for ( int j = i ; j < RocOupAQio ; 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 kMOpUeqyjI { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int kMOpUeqyjI = 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 jFExcbUNne { 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 jFExcbUNne = s . length ( ) ; String s1 = s . substring ( 0 , ( jFExcbUNne - 1 ) / 2 ) ; String s2 = s . substring ( ( jFExcbUNne + 3 ) / 2 - 1 , jFExcbUNne ) ; String res = s2 + s . charAt ( ( jFExcbUNne + 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 JHbchTVOIo { public static void main ( String [ ] args ) { int JHbchTVOIo = 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 wrKQBdDbrV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wrKQBdDbrV = sc . nextInt ( ) ; int max = 0 ; int count = 0 ; for ( int i = 0 ; i < wrKQBdDbrV ; i ++ ) { int temp = sc . nextInt ( ) ; if ( max <= temp ) { count ++ ; max = temp ; } } System . out . println ( count ) ; } } import java . util . * ; class xyzbbMbnJj { public static void main ( String [ ] args ) { new Solver ( ) . run ( ) ; } } class xyzbbMbnJj { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int xyzbbMbnJj = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = xyzbbMbnJj ; 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 qdfxKilSVD { 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 qdfxKilSVD = Integer . parseInt ( br . readLine ( ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; char [ ] c1 = st . nextToken ( ) . toCharArray ( ) ; char [ ] c2 = st . nextToken ( ) . toCharArray ( ) ; for ( int i = 0 ; i < qdfxKilSVD ; i ++ ) { pw . print ( c1 [ i ] ) ; pw . print ( c2 [ i ] ) ; } pw . flush ( ) ; pw . close ( ) ; } } import java . util . * ; public class AgoaTWGtxd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AgoaTWGtxd = 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 >= AgoaTWGtxd ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class fcfixiDROn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fcfixiDROn = 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 ( fcfixiDROn > s ) v = fcfixiDROn - s ; else if ( fcfixiDROn == s ) v = 0 ; else v = - 1 ; System . out . println ( v ) ; } } import java . util . * ; public class AQjTsOzjpf { public static void main ( String [ ] args ) { int AQjTsOzjpf = 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 ) ) ) AQjTsOzjpf ++ ; } System . out . println ( AQjTsOzjpf ) ; } } import java . util . Scanner ; public class ouFGtjvStO { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ouFGtjvStO = scan . nextInt ( ) ; int [ ] W = new int [ ouFGtjvStO ] ; int [ ] sub = new int [ ouFGtjvStO ] ; int ans ; for ( int i = 0 ; i < ouFGtjvStO ; i ++ ) { W [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < ouFGtjvStO ; i ++ ) { int S1 = 0 , S2 = 0 ; for ( int k = i ; k >= 0 ; k -- ) { S1 = S1 + W [ k ] ; } for ( int k = i + 1 ; k < ouFGtjvStO ; 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 KtflAKDGkC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; do { int KtflAKDGkC = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; if ( KtflAKDGkC == 0 && l == 0 ) { break ; } else { for ( int i = 0 ; i < KtflAKDGkC ; 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 luCOuPZnrU { 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 luCOuPZnrU = nextInt ( ) ; int B = nextInt ( ) ; if ( luCOuPZnrU == 1 ) { if ( B == 3 ) { println ( 2 ) ; return ; } else { println ( 3 ) ; return ; } } else if ( luCOuPZnrU == 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 qGLfLuwUdC { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int qGLfLuwUdC ; 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 ( qGLfLuwUdC = 0 ; qGLfLuwUdC < h ; qGLfLuwUdC ++ ) { System . out . print ( " " ) ; for ( j = 0 ; j < w - 1 ; j ++ ) { if ( ( qGLfLuwUdC % 2 != 0 && j % 2 == 0 ) ^ ( qGLfLuwUdC % 2 == 0 && j % 2 != 0 ) ) { System . out . print ( " . " ) ; } else { System . out . print ( " # " ) ; } } if ( ( qGLfLuwUdC % 2 != 0 && j % 2 == 0 ) ^ ( qGLfLuwUdC % 2 == 0 && j % 2 != 0 ) ) { System . out . println ( " . " ) ; } else { System . out . println ( " # " ) ; } } System . out . print ( " \n " ) ; } } } import java . util . * ; public class EgKKKhAqOj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] num = new int [ 5 ] ; for ( int EgKKKhAqOj = 0 ; EgKKKhAqOj < 5 ; EgKKKhAqOj ++ ) { num [ EgKKKhAqOj ] = sc . nextInt ( ) ; } int k = sc . nextInt ( ) ; String result = " Yay! " ; out : for ( int EgKKKhAqOj = 0 ; EgKKKhAqOj < 5 ; EgKKKhAqOj ++ ) { for ( int j = EgKKKhAqOj + 1 ; j < 5 ; j ++ ) { if ( Math . abs ( num [ EgKKKhAqOj ] - num [ j ] ) > k ) { result = " :( " ; break out ; } } } System . out . println ( result ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class GiNFLozlBX { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int GiNFLozlBX = stdIn . nextInt ( ) ; int [ ] d = new int [ GiNFLozlBX ] ; List < Integer > list = new ArrayList < > ( ) ; int cnt = 0 ; for ( int i = 0 ; i < GiNFLozlBX ; i ++ ) { int a = stdIn . nextInt ( ) ; if ( ! list . contains ( a ) ) { list . add ( a ) ; cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class ltPXyqRFqr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String ltPXyqRFqr = scan . next ( ) ; System . out . println ( ltPXyqRFqr . equals ( " ABC " ) ? " ARC " : " ABC " ) ; } } import java . util . Scanner ; public class zAaDLpKYJM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double zAaDLpKYJM = sc . nextDouble ( ) ; double h = sc . nextDouble ( ) ; double x = sc . nextDouble ( ) ; double y = sc . nextDouble ( ) ; System . out . print ( h * zAaDLpKYJM / 2.0 ) ; System . out . print ( " " ) ; if ( x == zAaDLpKYJM / 2.0 && y == h / 2.0 ) System . out . print ( 1 ) ; else System . out . print ( 0 ) ; } } import java . util . Scanner ; public class UFgNqUhoMi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String N_str = sc . next ( ) ; String [ ] N_list = N_str . split ( " " ) ; int UFgNqUhoMi = 0 ; for ( int i = 0 ; i < N_list . length ; i ++ ) { UFgNqUhoMi += Integer . parseInt ( N_list [ i ] ) ; } if ( UFgNqUhoMi % 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 pLkyFDoVOM { 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 pLkyFDoVOM { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String pLkyFDoVOM = in . next ( ) ; String t = in . next ( ) ; out . println ( pLkyFDoVOM . equals ( t . substring ( 0 , pLkyFDoVOM . length ( ) ) ) ? " Yes " : " No " ) ; } } } import java . util . * ; public class rBfNUsFMmP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] ABC = new int [ 3 ] ; for ( int rBfNUsFMmP = 0 ; rBfNUsFMmP < 3 ; rBfNUsFMmP ++ ) { ABC [ rBfNUsFMmP ] = 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 pRBWrreBdV { public static void main ( String [ ] args ) { int pRBWrreBdV , 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 ( pRBWrreBdV = 0 ; pRBWrreBdV < so . length ; pRBWrreBdV ++ ) { if ( so [ pRBWrreBdV ] <= n ) cnt ++ ; } out . println ( cnt ) ; } } import java . util . Scanner ; public class sRrfkEKoXg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long sRrfkEKoXg = sc . nextLong ( ) ; String b = sc . next ( ) ; b = b . replace ( " . " , " " ) ; int bb = Integer . parseInt ( b ) ; System . out . println ( sRrfkEKoXg * bb / 100 ) ; } } import java . util . Scanner ; public class kOwOfWaCWq { public static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int kOwOfWaCWq , sum ; kOwOfWaCWq = nextInt ( ) ; sum = 0 ; int [ ] arr = new int [ kOwOfWaCWq ] ; for ( int i = 0 ; i < kOwOfWaCWq ; i ++ ) { arr [ i ] = nextInt ( ) ; } for ( int i = 0 ; i < kOwOfWaCWq - 1 ; i ++ ) { for ( int j = i + 1 ; j < kOwOfWaCWq ; 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 qHZAOcmmth { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int qHZAOcmmth , t ; int [ ] data = new int [ 3 ] ; qHZAOcmmth = cin . nextInt ( ) ; while ( qHZAOcmmth -- > 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 mzwZFFaUSm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; sc . close ( ) ; int mzwZFFaUSm = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . substring ( i , i + 1 ) . equals ( T . substring ( i , i + 1 ) ) ) mzwZFFaUSm ++ ; } System . out . println ( mzwZFFaUSm ) ; } } import java . util . * ; class MADEfwzgiX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MADEfwzgiX , ans ; while ( sc . hasNext ( ) ) { MADEfwzgiX = sc . nextInt ( ) ; ans = 100000 ; for ( int i = 0 ; i < MADEfwzgiX ; i ++ ) { ans += ans / 20 ; if ( ans != ( ans = ans / 1000 * 1000 ) ) { ans += 1000 ; } } System . out . println ( ans ) ; } } } import java . util . * ; public class ybuUYjQzcu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ybuUYjQzcu = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int ans = 0 ; int p = ybuUYjQzcu + 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 zFEimmNbhm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zFEimmNbhm = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int t = ( y - 2 * zFEimmNbhm ) / 2 ; int c = zFEimmNbhm - t ; if ( t < 0 || c < 0 || y % 2 == 1 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class BTPrTNckWH { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; String T = scanner . next ( ) ; int BTPrTNckWH = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == T . charAt ( i ) ) continue ; BTPrTNckWH ++ ; } System . out . println ( BTPrTNckWH ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class wgrwcIVBNr { 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 wgrwcIVBNr = Integer . parseInt ( inputsArrays [ 0 ] ) ; int X = Integer . parseInt ( inputsArrays [ 1 ] ) ; int T = Integer . parseInt ( inputsArrays [ 2 ] ) ; int timeTaken = 0 ; while ( wgrwcIVBNr > 0 ) { timeTaken += T ; wgrwcIVBNr -= 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 BOOpIONQuv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int BOOpIONQuv = scan . nextInt ( ) ; System . out . println ( BOOpIONQuv + BOOpIONQuv * BOOpIONQuv + BOOpIONQuv * BOOpIONQuv * BOOpIONQuv ) ; } } import java . util . * ; import java . io . * ; class DHCcUmTMuE { 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 DHCcUmTMuE = str . length - 1 ; DHCcUmTMuE >= 0 ; DHCcUmTMuE -- ) { System . out . print ( str [ DHCcUmTMuE ] ) ; } } 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 vwnpefxTBZ { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int vwnpefxTBZ = in . nextInt ( ) ; int k = in . nextInt ( ) ; System . out . println ( solve ( vwnpefxTBZ , k ) ) ; in . close ( ) ; } private static double solve ( int vwnpefxTBZ , int k ) { double r = 0 ; for ( int i = 1 ; i <= vwnpefxTBZ ; i ++ ) { int p = i ; double x = 1 ; x /= vwnpefxTBZ ; while ( p < k ) { p *= 2 ; x /= 2 ; } r += x ; } return r ; } } import java . util . * ; public class EjYuiYoSvU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EjYuiYoSvU , B , T ; EjYuiYoSvU = sc . nextInt ( ) ; B = sc . nextInt ( ) ; T = sc . nextInt ( ) ; int result = ( T / EjYuiYoSvU ) * B ; System . out . println ( result ) ; } } import java . util . Scanner ; public class hIbdlGwTuK { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int hIbdlGwTuK = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; if ( B == 1 ) { System . out . println ( 0 ) ; return ; } int count = 0 ; while ( ( hIbdlGwTuK * count - ( count - 1 ) ) < B ) { count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class ejckeRGyHj { public static int g ( long x ) { int ejckeRGyHj = 0 ; while ( x > 0 ) { ++ ejckeRGyHj ; x /= 10 ; } return ejckeRGyHj ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; int ejckeRGyHj = Integer . MAX_VALUE ; for ( long i = 1 ; i * i <= N ; ++ i ) { if ( N % i == 0 ) { long a = N / i ; ejckeRGyHj = Math . min ( ejckeRGyHj , Math . max ( g ( i ) , g ( a ) ) ) ; } } System . out . println ( ejckeRGyHj ) ; } } import java . io . * ; import java . util . * ; public class HHmCcsnwzw { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int HHmCcsnwzw = sc . nextInt ( ) ; int [ ] a = new int [ HHmCcsnwzw ] ; int sum = 0 ; for ( int i = 0 ; i < HHmCcsnwzw ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int i = 0 ; i < HHmCcsnwzw - 1 ; i ++ ) { sum += a [ i ] ; } System . out . println ( a [ HHmCcsnwzw - 1 ] < sum ? " Yes " : " No " ) ; } public static PrintWriter out ; public static class HHmCcsnwzw { 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 DYCgIeBGMr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int DYCgIeBGMr = scan . nextInt ( ) ; scan . close ( ) ; long sum = 0 ; for ( int a = 1 ; a <= DYCgIeBGMr ; a ++ ) { for ( int b = 1 ; b <= DYCgIeBGMr ; b ++ ) { for ( int c = 1 ; c <= DYCgIeBGMr ; 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 EUCqXVOqrT { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EUCqXVOqrT , c , e = 0 ; EUCqXVOqrT = scan . nextInt ( ) ; c = scan . nextInt ( ) ; int [ ] [ ] a = new int [ EUCqXVOqrT ] [ c ] ; for ( int i = 0 ; i < EUCqXVOqrT ; 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 < EUCqXVOqrT ; j ++ ) { d += a [ j ] [ i ] ; } System . out . print ( d + " " ) ; } System . out . println ( e ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class GDJhWICern { 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 GDJhWICern = c . longValue ( ) ; System . out . println ( GDJhWICern ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class XDpapqOTiy { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int XDpapqOTiy , B , C , mili = 0 ; XDpapqOTiy = reader . nextInt ( ) ; B = reader . nextInt ( ) ; C = reader . nextInt ( ) ; mili = ( B + C ) - XDpapqOTiy ; 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 ozyYBTPNbm { 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 ozyYBTPNbm = 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 = ozyYBTPNbm ; 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 YOqSzFpJFU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YOqSzFpJFU = sc . nextInt ( ) ; int [ ] v = new int [ YOqSzFpJFU ] ; for ( int c = 0 ; c < YOqSzFpJFU ; c ++ ) { v [ c ] = sc . nextInt ( ) ; } Arrays . sort ( v ) ; double ans = ( double ) v [ 0 ] ; for ( int d = 1 ; d < YOqSzFpJFU ; d ++ ) { ans = ( ans + v [ d ] ) / 2 ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class jfMIjqgnTc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int jfMIjqgnTc = sc . nextInt ( ) ; sc . nextLine ( ) ; final List < Integer > ls = new ArrayList < > ( ) ; int max = - 1 ; int maxId = - 1 ; for ( int i = 0 ; i < jfMIjqgnTc ; i ++ ) { final int l = sc . nextInt ( ) ; ls . add ( l ) ; if ( l > max ) { max = l ; maxId = i ; } } int sum = 0 ; for ( int i = 0 ; i < jfMIjqgnTc ; 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 xklVVLcFNf { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int xklVVLcFNf = scanner . nextInt ( ) ; int ans = xklVVLcFNf + ( int ) Math . pow ( xklVVLcFNf , 2 ) + ( int ) Math . pow ( xklVVLcFNf , 3 ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; class IRyrvxNHrU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IRyrvxNHrU = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 1 ; i <= IRyrvxNHrU ; 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 ZSdzsdehgu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZSdzsdehgu = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < ZSdzsdehgu ; 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 uQOMnogKxl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long uQOMnogKxl = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long cnt = uQOMnogKxl / ( a + b ) * a ; uQOMnogKxl %= ( a + b ) ; cnt += Math . min ( a , uQOMnogKxl ) ; System . out . println ( cnt ) ; } } import java . util . Scanner ; public class GRlgJeVVCE { public static int eukleides ( int a , int b ) { if ( b % a == 0 ) { return a ; } int GRlgJeVVCE = b % a ; return eukleides ( GRlgJeVVCE , 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 jDtTJWIvqL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jDtTJWIvqL = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] l = new int [ jDtTJWIvqL ] ; for ( int i = 0 ; i < jDtTJWIvqL ; i ++ ) l [ i ] = sc . nextInt ( ) ; int point = 0 , cnt = 1 ; for ( int i = 0 ; i < jDtTJWIvqL ; i ++ ) { point += l [ i ] ; if ( point <= x ) cnt ++ ; else break ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class yDculbWTUW { public static void swap ( int [ ] A , int a , int b ) { int yDculbWTUW = A [ a ] ; A [ a ] = A [ b ] ; A [ b ] = yDculbWTUW ; } 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 KWMAXTTnCE { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int KWMAXTTnCE = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; long [ ] dp = new long [ KWMAXTTnCE + 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 <= KWMAXTTnCE ; i ++ ) { if ( dp [ i ] >= 0 ) { dp [ i ] = ( dp [ i - 1 ] + dp [ i - 2 ] ) % 1000000007 ; } else { dp [ i ] = 0 ; } } System . out . println ( dp [ KWMAXTTnCE ] ) ; } } import java . util . Scanner ; public class LwtNeJROmU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LwtNeJROmU = 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 <= LwtNeJROmU ; maiX ++ ) { if ( kaiX != - 1 ) { break ; } if ( maiX * 10000 > Y ) { break ; } for ( maiZ = 0 ; maiX + maiZ <= LwtNeJROmU ; maiZ ++ ) { maiY = LwtNeJROmU - ( 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 EdWajnuksm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EdWajnuksm = 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 ( EdWajnuksm == a ) { flag = true ; } } } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class bbWrgVtyFl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bbWrgVtyFl = sc . nextInt ( ) ; int [ ] h = new int [ bbWrgVtyFl ] ; for ( int i = 0 ; i < bbWrgVtyFl ; 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 < bbWrgVtyFl ; 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 == bbWrgVtyFl - 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 fCnOAcfwbD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fCnOAcfwbD = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; ArrayList < String > S = new ArrayList < > ( ) ; for ( int i = 0 ; i < fCnOAcfwbD ; i ++ ) { S . add ( sc . next ( ) ) ; } Collections . sort ( S ) ; for ( int i = 0 ; i < fCnOAcfwbD ; i ++ ) System . out . print ( S . get ( i ) ) ; sc . close ( ) ; } } import java . util . * ; public class uAsJzUYPRr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int uAsJzUYPRr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int five = 0 ; int seven = 0 ; if ( uAsJzUYPRr == 5 ) { five ++ ; } else if ( uAsJzUYPRr == 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 zgsPAdXYYX { 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 zgsPAdXYYX = 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 = zgsPAdXYYX * Math . cos ( Math . toRadians ( angle_H ) ) ; double A_y = zgsPAdXYYX * 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 gojtEpGnRl { 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 gojtEpGnRl = 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 ) { gojtEpGnRl = false ; break ; } } System . out . println ( gojtEpGnRl ? " YES " : " NO " ) ; } } import java . util . Scanner ; public class lONDsezhgA { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int lONDsezhgA = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; sc . close ( ) ; int bb = ( Y - 2 * lONDsezhgA ) ; if ( bb % 2 != 0 || bb < 0 ) { System . out . println ( " No " ) ; return ; } int b = bb / 2 ; int a = lONDsezhgA - b ; if ( a >= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } return ; } } import java . util . Scanner ; public class oVoQRRaISF { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long oVoQRRaISF = in . nextInt ( ) ; long sum = 0 ; for ( long i = 0 ; i <= oVoQRRaISF ; i ++ ) { if ( i % 3 != 0 && i % 5 != 0 ) sum += i ; } System . out . println ( sum ) ; } } import java . util . * ; public class pONgvaNaAH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int pONgvaNaAH = S . length ( ) ; char [ ] tmp ; tmp = new char [ pONgvaNaAH ] ; for ( int i = 0 ; i < pONgvaNaAH ; i ++ ) { tmp [ i ] = 'x' ; } System . out . println ( tmp ) ; } } import java . io . * ; class GEOOOISVyd { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int GEOOOISVyd = Integer . parseInt ( br . readLine ( ) ) ; double result = 100000 ; for ( int i = 0 ; i < GEOOOISVyd ; 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 FBNiBMvxoC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FBNiBMvxoC = sc . nextInt ( ) ; int [ ] ary = new int [ FBNiBMvxoC ] ; 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 [ FBNiBMvxoC - 1 ] , sum ) ; } } import java . util . Scanner ; public class frqWcPOStp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long frqWcPOStp = scanner . nextLong ( ) ; long k = scanner . nextLong ( ) ; int len = 0 ; if ( frqWcPOStp == 0 ) { System . out . println ( 1 ) ; return ; } while ( frqWcPOStp > 0 ) { ++ len ; frqWcPOStp /= k ; } System . out . println ( len ) ; } } import java . util . Scanner ; public class xaPqMUlpVv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xaPqMUlpVv = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ xaPqMUlpVv ] ; int [ ] c = new int [ xaPqMUlpVv ] ; int ans = 0 ; for ( int i = 0 ; i < xaPqMUlpVv ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < xaPqMUlpVv ; i ++ ) { ans += Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 1 ; i < xaPqMUlpVv ; i ++ ) { c [ i ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < xaPqMUlpVv - 1 ; i ++ ) { if ( a [ i ] + 1 == a [ i + 1 ] ) { ans += c [ a [ i ] ] ; } } System . out . println ( ans ) ; } } import java . util . * ; public class GArszFKnWM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GArszFKnWM = sc . nextInt ( ) ; int [ ] a = new int [ GArszFKnWM ] ; int count1 = 0 ; for ( int i = 0 ; i < GArszFKnWM ; 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 < GArszFKnWM ; i ++ ) { if ( a [ i ] == num ) { num ++ ; } else { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class dstZTBUhOg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dstZTBUhOg = scan . nextInt ( ) ; for ( int i = 0 ; i < dstZTBUhOg ; 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 IIicKpRbCL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { String str = scan . nextLine ( ) ; if ( str . equals ( " 0 " ) ) break ; int IIicKpRbCL = 0 ; char [ ] box = str . toCharArray ( ) ; for ( int i = 0 ; i < box . length ; i ++ ) IIicKpRbCL += box [ i ] - '0' ; System . out . println ( IIicKpRbCL ) ; } } } import java . util . * ; public class sIQLaKbgAz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sIQLaKbgAz = 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 < sIQLaKbgAz ; 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 EMVpICjWyS { 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 TrmeTzAsxI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TrmeTzAsxI = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int cnt = 0 ; while ( TrmeTzAsxI > 0 ) { cnt ++ ; TrmeTzAsxI = ( TrmeTzAsxI / l ) ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class pHrbmKbEFn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pHrbmKbEFn = sc . nextInt ( ) ; int [ ] v = new int [ pHrbmKbEFn ] ; int [ ] c = new int [ pHrbmKbEFn ] ; int [ ] a = new int [ pHrbmKbEFn ] ; for ( int i = 0 ; i < pHrbmKbEFn ; i ++ ) { v [ i ] = sc . nextInt ( ) ; } for ( int j = 0 ; j < pHrbmKbEFn ; j ++ ) { c [ j ] = sc . nextInt ( ) ; a [ j ] = v [ j ] - c [ j ] ; } int ans = 0 ; for ( int i = 0 ; i < pHrbmKbEFn ; i ++ ) { if ( a [ i ] >= 0 ) { ans += a [ i ] ; } } System . out . println ( ans ) ; } } import java . io . * ; public class ZJoyvCCSLh { public static void main ( String [ ] args ) throws IOException { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int ZJoyvCCSLh , n , right , left , x ; String str ; ZJoyvCCSLh = Integer . parseInt ( bf . readLine ( ) ) ; n = Integer . parseInt ( bf . readLine ( ) ) ; int [ ] order = new int [ ZJoyvCCSLh ] ; for ( int i = 0 ; i < ZJoyvCCSLh ; 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 < ZJoyvCCSLh ; i ++ ) { System . out . println ( order [ i ] ) ; } } } import java . util . * ; public class sGlvvGVEUk { public static void main ( String [ ] args ) { boolean sGlvvGVEUk = 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 poLWPOvstA { 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 BAyKscJwsB { 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 BAyKscJwsB = Integer . parseInt ( st . nextToken ( ) ) ; int K = Integer . parseInt ( st . nextToken ( ) ) ; st = new StringTokenizer ( input . readLine ( ) ) ; int [ ] arr = new int [ BAyKscJwsB ] ; int [ ] dp = new int [ BAyKscJwsB + 1 ] ; Arrays . fill ( dp , Integer . MAX_VALUE ) ; dp [ 0 ] = 0 ; for ( int i = 0 ; i < BAyKscJwsB ; i ++ ) { arr [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; } for ( int i = 0 ; i < BAyKscJwsB ; i ++ ) { for ( int k = 1 ; k < K + 1 ; k ++ ) { if ( i + k < BAyKscJwsB ) dp [ i + k ] = Math . min ( dp [ i + k ] , dp [ i ] + Math . abs ( arr [ i ] - arr [ i + k ] ) ) ; } } output . println ( dp [ BAyKscJwsB - 1 ] ) ; output . close ( ) ; } } import java . util . * ; public class wsudEhrFWo { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] line1 = line . split ( " " ) ; int wsudEhrFWo = Integer . parseInt ( line1 [ 0 ] ) ; int k = Integer . parseInt ( line1 [ 1 ] ) ; int q = Integer . parseInt ( line1 [ 2 ] ) ; int [ ] ary = new int [ wsudEhrFWo ] ; for ( int i = 0 ; i < wsudEhrFWo ; i ++ ) ary [ i ] = k - q ; for ( int i = 0 ; i < q ; i ++ ) { int a = sc . nextInt ( ) ; ary [ a - 1 ] ++ ; } for ( int i = 0 ; i < wsudEhrFWo ; i ++ ) { if ( ary [ i ] <= 0 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } } import java . util . * ; public class NXMexYcHgY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NXMexYcHgY = sc . nextInt ( ) ; long d = sc . nextInt ( ) ; d = d * d ; int cnt = 0 ; for ( int i = 0 ; i < NXMexYcHgY ; 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 TfNTKQWxmt { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int TfNTKQWxmt = in . nextInt ( ) ; int b = in . nextInt ( ) ; int sum1 = 0 , sum2 = 0 , sum = 0 ; TfNTKQWxmt = TfNTKQWxmt - 1 ; b = b - 1 ; sum1 = ( TfNTKQWxmt * ( TfNTKQWxmt + 1 ) ) / 2 ; sum2 = ( b * ( b + 1 ) ) / 2 ; sum = sum1 + sum2 ; System . out . println ( sum ) ; } } import java . util . Scanner ; public class TIbrivdzXB { public static int TIbrivdzXB ( int a , int b , int c ) { int TIbrivdzXB = 0 ; TIbrivdzXB = TIbrivdzXB + Math . abs ( b - a ) + Math . abs ( c - b ) ; return ( TIbrivdzXB ) ; } 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 ] = TIbrivdzXB ( A , B , C ) ; costSum [ 1 ] = TIbrivdzXB ( A , C , B ) ; costSum [ 2 ] = TIbrivdzXB ( B , A , C ) ; costSum [ 3 ] = TIbrivdzXB ( B , C , A ) ; costSum [ 4 ] = TIbrivdzXB ( C , A , B ) ; costSum [ 5 ] = TIbrivdzXB ( 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 gFvBQvLMRe { private static final int gFvBQvLMRe = 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 = gFvBQvLMRe ; 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 PiwZmLYNtn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; int PiwZmLYNtn = 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 ( PiwZmLYNtn % S == 0 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; import java . util . Collections ; public class JgBELTNyZP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JgBELTNyZP = sc . nextInt ( ) ; HashSet < Integer > A = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < JgBELTNyZP ; i ++ ) { A . add ( sc . nextInt ( ) ) ; } System . out . println ( A . size ( ) ) ; } } import java . util . * ; public class hluWqxNIcs { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int hluWqxNIcs = sc . nextInt ( ) ; int [ ] a = new int [ hluWqxNIcs ] ; for ( int i = 0 ; i < hluWqxNIcs ; i ++ ) a [ i ] = sc . nextInt ( ) ; int t = a [ 0 ] ; long sum = 0 ; for ( int i = 1 ; i < hluWqxNIcs ; 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 xKRrdPwpHB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xKRrdPwpHB = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < xKRrdPwpHB ; i ++ ) list . add ( sc . nextInt ( ) ) ; sc . close ( ) ; List < Integer > bloks = new ArrayList < > ( ) ; int target = Collections . min ( list ) ; for ( int idx = list . indexOf ( target ) ; idx <= xKRrdPwpHB ; idx ++ ) { int index = list . subList ( idx , xKRrdPwpHB ) . 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 ( xKRrdPwpHB - bloks . size ( ) ) ; } } } import java . util . Scanner ; import java . util . ArrayList ; class McTrkeefOL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int McTrkeefOL = sc . nextInt ( ) ; if ( McTrkeefOL == 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 >= McTrkeefOL ) { System . out . println ( i ) ; break ; } else if ( l == 0 ) { li . add ( i ) ; } i ++ ; l = 0 ; } } } } import java . util . Scanner ; public class DQdaJxSjpc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . next ( ) ; char DQdaJxSjpc = C . charAt ( 0 ) ; System . out . println ( ( char ) ( ( ( int ) DQdaJxSjpc ) + 1 ) ) ; } } import java . util . * ; public class NcAIndNEyo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NcAIndNEyo = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int min = x - NcAIndNEyo + 1 ; int max = x + NcAIndNEyo - 1 ; for ( int i = min ; i <= max ; i ++ ) { System . out . print ( i + " " ) ; } } } import java . util . Scanner ; public class xQyuzdfGVl { public static void main ( String [ ] args ) { int xQyuzdfGVl , t = 1 ; Scanner sc = new Scanner ( System . in ) ; while ( true ) { xQyuzdfGVl = sc . nextInt ( ) ; if ( xQyuzdfGVl == 0 ) break ; System . out . println ( " Case " + t ++ + " : " + xQyuzdfGVl ) ; } } } import java . util . * ; public class CAtrajelAw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CAtrajelAw , i , t , min , s1 , s2 ; int [ ] w ; CAtrajelAw = sc . nextInt ( ) ; w = new int [ CAtrajelAw ] ; for ( i = 0 ; i < CAtrajelAw ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } min = 99999 ; for ( t = 1 ; t < CAtrajelAw ; t ++ ) { s1 = 0 ; s2 = 0 ; for ( i = 0 ; i < t ; i ++ ) { s1 += w [ i ] ; } for ( ; i < CAtrajelAw ; 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 rKjRmUkifw { public static void main ( String [ ] args ) { String rKjRmUkifw = in . next ( ) ; if ( rKjRmUkifw . charAt ( 0 ) == rKjRmUkifw . charAt ( 1 ) && rKjRmUkifw . charAt ( 1 ) == rKjRmUkifw . 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 rKjRmUkifw { 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 txZSRPKAQw { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = reader . readLine ( ) . split ( " " ) ; int txZSRPKAQw , Y , Z ; txZSRPKAQw = Integer . parseInt ( arr [ 0 ] ) ; Y = Integer . parseInt ( arr [ 1 ] ) ; Z = Integer . parseInt ( arr [ 2 ] ) ; System . out . println ( Z + " " + txZSRPKAQw + " " + Y ) ; } } import java . util . Scanner ; import java . util . Arrays ; import java . util . List ; public class uVRVeBLVuT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String uVRVeBLVuT = sc . nextLine ( ) ; String [ ] array = uVRVeBLVuT . split ( " " ) ; List < String > list = Arrays . asList ( array ) ; System . out . println ( list . indexOf ( " 0 " ) + 1 ) ; } } import java . util . * ; class dXjOzAyJXC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dXjOzAyJXC = sc . nextInt ( ) ; sc . nextLine ( ) ; String S = sc . nextLine ( ) ; String [ ] Sarray = S . split ( " " ) ; String before = " " ; int ans = 0 ; for ( int i = 0 ; i < dXjOzAyJXC ; i ++ ) { if ( ! before . equals ( Sarray [ i ] ) ) { ans ++ ; } before = Sarray [ i ] ; } System . out . println ( ans ) ; } } import java . util . * ; class mWQnfDlmcM { 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 HZLTiEEDzT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; int HZLTiEEDzT = S . length ( ) ; loop : for ( int i = 0 ; i < HZLTiEEDzT ; i ++ ) { for ( int j = 0 ; j < HZLTiEEDzT ; j ++ ) { if ( S . charAt ( ( j + i ) % HZLTiEEDzT ) != T . charAt ( j ) ) { break ; } else { if ( j == HZLTiEEDzT - 1 ) { System . out . println ( " Yes " ) ; break loop ; } } } if ( i == HZLTiEEDzT - 1 ) { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class esyCGfAEOp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long esyCGfAEOp = 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 mAuIsLdgYj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mAuIsLdgYj = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; sc . close ( ) ; int count = 0 ; String str ; for ( int i = mAuIsLdgYj ; i <= B ; i ++ ) { str = " " + mAuIsLdgYj ; if ( str . charAt ( 0 ) == str . charAt ( 4 ) && str . charAt ( 1 ) == str . charAt ( 3 ) ) { count ++ ; } mAuIsLdgYj ++ ; } 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 whSNPMlHEu { 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 whSNPMlHEu { 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 JhvZapRPVo { public static void main ( String [ ] args ) throws Exception { Scanner sn = new Scanner ( System . in ) ; long JhvZapRPVo = sn . nextLong ( ) ; long sum = 0 ; for ( long i = 1 ; i <= JhvZapRPVo ; i ++ ) { if ( ( i % 3 ) == 0 || ( i % 5 ) == 0 || ( i % 15 ) == 0 ) { } else { sum += i ; } } System . out . print ( sum ) ; } } import java . util . Scanner ; public class OGqKkYXVJg { static char [ ] OGqKkYXVJg = { '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 OGqKkYXVJg = 0 ; while ( true ) { String T = stdIn . next ( ) ; if ( T . equals ( " END_OF_TEXT " ) ) { break ; } T = T . toLowerCase ( ) ; if ( T . equals ( W ) ) { OGqKkYXVJg ++ ; } } System . out . println ( OGqKkYXVJg ) ; } } import java . util . * ; class uadscWMAbw { Scanner sc ; Main ( ) { sc = new Scanner ( System . in ) ; } void calc ( ) { int uadscWMAbw = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( uadscWMAbw > 9 || B > 9 ) System . out . println ( - 1 ) ; else System . out . println ( uadscWMAbw * B ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . Scanner ; public class MzQgOXLsxL { 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 MzQgOXLsxL = 0 ; while ( ! wd [ MzQgOXLsxL ] . equals ( s ) ) MzQgOXLsxL += 1 ; int ans = 7 - MzQgOXLsxL ; 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 WdiLuivkvf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WdiLuivkvf = Integer . parseInt ( sc . next ( ) ) ; List < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; i < WdiLuivkvf ; 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 sfiBNCSonr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] scan = scanner . nextLine ( ) . split ( " " ) ; int sfiBNCSonr = 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 , sfiBNCSonr ) ; System . out . println ( sum ) ; } } import java . util . Scanner ; public class RmPUBDNzan { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; while ( true ) { int RmPUBDNzan = stdin . nextInt ( ) ; int y = stdin . nextInt ( ) ; if ( RmPUBDNzan == 0 && y == 0 ) { break ; } else if ( RmPUBDNzan > y ) { System . out . printf ( " %d %d%n " , y , RmPUBDNzan ) ; } else { System . out . printf ( " %d %d%n " , RmPUBDNzan , y ) ; } } } } import java . util . Scanner ; public class zBGRlOLRzX { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] numbers = new int [ 3 ] ; for ( int zBGRlOLRzX = 0 ; zBGRlOLRzX < numbers . length ; zBGRlOLRzX ++ ) { String input = scan . next ( ) ; numbers [ zBGRlOLRzX ] = Integer . parseInt ( input ) ; } for ( int zBGRlOLRzX = 0 ; zBGRlOLRzX < 3 ; zBGRlOLRzX ++ ) { int point = zBGRlOLRzX ; for ( int j = point ; j < 3 ; j ++ ) { if ( numbers [ point ] > numbers [ j ] ) { point = j ; } } int tmp = numbers [ point ] ; numbers [ point ] = numbers [ zBGRlOLRzX ] ; numbers [ zBGRlOLRzX ] = tmp ; } System . out . println ( numbers [ 0 ] + " " + numbers [ 1 ] + " " + numbers [ 2 ] ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class UMCoQAfGvC { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int UMCoQAfGvC = Integer . parseInt ( str [ 0 ] ) ; int d = Integer . parseInt ( str [ 1 ] ) ; int [ ] [ ] p = new int [ UMCoQAfGvC ] [ d ] ; for ( int i = 0 ; i < UMCoQAfGvC ; 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 < UMCoQAfGvC ; ++ i ) { for ( int j = i + 1 ; j < UMCoQAfGvC ; ++ j ) { if ( f ( p [ i ] , p [ j ] , d ) ) ++ count ; } } System . out . println ( count ) ; } private static boolean f ( int [ ] p , int [ ] p2 , int UMCoQAfGvC ) { int sum = 0 ; for ( int i = 0 ; i < UMCoQAfGvC ; ++ 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 PfFheSbVui { private static Scanner scan ; public static void main ( String [ ] args ) { scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int PfFheSbVui = str . length ( ) ; String rts = " " ; for ( int i = PfFheSbVui - 1 ; i >= 0 ; i -- ) { rts = rts + str . charAt ( i ) ; } System . out . println ( rts ) ; System . exit ( 0 ) ; } } import java . io . * ; public class CiqZnUKkyK { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder stb = new StringBuilder ( ) ; int CiqZnUKkyK = Integer . parseInt ( buf . readLine ( ) ) ; int [ ] h = new int [ CiqZnUKkyK ] ; String [ ] str = buf . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < h . length ; i ++ ) { h [ i ] = Integer . parseInt ( str [ i ] ) ; } Sert ( h , CiqZnUKkyK ) ; } public static void Sert ( int [ ] h , int CiqZnUKkyK ) { 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 yroMHKPaNP { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; int yroMHKPaNP = scanner . nextInt ( ) ; int num = scanner . nextInt ( ) ; int tmp = 0 ; for ( int i = 0 ; i < num ; i ++ ) { tmp += scanner . nextInt ( ) ; } int day = yroMHKPaNP - tmp ; if ( day >= 0 ) { System . out . println ( day ) ; } else { System . out . println ( - 1 ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class JOPVTQiQGf { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int JOPVTQiQGf = gi ( ) ; int c = 0 ; for ( int i = 1 ; i <= JOPVTQiQGf ; i += 2 ) { if ( yakusuC ( i ) == 8 ) { c ++ ; } } System . out . print ( c ) ; } public static int yakusuC ( int JOPVTQiQGf ) { StringBuilder sb = new StringBuilder ( ) ; int c = 0 ; for ( int i = 1 ; i <= JOPVTQiQGf ; i ++ ) { if ( JOPVTQiQGf % i == 0 ) { c ++ ; } } return c ; } public static long d ( long JOPVTQiQGf ) { String a = String . valueOf ( JOPVTQiQGf ) ; 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 JhunGesrWI { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int JhunGesrWI = 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 [ JhunGesrWI ] [ 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 lKAYdsNDbY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lKAYdsNDbY = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int count = 0 ; while ( lKAYdsNDbY > 0 ) { lKAYdsNDbY /= k ; count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class WwZOXCvTQA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > dan = new ArrayList < > ( ) ; int WwZOXCvTQA = sc . nextInt ( ) ; int [ ] d = new int [ WwZOXCvTQA ] ; for ( int i = 0 ; i < WwZOXCvTQA ; i ++ ) { d [ i ] = sc . nextInt ( ) ; if ( ! dan . contains ( d [ i ] ) ) { dan . add ( d [ i ] ) ; } } System . out . println ( dan . size ( ) ) ; } } import java . util . Scanner ; class nHNrSafBlM { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int nHNrSafBlM = stdIn . nextInt ( ) ; int [ ] a = new int [ nHNrSafBlM ] ; for ( int i = 0 ; i < nHNrSafBlM ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; } int max = 0 ; int max2 = 0 ; for ( int i = 0 ; i < nHNrSafBlM ; i ++ ) { if ( a [ i ] > max ) { max2 = max ; max = a [ i ] ; } else if ( a [ i ] > max2 ) { max2 = a [ i ] ; } } for ( int i = 0 ; i < nHNrSafBlM ; i ++ ) { if ( a [ i ] < max ) { System . out . println ( max ) ; } else { System . out . println ( max2 ) ; } } } } import java . util . * ; class ilKjjQXkyy { private static Scanner sc ; public static void main ( final String [ ] args ) { sc = new Scanner ( System . in ) ; long ilKjjQXkyy = sc . nextLong ( ) , ans = 0 , num = 100 ; while ( true ) { if ( num >= ilKjjQXkyy ) { System . out . println ( ans ) ; break ; } num += num / 100 ; ans ++ ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class eAkUTYzkyL { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int eAkUTYzkyL = Integer . parseInt ( br . readLine ( ) ) ; int answer = 0 ; for ( int i = 0 ; i < eAkUTYzkyL ; 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 IqdGMzhXfL { public static void main ( String [ ] args ) { String IqdGMzhXfL = new java . util . Scanner ( System . in ) . nextLine ( ) ; switch ( IqdGMzhXfL ) { 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 AfJEfOkGYZ { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; double AfJEfOkGYZ = sc . nextDouble ( ) ; double a = AfJEfOkGYZ / 3 ; double b = a * a * a ; System . out . println ( BigDecimal . valueOf ( a * a * a ) . toPlainString ( ) ) ; } } import java . util . Scanner ; public class BSPZUkpHMp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BSPZUkpHMp = sc . nextInt ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; char [ ] t = sc . next ( ) . toCharArray ( ) ; for ( int i = 0 ; i < BSPZUkpHMp ; 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 pfvRZRCugS { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int pfvRZRCugS = 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 < pfvRZRCugS ; 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 rMiTSEaIpU { static boolean [ ] prime ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; prime = new boolean [ 100000001 ] ; int rMiTSEaIpU = 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 ] ) { rMiTSEaIpU ++ ; } } System . out . println ( rMiTSEaIpU ) ; sc . close ( ) ; } } import java . util . Scanner ; public class lwGklhRVmm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lwGklhRVmm = sc . nextInt ( ) ; int [ ] A = new int [ lwGklhRVmm ] ; for ( int i = 0 ; i < lwGklhRVmm ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int ans = 1 ; for ( int i = 0 ; i < lwGklhRVmm ; 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 dAamYUJqay { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int dAamYUJqay = Integer . parseInt ( stdIn . next ( ) ) ; String s = stdIn . next ( ) ; int count = 0 ; int i = 0 ; while ( i < dAamYUJqay - 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 jlJiscSQUl { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { double jlJiscSQUl = scan . nextDouble ( ) ; double T = scan . nextDouble ( ) ; double S = scan . nextDouble ( ) ; double reqTime = ( jlJiscSQUl / S ) ; if ( reqTime > T ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . io . * ; class fsXmUdzJDu { 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 fsXmUdzJDu = Integer . parseInt ( arrays [ 0 ] ) + Integer . parseInt ( arrays [ 1 ] ) ; System . out . println ( Integer . toString ( fsXmUdzJDu ) . length ( ) ) ; str = br . readLine ( ) ; } } } import java . util . Scanner ; class dIRwJaYPWG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dIRwJaYPWG = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ dIRwJaYPWG ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < dIRwJaYPWG ; 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 < dIRwJaYPWG ; 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 uyKpQqGLan { 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 uyKpQqGLan = 0 ; uyKpQqGLan < s . length ( ) ; uyKpQqGLan ++ ) count [ s . charAt ( uyKpQqGLan ) - 97 ] ++ ; for ( int uyKpQqGLan = 0 ; uyKpQqGLan < 26 ; uyKpQqGLan ++ ) { if ( count [ uyKpQqGLan ] % 2 == 1 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class iaiUAOuiKr { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { while ( true ) { int iaiUAOuiKr = sc . nextInt ( ) ; int sum = 0 ; if ( iaiUAOuiKr == 0 ) { break ; } int [ ] scores = new int [ iaiUAOuiKr ] ; 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 / iaiUAOuiKr ; for ( int i = 0 ; i < scores . length ; i ++ ) { double x = Math . pow ( ( scores [ i ] - average ) , 2 ) ; y = x + y ; } variance = y / iaiUAOuiKr ; System . out . println ( Math . sqrt ( variance ) ) ; } } } } import java . io . * ; public class IaJiXfXlZg { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] line = br . readLine ( ) . split ( " " ) ; int IaJiXfXlZg = Integer . parseInt ( line [ 0 ] ) ; int c = Integer . parseInt ( line [ 1 ] ) ; int [ ] [ ] sheet = new int [ IaJiXfXlZg + 1 ] [ c + 1 ] ; for ( int i = 0 ; i < IaJiXfXlZg ; 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 [ IaJiXfXlZg ] [ c ] += a [ j ] ; sheet [ i ] [ c ] += a [ j ] ; sheet [ IaJiXfXlZg ] [ j ] += a [ j ] ; } } for ( int i = 0 ; i <= IaJiXfXlZg ; 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 GtitXewMmZ { Scanner sc = new Scanner ( System . in ) ; final int GtitXewMmZ = 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 XkrymNyyGT { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String W = scan . next ( ) ; String end = " END_OF_TEXT " ; int XkrymNyyGT = 0 ; for ( ; ; ) { String T = scan . next ( ) ; if ( T . equals ( end ) ) { break ; } else if ( T . equalsIgnoreCase ( W ) ) { XkrymNyyGT ++ ; } } System . out . println ( XkrymNyyGT ) ; } } import java . util . Scanner ; public class zntHsldWjA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zntHsldWjA = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; String S = " " ; if ( 2 * zntHsldWjA <= Y && Y <= 4 * zntHsldWjA && Y % 2 == 0 ) { S = " Yes " ; } else { S = " No " ; } System . out . println ( S ) ; } } import java . util . Scanner ; class LBmnmGjzeg { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LBmnmGjzeg = scan . nextInt ( ) ; int [ ] h = new int [ LBmnmGjzeg ] ; for ( int i = 0 ; i < LBmnmGjzeg ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } int ans = 0 ; int len = 0 ; for ( int i = 0 ; i < LBmnmGjzeg - 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 vCRpAmdQLs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double vCRpAmdQLs = sc . nextDouble ( ) ; sc . close ( ) ; double l = vCRpAmdQLs / 3 ; System . out . println ( Math . pow ( l , 3 ) ) ; } } import java . util . * ; public class dXnQpGNleO { 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 dXnQpGNleO = 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 ] ) { dXnQpGNleO ++ ; } } System . out . println ( dXnQpGNleO ) ; } } import java . util . Scanner ; public class FMiWidXYlJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FMiWidXYlJ = sc . nextInt ( ) ; int count = 0 ; int [ ] flag = new int [ 101 ] ; for ( int i = 0 ; i < FMiWidXYlJ ; 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 jxKhkvrYXm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jxKhkvrYXm = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; for ( int i = 0 ; i < M ; i ++ ) { jxKhkvrYXm -= sc . nextInt ( ) ; } if ( jxKhkvrYXm < 0 ) { System . out . println ( - 1 ) ; } else System . out . println ( jxKhkvrYXm ) ; } } import java . io . IOException ; public class qAbwFobNfj { public static void main ( String [ ] args ) throws IOException { int qAbwFobNfj = 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 ) { qAbwFobNfj |= 1 ; } else if ( num < 2 ) { qAbwFobNfj |= 2 ; } else if ( num < 3 ) { qAbwFobNfj |= 4 ; } else if ( num < 4 ) { qAbwFobNfj |= 8 ; } else if ( num < 5 ) { qAbwFobNfj |= 16 ; } else if ( num < 6 ) { qAbwFobNfj |= 32 ; } else if ( num < 7 ) { qAbwFobNfj |= 64 ; } else if ( num < 8 ) { qAbwFobNfj |= 128 ; } else { over ++ ; } if ( buf == '\n' ) break ; } int count = Integer . bitCount ( qAbwFobNfj ) ; int max = count + over ; if ( count == 0 ) count = 1 ; System . out . print ( count + " " + max ) ; } } import java . util . Scanner ; public class qDkMjGeHvI { public static void main ( String [ ] args ) throws Exception { Scanner s = new Scanner ( System . in ) ; String qDkMjGeHvI = s . next ( ) ; qDkMjGeHvI = qDkMjGeHvI . replaceAll ( " eraser " , " " ) ; qDkMjGeHvI = qDkMjGeHvI . replaceAll ( " erase " , " " ) ; qDkMjGeHvI = qDkMjGeHvI . replaceAll ( " dreamer " , " " ) ; qDkMjGeHvI = qDkMjGeHvI . replaceAll ( " dream " , " " ) ; System . out . println ( qDkMjGeHvI . 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 aENzTefOGm { 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 aENzTefOGm = Integer . parseInt ( line ) ; StringTokenizer tokens ; for ( int i = 0 ; i < aENzTefOGm ; 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 xrWtOpLDMl { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int xrWtOpLDMl = in . nextInt ( ) ; int [ ] a = new int [ xrWtOpLDMl ] ; for ( int i = 0 ; i < xrWtOpLDMl ; i ++ ) { a [ i ] = in . nextInt ( ) ; } int [ ] dp = new int [ xrWtOpLDMl ] ; int max = - 1 ; for ( int i = xrWtOpLDMl - 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 NScZycCllT { public static int getCvalue ( int n , int m ) { if ( n < 2 ) { return 0 ; } else { int NScZycCllT = n - m ; int a = 1 ; while ( n > NScZycCllT ) { 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 igggUrcerR { 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 rdkTaIWJZU { 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 rdkTaIWJZU = 0 ; rdkTaIWJZU < ary . length ; rdkTaIWJZU ++ ) { list . add ( new Integer ( ary [ rdkTaIWJZU ] ) ) ; } Collections . reverse ( list ) ; for ( int rdkTaIWJZU = 0 ; rdkTaIWJZU < list . size ( ) ; rdkTaIWJZU ++ ) { System . out . print ( list . get ( rdkTaIWJZU ) ) ; if ( rdkTaIWJZU == list . size ( ) - 1 ) { System . out . println ( ) ; } else { System . out . print ( " " ) ; } } } } import java . util . * ; public class MkVBeIVDAl { public static void main ( String [ ] args ) { Scanner sp = new Scanner ( System . in ) ; int MkVBeIVDAl = sp . nextInt ( ) ; int b = sp . nextInt ( ) ; int l = 0 ; int n = 0 ; if ( MkVBeIVDAl < b ) { l = b ; } else { l = MkVBeIVDAl ; } for ( int k = 0 ; k < l ; k ++ ) { if ( Math . abs ( MkVBeIVDAl - 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 cPaBTgDTRz { static int cPaBTgDTRz = 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]+ " ) ; cPaBTgDTRz = Integer . parseInt ( nyuryokuStr [ 0 ] ) ; weight = Integer . parseInt ( nyuryokuStr [ 1 ] ) ; if ( cPaBTgDTRz == 0 && weight == 0 ) { zeroFlag = false ; } else { for ( int h = 0 ; h < cPaBTgDTRz ; h ++ ) { for ( int w = 0 ; w < weight ; w ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } line = br . readLine ( ) ; } } } import java . util . * ; class aIjNCHTijQ { 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 aIjNCHTijQ = 0 ; if ( s1 . equals ( t1 ) ) { aIjNCHTijQ += 1 ; } else { aIjNCHTijQ += 0 ; } if ( s2 . equals ( t2 ) ) { aIjNCHTijQ += 1 ; } else { aIjNCHTijQ += 0 ; } if ( s3 . equals ( t3 ) ) { aIjNCHTijQ += 1 ; } else { aIjNCHTijQ += 0 ; } System . out . println ( aIjNCHTijQ ) ; } } import java . util . * ; import java . io . * ; public class gOBdfzFruO { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int gOBdfzFruO = scan . nextInt ( ) ; int max = 0 ; int ans = 0 ; int cnt = 0 ; for ( int i = 1 ; i <= gOBdfzFruO ; 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 uyqPVrMJOT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uyqPVrMJOT = sc . nextInt ( ) ; PriorityQueue < Integer > queue = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < uyqPVrMJOT ; i ++ ) { queue . add ( sc . nextInt ( ) ) ; } int sum = 0 ; for ( int i = 0 ; i < uyqPVrMJOT - 1 ; i ++ ) { sum += queue . poll ( ) ; } System . out . println ( queue . poll ( ) < sum ? " Yes " : " No " ) ; } } import java . util . Scanner ; class jOSkmpQXbA { 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 jOSkmpQXbA = 0 ; jOSkmpQXbA < t . length ( ) ; jOSkmpQXbA ++ ) { if ( c [ 0 ] == al [ jOSkmpQXbA ] ) { System . out . println ( al [ jOSkmpQXbA + 1 ] ) ; } } } } import java . io . * ; import java . lang . Math ; class CxfaDqouUI { public static void main ( String [ ] args ) throws IOException { double CxfaDqouUI , s , l ; InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String buf = br . readLine ( ) ; CxfaDqouUI = Double . parseDouble ( buf ) ; s = CxfaDqouUI * CxfaDqouUI * Math . PI ; l = 2 * CxfaDqouUI * Math . PI ; System . out . printf ( " %.6f %.6f \n " , s , l ) ; } } import java . util . * ; public class sCFPnXSKhc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String ans = " " ; for ( char sCFPnXSKhc : S . toCharArray ( ) ) { if ( sCFPnXSKhc == '0' ) { ans += " 0 " ; } else if ( sCFPnXSKhc == '1' ) { ans += " 1 " ; } else if ( sCFPnXSKhc == 'B' && ans . length ( ) == 0 ) { continue ; } else { ans = ans . substring ( 0 , ans . length ( ) - 1 ) ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . math . * ; class mdEaECIHby { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String mdEaECIHby = sc . next ( ) ; String ans = " " ; if ( mdEaECIHby . 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 VImgyXZueF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VImgyXZueF = Integer . parseInt ( sc . next ( ) ) ; int ex = Integer . parseInt ( sc . next ( ) ) ; int [ ] teki = new int [ VImgyXZueF ] ; for ( int i = 0 ; i < VImgyXZueF ; i ++ ) { teki [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( teki ) ; VImgyXZueF -= ex ; long res = 0L ; for ( int i = 0 ; i < VImgyXZueF ; 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 IzfQLDNlrP { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int IzfQLDNlrP = scanner . nextInt ( ) ; int routeCnt = scanner . nextInt ( ) ; Map < Integer , Integer > map = initMap ( IzfQLDNlrP ) ; 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 IzfQLDNlrP ) { Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 1 ; i <= IzfQLDNlrP ; i ++ ) { map . put ( i , 0 ) ; } return map ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class HgMhYRHJIl { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int HgMhYRHJIl = Integer . parseInt ( br . readLine ( ) ) ; String [ ] tmpArray = br . readLine ( ) . split ( " " ) ; int [ ] input = new int [ HgMhYRHJIl ] ; for ( int i = 0 ; i < HgMhYRHJIl ; i ++ ) { input [ i ] = Integer . parseInt ( tmpArray [ i ] ) ; } int target = 1 ; int length = 0 ; for ( int i = 0 ; i < HgMhYRHJIl ; i ++ ) { if ( input [ i ] == target ) { target ++ ; length ++ ; } } System . out . println ( length > 0 ? HgMhYRHJIl - length : - 1 ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class PQmlJXuQQX { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String str ; String [ ] arr ; int PQmlJXuQQX ; int j ; while ( ( str = br . readLine ( ) ) != null ) { arr = str . split ( " " ) ; PQmlJXuQQX = Integer . parseInt ( arr [ 0 ] ) ; j = Integer . parseInt ( arr [ 1 ] ) ; if ( PQmlJXuQQX == 0 && j == 0 ) { break ; } if ( PQmlJXuQQX <= 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 gMpRpIfLIy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gMpRpIfLIy = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int [ ] n = new int [ 5 ] ; int count = 0 ; int temp = 0 ; for ( int i = gMpRpIfLIy ; 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 NgxSmxEauk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NgxSmxEauk = 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 [ NgxSmxEauk ] ; for ( int i = 0 ; i < NgxSmxEauk ; 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 FsdunYXkcW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FsdunYXkcW = sc . nextInt ( ) ; int q = FsdunYXkcW ; int num = 0 ; while ( q > 0 ) { num += q % 10 ; q = q / 10 ; } if ( FsdunYXkcW % 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 sPRpabyhJZ { 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 sPRpabyhJZ { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int sPRpabyhJZ = in . nextInt ( ) ; int q = in . nextInt ( ) ; int r = in . nextInt ( ) ; out . println ( Math . min ( Math . min ( sPRpabyhJZ + q , sPRpabyhJZ + r ) , q + r ) ) ; } } static class sPRpabyhJZ { 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 OAwghEywVp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int OAwghEywVp = scanner . nextInt ( ) ; int N6 = OAwghEywVp / 100000 % 10 ; int N5 = OAwghEywVp / 10000 % 10 ; int N4 = OAwghEywVp / 1000 % 10 ; int N3 = OAwghEywVp / 100 % 10 ; int N2 = OAwghEywVp / 10 % 10 ; int result = 0 ; if ( N6 == 1 ) { result = 90909 ; } else if ( N5 != 0 ) { result = ( OAwghEywVp - 9999 ) + 909 ; } else if ( N4 != 0 ) { result = 909 ; } else if ( N3 != 0 ) { result = ( OAwghEywVp - 99 ) + 9 ; } else if ( N2 != 0 ) { result = 9 ; } else { result = OAwghEywVp ; } 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 iVQpOEmWFr { static final int iVQpOEmWFr = 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 mgtIOxYWLQ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int mgtIOxYWLQ = scan . nextInt ( ) ; scan . close ( ) ; String str = String . valueOf ( mgtIOxYWLQ ) ; 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 avEtzZviXO { public static void main ( String [ ] args ) throws Exception { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int avEtzZviXO = Integer . parseInt ( br . readLine ( ) ) ; Map < String , Integer > map = new TreeMap < > ( ) ; int max = 0 ; for ( int i = 0 ; i < avEtzZviXO ; 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 XWhAwfGJTa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XWhAwfGJTa = sc . nextInt ( ) ; String ans = " No " ; int jdg = XWhAwfGJTa % 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 upazafUhKN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int upazafUhKN = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; String ans = " NO " ; if ( upazafUhKN * b * c == 5 * 7 * 5 ) ans = " YES " ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . StringTokenizer ; public class QmTGleogzq { 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 QmTGleogzq = nin ( ) ; boolean res = false ; int c = 0 ; for ( int i = 0 ; i < QmTGleogzq ; ++ 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 YyWRUuyBsR { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int YyWRUuyBsR = Integer . parseInt ( br . readLine ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] s ; int a , b , c ; for ( int i = 0 ; i < YyWRUuyBsR ; ++ 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 veRnfZKglq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { int veRnfZKglq = Integer . parseInt ( br . readLine ( ) ) ; if ( veRnfZKglq == 0 ) { break ; } int [ ] su = new int [ veRnfZKglq ] ; 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 / veRnfZKglq ; double result = 0 ; for ( int i = 0 ; i < veRnfZKglq ; i ++ ) { result += ( Math . pow ( ( su [ i ] - avg ) , 2 ) / veRnfZKglq ) ; } System . out . println ( Math . sqrt ( result ) ) ; } } } import java . util . * ; class HbPVunkOvg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long HbPVunkOvg = sc . nextLong ( ) ; long [ ] A = new long [ ( int ) HbPVunkOvg ] ; int k = 1 ; int ans = 0 ; for ( int i = 0 ; i < HbPVunkOvg ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < HbPVunkOvg ; i ++ ) { if ( A [ i ] == k ) { k ++ ; } else { ans ++ ; } } if ( ans == HbPVunkOvg ) { ans = - 1 ; } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; public class qVtXDjBXvx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qVtXDjBXvx = Integer . parseInt ( sc . next ( ) ) ; int x = qVtXDjBXvx ; int num = 0 ; while ( x > 0 ) { num += x % 10 ; x /= 10 ; } if ( qVtXDjBXvx % num == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class RAAhnIMgIC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RAAhnIMgIC = sc . nextInt ( ) ; int cnt = 0 ; boolean isWin = false ; for ( int i = 0 ; i < RAAhnIMgIC ; 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 TFacqndpxG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int TFacqndpxG = scan . nextInt ( ) ; int [ ] a = new int [ TFacqndpxG ] ; int max = Integer . MIN_VALUE ; int subMax = Integer . MIN_VALUE ; for ( int i = 0 ; i < TFacqndpxG ; 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 < TFacqndpxG ; i ++ ) { if ( a [ i ] == max ) { System . out . println ( subMax ) ; } else { System . out . println ( max ) ; } } } } import java . util . Scanner ; public class uDqwVGrkzj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int uDqwVGrkzj = sc . nextInt ( ) ; System . out . println ( ( uDqwVGrkzj + 2 - 1 ) / 2 ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class SrfSICzgHO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SrfSICzgHO = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] D = new int [ K ] ; int [ ] A = new int [ SrfSICzgHO + 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 ( SrfSICzgHO - count ) ; } } public class UPchKanAKm { public static void main ( String [ ] args ) { java . util . Scanner scan = new java . util . Scanner ( System . in ) ; int UPchKanAKm , b , c , d , e ; long f ; UPchKanAKm = scan . nextInt ( ) ; d = - 1000000 ; e = 1000000 ; f = 0 ; if ( 0 <= UPchKanAKm && UPchKanAKm <= 10000 ) { for ( b = 1 ; b <= UPchKanAKm ; 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 SvfMTeTVKl { 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 SvfMTeTVKl = 0 ; SvfMTeTVKl < oneline . length ; SvfMTeTVKl ++ ) { data [ SvfMTeTVKl ] = Integer . parseInt ( oneline [ SvfMTeTVKl ] ) ; } int area = data [ 0 ] * data [ 1 ] ; int length = 2 * ( data [ 0 ] + data [ 1 ] ) ; System . out . println ( area + " " + length ) ; } } import java . util . Scanner ; public class tKQhKJnQuy { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int tKQhKJnQuy = scn . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= tKQhKJnQuy ; i ++ ) { for ( int j = 1 ; j <= tKQhKJnQuy ; j ++ ) { for ( int k = 1 ; k <= tKQhKJnQuy ; 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 vFEOPhKErg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vFEOPhKErg = 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 >= vFEOPhKErg && temp <= r ) { count ++ ; } } } } System . out . println ( count ) ; } } import java . util . * ; public class JFTQogdRwi { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] tokens = in . nextLine ( ) . split ( " " ) ; in . close ( ) ; int JFTQogdRwi = 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 ( JFTQogdRwi > min ) { result -= 1 ; } if ( B < max ) { result -= 1 ; } System . out . println ( result ) ; } } import java . util . * ; public class JNfBlfrRQs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long JNfBlfrRQs = scan . nextLong ( ) ; long a = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long c = a + b ; long d = JNfBlfrRQs % c ; if ( ( a == 0 ) || ( c == 0 ) ) { System . out . println ( " 0 " ) ; return ; } long g = ( long ) ( JNfBlfrRQs - d ) / c ; if ( g == 0 ) { if ( JNfBlfrRQs <= a ) { System . out . println ( JNfBlfrRQs ) ; } 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 ShqfRupING { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { Scanner scanner = new Scanner ( System . in ) ; int ShqfRupING = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; if ( ShqfRupING < 1 || ShqfRupING > 9 || B < 1 || B > 9 ) { System . out . println ( - 1 ) ; return ; } System . out . println ( ShqfRupING * B ) ; } } import java . util . Scanner ; public class ewoyKjpsPA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ewoyKjpsPA = sc . nextInt ( ) , n = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; if ( n == 100 ) n ++ ; sb . append ( n ) ; for ( int i = 0 ; i < ewoyKjpsPA ; 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 deTeFsSlup { 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 deTeFsSlup { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long deTeFsSlup = in . nextLong ( ) ; long base = 100 ; long year = 1 ; while ( true ) { base += Math . floor ( base / 100 ) ; if ( deTeFsSlup <= base ) { out . println ( year ) ; return ; } else { year ++ ; } } } } } import java . util . Scanner ; public class yuVCGhNRmq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; char [ ] S = scanner . next ( ) . toCharArray ( ) ; for ( int yuVCGhNRmq = 0 ; yuVCGhNRmq < S . length ; yuVCGhNRmq ++ ) { if ( ( yuVCGhNRmq + 1 ) % 2 == 1 ) { if ( S [ yuVCGhNRmq ] == 'L' ) { System . out . println ( " No " ) ; return ; } } else { if ( S [ yuVCGhNRmq ] == 'R' ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class XcLlrquicK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XcLlrquicK = 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 ; XcLlrquicK > 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 ] > XcLlrquicK - 1 ) count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class PFmQqIjRgd { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int PFmQqIjRgd = s . nextInt ( ) ; System . out . println ( ( double ) PFmQqIjRgd * PFmQqIjRgd * PFmQqIjRgd / 27 ) ; s . close ( ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class qnzVTgyDuP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qnzVTgyDuP = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < qnzVTgyDuP ; i ++ ) { map . put ( i , sc . nextInt ( ) ) ; } int cnt = 0 ; cnt += map . get ( 0 ) ; for ( int i = 1 ; i < qnzVTgyDuP ; 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 LxaWhDqJdT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LxaWhDqJdT = 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 [ LxaWhDqJdT ] ; int t = 0 ; for ( int i = 1 ; i < LxaWhDqJdT ; ++ 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 oZNoOhKAae { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oZNoOhKAae = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( oZNoOhKAae > 9 || b > 9 ? " -1 " : oZNoOhKAae * b ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class bGaVGcrWOl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String bGaVGcrWOl = sc . nextLine ( ) ; System . out . println ( " 2018 " + bGaVGcrWOl . substring ( 4 ) ) ; } } import java . util . Scanner ; public class qXjSeajTpz { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int qXjSeajTpz = sc . nextInt ( ) ; int [ ] a = new int [ qXjSeajTpz ] ; for ( int i = 0 ; i < qXjSeajTpz ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } printArray ( a ) ; for ( int i = 1 ; i < qXjSeajTpz ; 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 YKYJEnQnpD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String YKYJEnQnpD = sc . next ( ) ; if ( YKYJEnQnpD . equals ( " SSS " ) ) { System . out . println ( 0 ) ; return ; } if ( YKYJEnQnpD . equals ( " RRR " ) ) { System . out . println ( 3 ) ; return ; } if ( YKYJEnQnpD . equals ( " RRS " ) || YKYJEnQnpD . equals ( " SRR " ) ) { System . out . println ( 2 ) ; return ; } System . out . println ( 1 ) ; } } import java . util . * ; public class HFuXymbMgm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HFuXymbMgm = sc . nextInt ( ) ; PriorityQueue < Double > q = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < HFuXymbMgm ; 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 wRNsPizZdh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wRNsPizZdh = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; int ans = 0 ; for ( int i = 0 ; i < wRNsPizZdh ; i ++ ) { String s = sc . next ( ) ; if ( ! set . contains ( s ) ) { set . add ( s ) ; ans ++ ; } } System . out . print ( ans ) ; } } import java . util . Scanner ; public class uhgtoXLtdU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double uhgtoXLtdU = sc . nextInt ( ) ; double b = sc . nextInt ( ) ; double c = sc . nextInt ( ) ; double d = sc . nextInt ( ) ; double tturn = Math . ceil ( c / b ) ; double aturn = Math . ceil ( uhgtoXLtdU / 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 UpuWVCPFuo { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int UpuWVCPFuo = 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 <= UpuWVCPFuo && y - r >= 0 && y + r <= H ) ? " Yes " : " No " ) ; } } import java . util . * ; public class rdJCHaNofN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rdJCHaNofN = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; double ans = 100001.0 ; double bef ; int answer = 0 ; for ( int i = 0 ; i < rdJCHaNofN ; 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 gCWvqCiLkq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int gCWvqCiLkq = Integer . parseInt ( sc . next ( ) ) ; List < Integer > a = new ArrayList < > ( ) ; a . add ( gCWvqCiLkq ) ; 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 YJOIFHOHQF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YJOIFHOHQF = sc . nextInt ( ) ; int [ ] d = new int [ YJOIFHOHQF ] ; for ( int i = 0 ; i < YJOIFHOHQF ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; int ans = 1 ; for ( int i = 1 ; i < YJOIFHOHQF ; i ++ ) { if ( d [ i - 1 ] != d [ i ] ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class vmIlXAVVYV { 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 vmIlXAVVYV = 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 >= vmIlXAVVYV ) { 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 iuezTXzKOR { static class iuezTXzKOR { 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 iuezTXzKOR = " " ; try { iuezTXzKOR = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return iuezTXzKOR ; } 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 JieAIwnRVi { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int JieAIwnRVi = sc . nextInt ( ) ; String [ ] str = new String [ JieAIwnRVi ] ; for ( int i = 0 ; i < JieAIwnRVi ; 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 HjQGkwMktG { 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 HjQGkwMktG ; for ( int i = 0 ; i < a . length ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( a [ i ] < a [ j ] ) { HjQGkwMktG = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = HjQGkwMktG ; } } } HjQGkwMktG = a [ 1 ] - a [ 0 ] ; HjQGkwMktG += a [ 2 ] - a [ 1 ] ; System . out . println ( HjQGkwMktG ) ; } } import java . util . Scanner ; public class yKcddhesQd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yKcddhesQd = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int count = 0 ; if ( yKcddhesQd == b ) { count ++ ; } if ( b == c ) { count ++ ; } if ( c == yKcddhesQd ) { count ++ ; } System . out . println ( count == 1 ? " Yes " : " No " ) ; } } import java . util . * ; public class FEXCNTUGJF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Integer n = Integer . valueOf ( sc . nextLine ( ) ) ; String FEXCNTUGJF = sc . nextLine ( ) ; Map < Integer , Integer > vList = str2List ( FEXCNTUGJF ) ; 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 zwtntGFMGW { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int zwtntGFMGW = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] m = new int [ zwtntGFMGW ] ; int minCost = Integer . MAX_VALUE ; int total = 0 ; for ( int i = 0 ; i < zwtntGFMGW ; i ++ ) { m [ i ] = sc . nextInt ( ) ; minCost = Math . min ( minCost , m [ i ] ) ; total += m [ i ] ; } System . out . println ( ( x - total ) / minCost + zwtntGFMGW ) ; } } import java . util . Scanner ; public class yHuCAIhiuT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; int yHuCAIhiuT = Integer . parseInt ( String . join ( " " , S . split ( " / " ) ) ) ; System . out . println ( yHuCAIhiuT <= 20190430 ? " Heisei " : " TBD " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class jgWUrZqkpo { 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 jgWUrZqkpo { int jgWUrZqkpo ; int cnt ; public void init ( ) { jgWUrZqkpo = 0 ; cnt = 0 ; } public void readHead ( String str ) { String [ ] strArr = str . split ( " " ) ; jgWUrZqkpo = 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 < jgWUrZqkpo ; } public void readBody ( String str ) { cnt ++ ; } public void solve ( ) { } } import java . util . ArrayList ; import java . util . Scanner ; class DWbtQViIFw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DWbtQViIFw = sc . nextInt ( ) ; int firstPoint = sc . nextInt ( ) ; ArrayList < Integer > playerPoint = new ArrayList < > ( ) ; for ( int i = 0 ; i < DWbtQViIFw ; 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 < DWbtQViIFw ; i ++ ) { System . out . println ( firstPoint - cnt + playerPoint . get ( i ) > 0 ? " Yes " : " No " ) ; } } } import java . math . BigDecimal ; import java . util . Scanner ; public class NxxOgLuHns { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long NxxOgLuHns = sc . nextLong ( ) ; BigDecimal ans = new BigDecimal ( 1 ) ; BigDecimal over = new BigDecimal ( 1000000000000000000L ) ; boolean ov = false ; boolean ze = false ; for ( int i = 0 ; i < NxxOgLuHns ; 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 QAYuZcJmrH { 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 QAYuZcJmrH : chars ) { if ( QAYuZcJmrH == '1' ) { System . out . print ( 9 ) ; } else { System . out . print ( 1 ) ; } } } } import java . util . Scanner ; class JkxdCdGVBg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JkxdCdGVBg = sc . nextInt ( ) ; String temp = String . valueOf ( JkxdCdGVBg / 100 ) ; int tem = Integer . parseInt ( temp + temp + temp ) ; if ( JkxdCdGVBg <= tem ) { System . out . println ( tem ) ; } else { System . out . println ( tem + 111 ) ; } } } import java . util . Scanner ; public class tfInYEVslv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tfInYEVslv = 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 ) == tfInYEVslv ) { System . out . println ( price ) ; f ++ ; break ; } } if ( f == 0 ) { System . out . println ( - 1 ) ; } } } import java . util . * ; public class wFwHyazwhw { public static void main ( String [ ] args ) { Scanner read = new Scanner ( System . in ) ; int wFwHyazwhw = read . nextInt ( ) ; int [ ] d = new int [ wFwHyazwhw ] ; d [ 0 ] = read . nextInt ( ) - 1 ; boolean ban = true ; for ( int i = 1 ; i < wFwHyazwhw ; 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 QacqsIcHUZ { 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 QacqsIcHUZ = 0 ; QacqsIcHUZ < a . length ; QacqsIcHUZ ++ ) { if ( Character . isLowerCase ( a [ QacqsIcHUZ ] ) ) System . out . print ( Character . toUpperCase ( a [ QacqsIcHUZ ] ) ) ; else if ( Character . isUpperCase ( a [ QacqsIcHUZ ] ) ) System . out . print ( Character . toLowerCase ( a [ QacqsIcHUZ ] ) ) ; else System . out . print ( a [ QacqsIcHUZ ] ) ; if ( QacqsIcHUZ == a . length - 1 ) System . out . println ( ) ; } } } import java . util . Scanner ; public class hKNKjgyxmH { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner scan = new Scanner ( System . in ) ; String W = scan . nextLine ( ) . toLowerCase ( ) ; int hKNKjgyxmH = 0 ; while ( scan . hasNext ( ) ) { String t = scan . next ( ) ; if ( t . equals ( " END_OF_TEXT " ) ) break ; t = t . toLowerCase ( ) ; if ( t . equals ( W ) ) hKNKjgyxmH ++ ; } System . out . println ( hKNKjgyxmH ) ; System . exit ( 0 ) ; } } import java . util . * ; public class QbKVjyxyNN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QbKVjyxyNN = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < QbKVjyxyNN ; i ++ ) { int x = sc . nextInt ( ) ; while ( x > 0 && x % 2 == 0 ) { count ++ ; x /= 2 ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class KRohobHBdL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long KRohobHBdL , b , g , l ; while ( sc . hasNext ( ) ) { KRohobHBdL = sc . nextLong ( ) ; b = sc . nextLong ( ) ; g = gcd ( KRohobHBdL , b ) ; l = ( KRohobHBdL * b ) / g ; System . out . println ( g + " " + l ) ; } } private static long gcd ( long KRohobHBdL , long b ) { if ( KRohobHBdL == 0 ) return b ; else if ( b == 0 ) return KRohobHBdL ; return gcd ( b , KRohobHBdL % b ) ; } } import java . io . * ; import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class oFTZCRrWBD { 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 oFTZCRrWBD = Integer . parseInt ( s [ 0 ] ) ; int B = Integer . parseInt ( s [ 1 ] ) ; String U = br . readLine ( ) ; if ( U . equals ( S ) ) out . println ( ( oFTZCRrWBD - 1 ) + " " + B ) ; else out . println ( oFTZCRrWBD + " " + ( B - 1 ) ) ; } } import java . util . Scanner ; class mdeEFkfbEp { public static void main ( String [ ] a ) { Scanner scan = new Scanner ( System . in ) ; int mdeEFkfbEp = scan . nextInt ( ) ; int debt = 100000 ; for ( int i = 0 ; i < mdeEFkfbEp ; 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 zvTcvdIbcV { static int zvTcvdIbcV ; static int [ ] a ; private static void init ( ) { Scanner scanner = new Scanner ( System . in ) ; zvTcvdIbcV = scanner . nextInt ( ) ; a = new int [ zvTcvdIbcV ] ; for ( int i = 0 ; i < zvTcvdIbcV ; i ++ ) a [ i ] = scanner . nextInt ( ) ; scanner . close ( ) ; } private static boolean check ( ) { boolean ok = true ; for ( int i = 0 ; i < zvTcvdIbcV ; 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 < zvTcvdIbcV ; j ++ ) { a [ j ] = a [ j ] / 2 ; } } else { break ; } } System . out . println ( count ) ; } } import java . util . Scanner ; class lxSVkZMDSL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; double lxSVkZMDSL = Double . parseDouble ( s1 ) ; double s = Math . PI * lxSVkZMDSL * lxSVkZMDSL ; double l = Math . PI * ( lxSVkZMDSL + lxSVkZMDSL ) ; System . out . println ( String . format ( " %1$3f " , s ) + " " + String . format ( " %1$3f " , l ) ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class fAsIuxCibA { 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 fAsIuxCibA = Integer . parseInt ( st . nextToken ( ) ) ; int y = Integer . parseInt ( st . nextToken ( ) ) ; int z = Integer . parseInt ( st . nextToken ( ) ) ; int temp = fAsIuxCibA ; fAsIuxCibA = y ; y = temp ; temp = fAsIuxCibA ; fAsIuxCibA = z ; z = temp ; System . out . println ( fAsIuxCibA + " " + y + " " + z ) ; } } import java . util . * ; public class YbyyLyDIEw { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; int YbyyLyDIEw = keyboard . nextInt ( ) ; int Y = keyboard . nextInt ( ) ; int turu = 2 ; int kame = 4 ; String ans = " No " ; for ( int i = 0 ; i < YbyyLyDIEw + 1 ; i ++ ) { if ( i * turu + ( YbyyLyDIEw - i ) * kame == Y ) { ans = " Yes " ; } } System . out . println ( ans ) ; keyboard . close ( ) ; } } import java . util . Scanner ; public class JDQNQKseee { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String t ; String h ; int JDQNQKseee = 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 ) { JDQNQKseee += 3 ; } else if ( t . compareTo ( h ) < 0 ) { h_point += 3 ; } else { JDQNQKseee += 1 ; h_point += 1 ; } } System . out . println ( JDQNQKseee + " " + h_point ) ; } } import java . util . Scanner ; public class IJiKEYgOvG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String line = sc . next ( ) ; if ( line . equals ( " - " ) ) { break ; } ; int IJiKEYgOvG = line . length ( ) ; char [ ] str = new char [ IJiKEYgOvG ] ; for ( int i = 0 ; i < IJiKEYgOvG ; 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 [ IJiKEYgOvG ] ; System . arraycopy ( str , 0 , hoge , 0 , IJiKEYgOvG ) ; for ( int j = 0 ; j < IJiKEYgOvG ; j ++ ) { str [ j ] = hoge [ ( j + h ) % IJiKEYgOvG ] ; } } for ( int k = 0 ; k < IJiKEYgOvG ; 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 FcnMSlamSX { 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 FcnMSlamSX { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int FcnMSlamSX = in . nextInt ( ) ; int x = in . nextInt ( ) ; int d = 0 ; int best = 1 ; for ( int i = 0 ; i < FcnMSlamSX ; i ++ ) { d += in . nextInt ( ) ; if ( d > x ) { best = i + 1 ; break ; } if ( i == FcnMSlamSX - 1 ) best = FcnMSlamSX + 1 ; } out . println ( best ) ; } } } import java . util . Scanner ; public class PuggjhjDvw { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int PuggjhjDvw = in . nextInt ( ) ; int i = 1000 ; while ( i < PuggjhjDvw ) { i += 1000 ; } System . out . println ( i - PuggjhjDvw ) ; } } import java . util . * ; public class iWlAEFDjZK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iWlAEFDjZK = sc . nextInt ( ) ; int [ ] a = new int [ iWlAEFDjZK ] ; for ( int i = 0 ; i < iWlAEFDjZK ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; boolean is_odd = false ; while ( ! is_odd ) { for ( int i = 0 ; i < iWlAEFDjZK ; 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 easMQxVTbD { public static void main ( String [ ] args ) throws IOException { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String easMQxVTbD = br . readLine ( ) ; StringBuffer sb = new StringBuffer ( easMQxVTbD ) ; System . out . println ( sb . reverse ( ) ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class HoYwTYWqcB { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int HoYwTYWqcB = scanner . nextInt ( ) ; String s ; HashSet < String > list = new HashSet < String > ( HoYwTYWqcB ) ; for ( int i = 0 ; i < HoYwTYWqcB ; i ++ ) { s = scanner . next ( ) ; list . add ( s ) ; } System . out . println ( list . size ( ) ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class zSHxjGBSXc { public static void main ( String [ ] args ) { Scanner f = new Scanner ( System . in ) ; while ( true ) { int zSHxjGBSXc = f . nextInt ( ) ; if ( zSHxjGBSXc == 0 ) break ; BigDecimal [ ] entries = new BigDecimal [ zSHxjGBSXc ] ; BigDecimal sum = new BigDecimal ( 0 ) ; BigDecimal std = new BigDecimal ( 0 ) ; for ( int i = 0 ; i < zSHxjGBSXc ; i ++ ) { BigDecimal temp = new BigDecimal ( f . nextInt ( ) ) ; entries [ i ] = temp ; sum = sum . add ( temp ) ; } BigDecimal average = sum . divide ( new BigDecimal ( zSHxjGBSXc ) , 6 , BigDecimal . ROUND_HALF_UP ) ; for ( int i = 0 ; i < zSHxjGBSXc ; i ++ ) { std = std . add ( entries [ i ] . subtract ( average ) . pow ( 2 ) ) ; } System . out . println ( Math . sqrt ( std . divide ( new BigDecimal ( zSHxjGBSXc ) , 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 ddgrhwAYqX { 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 ddgrhwAYqX { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String ddgrhwAYqX = in . nextString ( ) ; out . println ( ddgrhwAYqX . replaceAll ( " 1 " , " 2 " ) . replaceAll ( " 9 " , " 1 " ) . replaceAll ( " 2 " , " 9 " ) ) ; } } static class ddgrhwAYqX { 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 UXiGpFWgTz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] num = new int [ 3 ] ; for ( int UXiGpFWgTz = 0 ; UXiGpFWgTz < 3 ; UXiGpFWgTz ++ ) { num [ UXiGpFWgTz ] = scan . nextInt ( ) ; } int k = scan . nextInt ( ) ; Arrays . sort ( num ) ; for ( int UXiGpFWgTz = 1 ; UXiGpFWgTz <= k ; UXiGpFWgTz ++ ) { num [ 2 ] *= 2 ; } int sum = 0 ; for ( int UXiGpFWgTz = 0 ; UXiGpFWgTz < 3 ; UXiGpFWgTz ++ ) { sum += num [ UXiGpFWgTz ] ; } System . out . println ( sum ) ; } } import java . lang . reflect . Array ; import java . util . * ; public class dqDGvHGyNg { static int dqDGvHGyNg ; 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 OZkXWJQbYr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int OZkXWJQbYr = scan . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= OZkXWJQbYr ; 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 dbGFKvesvL { public static void main ( String [ ] arges ) { List < String > klist = new ArrayList < String > ( ) ; int dbGFKvesvL = 0 ; Scanner sc = new Scanner ( System . in ) ; while ( dbGFKvesvL < 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 JTOyGhqKaG { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long JTOyGhqKaG = scanner . nextLong ( ) ; String S = scanner . next ( ) ; scanner . close ( ) ; long ans = 1 ; for ( int i = 0 ; i < JTOyGhqKaG - 1 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( i + 1 ) ) ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; class eUOUqiuzmJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eUOUqiuzmJ = Integer . parseInt ( sc . next ( ) ) ; int W = Integer . parseInt ( sc . next ( ) ) ; while ( eUOUqiuzmJ != 0 && W != 0 ) { if ( eUOUqiuzmJ > 300 || W > 300 ) break ; for ( int i = 0 ; i < eUOUqiuzmJ ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; eUOUqiuzmJ = Integer . parseInt ( sc . next ( ) ) ; W = Integer . parseInt ( sc . next ( ) ) ; } } } import java . util . Scanner ; class QbvLwLNknb { public static void main ( String [ ] args ) { int QbvLwLNknb , H , x , y , r ; Scanner sc = new Scanner ( System . in ) ; QbvLwLNknb = sc . nextInt ( ) ; H = sc . nextInt ( ) ; x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; r = sc . nextInt ( ) ; if ( x + r > QbvLwLNknb || x - r < 0 ) { System . out . println ( " No " ) ; } else if ( y + r > H || y - r < 0 ) { System . out . println ( " No " ) ; } else if ( x > QbvLwLNknb || y > H ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; public class QflYeQgGWF { public static void main ( String [ ] args ) { Scanner sc1 = new Scanner ( System . in ) ; int QflYeQgGWF = sc1 . nextInt ( ) ; int b = sc1 . nextInt ( ) ; int max = QflYeQgGWF + b ; if ( max < QflYeQgGWF - b ) { max = QflYeQgGWF - b ; } if ( max < QflYeQgGWF * b ) { max = QflYeQgGWF * b ; } System . out . print ( max ) ; } } import java . util . Scanner ; public class dNeBunyToU { void run ( ) { Scanner s = new Scanner ( System . in ) ; String W = s . next ( ) ; int dNeBunyToU = 0 ; while ( true ) { String T = s . next ( ) ; if ( T . equals ( " END_OF_TEXT " ) ) break ; if ( W . compareToIgnoreCase ( T ) == 0 ) { dNeBunyToU ++ ; } } System . out . println ( dNeBunyToU ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; class GeNIymIhQy { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int GeNIymIhQy = sc . nextInt ( ) ; int [ ] ar = new int [ GeNIymIhQy ] ; for ( int i = 0 ; i < GeNIymIhQy ; 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 < GeNIymIhQy ; 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 PpbephWfgA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PpbephWfgA = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] P = new int [ PpbephWfgA ] ; for ( int i = 0 ; i < PpbephWfgA ; 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 OakOJTwifD { void reverse ( ) { Scanner s = new Scanner ( System . in ) ; int OakOJTwifD = s . nextInt ( ) ; int [ ] a = new int [ OakOJTwifD ] ; for ( int i = 0 ; i < OakOJTwifD ; i ++ ) { a [ i ] = s . nextInt ( ) ; } for ( int i = OakOJTwifD - 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 aHsoZqpitx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aHsoZqpitx = sc . nextInt ( ) ; int [ ] n = new int [ aHsoZqpitx ] ; int [ ] m = new int [ aHsoZqpitx ] ; for ( int i = 0 ; i < aHsoZqpitx ; i ++ ) { n [ i ] = sc . nextInt ( ) ; m [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; for ( int i = 0 ; i < aHsoZqpitx ; 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 RJlKwjgjKE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] a = sc . next ( ) . toCharArray ( ) ; int RJlKwjgjKE = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( a [ i ] == '1' ) { RJlKwjgjKE += 1 ; } } System . out . print ( RJlKwjgjKE ) ; } } import java . util . * ; public class kWQcbaYhdR { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int kWQcbaYhdR = 0 ; char p = '.' ; for ( char ch : sc . next ( ) . toCharArray ( ) ) { kWQcbaYhdR = ( ( p == '.' || p == 'S' ) && ch == 'R' ) ? 1 : kWQcbaYhdR ; if ( ch == 'R' && p == 'R' ) kWQcbaYhdR ++ ; p = ch ; } System . out . println ( kWQcbaYhdR ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { solve ( ) ; } } import java . util . Scanner ; public class eeygSpepwm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String eeygSpepwm = sc . next ( ) ; if ( eeygSpepwm . equals ( " AAA " ) || eeygSpepwm . equals ( " BBB " ) ) { System . out . print ( " No " ) ; } else { System . out . print ( " Yes " ) ; } } } import java . util . Scanner ; public class EudxWNbSAj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EudxWNbSAj ; int b ; EudxWNbSAj = scan . nextInt ( ) ; b = scan . nextInt ( ) ; sizeComparison ( EudxWNbSAj , b ) ; } public static void sizeComparison ( int EudxWNbSAj , int b ) { String i = " == " ; if ( EudxWNbSAj < b ) { i = " < " ; } else if ( EudxWNbSAj > b ) { i = " > " ; } System . out . println ( " a " + i + " b " ) ; } } import java . util . Scanner ; public class XxSNEIEDnQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long XxSNEIEDnQ = Integer . parseInt ( sc . next ( ) ) ; long B = Integer . parseInt ( sc . next ( ) ) ; System . out . print ( XxSNEIEDnQ * B / gcd ( XxSNEIEDnQ , 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 BjVANbwxAI { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String word ; String [ ] sen = new String [ 1000 ] ; int BjVANbwxAI = 0 ; word = scan . next ( ) ; while ( true ) { sen [ BjVANbwxAI ] = scan . next ( ) ; if ( sen [ BjVANbwxAI ] . equals ( " END_OF_TEXT " ) ) break ; BjVANbwxAI ++ ; } int ans = 0 ; int num = word . length ( ) ; ; for ( int j = 0 ; j < BjVANbwxAI + 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 WAQfqryofQ { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] numberArray = br . readLine ( ) . split ( " " ) ; int WAQfqryofQ = Integer . parseInt ( numberArray [ 0 ] ) ; int K = Integer . parseInt ( numberArray [ 1 ] ) ; String [ ] inputArray = br . readLine ( ) . split ( " " ) ; int [ ] priceArray = new int [ WAQfqryofQ ] ; for ( int i = 0 ; i < WAQfqryofQ ; 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 rtsvFSVQXi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rtsvFSVQXi = 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 == rtsvFSVQXi && b_tax == B ) { ans = i ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; public class SlLMmdljIy { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int SlLMmdljIy = Integer . parseInt ( sc . nextLine ( ) ) ; String line = sc . nextLine ( ) ; String [ ] line1 = line . split ( " " ) ; int [ ] ary = new int [ SlLMmdljIy ] ; for ( int i = 0 ; i < SlLMmdljIy ; i ++ ) ary [ i ] = Integer . parseInt ( line1 [ i ] ) ; int [ ] ary1 = new int [ SlLMmdljIy ] ; for ( int i = 0 ; i < SlLMmdljIy ; i ++ ) ary1 [ ary [ i ] - 1 ] = i + 1 ; for ( int i = 0 ; i < SlLMmdljIy ; i ++ ) System . out . print ( ary1 [ i ] + " " ) ; } } import java . util . * ; import java . io . * ; public class UuWdBkVHht { 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 UuWdBkVHht = " " + nextInt ( ) ; if ( UuWdBkVHht . 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 SsnZbsQYcb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String answer = " Heisei " ; int SsnZbsQYcb , month , day ; SsnZbsQYcb = Integer . parseInt ( s . substring ( 0 , 4 ) ) ; month = Integer . parseInt ( s . substring ( 5 , 7 ) ) ; if ( SsnZbsQYcb > 2019 ) answer = " TBD " ; if ( SsnZbsQYcb == 2019 && month >= 5 ) answer = " TBD " ; System . out . println ( answer ) ; } } import java . io . PrintStream ; import java . util . Scanner ; public class LANODiOZxt { private static final PrintStream so = System . out ; private static final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int LANODiOZxt = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x <= LANODiOZxt ; x ++ ) { for ( int y = 0 ; y <= LANODiOZxt ; y ++ ) { int z = S - ( x + y ) ; if ( 0 <= z && z <= LANODiOZxt ) { count ++ ; } } } so . println ( count ) ; } } import java . util . Scanner ; class UtafGiIAoL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int [ ] A = new int [ str . length ( ) ] ; for ( int UtafGiIAoL = 0 ; UtafGiIAoL < str . length ( ) ; UtafGiIAoL ++ ) { A [ UtafGiIAoL ] = str . charAt ( UtafGiIAoL ) ; } 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 aFGGDbHXiY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aFGGDbHXiY = sc . nextInt ( ) ; int h = 0 ; int m = 0 ; int s = 0 ; while ( aFGGDbHXiY >= 3600 ) { aFGGDbHXiY = aFGGDbHXiY - 3600 ; h ++ ; } while ( aFGGDbHXiY >= 60 ) { aFGGDbHXiY = aFGGDbHXiY - 60 ; m ++ ; } s = aFGGDbHXiY ; System . out . println ( h + " : " + m + " : " + s ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class UjVsOSYqKH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UjVsOSYqKH = sc . nextInt ( ) ; int [ ] arr = new int [ UjVsOSYqKH ] ; for ( int i = 0 ; i < UjVsOSYqKH ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; boolean isDistinct = true ; for ( int i = 1 ; i < UjVsOSYqKH ; 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 aNkUNQzHny { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aNkUNQzHny = Integer . parseInt ( sc . next ( ) ) ; int [ ] numList = new int [ aNkUNQzHny ] ; for ( int i = 0 ; i < aNkUNQzHny ; i ++ ) { numList [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int r = 0 ; for ( int i = 0 ; i < aNkUNQzHny ; i ++ ) { for ( int j = i + 1 ; j < aNkUNQzHny ; j ++ ) { r += numList [ i ] * numList [ j ] ; } } System . out . println ( r ) ; } } import java . util . * ; class sYjjAPtHJY { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int sYjjAPtHJY = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = - 1 ; for ( int i = 12 ; i <= 1000 ; i ++ ) { if ( i * 8 / 100 == sYjjAPtHJY && 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 JzGCZgMDNh { private static final String JzGCZgMDNh = " 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 ( JzGCZgMDNh ) ) { tomorrow = WATHER_CLOUDY ; } else if ( today . equals ( WATHER_CLOUDY ) ) { tomorrow = WATHER_RAINY ; } else if ( today . equals ( WATHER_RAINY ) ) { tomorrow = JzGCZgMDNh ; } 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 zfYPSeSRcA { static class zfYPSeSRcA { 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 zfYPSeSRcA = 1 ; while ( zfYPSeSRcA -- > 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 NZYkAhOlOj { private final static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int NZYkAhOlOj = sc . nextInt ( ) ; long K = sc . nextInt ( ) ; long Q = sc . nextInt ( ) ; long [ ] array = new long [ NZYkAhOlOj ] ; for ( int i = 0 ; i < Q ; i ++ ) { array [ sc . nextInt ( ) - 1 ] ++ ; } for ( int i = 0 ; i < NZYkAhOlOj ; i ++ ) { if ( ( K + array [ i ] - Q ) > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; public class VAegzSaXfm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VAegzSaXfm = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; char [ ] p = { 'A' , 'B' , 'C' } ; int idx = 0 ; int count = 0 ; for ( int i = 0 ; i < VAegzSaXfm ; 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 XHhTvuUyjK { 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 XHhTvuUyjK = Integer . parseInt ( st . nextToken ( ) ) ; long m = Integer . parseInt ( st . nextToken ( ) ) ; long gcd ; long lcm = XHhTvuUyjK * m ; while ( XHhTvuUyjK % m != 0 ) { long t = m ; m = XHhTvuUyjK % m ; XHhTvuUyjK = t ; } gcd = m ; lcm = lcm / gcd ; System . out . println ( gcd + " " + lcm ) ; } } catch ( Exception e ) { System . out . println ( " Exception! " ) ; } } } import java . util . Scanner ; public class vOoPumeAlL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vOoPumeAlL = sc . nextInt ( ) ; int a , b , c ; for ( int i = 0 ; i < vOoPumeAlL ; 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 FLOGcOWctl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String FLOGcOWctl = sc . next ( ) ; StringBuilder sb = new StringBuilder ( FLOGcOWctl ) ; String ans = FLOGcOWctl . replace ( " eraser " , " " ) . replace ( " erase " , " " ) . replace ( " dreamer " , " " ) . replace ( " dream " , " " ) ; System . out . println ( ans . equals ( " " ) ? " YES " : " NO " ) ; } } import java . util . Scanner ; class VaEljFrkfn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VaEljFrkfn = sc . nextInt ( ) ; int [ ] height = new int [ VaEljFrkfn ] ; for ( int i = 0 ; i < VaEljFrkfn ; i ++ ) { height [ i ] = Integer . parseInt ( sc . next ( ) ) ; } boolean pos = true ; for ( int i = 0 ; i < VaEljFrkfn - 1 ; i ++ ) { if ( height [ VaEljFrkfn - i - 2 ] - height [ VaEljFrkfn - i - 1 ] <= 0 ) { continue ; } else if ( height [ VaEljFrkfn - i - 2 ] - height [ VaEljFrkfn - i - 1 ] == 1 ) { height [ VaEljFrkfn - 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 oRZBmbtbsF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oRZBmbtbsF = Integer . parseInt ( sc . next ( ) ) ; int Y = Integer . parseInt ( sc . next ( ) ) ; int k = 0 ; PrintWriter out = new PrintWriter ( System . out ) ; for ( int i = 0 ; i <= oRZBmbtbsF ; i ++ ) { for ( int j = 0 ; j <= oRZBmbtbsF - i ; j ++ ) { k = oRZBmbtbsF - 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 KETJRYaZwS { 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 mzsEnuceji { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mzsEnuceji = sc . nextInt ( ) ; HashMap < String , Long > map = new HashMap < > ( ) ; for ( int i = 0 ; i < mzsEnuceji ; 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 cpIoBKRSvW { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int cpIoBKRSvW = in . nextInt ( ) ; int [ ] d = new int [ cpIoBKRSvW ] ; for ( int i = 0 ; i < cpIoBKRSvW ; i ++ ) { d [ i ] = in . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < cpIoBKRSvW ; i ++ ) { for ( int j = i + 1 ; j < cpIoBKRSvW ; j ++ ) { sum += d [ i ] * d [ j ] ; } } System . out . println ( sum ) ; } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class BEXYjvtVqf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BEXYjvtVqf = sc . nextInt ( ) ; Set < String > used = new HashSet < String > ( ) ; String s = sc . next ( ) ; used . add ( s ) ; for ( int i = 1 ; i < BEXYjvtVqf ; 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 == BEXYjvtVqf - 1 ) { System . out . println ( " Yes " ) ; } s = t ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class rXhIgbBzww { public static void main ( String [ ] args ) throws Exception { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String [ ] array = reader . readLine ( ) . split ( " " ) ; int rXhIgbBzww = Integer . parseInt ( array [ 0 ] ) ; int B = Integer . parseInt ( array [ 1 ] ) ; int C = Integer . parseInt ( array [ 2 ] ) ; System . out . println ( Math . max ( B + C - rXhIgbBzww , 0 ) ) ; } } } import java . util . * ; public class pDWNxxsAsQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String word = sc . next ( ) ; String mae = " " ; String usiro = " " ; while ( ! word . equals ( " - " ) ) { int pDWNxxsAsQ = sc . nextInt ( ) ; for ( int i = 0 ; i < pDWNxxsAsQ ; 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 hydYzVBeWH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hydYzVBeWH = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { int button = 0 ; if ( hydYzVBeWH > B ) { sum += hydYzVBeWH ; hydYzVBeWH -= 1 ; } else { sum += B ; B -= 1 ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class YwfYsTBwQC { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int YwfYsTBwQC = Integer . parseInt ( str ) ; str = scan . next ( ) ; int b = Integer . parseInt ( str ) ; if ( YwfYsTBwQC < b ) System . out . println ( " a < b " ) ; else if ( YwfYsTBwQC > b ) System . out . println ( " a > b " ) ; else if ( YwfYsTBwQC == b ) System . out . println ( " a == b " ) ; } } import java . util . Scanner ; public class EBBNcmkcfU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] result = new int [ 26 ] ; for ( int EBBNcmkcfU = 0 ; EBBNcmkcfU < result . length ; EBBNcmkcfU ++ ) { result [ EBBNcmkcfU ] = 0 ; } while ( sc . hasNext ( ) ) { String input = sc . nextLine ( ) ; for ( int EBBNcmkcfU = 0 ; EBBNcmkcfU < input . length ( ) ; EBBNcmkcfU ++ ) { char ch = input . charAt ( EBBNcmkcfU ) ; 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 EBBNcmkcfU = 0 ; EBBNcmkcfU < result . length ; EBBNcmkcfU ++ ) { char alphabet = ( char ) ( EBBNcmkcfU + 'a' ) ; System . out . println ( alphabet + " : " + result [ EBBNcmkcfU ] ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class tfmaxiaJOj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tfmaxiaJOj = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; while ( tfmaxiaJOj > 0 || c > 0 ) { c -= b ; if ( c <= 0 ) break ; tfmaxiaJOj -= d ; } if ( tfmaxiaJOj > 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . * ; import java . util . * ; public class wYEInxCzAP { 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 QiDeKhppwg { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int QiDeKhppwg = stdIn . nextInt ( ) ; int [ ] d = new int [ QiDeKhppwg ] ; for ( int i = 0 ; i < QiDeKhppwg ; i ++ ) { d [ i ] = stdIn . nextInt ( ) ; } Arrays . sort ( d ) ; int count = 0 ; for ( int i = 0 ; i < QiDeKhppwg ; 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 uFsMzmImHi { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int uFsMzmImHi = scn . nextInt ( ) ; ArrayList < Integer > element = new ArrayList < Integer > ( ) ; for ( int i = 1 ; ; ) { if ( i == 1 ) { element . add ( uFsMzmImHi ) ; } else { if ( uFsMzmImHi % 2 == 1 ) { uFsMzmImHi = odd ( uFsMzmImHi ) ; } else { uFsMzmImHi = even ( uFsMzmImHi ) ; } if ( element . indexOf ( uFsMzmImHi ) == - 1 ) { element . add ( uFsMzmImHi ) ; } 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 ALWQQmJpoM { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int ALWQQmJpoM = in . nextInt ( ) ; double side = ( double ) ALWQQmJpoM / 3 ; System . out . println ( side * side * side ) ; } } import java . util . * ; public class BYQqLGyYEg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BYQqLGyYEg = sc . nextInt ( ) ; int [ ] value = new int [ BYQqLGyYEg ] ; for ( int i = 0 ; i < BYQqLGyYEg ; 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 rLROgVDztD { public static void main ( String [ ] args ) { int rLROgVDztD ; int M ; int temp ; int sum = 0 ; int P ; ArrayList < Integer > A = new ArrayList < Integer > ( ) ; Scanner sc = new Scanner ( System . in ) ; rLROgVDztD = sc . nextInt ( ) ; M = sc . nextInt ( ) ; int i ; for ( i = 0 ; i < rLROgVDztD ; 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 lFCAtLfkSn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Integer int1 = scanner . nextInt ( ) ; Integer int2 = scanner . nextInt ( ) ; int lFCAtLfkSn = int1 * int2 ; System . out . println ( lFCAtLfkSn ) ; } } import java . util . * ; class zXTfNnXRbA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zXTfNnXRbA = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < zXTfNnXRbA ; 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 QIGIbqXKwt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int QIGIbqXKwt = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String u = sc . next ( ) ; if ( s . equals ( u ) ) QIGIbqXKwt -- ; if ( t . equals ( u ) ) b -- ; System . out . println ( QIGIbqXKwt + " " + b ) ; } } import java . util . * ; public class fbFfTZZOsd { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int fbFfTZZOsd = scn . nextInt ( ) ; int k = scn . nextInt ( ) ; int [ ] a = new int [ fbFfTZZOsd ] ; 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 NHbmaMDclN { 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 NHbmaMDclN = 0 ; NHbmaMDclN < 2 ; NHbmaMDclN ++ ) { x [ NHbmaMDclN ] = Integer . parseInt ( str2 [ NHbmaMDclN ] ) ; } 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 nynYQEbKWi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double nynYQEbKWi = scan . nextDouble ( ) ; double area = nynYQEbKWi * nynYQEbKWi * Math . PI ; double circumference = 2 * nynYQEbKWi * Math . PI ; System . out . printf ( " %f %f \n " , area , circumference ) ; } } import java . util . Scanner ; import java . lang . Math ; class qIrzuyWXTQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] alp = s . toCharArray ( ) ; int qIrzuyWXTQ = ( int ) ( alp [ 0 ] ) ; alp [ 0 ] = ( char ) ( qIrzuyWXTQ + 1 ) ; System . out . print ( alp [ 0 ] ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; class QobfmbCSEH { public static void main ( String [ ] args ) throws Exception { int [ ] antenna = new int [ 5 ] ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; for ( int QobfmbCSEH = 0 ; QobfmbCSEH < antenna . length ; QobfmbCSEH ++ ) { antenna [ QobfmbCSEH ] = 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 WBaQdnfmHN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int WBaQdnfmHN = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( WBaQdnfmHN == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < W ; i ++ ) { System . out . printf ( " # " ) ; } System . out . printf ( " %n " ) ; for ( int i = 0 ; i < WBaQdnfmHN - 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 vSfbvLRhNw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int vSfbvLRhNw = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int ans = 0 ; if ( b <= c || d <= vSfbvLRhNw ) { ans = 0 ; } else if ( c <= vSfbvLRhNw && b <= d ) { ans = b - vSfbvLRhNw ; } else if ( vSfbvLRhNw <= c && d <= b ) { ans = d - c ; } else if ( vSfbvLRhNw <= c && c <= b && b <= d ) { ans = b - c ; } else if ( c <= vSfbvLRhNw && vSfbvLRhNw <= d && d <= b ) { ans = d - vSfbvLRhNw ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class jAOHbLSvdr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jAOHbLSvdr = sc . nextInt ( ) ; int [ ] t = new int [ jAOHbLSvdr + 1 ] ; int [ ] x = new int [ jAOHbLSvdr + 1 ] ; int [ ] y = new int [ jAOHbLSvdr + 1 ] ; t [ 0 ] = 0 ; x [ 0 ] = 0 ; y [ 0 ] = 0 ; boolean result = true ; for ( int i = 1 ; i <= jAOHbLSvdr ; 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 CgMlXvoLfX { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int CgMlXvoLfX = 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 < CgMlXvoLfX ; 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 HRUbYIOAaw { 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 HRUbYIOAaw = 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 ] ) { HRUbYIOAaw = false ; System . out . println ( " No " ) ; break outside ; } } } if ( HRUbYIOAaw ) { System . out . println ( " Yes " ) ; } } } import java . util . * ; public class ALNWOhdxMH { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s ; int ALNWOhdxMH ; int i ; Deck d = new Deck ( ) ; while ( ! ( s = sc . next ( ) ) . equals ( " - " ) ) { d . setDeck ( s ) ; ALNWOhdxMH = sc . nextInt ( ) ; for ( i = 0 ; i < ALNWOhdxMH ; i ++ ) { d . shuffle ( sc . nextInt ( ) ) ; } d . printDeck ( ) ; } } } class ALNWOhdxMH { 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 qAzUxlmtyq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] an = new int [ 5 ] ; for ( int qAzUxlmtyq = 0 ; qAzUxlmtyq < 5 ; qAzUxlmtyq ++ ) { an [ qAzUxlmtyq ] = 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 YIokEvjytx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YIokEvjytx = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( YIokEvjytx > b ) { System . out . println ( 2 * YIokEvjytx - 1 ) ; } else if ( YIokEvjytx == b ) { System . out . println ( 2 * YIokEvjytx ) ; } 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 SYwZibGyNh { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int SYwZibGyNh = fs . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= SYwZibGyNh ; ++ i ) { if ( i % 3 != 0 && i % 5 != 0 ) ans += i ; } System . out . println ( ans ) ; } static class SYwZibGyNh { 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 SYwZibGyNh ) { int [ ] a = new int [ SYwZibGyNh ] ; for ( int i = 0 ; i < SYwZibGyNh ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . io . * ; import java . util . * ; class djNQiZzAaF { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int djNQiZzAaF = 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 < djNQiZzAaF - arr [ n - 1 ] + arr [ 0 ] ) { System . out . println ( djNQiZzAaF - ( djNQiZzAaF - arr [ n - 1 ] + arr [ 0 ] ) ) ; } else { System . out . println ( djNQiZzAaF - maxdiff ) ; } } } import java . io . IOException ; import java . util . ArrayList ; import java . util . Scanner ; class cNBYWFLetr { 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 cNBYWFLetr = 1 ; int x = 1 ; int kumi = 0 ; while ( cNBYWFLetr != 0 || x != 0 ) { cNBYWFLetr = scan . nextInt ( ) ; x = scan . nextInt ( ) ; NN . add ( cNBYWFLetr ) ; 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 MgiFrcfScQ { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int MgiFrcfScQ = Integer . parseInt ( scanner . next ( ) ) ; double x ; x = ( double ) MgiFrcfScQ / 3.0 ; System . out . println ( Math . pow ( x , 3 ) ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class zhZBHoNIUU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zhZBHoNIUU = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; List < Integer > cList = new ArrayList < > ( ) ; List < Integer > tList = new ArrayList < > ( ) ; for ( int i = 0 ; i < zhZBHoNIUU ; i ++ ) { cList . add ( sc . nextInt ( ) ) ; tList . add ( sc . nextInt ( ) ) ; } Integer minCost = null ; for ( int i = 0 ; i < zhZBHoNIUU ; 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 MpAYTRYBYW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MpAYTRYBYW = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int c = 0 ; for ( int i = 0 ; i < MpAYTRYBYW ; i ++ ) { int b = sc . nextInt ( ) ; if ( a <= b ) c ++ ; } System . out . println ( c ) ; } } import java . util . Scanner ; public class mLrLBVtgmv { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int mLrLBVtgmv = stdIn . nextInt ( ) ; int Q = stdIn . nextInt ( ) ; int [ ] ans = new int [ mLrLBVtgmv ] ; int [ ] kota = new int [ Q ] ; String S = stdIn . next ( ) ; int z = 1 , y = 0 , l = 0 , r = 0 , num = 0 ; while ( z < mLrLBVtgmv ) { 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 cjvYusbnAC { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int cjvYusbnAC = sc . nextInt ( ) ; if ( cjvYusbnAC == 2 ) { System . out . println ( cjvYusbnAC ) ; return ; } ArrayList < Integer > list = getPrime ( cjvYusbnAC ) ; while ( true ) { if ( check ( cjvYusbnAC , list ) ) { System . out . println ( cjvYusbnAC ) ; return ; } cjvYusbnAC ++ ; } } 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 ywZYRNAlJZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ywZYRNAlJZ = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ ywZYRNAlJZ ] ; int [ ] B = new int [ ywZYRNAlJZ - 1 ] ; for ( int i = 0 ; i < ywZYRNAlJZ - 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 < ywZYRNAlJZ - 1 ; i ++ ) { sum += Math . min ( B [ i ] , B [ i - 1 ] ) ; } } sum += B [ ywZYRNAlJZ - 2 ] ; System . out . println ( sum ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class ERNBrrXwew { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ERNBrrXwew = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < ERNBrrXwew ; 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 lQhLLOVnfR { public static void main ( String [ ] args ) { new Main ( ) ; } public Main ( ) { Scanner sc = new Scanner ( System . in ) ; int lQhLLOVnfR = Integer . parseInt ( sc . next ( ) ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int remainder = lQhLLOVnfR % A ; int n = lQhLLOVnfR / A ; System . out . println ( remainder > 0 ? n + 1 : n ) ; } } import java . io . * ; import java . util . Scanner ; public class YXarQEfiZK { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] s = br . readLine ( ) . split ( " " ) ; long YXarQEfiZK = 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 = YXarQEfiZK % sum ; if ( sum > a ) sum = a ; long x = YXarQEfiZK / ( a + b ) ; System . out . println ( x * a + sum ) ; } } } import java . util . * ; public class icVJpQNXFw { 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 kDljzkSXIb { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( System . in ) ; long kDljzkSXIb = sc . nextLong ( ) ; long f = kDljzkSXIb / 500 , f2 = ( kDljzkSXIb % 500 ) / 5 ; System . out . println ( f * 1000 + f2 * 5 ) ; } } import java . util . * ; import java . io . * ; import java . math . BigInteger ; public class PpfevMcBwf { 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 PpfevMcBwf = Integer . parseInt ( st1 . nextToken ( ) ) ; int k = Integer . parseInt ( st1 . nextToken ( ) ) ; int q = Integer . parseInt ( st1 . nextToken ( ) ) ; int [ ] arr = new int [ PpfevMcBwf ] ; for ( int i = 0 ; i < q ; i ++ ) { arr [ Integer . parseInt ( br . readLine ( ) ) - 1 ] ++ ; } for ( int i = 0 ; i < PpfevMcBwf ; i ++ ) { if ( k - ( q - arr [ i ] ) > 0 ) { out . println ( " Yes " ) ; } else { out . println ( " No " ) ; } } out . flush ( ) ; out . close ( ) ; } } import java . util . Scanner ; public class xCmCaISOvr { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int xCmCaISOvr = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( xCmCaISOvr > b ) { ans += xCmCaISOvr ; xCmCaISOvr -- ; } else { ans += b ; b -- ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; public class BkkWrJoTbO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BkkWrJoTbO = sc . nextInt ( ) ; String s = sc . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int start = ( int ) s . charAt ( i ) ; int ans = start + BkkWrJoTbO ; 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 oigagAPOKY { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { final String s = reader . readLine ( ) ; boolean oigagAPOKY = 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 ) { oigagAPOKY = true ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( i == at ) continue ; if ( s . charAt ( i ) < 'a' || 'z' < s . charAt ( i ) ) { oigagAPOKY = false ; break ; } } } } System . out . println ( oigagAPOKY ? " AC " : " WA " ) ; } } } import java . util . Scanner ; public class oUStMSeUIV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oUStMSeUIV = sc . nextInt ( ) ; int [ ] P = new int [ oUStMSeUIV + 1 ] ; for ( int i = 1 ; i <= oUStMSeUIV ; i ++ ) { P [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int ans = 1 ; int min = P [ 1 ] ; for ( int i = 2 ; i <= oUStMSeUIV ; i ++ ) { min = Math . min ( min , P [ i ] ) ; if ( P [ i ] <= min ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; class JUhQxAZCQb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int JUhQxAZCQb = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; boolean flag = true ; long aa = JUhQxAZCQb , bb = b ; while ( flag ) { if ( aa < bb ) { aa += JUhQxAZCQb ; } else if ( bb < aa ) { bb += b ; } else if ( aa == bb ) { flag = false ; } } System . out . println ( aa ) ; } } import java . util . Scanner ; public class ryzJBDqbBi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ryzJBDqbBi = sc . nextInt ( ) + sc . nextInt ( ) ; int [ ] nums = { 1 , 2 , 3 } ; switch ( ryzJBDqbBi ) { 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 bmMwezCddU { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; int bmMwezCddU = 1 ; while ( ! str . equals ( " 0 " ) ) { System . out . println ( " Case " + bmMwezCddU + " : " + str ) ; bmMwezCddU ++ ; str = br . readLine ( ) ; } } } import java . util . HashMap ; import java . util . Scanner ; class diNEZhXqce { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int diNEZhXqce = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( ( long ) diNEZhXqce * b / gcd ( diNEZhXqce , b ) ) ; } public static int gcd ( int diNEZhXqce , int b ) { if ( diNEZhXqce % b == 0 ) { return b ; } return gcd ( b , diNEZhXqce % b ) ; } } import java . io . * ; public class bTsUrvvnIr { public static void main ( String [ ] args ) { int bTsUrvvnIr = 0 , f = 0 , r = 0 ; try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String [ ] strAry = br . readLine ( ) . split ( " " ) ; bTsUrvvnIr = Integer . parseInt ( strAry [ 0 ] ) ; f = Integer . parseInt ( strAry [ 1 ] ) ; r = Integer . parseInt ( strAry [ 2 ] ) ; if ( bTsUrvvnIr == - 1 && f == - 1 && r == - 1 ) break ; System . out . printf ( " %s \n " , judge ( bTsUrvvnIr , f , r ) ) ; } } catch ( Exception e ) { System . err . println ( e ) ; } } private static String judge ( int bTsUrvvnIr , int f , int r ) { if ( ( bTsUrvvnIr == - 1 || f == - 1 ) || bTsUrvvnIr + f < 30 ) return " F " ; else if ( bTsUrvvnIr + f < 50 ) { if ( r >= 50 ) return " C " ; else return " D " ; } else if ( bTsUrvvnIr + f < 65 ) return " C " ; else if ( bTsUrvvnIr + f < 80 ) return " B " ; else return " A " ; } } import java . util . * ; class SeBDqcAyPg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SeBDqcAyPg = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; System . out . println ( SeBDqcAyPg <= f * t ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class rBoEJpBbSZ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rBoEJpBbSZ = scan . nextInt ( ) ; int n1 = rBoEJpBbSZ + 1 ; long [ ] m = new long [ n1 ] ; long [ ] h = new long [ rBoEJpBbSZ ] ; for ( int i = 0 ; i < n1 ; i ++ ) { m [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < rBoEJpBbSZ ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } long result = 0 ; for ( int i = 0 ; i < rBoEJpBbSZ ; 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 ZKvzscakGG { 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 ZKvzscakGG = 0 ; ZKvzscakGG < nANDmStr . length ; ZKvzscakGG ++ ) { nANDm [ ZKvzscakGG ] = Integer . parseInt ( nANDmStr [ ZKvzscakGG ] ) ; } 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 ZKvzscakGG = 0 ; ZKvzscakGG < vector . length ; ZKvzscakGG ++ ) { vectorStr [ ZKvzscakGG ] = input . readLine ( ) ; vector [ ZKvzscakGG ] = Integer . parseInt ( vectorStr [ ZKvzscakGG ] ) ; } 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 bvmlpshUqm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int bvmlpshUqm = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; if ( bvmlpshUqm == 0 ) break ; int count = 0 ; for ( int i = 1 ; i <= bvmlpshUqm - 2 ; i ++ ) { for ( int j = i + 1 ; j <= bvmlpshUqm - 1 ; j ++ ) { int check_number = x - i - j ; if ( check_number <= bvmlpshUqm && check_number > j ) { count ++ ; } } } System . out . println ( count ) ; } } } import java . util . Scanner ; public class NJVpCPuiyO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final String S = sc . next ( ) ; int NJVpCPuiyO ; if ( " RRR " . equals ( S ) ) { NJVpCPuiyO = 3 ; } else if ( " RRS " . equals ( S ) || " SRR " . equals ( S ) ) { NJVpCPuiyO = 2 ; } else if ( S . contains ( " R " ) ) { NJVpCPuiyO = 1 ; } else { NJVpCPuiyO = 0 ; } System . out . println ( NJVpCPuiyO ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class SlpRNaoniP { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int SlpRNaoniP = scan . nextInt ( ) ; String [ ] s = new String [ SlpRNaoniP ] ; int [ ] cnt = new int [ SlpRNaoniP ] ; String [ ] scheck = new String [ SlpRNaoniP ] ; for ( int i = 0 ; i < SlpRNaoniP ; 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 < SlpRNaoniP ; i ++ ) { if ( i != 0 && s [ i ] . equals ( s [ i - 1 ] ) == false ) { scheck [ suffix ] = s [ i - 1 ] ; suffix += 1 ; } if ( i == SlpRNaoniP - 1 ) scheck [ suffix ] = s [ i ] ; if ( i == SlpRNaoniP - 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 HBfQAUmKpc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HBfQAUmKpc = sc . nextInt ( ) ; int i = 0 ; for ( i = HBfQAUmKpc ; 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 yqZgbdeirn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yqZgbdeirn = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int a = - 1 ; int b = - 1 ; int c = - 1 ; for ( int i = 0 ; i <= yqZgbdeirn ; i ++ ) { for ( int j = 0 ; j <= yqZgbdeirn - i ; j ++ ) { if ( Y == ( 10000 * i + 5000 * j + 1000 * ( yqZgbdeirn - i - j ) ) ) { a = i ; b = j ; c = yqZgbdeirn - i - j ; } } } System . out . print ( a + " " ) ; System . out . print ( b + " " ) ; System . out . print ( c ) ; } } import java . util . Scanner ; class tmtnnkiNIL { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) , t ; int tmtnnkiNIL = 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 ) ) tmtnnkiNIL ++ ; } 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 ( tmtnnkiNIL , countEven ) ) ; } } import java . util . * ; public class ZuroEttKgN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZuroEttKgN = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] allList = new int [ 2 * ZuroEttKgN ] ; for ( int i = 0 ; i < 2 * ZuroEttKgN ; i ++ ) { allList [ i ] = sc . nextInt ( ) ; } int cost = 10001 ; for ( int i = 1 ; i < 2 * ZuroEttKgN ; 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 bggkeoYJfk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { int bggkeoYJfk = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( bggkeoYJfk == 0 && b == 0 ) break ; if ( bggkeoYJfk < b ) System . out . println ( bggkeoYJfk + " " + b ) ; else System . out . println ( b + " " + bggkeoYJfk ) ; } } } import java . util . Scanner ; public class vdKEuOhOyg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long vdKEuOhOyg = sc . nextLong ( ) ; if ( vdKEuOhOyg < 10 ) { System . out . println ( vdKEuOhOyg ) ; } else if ( vdKEuOhOyg < 100 ) { System . out . println ( 9 ) ; } else if ( vdKEuOhOyg < 1000 ) { System . out . println ( 9 + vdKEuOhOyg - 99 ) ; } else if ( vdKEuOhOyg < 10000 ) { System . out . println ( 909 ) ; } else if ( vdKEuOhOyg < 100000 ) { System . out . println ( 909 + vdKEuOhOyg - 9999 ) ; } else { System . out . println ( 90909 ) ; } sc . close ( ) ; } } import java . util . * ; public class zmYhYWKtbr { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int zmYhYWKtbr = s . nextInt ( ) ; int k = s . nextInt ( ) ; long [ ] h = new long [ zmYhYWKtbr ] ; for ( int i = 0 ; i < zmYhYWKtbr ; i ++ ) { h [ i ] = s . nextLong ( ) ; } long [ ] dp = new long [ zmYhYWKtbr ] ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < zmYhYWKtbr ; 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 [ zmYhYWKtbr - 1 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class sxTAVFuVPr { 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 QEWlJSjNaN { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] line = br . readLine ( ) . split ( " " ) ; int QEWlJSjNaN = Integer . parseInt ( line [ 0 ] ) ; int n = Integer . parseInt ( line [ 1 ] ) ; line = br . readLine ( ) . split ( " " ) ; br . close ( ) ; boolean flg = false ; for ( String s : line ) { if ( ( QEWlJSjNaN -= Integer . parseInt ( s ) ) <= 0 ) { flg = true ; break ; } } if ( flg ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class WilmrGCFSR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WilmrGCFSR = 2 ; int m = sc . nextInt ( ) ; int [ ] [ ] table = new int [ WilmrGCFSR ] [ m ] ; for ( int i = 0 ; i < WilmrGCFSR ; 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 tVZNVhvrTy { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int tVZNVhvrTy = 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 ( tVZNVhvrTy * A , B ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class doXMgBUPoZ { 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 doXMgBUPoZ = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < doXMgBUPoZ ; 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 PYvqtQqvzo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PYvqtQqvzo = sc . nextInt ( ) ; int [ ] arr = new int [ 1000000 ] ; arr [ 0 ] = PYvqtQqvzo ; Set < Integer > set = new HashSet < > ( ) ; set . add ( PYvqtQqvzo ) ; 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 ZGosuxCfoo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String val = S . substring ( 0 , 4 ) ; int ZGosuxCfoo = Integer . parseInt ( val ) ; String val2 = S . substring ( 5 , 7 ) ; int mm = Integer . parseInt ( val2 ) ; if ( ( ZGosuxCfoo == 2019 && mm < 5 ) || ZGosuxCfoo <= 2018 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . Scanner ; public class fJGbaijHaI { public static void main ( String [ ] args ) { int fJGbaijHaI ; String S ; String T ; StringBuilder ans = new StringBuilder ( ) ; Scanner sc = new Scanner ( System . in ) ; fJGbaijHaI = sc . nextInt ( ) ; S = sc . next ( ) ; T = sc . next ( ) ; for ( int i = 0 ; i < fJGbaijHaI ; i ++ ) { ans . append ( S . charAt ( i ) ) . append ( T . charAt ( i ) ) ; } System . out . println ( ans ) ; } } import java . io . * ; public class lTRGEOPeBD { 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 lTRGEOPeBD = Integer . parseInt ( text [ 0 ] ) ; String b = text [ 1 ] ; int c = Integer . parseInt ( text [ 2 ] ) ; while ( b . equals ( " ? " ) == false ) { if ( b . equals ( " + " ) ) { System . out . println ( lTRGEOPeBD + c ) ; } else if ( b . equals ( " - " ) ) { System . out . println ( lTRGEOPeBD - c ) ; } else if ( b . equals ( " * " ) ) { System . out . println ( lTRGEOPeBD * c ) ; } else if ( b . equals ( " / " ) ) { System . out . println ( lTRGEOPeBD / c ) ; } str = br . readLine ( ) ; text = str . split ( " " ) ; lTRGEOPeBD = 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 UMkQAfkBxl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UMkQAfkBxl = sc . nextInt ( ) ; int [ ] a = new int [ UMkQAfkBxl ] ; for ( int i = 0 ; i < UMkQAfkBxl ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Set < Integer > lhs = new LinkedHashSet < Integer > ( ) ; for ( int i = 0 ; i < UMkQAfkBxl ; 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 DgLJRUjwuq { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int DgLJRUjwuq = Integer . parseInt ( st . nextToken ( ) ) ; int N = Integer . parseInt ( st . nextToken ( ) ) ; String regex = String . format ( " [0-9] { %d } -[0-9] { %d } " , DgLJRUjwuq , 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 cqHMTYCjvA { public static void main ( String [ ] args ) { int cqHMTYCjvA , 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 ] ; cqHMTYCjvA = 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 IIdcgFfYch { 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 IIdcgFfYch = sc . nextInt ( ) ; sc . close ( ) ; long sum = 0 ; if ( IIdcgFfYch >= a [ 0 ] ) { sum += a [ 0 ] ; IIdcgFfYch -= a [ 0 ] ; } else { sum += IIdcgFfYch ; IIdcgFfYch = 0 ; } if ( IIdcgFfYch >= a [ 1 ] ) { IIdcgFfYch -= a [ 1 ] ; } else { IIdcgFfYch = 0 ; } if ( IIdcgFfYch >= a [ 2 ] ) { sum -= a [ 2 ] ; IIdcgFfYch -= a [ 2 ] ; } else { sum -= IIdcgFfYch ; IIdcgFfYch = 0 ; } System . out . println ( sum ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class hZesocmZAL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int hZesocmZAL = scan . nextInt ( ) ; if ( hZesocmZAL <= 100 ) { List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < hZesocmZAL ; 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 mLnippWbwt { 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 mLnippWbwt = Integer . parseInt ( n ) ; int xx = Integer . parseInt ( x ) ; int tt = Integer . parseInt ( t ) ; int times ; if ( mLnippWbwt % xx == 0 ) { times = mLnippWbwt / xx ; } else { times = ( mLnippWbwt / xx ) + 1 ; } int answer = tt * times ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class tqioUTuVET { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tqioUTuVET = 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 <= tqioUTuVET ; i ++ ) System . out . println ( d [ i ] ) ; } } import java . util . Scanner ; public class MCtBSUVWyu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String MCtBSUVWyu = scan . nextLine ( ) ; if ( MCtBSUVWyu . equals ( " ABC " ) ) { MCtBSUVWyu = MCtBSUVWyu . replace ( " ABC " , " ARC " ) ; } else { MCtBSUVWyu = MCtBSUVWyu . replace ( " ARC " , " ABC " ) ; } System . out . println ( MCtBSUVWyu ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . lang . Math ; public class RdnhYzmBMw { static class RdnhYzmBMw { 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 RdnhYzmBMw = 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 == RdnhYzmBMw && k2 == b ) { System . out . println ( i ) ; return ; } } System . out . println ( " -1 " ) ; } } import java . util . * ; public class NQfitfknqt { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int NQfitfknqt = sc . nextInt ( ) ; int sweet = NQfitfknqt ; if ( NQfitfknqt % 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 YBhHbyhpOR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double YBhHbyhpOR = ( double ) Integer . parseInt ( sc . next ( ) ) ; System . out . println ( String . format ( " %.12f " , Math . pow ( YBhHbyhpOR / 3 , 3 ) ) ) ; } } import java . util . Scanner ; public class pXQGYIzzOB { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int pXQGYIzzOB = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int c = stdIn . nextInt ( ) ; int x = b + c ; if ( pXQGYIzzOB < x ) System . out . println ( x - pXQGYIzzOB ) ; else System . out . println ( " 0 " ) ; } } import java . util . * ; public class ouQNWUJNdE { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int ouQNWUJNdE = s . nextInt ( ) ; int [ ] H = new int [ ouQNWUJNdE ] ; for ( int i = 0 ; i < ouQNWUJNdE ; i ++ ) { H [ i ] = s . nextInt ( ) ; } int cnt = 0 ; List < Integer > l = new ArrayList < > ( ) ; for ( int j = 0 ; j < ouQNWUJNdE ; 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 gObGDLqUVS { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int gObGDLqUVS = scanner . nextInt ( ) ; int Q = scanner . nextInt ( ) ; int R = scanner . nextInt ( ) ; int t = gObGDLqUVS + Q ; if ( t > R + gObGDLqUVS ) { t = R + gObGDLqUVS ; } if ( t > Q + R ) { t = Q + R ; } System . out . println ( t ) ; } } import java . util . * ; public class hMTZYjpaJF { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; String S = scn . nextLine ( ) ; int hMTZYjpaJF = S . length ( ) ; String str_before = S . substring ( 0 , ( hMTZYjpaJF - 1 ) / 2 ) ; String str_after = S . substring ( ( hMTZYjpaJF + 2 ) / 2 , hMTZYjpaJF ) ; 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 aCBnwvOKWb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aCBnwvOKWb = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ aCBnwvOKWb ] ; for ( int i = 0 ; i < aCBnwvOKWb ; i ++ ) { A [ i ] = Integer . parseInt ( sc . next ( ) ) ; } double sum = 0 ; for ( int i = 0 ; i < aCBnwvOKWb ; i ++ ) { sum += ( 1.0 / A [ i ] ) ; } System . out . println ( 1.0 / sum ) ; } } import java . util . * ; public class mmZqYwFNxr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mmZqYwFNxr = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; String [ ] s = new String [ mmZqYwFNxr ] ; for ( int i = 0 ; i < mmZqYwFNxr ; i ++ ) { s [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < mmZqYwFNxr ; i ++ ) { for ( int j = mmZqYwFNxr - 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 TINmUOctNP { public static void main ( String [ ] args ) { Scanner sca = new Scanner ( System . in ) ; String s = sca . next ( ) ; String t = sca . next ( ) ; int TINmUOctNP = sca . nextInt ( ) ; int b = sca . nextInt ( ) ; String u = sca . next ( ) ; if ( u . equals ( s ) ) { TINmUOctNP -- ; } else { b -- ; } System . out . print ( TINmUOctNP ) ; System . out . print ( " " ) ; System . out . println ( b ) ; sca . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class lRIYssxqzF { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int lRIYssxqzF = scan . nextInt ( ) ; int [ ] array = new int [ lRIYssxqzF ] ; int [ ] copy = new int [ lRIYssxqzF ] ; for ( int count = 0 ; count < lRIYssxqzF ; count ++ ) { int n = scan . nextInt ( ) ; array [ count ] = n ; copy [ count ] = n ; } scan . close ( ) ; Arrays . sort ( copy ) ; int counter = 0 ; for ( int count = 0 ; count < lRIYssxqzF ; 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 SerLTEzxDe { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { String s = in . next ( ) ; int SerLTEzxDe = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' ) { SerLTEzxDe ++ ; } } System . out . println ( SerLTEzxDe ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class eduklElsHf { public static void main ( String [ ] args ) throws IOException { int eduklElsHf , nTaro = 0 , nHana = 0 ; String str ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; eduklElsHf = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < eduklElsHf ; 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 tCVeIJLpKa { 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 tCVeIJLpKa = Integer . parseInt ( num [ 0 ] ) ; int numB = Integer . parseInt ( num [ 1 ] ) ; if ( strU . equals ( strS ) ) { tCVeIJLpKa -= 1 ; } else { numB -= 1 ; } System . out . println ( tCVeIJLpKa + " " + numB ) ; } } import java . util . Scanner ; public class mQEfwqQBKC { public static void main ( String [ ] args ) { final int mQEfwqQBKC = 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 ] ) % mQEfwqQBKC ; if ( i + 2 < a . length && a [ i + 2 ] != - 1 ) { a [ i + 2 ] = ( a [ i ] + a [ i + 2 ] ) % mQEfwqQBKC ; } } System . out . println ( a [ N ] % mQEfwqQBKC ) ; } } import java . util . * ; public class aRebcmeTNw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aRebcmeTNw = sc . nextInt ( ) ; Map < String , Integer > s = new HashMap < String , Integer > ( ) ; char [ ] c ; String ds ; long ans = 0 ; int tmp ; for ( int i = 0 ; i < aRebcmeTNw ; 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 dIgdfYlPIb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Long N = sc . nextLong ( ) ; Long total = 0L ; for ( int dIgdfYlPIb = 1 ; dIgdfYlPIb <= N ; ++ dIgdfYlPIb ) { if ( dIgdfYlPIb % 3 == 0 && dIgdfYlPIb % 5 == 0 ) { continue ; } else if ( dIgdfYlPIb % 3 == 0 ) { continue ; } else if ( dIgdfYlPIb % 5 == 0 ) { continue ; } else { total += dIgdfYlPIb ; } } 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 JaKcYINiOe { 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 JaKcYINiOe { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { String S = in . next ( ) ; int JaKcYINiOe = 0 ; for ( int i = 0 ; i < S . length ( ) / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( S . length ( ) - 1 - i ) ) { JaKcYINiOe ++ ; } } out . println ( JaKcYINiOe ) ; } } static class JaKcYINiOe { 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 qFKYJhlewm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int qFKYJhlewm = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; int a = 0 ; for ( int i = 1 ; i <= qFKYJhlewm ; 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 JdORWoUYwP { 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 JdORWoUYwP = 0 ; JdORWoUYwP < s . length ( ) ; JdORWoUYwP ++ ) { char ch = s . charAt ( JdORWoUYwP ) ; if ( JdORWoUYwP % 2 == 0 ) { if ( ch == 'L' ) return false ; } else { if ( ch == 'R' ) return false ; } } return true ; } } import java . util . Scanner ; class hBIJYvvhth { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int hBIJYvvhth = scanner . nextInt ( ) ; int [ ] array = new int [ hBIJYvvhth ] ; for ( int i = 0 ; i < hBIJYvvhth ; i ++ ) { array [ i ] = scanner . nextInt ( ) ; } insertionSort ( array , hBIJYvvhth ) ; scanner . close ( ) ; } public static int [ ] insertionSort ( int [ ] array , int hBIJYvvhth ) { int sub ; int comp = 0 ; int i ; for ( int cou = 0 ; cou < hBIJYvvhth ; cou ++ ) { System . out . print ( array [ cou ] ) ; if ( cou == hBIJYvvhth - 1 ) { System . out . print ( " \n " ) ; } else { System . out . print ( " " ) ; } } for ( i = 1 ; i <= hBIJYvvhth - 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 < hBIJYvvhth ; cou ++ ) { System . out . print ( array [ cou ] ) ; if ( cou == hBIJYvvhth - 1 ) { System . out . print ( " \n " ) ; } else { System . out . print ( " " ) ; } } } return array ; } } import java . util . Scanner ; public class wMeRpYGJPc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wMeRpYGJPc = sc . nextInt ( ) ; sc . nextLine ( ) ; int [ ] p = new int [ wMeRpYGJPc ] ; for ( int i = 0 ; i < wMeRpYGJPc ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < wMeRpYGJPc ; 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 IsWHqFAQnM { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int IsWHqFAQnM = scan . nextInt ( ) ; boolean flag = true ; PriorityQueue in = new PriorityQueue ( ) ; for ( int x = 0 ; x < IsWHqFAQnM ; x ++ ) { int input = scan . nextInt ( ) ; in . offer ( input ) ; } int before = ( int ) in . poll ( ) ; int after ; for ( int x = 1 ; x < IsWHqFAQnM ; 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 LxzOtTJQkT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LxzOtTJQkT = 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 ( LxzOtTJQkT % 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 AOQZSaSgoh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String AOQZSaSgoh = sc . next ( ) ; if ( Character . isUpperCase ( AOQZSaSgoh . charAt ( 0 ) ) ) { System . out . println ( 'A' ) ; } else System . out . println ( 'a' ) ; } } import java . util . Scanner ; public class TZPeEojkKc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TZPeEojkKc = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = a ; i <= TZPeEojkKc ; 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 ArXcSKTAhH { 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 ArXcSKTAhH = in . nextInt ( ) ; int M = in . nextInt ( ) ; int cL = 0 ; int cR = ArXcSKTAhH + 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 ArXcSKTAhH 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 KsYJhcGzGp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KsYJhcGzGp = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int t = KsYJhcGzGp - 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 nwDiRPPAMR { public static void main ( String [ ] args ) { Scanner dataScanner = new Scanner ( System . in ) ; String [ ] data = dataScanner . nextLine ( ) . split ( " " ) ; int nwDiRPPAMR = 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 ( nwDiRPPAMR , 0 ) + 1 ; i ++ ) { for ( Integer j = 0 ; j < Math . max ( nwDiRPPAMR - i , 0 ) + 1 ; j ++ ) { int k = nwDiRPPAMR - 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 HXmIzNzlwd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int HXmIzNzlwd = scanner . nextInt ( ) ; int D = scanner . nextInt ( ) ; int [ ] [ ] X = new int [ HXmIzNzlwd ] [ D ] ; for ( int i = 0 ; i < HXmIzNzlwd ; i ++ ) { for ( int j = 0 ; j < D ; j ++ ) { X [ i ] [ j ] = scanner . nextInt ( ) ; } } int resultNumber = 0 ; int temp = 0 ; for ( int i = 0 ; i < HXmIzNzlwd - 1 ; i ++ ) { for ( int j = i + 1 ; j < HXmIzNzlwd ; 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 mDzdZPhcgN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mDzdZPhcgN = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = - 1 ; if ( ( mDzdZPhcgN < 10 ) && ( b < 10 ) ) ans = ( mDzdZPhcgN * b ) ; System . out . println ( ans ) ; } } import java . util . * ; public class tAxwnrXclX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tAxwnrXclX = 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 ( tAxwnrXclX <= all ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; class izPfROTdLO { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int izPfROTdLO = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( izPfROTdLO >= s . length ( ) ) { System . out . println ( s ) ; } else { System . out . println ( s . substring ( 0 , izPfROTdLO ) + " ... " ) ; } } catch ( Exception e ) { } finally { } } } import java . util . Scanner ; public class pjsDJVaabP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double pjsDJVaabP = sc . nextDouble ( ) ; double ans ; ans = Math . ceil ( pjsDJVaabP / 2 ) ; int a ; a = ( int ) ans ; System . out . println ( a ) ; return ; } } import java . util . Scanner ; import java . lang . Math ; public class GbUSCHYQOY { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( scan . hasNext ( ) ) { String input = scan . nextLine ( ) ; String [ ] inputs = input . split ( " " ) ; int GbUSCHYQOY = Integer . parseInt ( inputs [ 0 ] ) ; int width = Integer . parseInt ( inputs [ 1 ] ) ; if ( GbUSCHYQOY == 0 && width == 0 ) { break ; } for ( int i = 0 ; i < GbUSCHYQOY ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . Scanner ; class GgFqrDcWYU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GgFqrDcWYU = Integer . parseInt ( sc . next ( ) ) ; boolean aa = false ; boolean bb = true ; for ( int i = 0 ; i < GgFqrDcWYU ; 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 DQTWrsPrBv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String a = " " ; for ( int DQTWrsPrBv = 0 ; DQTWrsPrBv < s . length ( ) ; DQTWrsPrBv ++ ) { switch ( s . charAt ( DQTWrsPrBv ) ) { 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 fdRwCVbTZc { public static void main ( String [ ] args ) throws IOException { Scanner S = new Scanner ( System . in ) ; String Str = S . nextLine ( ) ; int fdRwCVbTZc = Integer . parseInt ( Str ) ; int seconds = fdRwCVbTZc % 60 ; int hour = fdRwCVbTZc / 3600 ; int minute = fdRwCVbTZc / 60 - hour * 60 ; System . out . println ( hour + " : " + minute + " : " + seconds ) ; } } import java . util . * ; public class ymQZlkHAGP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ymQZlkHAGP = sc . nextInt ( ) , x = sc . nextInt ( ) ; int cnt = ymQZlkHAGP <= x ? 1 : 0 , cur = 0 , temp ; for ( int i = 0 ; i < ymQZlkHAGP ; ++ i ) { temp = sc . nextInt ( ) ; cur += temp ; if ( cur <= x ) ++ cnt ; } System . out . printf ( " %d \n " , cnt ) ; } } import java . util . * ; public class nlkrxKIuyr { public static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int nlkrxKIuyr = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; int [ ] stones = new int [ nlkrxKIuyr + 1 ] ; int [ ] dp = new int [ nlkrxKIuyr + 1 ] ; for ( int i = 1 ; i <= nlkrxKIuyr ; i ++ ) { stones [ i ] = scanner . nextInt ( ) ; } System . out . println ( solve ( stones , dp , nlkrxKIuyr , k ) ) ; } public static int solve ( int [ ] stones , int [ ] dp , int nlkrxKIuyr , int k ) { if ( nlkrxKIuyr <= 1 ) { return 0 ; } for ( int i = 2 ; i <= nlkrxKIuyr ; 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 [ nlkrxKIuyr ] ; } } import java . util . Scanner ; public class dIRnJxSuZu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dIRnJxSuZu = sc . nextInt ( ) ; int [ ] a = new int [ dIRnJxSuZu ] ; int b = 0 ; int [ ] c = new int [ dIRnJxSuZu - 1 ] ; for ( int i = 0 ; i < dIRnJxSuZu ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < dIRnJxSuZu ; i ++ ) { b += sc . nextInt ( ) ; } for ( int i = 0 ; i < dIRnJxSuZu - 1 ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < dIRnJxSuZu ; 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 bfdbIPvnwK { void solve ( Scanner in , PrintWriter out ) { int bfdbIPvnwK = in . nextInt ( ) ; int cpt = 0 ; for ( int i = 0 ; i < bfdbIPvnwK ; ++ 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 GZNYoEatMC { 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 GZNYoEatMC = 0 ; GZNYoEatMC < ss . length ; GZNYoEatMC ++ ) { a [ GZNYoEatMC ] = ss [ GZNYoEatMC ] . length ( ) ; } Arrays . sort ( a , Collections . reverseOrder ( ) ) ; out . println ( a [ 0 ] ) ; } out . flush ( ) ; } } import java . util . Scanner ; public class hDIgnGATVM { 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 hDIgnGATVM = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( forecast . charAt ( i ) == weather . charAt ( i ) ) { hDIgnGATVM ++ ; } } return hDIgnGATVM ; } } import java . util . * ; public class AEjQuqKMcY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AEjQuqKMcY = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] [ ] mrxA = new int [ AEjQuqKMcY ] [ m ] ; int [ ] [ ] mrxB = new int [ m ] [ l ] ; long [ ] [ ] mrxC = new long [ AEjQuqKMcY ] [ l ] ; for ( int i = 0 ; i < AEjQuqKMcY ; 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 < AEjQuqKMcY ; 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 kDUCmBsirE { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kDUCmBsirE = 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 ( kDUCmBsirE > 0 ) { kDUCmBsirE = kDUCmBsirE - numd ; } else { System . out . println ( " No " ) ; break ; } } } scan . close ( ) ; } } import java . util . * ; public class VNlSGJiTTO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VNlSGJiTTO = 0 ; int [ ] line = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { line [ i ] = sc . nextInt ( ) ; VNlSGJiTTO += line [ i ] ; } int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < 3 ; i ++ ) { min = Math . min ( min , VNlSGJiTTO - line [ i ] ) ; } System . out . println ( min ) ; } } import java . util . * ; public class KEzrnQlSbk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KEzrnQlSbk = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ KEzrnQlSbk ] ; int x = 0 ; int aa = 0 ; for ( int i = 0 ; i < KEzrnQlSbk ; i ++ ) { a [ i ] = sc . nextInt ( ) ; aa += a [ i ] ; } for ( int i = 0 ; i < KEzrnQlSbk ; 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 IBxGxymFNh { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { Scanner scanner = new Scanner ( System . in ) ; int IBxGxymFNh = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; if ( ( IBxGxymFNh + B ) % 2 == 0 ) { System . out . println ( ( IBxGxymFNh + B ) / 2 ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . util . Scanner ; import java . util . Stack ; public class jBKsvsHYZx { 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 jBKsvsHYZx = stack . pop ( ) ; int v2 = stack . pop ( ) ; stack . push ( v2 + jBKsvsHYZx ) ; break ; } case " - " : { int jBKsvsHYZx = stack . pop ( ) ; int v2 = stack . pop ( ) ; stack . push ( v2 - jBKsvsHYZx ) ; break ; } case " * " : { int jBKsvsHYZx = stack . pop ( ) ; int v2 = stack . pop ( ) ; stack . push ( v2 * jBKsvsHYZx ) ; 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 EqMJPDBvXM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EqMJPDBvXM = Integer . parseInt ( sc . next ( ) ) ; int [ ] v = new int [ EqMJPDBvXM ] ; int [ ] c = new int [ EqMJPDBvXM ] ; for ( int i = 0 ; i < EqMJPDBvXM ; i ++ ) { v [ i ] = Integer . parseInt ( sc . next ( ) ) ; } for ( int i = 0 ; i < EqMJPDBvXM ; i ++ ) { c [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int count = 0 ; for ( int i = 0 ; i < EqMJPDBvXM ; i ++ ) { if ( c [ i ] < v [ i ] ) { count += v [ i ] - c [ i ] ; } } System . out . println ( count ) ; } } import java . util . * ; class CxRUsZsyXH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long CxRUsZsyXH = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ret = 0 ; long rep = ( long ) ( CxRUsZsyXH / ( a + b ) ) ; ret += rep * a ; long remain = CxRUsZsyXH - ( 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 WBscRDBmPj { 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 WBscRDBmPj = 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 ) ) WBscRDBmPj = true ; } System . out . println ( WBscRDBmPj == true ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class UacDQEHbVj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int UacDQEHbVj = scan . nextInt ( ) ; int [ ] a = new int [ UacDQEHbVj ] ; for ( int i = 0 ; i < UacDQEHbVj ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } int max = 0 ; int count = 0 ; for ( int i = 0 ; i < UacDQEHbVj ; i ++ ) { if ( a [ i ] >= max ) { max = a [ i ] ; count = count + 1 ; } } System . out . println ( count ) ; } } import java . util . * ; class QVoZWCvGlx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QVoZWCvGlx = sc . nextInt ( ) ; if ( QVoZWCvGlx % 2 == 0 ) { int [ ] d = new int [ QVoZWCvGlx ] ; for ( int i = 0 ; i < QVoZWCvGlx ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; int ans = d [ QVoZWCvGlx / 2 ] - d [ QVoZWCvGlx / 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 kuCqSvujAV { static class kuCqSvujAV { 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 kuCqSvujAV = fr . next ( ) . charAt ( 0 ) ; if ( kuCqSvujAV >= 65 && kuCqSvujAV <= 90 ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . Scanner ; import java . util . Arrays ; public class wHhThAkwHP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wHhThAkwHP = sc . nextInt ( ) ; int [ ] array = new int [ wHhThAkwHP ] ; for ( int i = 0 ; i < wHhThAkwHP ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int i ; for ( i = 0 ; i < wHhThAkwHP - 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 == ( wHhThAkwHP - 1 ) ) { System . out . println ( " Yes " ) ; } } } import java . math . BigInteger ; import java . util . Scanner ; public class aHDiAXfFOf { private static long aHDiAXfFOf ; private static String [ ] numeralSystem ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; BigInteger bigInteger = new BigInteger ( scanner . next ( ) ) ; aHDiAXfFOf = 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 ( aHDiAXfFOf > 26 ) { res = numeralSystem [ ( int ) ( aHDiAXfFOf % 26 ) ] . concat ( res ) ; aHDiAXfFOf -- ; aHDiAXfFOf /= 26 ; } res = numeralSystem [ ( int ) aHDiAXfFOf ] . concat ( res ) ; return res ; } } import java . util . * ; import javax . lang . model . util . ElementScanner6 ; public class azNxARnUBs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int azNxARnUBs = sc . nextInt ( ) ; HashSet < String > s = new HashSet < > ( ) ; for ( int i = 0 ; i < azNxARnUBs ; i ++ ) { String a = sc . next ( ) ; s . add ( a ) ; } int out = s . size ( ) ; System . out . println ( out ) ; } } import java . util . Scanner ; public class sibjvkGgfh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sibjvkGgfh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( sibjvkGgfh <= b ) { String stringA = String . valueOf ( sibjvkGgfh ) ; for ( int i = 1 ; i < b ; i ++ ) { stringA += sibjvkGgfh ; } System . out . println ( stringA ) ; } else { String stringB = String . valueOf ( b ) ; for ( int i = 1 ; i < sibjvkGgfh ; i ++ ) { stringB += b ; } System . out . println ( stringB ) ; } sc . close ( ) ; } } import java . util . * ; public class UUcMvekaDo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int UUcMvekaDo = scan . nextInt ( ) ; int l = scan . nextInt ( ) ; int [ ] arr = new int [ UUcMvekaDo ] ; int sum = 0 ; int min = 0 ; for ( int i = 0 ; i < UUcMvekaDo ; i ++ ) { arr [ i ] = l + i ; sum += arr [ i ] ; } if ( l >= 0 ) { System . out . print ( sum - l ) ; } else { if ( UUcMvekaDo + l > 0 ) { min = sum ; } else { min = sum - ( UUcMvekaDo + l - 1 ) ; } System . out . print ( min ) ; } } } import java . util . Scanner ; public class jRJUgsAwwo { public static void main ( String [ ] args ) throws Exception { Scanner stdin = new Scanner ( System . in ) ; int jRJUgsAwwo = 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 ylnwKqfnZz { 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 ylnwKqfnZz = Integer . parseInt ( st . nextToken ( ) ) ; if ( ylnwKqfnZz == 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 XfmjpKTLpQ { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String K = sc . next ( ) ; int XfmjpKTLpQ = 101 ; if ( K . length ( ) <= 3 ) XfmjpKTLpQ = 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 ( XfmjpKTLpQ <= index0 + 1 ) System . out . println ( 1 ) ; else System . out . println ( S . charAt ( index0 + 1 ) ) ; } } } import java . util . * ; public class kJizrbbCEM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double kJizrbbCEM = 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 ( kJizrbbCEM , 2 ) + Math . pow ( longB , 2 ) - 2.0 * kJizrbbCEM * 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 vCPkjQxhsD { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; long vCPkjQxhsD = 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 >= vCPkjQxhsD ) { System . out . println ( " 1 " ) ; } else { System . out . println ( str [ ( int ) one ] ) ; } } } import java . util . Scanner ; public class hhkNxfrofP { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int hhkNxfrofP = scan . nextInt ( ) ; int [ ] array = new int [ hhkNxfrofP + 1 ] ; for ( int i = 1 ; i <= hhkNxfrofP ; i ++ ) { array [ i ] = scan . nextInt ( ) ; } int [ ] result = new int [ hhkNxfrofP + 1 ] ; for ( int i = 1 ; i <= hhkNxfrofP ; i ++ ) { result [ array [ i ] ] = i ; } for ( int i = 1 ; i <= hhkNxfrofP ; i ++ ) { if ( i != hhkNxfrofP ) { System . out . print ( result [ i ] + " " ) ; } else { System . out . print ( result [ i ] ) ; } } } } import java . util . Scanner ; public class WCRWuORFUK { public static void main ( String [ ] args ) { ( new Main ( ) ) . execute ( ) ; } public void execute ( ) { Scanner sc = new Scanner ( System . in ) ; int WCRWuORFUK = sc . nextInt ( ) ; int [ ] p = new int [ WCRWuORFUK + 1 ] ; int ngPos = 0 ; int ngNum = 0 ; int changeCount = 0 ; boolean ok = true ; for ( int i = 1 ; i <= WCRWuORFUK ; 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 YVgJjrOIfL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YVgJjrOIfL = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( YVgJjrOIfL >= S . length ( ) ) { System . out . println ( S ) ; } else { System . out . println ( S . substring ( 0 , YVgJjrOIfL ) + " ... " ) ; } } } import java . util . Scanner ; public class lpzaUUhouQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lpzaUUhouQ = sc . nextInt ( ) ; long sum = 0 ; for ( int a = 1 ; a <= lpzaUUhouQ ; a ++ ) { for ( int b = 1 ; b <= lpzaUUhouQ ; b ++ ) { int sur_1 = gcd ( a , b ) ; for ( int c = 1 ; c <= lpzaUUhouQ ; 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 WVfmTMcvZQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WVfmTMcvZQ = sc . nextInt ( ) ; int [ ] in = new int [ WVfmTMcvZQ ] ; for ( int i = 0 ; i < WVfmTMcvZQ ; i ++ ) { in [ i ] = sc . nextInt ( ) ; } int count = 0 ; int ans = 0 ; for ( int i = 0 ; i < WVfmTMcvZQ - 1 ; i ++ ) { if ( in [ i ] >= in [ i + 1 ] ) { count ++ ; } else { ans = Math . max ( ans , count ) ; count = 0 ; } if ( i == WVfmTMcvZQ - 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 oPABFqbUpQ { 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 oPABFqbUpQ = Integer . parseInt ( in . readLine ( ) ) ; int lim = 1000000 , i = 2 , a = oPABFqbUpQ ; HashSet < Integer > set = new HashSet ( ) ; set . add ( oPABFqbUpQ ) ; 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 WGpMmfJjOH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WGpMmfJjOH = sc . nextInt ( ) ; ArrayList < Integer > asiba = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < WGpMmfJjOH ; 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 < WGpMmfJjOH ; 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 ( WGpMmfJjOH - 1 ) ) ; } } import java . util . * ; public class ZoCelQMapw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZoCelQMapw = sc . nextInt ( ) ; String S = sc . next ( ) ; String [ ] ABCList = S . split ( " ABC " , - 1 ) ; System . out . println ( ABCList . length - 1 ) ; } } import java . util . * ; public class kINLIAEicL { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int kINLIAEicL = scanner . nextInt ( ) ; int n = scanner . nextInt ( ) ; if ( n == 100 ) { n ++ ; } System . out . println ( ( int ) Math . pow ( 100 , kINLIAEicL ) * n ) ; } } import java . util . Scanner ; class EfmcdaBvsc { 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 EfmcdaBvsc = 0 ; EfmcdaBvsc < 3 ; ++ EfmcdaBvsc ) { if ( n [ EfmcdaBvsc ] == '1' ) n [ EfmcdaBvsc ] = '9' ; else if ( n [ EfmcdaBvsc ] == '9' ) n [ EfmcdaBvsc ] = '1' ; } System . out . print ( n ) ; } } import java . util . Scanner ; public class rNDDqnjPMq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] a = new char [ 10 ] ; for ( int rNDDqnjPMq = 0 ; rNDDqnjPMq < s . length ( ) ; rNDDqnjPMq ++ ) { a [ rNDDqnjPMq ] = s . charAt ( rNDDqnjPMq ) ; } a [ 3 ] = '8' ; for ( int rNDDqnjPMq = 0 ; rNDDqnjPMq < a . length ; rNDDqnjPMq ++ ) { System . out . print ( a [ rNDDqnjPMq ] ) ; } } } import java . util . Scanner ; public class LPvVaxmLuf { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int LPvVaxmLuf = Integer . parseInt ( scanner . next ( ) ) ; int breakCount = 0 ; int kIndex = 1 ; for ( int i = 0 ; i < LPvVaxmLuf ; i ++ ) { int num = Integer . parseInt ( scanner . next ( ) ) ; if ( kIndex != num ) { breakCount ++ ; } else { kIndex ++ ; } } scanner . close ( ) ; if ( breakCount == LPvVaxmLuf ) { System . out . println ( " -1 " ) ; } else { System . out . println ( breakCount ) ; } } } import java . util . Scanner ; public class krBIYSdYTF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int krBIYSdYTF = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int a3 = sc . nextInt ( ) ; int sa12 = Math . abs ( krBIYSdYTF - a2 ) ; int sa23 = Math . abs ( a2 - a3 ) ; int sa31 = Math . abs ( a3 - krBIYSdYTF ) ; 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 wgHKQPuNSC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long wgHKQPuNSC = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; long result1 = Math . max ( 0 , wgHKQPuNSC - K ) ; long result2 = Math . max ( 0 , Math . min ( wgHKQPuNSC + B - K , B ) ) ; System . out . println ( result1 + " " + result2 ) ; } } import java . util . * ; import java . math . * ; public class MuIQDvukkj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String MuIQDvukkj = sc . next ( ) ; String sb = sc . next ( ) ; BigDecimal A = new BigDecimal ( MuIQDvukkj ) ; BigDecimal B = new BigDecimal ( sb ) ; System . out . println ( A . multiply ( B ) . setScale ( 0 , BigDecimal . ROUND_DOWN ) ) ; } } import java . util . Scanner ; public class xCHXtaLRBF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xCHXtaLRBF = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int [ ] h = new int [ xCHXtaLRBF ] ; for ( int i = 0 ; i < xCHXtaLRBF ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } double ansDiff = 1000000 ; int ansNum = 0 ; for ( int i = 0 ; i < xCHXtaLRBF ; 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 slotoiIOuR { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int slotoiIOuR = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] ary = new int [ slotoiIOuR ] ; for ( int i = 0 ; i < slotoiIOuR ; i ++ ) ary [ i ] = sc . nextInt ( ) ; sc . close ( ) ; Arrays . sort ( ary ) ; for ( int i = 0 ; i < slotoiIOuR ; i ++ ) { if ( ary [ i ] >= k ) { System . out . println ( slotoiIOuR - i ) ; System . exit ( 0 ) ; } } System . out . println ( " 0 " ) ; } } import java . util . Scanner ; public class QsugllOrQL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QsugllOrQL = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int n = QsugllOrQL / X ; if ( QsugllOrQL % 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 MLhtdGBrSV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MLhtdGBrSV = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sc . close ( ) ; List < Integer > ary = new ArrayList < > ( ) ; int flg = 1 ; while ( flg <= MLhtdGBrSV || flg <= B ) { if ( MLhtdGBrSV % 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 MqMzwWltVR { static class MqMzwWltVR { double MqMzwWltVR , s ; pair ( double MqMzwWltVR , double s ) { this . MqMzwWltVR = MqMzwWltVR ; 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 VQiuvpiCnZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . nextLine ( ) . toLowerCase ( ) ; int VQiuvpiCnZ = 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 ( ) ) ) { VQiuvpiCnZ += 1 ; } } } System . out . println ( VQiuvpiCnZ ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class FnauvhlycY { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int FnauvhlycY = 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 ( FnauvhlycY % 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 qDgFWFpeqy { 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 qDgFWFpeqy { public void solve ( Scanner in , PrintWriter out ) { int qDgFWFpeqy = in . nextInt ( ) , b = in . nextInt ( ) ; out . println ( ( qDgFWFpeqy * b ) % 2 == 0 ? " Even " : " Odd " ) ; } } } import java . util . Scanner ; public class AGbiYWFelR { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; int AGbiYWFelR = stdin . nextInt ( ) ; int b = stdin . nextInt ( ) ; System . out . printf ( " %d %d %f " , AGbiYWFelR / b , AGbiYWFelR % b , ( double ) AGbiYWFelR / b ) ; } } import java . util . * ; import java . math . * ; import java . io . * ; public class FoxviENsEo { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int [ ] a = new int [ 5 ] ; for ( int FoxviENsEo = 0 ; FoxviENsEo < 5 ; FoxviENsEo ++ ) { a [ FoxviENsEo ] = sc . nextInt ( ) ; } int ans = 3928237 ; for ( int FoxviENsEo = 0 ; FoxviENsEo < 5 ; FoxviENsEo ++ ) { int sum = 0 ; for ( int j = 0 ; j < 5 ; j ++ ) { if ( FoxviENsEo != 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 sGwkpNGpvD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sGwkpNGpvD = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int min = x - sGwkpNGpvD + 1 ; int max = x + sGwkpNGpvD - 1 ; for ( int i = min ; i <= max ; i ++ ) { System . out . print ( i + ( i == max ? " " : " " ) ) ; } System . out . println ( ) ; } } import java . io . * ; public class EJibrbfyQU { public static void main ( String [ ] arg ) throws IOException { InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( is ) ; String EJibrbfyQU = br . readLine ( ) ; String [ ] spl = EJibrbfyQU . 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 KztnsyvFji { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = reader . readLine ( ) ; char KztnsyvFji = line . charAt ( 0 ) ; KztnsyvFji ++ ; System . out . println ( KztnsyvFji ) ; } } import java . util . * ; public class lPhFPNzpPf { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String lPhFPNzpPf = in . next ( ) ; String res ; if ( lPhFPNzpPf . equals ( " Sunny " ) ) { res = " Cloudy " ; } else if ( lPhFPNzpPf . equals ( " Cloudy " ) ) { res = " Rainy " ; } else { res = " Sunny " ; } System . out . println ( res ) ; in . close ( ) ; } } import java . util . Scanner ; class KiWODTyvBl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KiWODTyvBl = 0 ; int b = 0 ; int c = 0 ; KiWODTyvBl = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; if ( KiWODTyvBl < b && b < c && KiWODTyvBl < c ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class LtLAOZqjYW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LtLAOZqjYW = Integer . parseInt ( sc . next ( ) ) ; switch ( LtLAOZqjYW % 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 DLnJVMXPUZ { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int DLnJVMXPUZ = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int T = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( ( T / DLnJVMXPUZ ) * B ) ; } } } import java . util . Scanner ; public class AouLjFWmdk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 100 ] ; int AouLjFWmdk = 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 ) { AouLjFWmdk ++ ; } } System . out . println ( AouLjFWmdk ) ; } } import java . io . * ; import java . util . * ; import java . util . function . * ; final class jIVQShqJVo { static final Solver INSTANCE = new Solver ( ) ; void solve ( Supplier < String > sc ) { String S = sc . get ( ) ; int jIVQShqJVo = Integer . parseInt ( S . substring ( 0 , 2 ) , 10 ) ; int right = Integer . parseInt ( S . substring ( 2 ) , 10 ) ; if ( isYear ( jIVQShqJVo ) && isYear ( right ) ) { System . out . println ( " NA " ) ; } else if ( isYear ( jIVQShqJVo ) ) { 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 jIVQShqJVo { 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 UMkXqlofcs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UMkXqlofcs = sc . nextInt ( ) ; int [ ] len = new int [ UMkXqlofcs ] ; int sum = 0 ; int max = 0 ; for ( int i = 0 ; i < UMkXqlofcs ; i ++ ) { int temp = sc . nextInt ( ) ; if ( temp > max ) { max = temp ; } sum += temp ; } System . out . println ( max < sum - max ? " Yes " : " No " ) ; } } import java . util . * ; class UHOUxoOOpA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UHOUxoOOpA = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; Integer [ ] h = new Integer [ UHOUxoOOpA ] ; long ans = 0 ; for ( int i = 0 ; i < UHOUxoOOpA ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } if ( k >= UHOUxoOOpA ) { 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 < UHOUxoOOpA ; i ++ ) { ans += h [ i ] ; } System . out . println ( ans ) ; } } } import java . util . * ; public class vtBNBgsJhh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vtBNBgsJhh = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] cities = new int [ vtBNBgsJhh ] ; 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 < vtBNBgsJhh ; j ++ ) { System . out . println ( cities [ j ] ) ; } } } import java . util . * ; public class wibEPOowdj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wibEPOowdj = sc . nextInt ( ) ; Integer [ ] dArr = new Integer [ wibEPOowdj ] ; for ( int i = 0 ; i < wibEPOowdj ; i ++ ) { dArr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( dArr , Collections . reverseOrder ( ) ) ; int count = 1 ; for ( int i = 1 ; i < wibEPOowdj ; 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 zxWFyWIfne { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int zxWFyWIfne = 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 ( zxWFyWIfne , 2 ) + Math . pow ( B , 2 ) - ( double ) ( ( double ) ( 2 * zxWFyWIfne * B ) * Math . cos ( sita ) ) ) ) ; System . out . print ( answer ) ; } } } import java . util . Scanner ; public class wIPBtlNBku { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wIPBtlNBku = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; long [ ] x = new long [ wIPBtlNBku ] ; long [ ] y = new long [ wIPBtlNBku ] ; int count = 0 ; for ( int i = 0 ; i < wIPBtlNBku ; i ++ ) { x [ i ] = sc . nextLong ( ) ; y [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < wIPBtlNBku ; 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 ompjIVuiKd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ompjIVuiKd = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; sc . close ( ) ; int answer = 0 ; answer += ( ompjIVuiKd * ( ompjIVuiKd - 1 ) ) / 2 ; answer += ( m * ( m - 1 ) ) / 2 ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class qIxyEfLMLH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qIxyEfLMLH = sc . nextInt ( ) ; int yoke = 0 ; int count = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { count += qIxyEfLMLH % 10 ; qIxyEfLMLH -= qIxyEfLMLH % 10 ; qIxyEfLMLH /= 10 ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class HgUbvAPpAU { public static int total ( int t ) { int HgUbvAPpAU = 0 ; while ( t != 0 ) { HgUbvAPpAU += t % 10 ; t /= 10 ; } return HgUbvAPpAU ; } 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 iFeiJJadil { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iFeiJJadil = sc . nextInt ( ) ; int [ ] B = new int [ iFeiJJadil ] ; for ( int i = 0 ; i < iFeiJJadil - 1 ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } int total = 0 ; for ( int i = 0 ; i < iFeiJJadil ; i ++ ) { if ( i == 0 ) total += B [ i ] ; else if ( i == iFeiJJadil - 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 bIqgrlikjN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bIqgrlikjN = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; System . out . println ( t / bIqgrlikjN * b ) ; } } import java . util . * ; public class AhQGxqHZfh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AhQGxqHZfh = sc . nextInt ( ) ; int [ ] arr = new int [ AhQGxqHZfh + 1 ] ; arr [ 0 ] = - 1 ; for ( int i = 1 ; i < AhQGxqHZfh + 1 ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } String ans = " Yes " ; for ( int i = 1 ; i < AhQGxqHZfh ; 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 dIjWlOPKwP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dIjWlOPKwP = sc . nextInt ( ) ; int x_500 = dIjWlOPKwP / 500 ; dIjWlOPKwP = dIjWlOPKwP - dIjWlOPKwP / 500 * 500 ; int x_5 = dIjWlOPKwP / 5 ; int ans = x_500 * 1000 + x_5 * 5 ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class FoEdIYbVne { 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 FoEdIYbVne = readInt ( ) ; if ( FoEdIYbVne % 1000 == 0 ) pw . println ( 0 ) ; else pw . println ( 1000 - FoEdIYbVne % 1000 ) ; pw . close ( ) ; } } import java . util . * ; import java . lang . * ; public class xgbeVhnRbb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String xgbeVhnRbb = scan . next ( ) ; if ( xgbeVhnRbb . equals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } if ( xgbeVhnRbb . equals ( " ARC " ) ) { System . out . println ( " ABC " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class MTsKyaNPMb { public static void main ( String [ ] args ) throws IOException { int [ ] data = new int [ 10 ] ; final String BR = System . getProperty ( " line.separator " ) ; int MTsKyaNPMb = 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 ( MTsKyaNPMb < datum ) { temp1 = MTsKyaNPMb ; temp2 = second ; MTsKyaNPMb = datum ; second = temp1 ; third = temp2 ; } else if ( second < datum ) { temp2 = second ; second = datum ; third = temp2 ; } else if ( third < datum ) { third = datum ; } } System . out . println ( MTsKyaNPMb + BR + second + BR + third ) ; } } import java . util . Scanner ; public class AXCRKpwCYF { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] menu = new int [ 5 ] ; int AXCRKpwCYF = 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 ) { AXCRKpwCYF += menu [ i ] ; } else { AXCRKpwCYF += menu [ i ] + ( 10 - ( menu [ i ] % 10 ) ) ; } } } AXCRKpwCYF += menu [ idx ] ; System . out . println ( AXCRKpwCYF ) ; } } import java . util . * ; public class LDGdvRLWlS { public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . exec ( ) ; } private void exec ( ) { Scanner scan = new Scanner ( System . in ) ; int LDGdvRLWlS = 0 ; int count7 = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { switch ( scan . nextInt ( ) ) { case 5 : LDGdvRLWlS ++ ; break ; case 7 : count7 ++ ; break ; default : } } if ( LDGdvRLWlS == 2 && count7 == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } scan . close ( ) ; } } import java . util . * ; public class nJtkBLpZpR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nJtkBLpZpR = 0 ; int count7 = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { switch ( sc . nextInt ( ) ) { case 5 : nJtkBLpZpR ++ ; break ; case 7 : count7 ++ ; break ; } } if ( nJtkBLpZpR == 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 mZmYRLIyDq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mZmYRLIyDq = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; String [ ] name = new String [ mZmYRLIyDq ] ; 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 < mZmYRLIyDq ; ++ 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 AELXWJdVPR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AELXWJdVPR = sc . nextInt ( ) ; int c0 = 0 ; int c1 = 0 ; int c2 = 0 ; int c3 = 0 ; for ( int i = 0 ; i < AELXWJdVPR + 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 ZmxexUxloH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZmxexUxloH = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; boolean [ ] sunukes = new boolean [ ZmxexUxloH ] ; 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 jDZidTyNDz { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int jDZidTyNDz = 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 < jDZidTyNDz ; 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 InrFxudyyi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int InrFxudyyi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] surp = new int [ Math . min ( InrFxudyyi , b ) + 1 ] ; for ( int i = 1 ; i <= Math . min ( InrFxudyyi , b ) ; i ++ ) { if ( InrFxudyyi % i == 0 && b % i == 0 ) { surp [ i ] = i ; } } Arrays . sort ( surp ) ; System . out . println ( surp [ Math . min ( InrFxudyyi , b ) - k + 1 ] ) ; } } import java . util . * ; import java . io . * ; class esffhIdtXs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out , true ) ; String str = sc . nextLine ( ) ; int esffhIdtXs = 0 ; int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == 'R' ) { count ++ ; esffhIdtXs = Math . esffhIdtXs ( count , esffhIdtXs ) ; } else { count = 0 ; } } out . println ( esffhIdtXs ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class MfwBwPvMRU { public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; boolean MfwBwPvMRU = 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 ; MfwBwPvMRU = true ; } } if ( MfwBwPvMRU ) System . out . println ( cost ) ; else System . out . println ( " TLE " ) ; } static class MfwBwPvMRU { 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 gVmiEdRwvx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int gVmiEdRwvx = 0 ; while ( gVmiEdRwvx == 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 aJyevrAbLF { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int aJyevrAbLF = scan . nextInt ( ) ; int [ ] h = new int [ aJyevrAbLF + 1 ] ; for ( int i = 1 ; i <= aJyevrAbLF ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } h [ 0 ] = 0 ; for ( int i = 1 ; i <= aJyevrAbLF ; i ++ ) { if ( h [ i ] > h [ i - 1 ] ) { h [ i ] -- ; } } for ( int i = 1 ; i <= aJyevrAbLF ; i ++ ) { if ( h [ i ] >= h [ i - 1 ] ) { } else { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; class YlymabnUct { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; double YlymabnUct = cin . nextDouble ( ) ; System . out . printf ( " %.6f %.6f \n " , cal_area ( YlymabnUct ) , cal_cirum ( YlymabnUct ) ) ; } private static double cal_cirum ( double YlymabnUct ) { return ( YlymabnUct * 2 * Math . PI ) ; } private static double cal_area ( double YlymabnUct ) { return ( YlymabnUct * YlymabnUct * Math . PI ) ; } } import java . util . Scanner ; public class MkZtoYtiMj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int MkZtoYtiMj = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] ary = new int [ MkZtoYtiMj ] ; long sum = 0 ; for ( int i = 0 ; i < MkZtoYtiMj ; i ++ ) { ary [ i ] = sc . nextInt ( ) ; sum += ary [ i ] ; } sc . close ( ) ; int m2 = 0 ; for ( int i = 0 ; i < MkZtoYtiMj ; 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 GIwTyrfHEu { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long GIwTyrfHEu = scanner . nextLong ( ) ; long count = 0 ; while ( GIwTyrfHEu > 1 ) { GIwTyrfHEu = GIwTyrfHEu / 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 qxwUEjPQKG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qxwUEjPQKG = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] r = new int [ 2 * m ] ; int [ ] rr = new int [ qxwUEjPQKG + 1 ] ; for ( int i = 0 ; i < 2 * m ; i ++ ) { r [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < qxwUEjPQKG + 1 ; i ++ ) { rr [ i ] = 0 ; } for ( int i = 0 ; i < 2 * m ; i ++ ) { rr [ r [ i ] ] ++ ; } for ( int i = 1 ; i <= qxwUEjPQKG ; i ++ ) { System . out . println ( rr [ i ] ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class mXqEMumAdo { 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 mXqEMumAdo = Integer . parseInt ( data [ 0 ] ) ; int b = Integer . parseInt ( data [ 1 ] ) ; if ( mXqEMumAdo == 0 && b == 0 ) break ; for ( int y = 0 ; y < mXqEMumAdo ; 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 AASIooWmAV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AASIooWmAV = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; sc . close ( ) ; if ( Y % 2 == 1 ) { System . out . println ( " No " ) ; return ; } double ans = Y / 2 - AASIooWmAV ; if ( ans < 0 || ans > AASIooWmAV || ans % 1 != 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class TXubzuzolF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TXubzuzolF , m , l ; TXubzuzolF = sc . nextInt ( ) ; m = sc . nextInt ( ) ; l = sc . nextInt ( ) ; long [ ] [ ] A = new long [ TXubzuzolF ] [ m ] ; long [ ] [ ] B = new long [ m ] [ l ] ; for ( int i = 0 ; i < TXubzuzolF ; 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 < TXubzuzolF ; 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 KemRySJDYW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KemRySJDYW = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int res10000 = - 1 , res5000 = - 1 , res1000 = - 1 ; sc . close ( ) ; for ( int a = 0 ; a <= KemRySJDYW ; a ++ ) { for ( int b = 0 ; b + a <= KemRySJDYW ; b ++ ) { int c = KemRySJDYW - 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 TGkpsnzGxz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = sc . nextLine ( ) . split ( " " ) ; int TGkpsnzGxz = Integer . parseInt ( s [ 0 ] ) ; int b = Integer . parseInt ( s [ 1 ] ) ; int d = TGkpsnzGxz / b ; int r = TGkpsnzGxz % b ; double af = ( double ) TGkpsnzGxz ; 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 hJrErgClip { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hJrErgClip = sc . nextInt ( ) ; int [ ] A = new int [ hJrErgClip + 1 ] ; int [ ] B = new int [ hJrErgClip ] ; for ( int i = 0 ; i < hJrErgClip + 1 ; i ++ ) A [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < hJrErgClip ; i ++ ) B [ i ] = sc . nextInt ( ) ; long res = 0 ; for ( int i = 0 ; i < hJrErgClip ; 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 ZnJLHmwfcJ { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String ZnJLHmwfcJ = sc . next ( ) ; String t = sc . next ( ) ; if ( ZnJLHmwfcJ . equals ( t . substring ( 0 , ZnJLHmwfcJ . length ( ) ) ) && ( t . length ( ) - ZnJLHmwfcJ . length ( ) == 1 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class riosnRHwbc { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int riosnRHwbc = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; int [ ] [ ] a = new int [ riosnRHwbc ] [ m ] ; int [ ] b = new int [ m ] ; for ( int y = 0 ; y < riosnRHwbc ; 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 < riosnRHwbc ; 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 AakzMfYGra { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AakzMfYGra = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; true ; i ++ ) { AakzMfYGra -= m ; ans ++ ; if ( AakzMfYGra <= 0 ) { break ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; public class pspHogIpaf { public static void main ( String [ ] hi ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; int pspHogIpaf = Integer . parseInt ( st . nextToken ( ) ) ; int X = Integer . parseInt ( st . nextToken ( ) ) ; int T = Integer . parseInt ( st . nextToken ( ) ) ; int time = pspHogIpaf / X ; time *= T ; if ( pspHogIpaf % X > 0 ) time += T ; System . out . println ( time ) ; } } import java . util . * ; import java . math . BigDecimal ; import java . math . RoundingMode ; public class LmYqdarAqV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LmYqdarAqV = 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 == LmYqdarAqV && t1 == B ) { ans = i ; break ; } } System . out . print ( ans ) ; } } import java . util . * ; public class HRLAnkcfrM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String result = " " ; for ( int HRLAnkcfrM = 0 ; HRLAnkcfrM < s . length ( ) ; HRLAnkcfrM ++ ) { switch ( s . charAt ( HRLAnkcfrM ) ) { 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 AKIfZMjcfq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int AKIfZMjcfq = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int powD = 1 ; for ( int i = 0 ; i < AKIfZMjcfq ; 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 tudujbwZtw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int tudujbwZtw = Integer . parseInt ( s . substring ( 0 , 2 ) ) ; int b = Integer . parseInt ( s . substring ( 2 ) ) ; String ans = " NA " ; if ( ( tudujbwZtw >= 1 && tudujbwZtw <= 12 ) && ( b >= 1 && b <= 12 ) ) { ans = " AMBIGUOUS " ; } else if ( tudujbwZtw >= 1 && tudujbwZtw <= 12 ) { ans = " MMYY " ; } else if ( b >= 1 && b <= 12 ) { ans = " YYMM " ; } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; class kYqlNqdnKe { static int kYqlNqdnKe , 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 ( ) , " " ) ; kYqlNqdnKe = Integer . parseInt ( tok . nextToken ( ) ) ; k = Integer . parseInt ( tok . nextToken ( ) ) ; arr = new int [ kYqlNqdnKe ] ; tok = new StringTokenizer ( br . readLine ( ) , " " ) ; for ( int i = 0 ; i < kYqlNqdnKe ; i ++ ) { arr [ i ] = Integer . parseInt ( tok . nextToken ( ) ) ; } dp = new long [ kYqlNqdnKe ] ; 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 < kYqlNqdnKe ; 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 vzDObgszGC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vzDObgszGC = sc . nextInt ( ) ; int [ ] H = new int [ vzDObgszGC ] ; for ( int i = 0 ; i < vzDObgszGC ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < vzDObgszGC ; 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 AwvWOytRwo { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int AwvWOytRwo = gi ( ) ; int [ ] A = new int [ AwvWOytRwo ] ; for ( int i = 0 ; i < AwvWOytRwo ; i ++ ) { A [ i ] = gi ( ) ; } Arrays . parallelSort ( A ) ; System . out . println ( A [ A . length - 1 ] - A [ 0 ] ) ; } public static int s ( int AwvWOytRwo ) { String S = String . valueOf ( AwvWOytRwo ) ; 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 AwvWOytRwo ) { String a = String . valueOf ( AwvWOytRwo ) ; 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 feOblYcqAq { public static void main ( String [ ] args ) { int feOblYcqAq ; int i , j ; int v ; Scanner scan = new Scanner ( System . in ) ; String str = new String ( ) ; feOblYcqAq = scan . nextInt ( ) ; int [ ] A = new int [ feOblYcqAq ] ; for ( i = 0 ; i < feOblYcqAq ; i ++ ) A [ i ] = scan . nextInt ( ) ; for ( i = 0 ; i < feOblYcqAq ; 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 ZIAJZDXVJt { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int ZIAJZDXVJt = 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 ] [ ZIAJZDXVJt ] ; 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 < ZIAJZDXVJt ; 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 eLRxjVrwLi { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; long eLRxjVrwLi = sc . nextLong ( ) ; int m = sc . nextInt ( ) ; long sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) sum += sc . nextLong ( ) ; System . out . println ( ( sum <= eLRxjVrwLi ) ? eLRxjVrwLi - sum : " -1 " ) ; } static class eLRxjVrwLi { 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 exhVNNAUBK { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int exhVNNAUBK = scanner . nextInt ( ) ; int result = 0 ; int max = 0 ; for ( int i = 0 ; i < exhVNNAUBK ; i ++ ) { int a = scanner . nextInt ( ) ; if ( a >= max ) { max = a ; result ++ ; } } System . out . println ( result ) ; } } import java . util . Scanner ; public class VCoQUinfLH { 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 VCoQUinfLH = 0 ; VCoQUinfLH < 3 ; VCoQUinfLH ++ ) { if ( a [ VCoQUinfLH ] . equals ( " 1 " ) ) { a [ VCoQUinfLH ] = " 9 " ; } else if ( a [ VCoQUinfLH ] . equals ( " 9 " ) ) { a [ VCoQUinfLH ] = " 1 " ; } } System . out . println ( a [ 0 ] + a [ 1 ] + a [ 2 ] ) ; } } import java . util . Scanner ; public class ISFkLIObVq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ISFkLIObVq = sc . nextInt ( ) ; int [ ] nums = new int [ ISFkLIObVq ] ; for ( int i = 0 ; i < ISFkLIObVq ; i ++ ) { nums [ i ] = sc . nextInt ( ) ; } boolean result = true ; for ( int i = 0 ; i < ISFkLIObVq ; 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 BsTrBqhJDO { 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 BsTrBqhJDO ; BsTrBqhJDO = a ; a = b ; b = BsTrBqhJDO % 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 nMpArnfCkQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nMpArnfCkQ = sc . nextInt ( ) ; int [ ] [ ] a = new int [ 2 ] [ nMpArnfCkQ ] ; for ( int i = 0 ; i < nMpArnfCkQ ; i ++ ) { a [ 0 ] [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < nMpArnfCkQ ; i ++ ) { a [ 1 ] [ i ] = sc . nextInt ( ) ; } int max = 0 ; int first = 0 ; for ( int i = 0 ; i < nMpArnfCkQ ; i ++ ) { first += a [ 0 ] [ i ] ; int second = 0 ; for ( int j = i ; j < nMpArnfCkQ ; j ++ ) { second += a [ 1 ] [ j ] ; } max = Math . max ( max , first + second ) ; } System . out . println ( max ) ; sc . close ( ) ; } } import java . util . Scanner ; public class ZeKWbxXyym { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ZeKWbxXyym = sc . nextLong ( ) ; long A = 1 ; for ( long i = 1 ; i * i <= ZeKWbxXyym ; i ++ ) { if ( ZeKWbxXyym % i == 0 && i > A ) { A = i ; } } long B = ZeKWbxXyym / A ; System . out . println ( A + B - 2 ) ; sc . close ( ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class iDoabqnzwq { 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 TePJdxcgyP { public static void main ( String [ ] args ) { try ( Scanner cs = new Scanner ( System . in ) ) { String line = cs . nextLine ( ) ; String answer = " " ; int TePJdxcgyP = line . TePJdxcgyP ( ) ; for ( int i = 0 ; i < TePJdxcgyP ; 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 KEqCLZoHkz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int KEqCLZoHkz = scan . nextInt ( ) ; int [ ] a = new int [ KEqCLZoHkz ] ; for ( int i = 0 ; i < KEqCLZoHkz ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } long sum = 0 ; while ( true ) { boolean flag = true ; for ( int i = 0 ; i < KEqCLZoHkz ; 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 JNNlZpNvRs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String JNNlZpNvRs = scan . next ( ) ; String b = scan . next ( ) ; if ( JNNlZpNvRs . equals ( b . substring ( 0 , b . length ( ) - 1 ) ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; } } import java . util . * ; class PulagfZedd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long PulagfZedd = sc . nextLong ( ) ; long r = sc . nextLong ( ) ; long min = PulagfZedd * ( PulagfZedd + 1 ) % 2019 ; if ( ( r - PulagfZedd ) >= 2018 ) { System . out . println ( 0 ) ; } else if ( ( r - PulagfZedd ) < ( 2019 - PulagfZedd % 2019 ) ) { for ( long e = PulagfZedd ; 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 EXoLqxAVfH { public static void main ( String [ ] a ) { Scanner scan = new Scanner ( System . in ) ; int EXoLqxAVfH = scan . nextInt ( ) ; Map < Integer , Integer > numMap = new HashMap < > ( ) ; for ( int i = 1 ; i < EXoLqxAVfH + 1 ; i ++ ) { int s = scan . nextInt ( ) ; int dis = EXoLqxAVfH - s ; numMap . put ( EXoLqxAVfH - dis , i ) ; } for ( int j = 1 ; j < numMap . size ( ) + 1 ; j ++ ) { System . out . printf ( " %d " , numMap . get ( j ) ) ; } } } import java . util . * ; public class SyTpcOpxyE { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final String SyTpcOpxyE = sc . next ( ) ; final String t = sc . next ( ) ; sc . close ( ) ; String result = " No " ; if ( t . length ( ) == SyTpcOpxyE . length ( ) + 1 && t . substring ( 0 , SyTpcOpxyE . length ( ) ) . equals ( SyTpcOpxyE ) ) { result = " Yes " ; } System . out . println ( result ) ; } } import java . util . * ; public class jFVvvtCByP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jFVvvtCByP = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int base = 1 ; for ( int i = 0 ; i < jFVvvtCByP ; i ++ ) { base *= 100 ; } if ( N % 100 == 0 ) { System . out . println ( base * ( N + 1 ) ) ; } else { System . out . println ( base * N ) ; } } } import java . util . * ; public class fvCtsaOtbV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fvCtsaOtbV = sc . nextInt ( ) ; Set < Integer > visited = new HashSet < > ( ) ; int cnt = 0 ; while ( fvCtsaOtbV > 0 ) { fvCtsaOtbV -- ; int num = sc . nextInt ( ) ; if ( visited . contains ( num ) ) continue ; visited . add ( num ) ; cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . * ; public class qrZRmolVOs { 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 qrZRmolVOs = sArray . length - tArray . length + 1 ; String part = new String ( ) ; int count = 9999 ; for ( int i = 0 ; i < qrZRmolVOs ; 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 lWWrPVBqzw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lWWrPVBqzw = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] arr = new int [ lWWrPVBqzw ] ; int totalVotes = 0 ; for ( int i = 0 ; i < lWWrPVBqzw ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; totalVotes += arr [ i ] ; } double popular = totalVotes / ( 4 * m ) ; int ans = 0 ; for ( int i = 0 ; i < lWWrPVBqzw ; 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 HJhmyGTyFF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HJhmyGTyFF = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < HJhmyGTyFF ; ++ 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 CMQtmwScxx { static String a ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int CMQtmwScxx = stdIn . nextInt ( ) ; int count = 0 ; IN : for ( int i = 0 ; i < CMQtmwScxx ; 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 mBXdOxOoJP { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int mBXdOxOoJP = sc . nextInt ( ) ; int sum = 0 ; int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < mBXdOxOoJP ; 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 QGvEhEOZXq { void solve ( ) { char [ ] a = incharar ( ) ; int QGvEhEOZXq = 0 ; for ( int i = 0 ; i < a . length / 2 ; i ++ ) { if ( a [ i ] != a [ a . length - i - 1 ] ) QGvEhEOZXq ++ ; } out . println ( QGvEhEOZXq ) ; } 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 efPBUUXJaa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int efPBUUXJaa = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ efPBUUXJaa ] ; for ( int i = 0 ; i < efPBUUXJaa ; i ++ ) { a [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int count = 0 ; uncode : while ( true ) { for ( int i = 0 ; i < efPBUUXJaa ; 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 erLDKoOLcv { public static void main ( String [ ] args ) throws IOException { PrintWriter out = new PrintWriter ( System . out ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int erLDKoOLcv = Integer . parseInt ( br . readLine ( ) ) ; int answer = ( int ) ( Math . ceil ( erLDKoOLcv / 1000.0 ) ) ; out . println ( answer * 1000 - erLDKoOLcv ) ; out . flush ( ) ; out . close ( ) ; } static class erLDKoOLcv { 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 SPuLMJDXTf { 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 SPuLMJDXTf = s . equals ( Arrays . asList ( 2L , 2L ) ) ? " Yes " : " No " ; System . out . println ( SPuLMJDXTf ) ; } } 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 pXrhhxuTty { 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 pXrhhxuTty = 0 ; pXrhhxuTty < firstRow . size ( ) ; pXrhhxuTty ++ ) { ballsCountAndColor . put ( firstRow . get ( pXrhhxuTty ) , ballsCount . get ( pXrhhxuTty ) ) ; } 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 NTaYAqAfxz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NTaYAqAfxz = sc . nextInt ( ) ; int a ; ArrayList < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; i < NTaYAqAfxz ; 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 iByOEhSGAq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iByOEhSGAq = sc . nextInt ( ) ; int [ ] youso1 = new int [ iByOEhSGAq ] ; for ( int i = 0 ; i < iByOEhSGAq ; i ++ ) { youso1 [ i ] = sc . nextInt ( ) ; } int [ ] youso2 = youso1 . clone ( ) ; Arrays . sort ( youso2 ) ; for ( int i = 0 ; i < iByOEhSGAq ; i ++ ) { if ( youso1 [ i ] < youso2 [ iByOEhSGAq - 1 ] ) { System . out . println ( youso2 [ iByOEhSGAq - 1 ] ) ; } else { System . out . println ( youso2 [ iByOEhSGAq - 2 ] ) ; } } } } import java . util . ArrayList ; import java . util . Iterator ; import java . util . Scanner ; public class kNWXWgDcQA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long kNWXWgDcQA = sc . nextLong ( ) ; long result = 0 ; long num = sc . nextLong ( ) ; for ( int i = 1 ; i < kNWXWgDcQA ; 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 xMLXlgmLLf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xMLXlgmLLf = scan . nextInt ( ) ; boolean f = false ; for ( int i = 0 ; i < xMLXlgmLLf ; i ++ ) { for ( int j = 0 ; j < xMLXlgmLLf ; j ++ ) { if ( ( 4 * i ) + ( 7 * j ) == xMLXlgmLLf ) { f = true ; System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } } import java . io . * ; import java . util . * ; public class nFUlqHRmjc { static PrintWriter out = new PrintWriter ( ( System . out ) ) ; public static void main ( String [ ] args ) throws IOException { Kioken sc = new Kioken ( ) ; char nFUlqHRmjc = sc . next ( ) . charAt ( 0 ) ; if ( Character . isUpperCase ( nFUlqHRmjc ) ) { out . println ( " A " ) ; } else { out . println ( " a " ) ; } out . close ( ) ; } public static void kamehameha ( ) { } static class nFUlqHRmjc { 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 ykByKGmAzS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ykByKGmAzS = sc . nextInt ( ) ; int [ ] color = new int [ 9 ] ; int ans = 0 ; for ( int i = 0 ; i < ykByKGmAzS ; 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 MqSqeVzjDi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] a = sc . nextLine ( ) . split ( " " ) ; int MqSqeVzjDi = a . length ; String answer = " " ; for ( int i = 0 ; i < MqSqeVzjDi ; 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 JdYaSwpRBz { long JdYaSwpRBz = 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 yQmTBiGJsA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; for ( int yQmTBiGJsA = 1 ; ; yQmTBiGJsA ++ ) { int x = sc . nextInt ( ) ; if ( x == 0 ) { break ; } System . out . printf ( " Case %d: %d \n " , yQmTBiGJsA , x ) ; } } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class PvhJTShYRI { 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 PvhJTShYRI { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int PvhJTShYRI = Integer . parseInt ( in . next ( ) ) ; int preT = 0 ; int preX = 0 ; int preY = 0 ; for ( int i = 0 ; i < PvhJTShYRI ; 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 mMymSLecfw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; StringBuilder output = new StringBuilder ( ) ; for ( int mMymSLecfw = 0 ; mMymSLecfw < input . length ( ) ; ++ mMymSLecfw ) { if ( input . charAt ( mMymSLecfw ) != 'B' ) { output . append ( input . charAt ( mMymSLecfw ) ) ; } else { int len = output . length ( ) ; if ( len > 0 ) { output . deleteCharAt ( len - 1 ) ; } } } sc . close ( ) ; System . out . println ( output ) ; } } import java . util . Scanner ; public class jPZARltoky { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int jPZARltoky = in . nextInt ( ) ; int lim = in . nextInt ( ) ; int pos = 0 ; int ans = 0 ; for ( int i = 0 ; i < jPZARltoky ; i ++ ) { pos += in . nextInt ( ) ; if ( lim < pos ) { ans = i + 1 ; break ; } else if ( lim == pos ) { ans = i + 2 ; break ; } else if ( i == jPZARltoky - 1 ) { ans = jPZARltoky + 1 ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class EvLhITPxMj { public static void main ( String [ ] args ) { int EvLhITPxMj = 0 ; Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; sc . close ( ) ; for ( int i = 0 ; i < x ; i ++ ) { EvLhITPxMj += 2 ; if ( ( i + 1 ) == x ) { if ( EvLhITPxMj == y ) { System . out . println ( " Yes " ) ; } else { for ( int j = i ; j >= 0 ; j -- ) { EvLhITPxMj -= 2 ; EvLhITPxMj += 4 ; if ( EvLhITPxMj == y ) { System . out . println ( " Yes " ) ; break ; } if ( j == 0 ) { System . out . println ( " No " ) ; } } } } } } } import java . util . * ; public class CVTQvfuOom { void solve ( ) { Scanner scan = new Scanner ( System . in ) ; int CVTQvfuOom = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int [ ] h = new int [ CVTQvfuOom ] ; for ( int i = 0 ; i < CVTQvfuOom ; i ++ ) h [ i ] = scan . nextInt ( ) ; int [ ] dp = new int [ CVTQvfuOom ] ; for ( int i = 0 ; i < CVTQvfuOom ; i ++ ) dp [ i ] = Integer . MAX_VALUE ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 0 ; i < CVTQvfuOom ; 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 [ CVTQvfuOom - 1 ] ) ; scan . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class RFXpAVBshx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RFXpAVBshx = sc . nextInt ( ) ; int [ ] a1 = new int [ RFXpAVBshx + 2 ] ; int [ ] a2 = new int [ RFXpAVBshx + 1 ] ; a1 [ 0 ] = 0 ; a2 [ 0 ] = 0 ; int sum = 0 ; int subsum = 0 ; int sum1 = 0 ; int sum2 = 0 ; for ( int i = 1 ; i <= RFXpAVBshx ; i ++ ) { a1 [ i ] = sc . nextInt ( ) ; } sum1 = a1 [ 1 ] ; a1 [ RFXpAVBshx + 1 ] = 0 ; for ( int i = 1 ; i <= RFXpAVBshx ; i ++ ) { a2 [ i ] = sc . nextInt ( ) ; sum2 += a2 [ i ] ; } for ( int i = 1 ; i <= RFXpAVBshx ; 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 avFprZgRDM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int avFprZgRDM = 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 ) * avFprZgRDM + Math . max ( 0 , Y - i ) * B ; min = Math . min ( min , amount ) ; } System . out . println ( min ) ; } } import java . util . Scanner ; public class lVSbNEVFJH { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int lVSbNEVFJH = scanner . nextInt ( ) ; System . out . println ( 2 * lVSbNEVFJH * Math . PI ) ; } } import java . util . Scanner ; public class ZaoUpGmNzW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ZaoUpGmNzW = sc . nextLong ( ) ; System . out . println ( hit ( ZaoUpGmNzW ) ) ; } private static long hit ( long ZaoUpGmNzW ) { return ZaoUpGmNzW == 1 ? 1 : hit ( ZaoUpGmNzW / 2 ) * 2 + 1 ; } } import java . util . Scanner ; class YHYHDAuZHR { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str1 = scan . next ( ) ; String str2 = scan . next ( ) ; int YHYHDAuZHR = Integer . parseInt ( str1 ) ; int b = Integer . parseInt ( str2 ) ; System . out . println ( YHYHDAuZHR * b + " " + ( YHYHDAuZHR * 2 + b * 2 ) ) ; } } import java . util . * ; public class HiepbcAKTw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HiepbcAKTw = 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 ( HiepbcAKTw - count ) ) ) ) { System . out . println ( HiepbcAKTw - count ) ; break ; } if ( ! ( Arrays . asList ( nums ) . contains ( String . valueOf ( HiepbcAKTw + count ) ) ) ) { System . out . println ( HiepbcAKTw + count ) ; break ; } } } } import java . util . Scanner ; public class wMYNfuNtMT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wMYNfuNtMT = sc . nextInt ( ) ; int c = 0 ; while ( wMYNfuNtMT > c ) { c = c + 1000 ; } c = c - wMYNfuNtMT ; System . out . println ( c ) ; } } import java . util . Scanner ; public class hmUUCShNyH { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int hmUUCShNyH = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( k <= hmUUCShNyH ) { System . out . println ( k ) ; return ; } if ( k <= hmUUCShNyH + b ) { System . out . println ( hmUUCShNyH ) ; return ; } System . out . println ( hmUUCShNyH - ( k - hmUUCShNyH - b ) ) ; } } import java . util . Scanner ; public class qkAcutXjAv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] lines = line . split ( " " ) ; int qkAcutXjAv = Integer . parseInt ( lines [ 0 ] ) ; int B = Integer . parseInt ( lines [ 1 ] ) ; System . out . println ( qkAcutXjAv * B ) ; } } import java . util . Arrays ; import java . util . Scanner ; class ONfRGhzwfh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ONfRGhzwfh = sc . nextInt ( ) ; int [ ] a = new int [ ONfRGhzwfh ] ; for ( int i = 0 ; i < ONfRGhzwfh ; i ++ ) a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; int ans = a [ ONfRGhzwfh / 2 ] - a [ ONfRGhzwfh / 2 - 1 ] ; System . out . println ( ans ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class rAMtYifLJL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rAMtYifLJL = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; if ( rAMtYifLJL <= m ) { System . out . println ( " unsafe " ) ; } else { System . out . println ( " safe " ) ; } } } import java . util . Scanner ; public class VTmzDSUhRD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] list = sc . next ( ) . toCharArray ( ) ; boolean VTmzDSUhRD = 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 ( ! VTmzDSUhRD ) { VTmzDSUhRD = true ; tmp = 0 ; } tmp ++ ; } else { if ( VTmzDSUhRD ) { VTmzDSUhRD = false ; max = Math . max ( max , tmp ) ; } } } System . out . println ( Math . max ( max , tmp ) ) ; } } import java . util . * ; import java . io . * ; class MpcpIorqhe { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String [ ] input = br . readLine ( ) . split ( " " ) ; int MpcpIorqhe = Integer . parseInt ( input [ 0 ] ) ; int M = Integer . parseInt ( input [ 1 ] ) ; int result = 0 ; if ( MpcpIorqhe > 1 ) { result += ( MpcpIorqhe * ( MpcpIorqhe - 1 ) ) / 2 ; } if ( M > 1 ) { result += ( M * ( M - 1 ) ) / 2 ; } System . out . println ( result ) ; } } } import java . util . Scanner ; public class JunpkgMRpH { public static void main ( String [ ] args ) { Scanner nine = new Scanner ( System . in ) ; int JunpkgMRpH = nine . nextInt ( ) ; int number2 = nine . nextInt ( ) ; if ( 1 <= JunpkgMRpH && JunpkgMRpH <= 9 && 1 <= number2 && number2 <= 9 ) { int answer = JunpkgMRpH * number2 ; System . out . println ( answer ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . * ; public class isXUtCuJrR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long isXUtCuJrR = sc . nextLong ( ) ; long num = 2 ; while ( num <= isXUtCuJrR ) num *= 2 ; System . out . println ( num - 1 ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class euSrIwPRQM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int euSrIwPRQM = sc . nextInt ( ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < euSrIwPRQM ; 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 < euSrIwPRQM - 1 ; i ++ ) { if ( a . get ( i + 1 ) == flg + 1 ) { flg ++ ; } else { cnt ++ ; } } } System . out . println ( cnt ) ; } } import java . util . * ; public class JahAYeIHMg { public static void main ( String [ ] args ) throws java . io . IOException { int JahAYeIHMg , h , m , s ; Scanner in = new Scanner ( System . in ) ; JahAYeIHMg = in . nextInt ( ) ; h = JahAYeIHMg / 3600 ; JahAYeIHMg = JahAYeIHMg % 3600 ; m = JahAYeIHMg / 60 ; s = JahAYeIHMg % 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 kWdXiKvfiL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kWdXiKvfiL = scan . nextInt ( ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; List < Integer > totalList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i <= kWdXiKvfiL ; 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 hjQQWgoAde { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long hjQQWgoAde = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( k <= hjQQWgoAde ) { hjQQWgoAde = hjQQWgoAde - k ; k = 0 ; } else { k = k - hjQQWgoAde ; hjQQWgoAde = 0 ; } if ( k <= b ) { b = b - k ; k = 0 ; } else { k = k - b ; b = 0 ; } System . out . println ( hjQQWgoAde + " " + b ) ; } } import java . util . Scanner ; public class fGevCBSzSW { public static void main ( String [ ] args ) { int fGevCBSzSW , 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 ( fGevCBSzSW = 0 ; fGevCBSzSW < n ; fGevCBSzSW ++ ) { name [ fGevCBSzSW ] = sc . next ( ) ; time [ fGevCBSzSW ] = 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 LDGtLicxzn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LDGtLicxzn = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int [ ] [ ] table = new int [ LDGtLicxzn + 1 ] [ y + 1 ] ; for ( int i = 0 ; i < LDGtLicxzn ; i ++ ) { for ( int j = 0 ; j < y ; j ++ ) { table [ i ] [ j ] = sc . nextInt ( ) ; table [ i ] [ y ] += table [ i ] [ j ] ; table [ LDGtLicxzn ] [ j ] += table [ i ] [ j ] ; table [ LDGtLicxzn ] [ y ] += table [ i ] [ j ] ; } } for ( int i = 0 ; i < LDGtLicxzn + 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 KIdnDSKzSR { public static void main ( String [ ] args ) { int KIdnDSKzSR , b , i , small , sum = 0 ; String s = " " ; Scanner sc = new Scanner ( System . in ) ; KIdnDSKzSR = sc . nextInt ( ) ; b = sc . nextInt ( ) ; if ( KIdnDSKzSR < b ) { small = KIdnDSKzSR ; for ( i = b - 1 ; i >= 0 ; i -- ) { sum = sum + ( int ) Math . pow ( 10 , i ) ; } small = KIdnDSKzSR * sum ; s = " " + small ; } else { small = b ; for ( i = KIdnDSKzSR - 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 QHdKHgWFgO { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; long QHdKHgWFgO = scn . nextInt ( ) ; System . out . println ( ( long ) ( QHdKHgWFgO + Math . pow ( QHdKHgWFgO , 2 ) + Math . pow ( QHdKHgWFgO , 3 ) ) ) ; } } import java . util . Scanner ; public class iHIgAHPkhm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iHIgAHPkhm = sc . nextInt ( ) ; int [ ] A = new int [ iHIgAHPkhm ] ; for ( int i = 0 ; i < iHIgAHPkhm ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < iHIgAHPkhm ; i ++ ) { int minj = i ; for ( int j = i ; j < iHIgAHPkhm ; 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 < iHIgAHPkhm - 1 ; i ++ ) { System . out . print ( A [ i ] + " " ) ; } System . out . println ( A [ iHIgAHPkhm - 1 ] ) ; System . out . print ( count ) ; System . out . printf ( " \n " ) ; } } import java . io . * ; import java . util . StringTokenizer ; public class KeWiMtYLWd { 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 KeWiMtYLWd = read . readLine ( ) ; if ( KeWiMtYLWd . charAt ( 0 ) == '7' ) { prnt . println ( " Yes " ) ; } else if ( KeWiMtYLWd . charAt ( 1 ) == '7' ) { prnt . println ( " Yes " ) ; } else if ( KeWiMtYLWd . charAt ( 2 ) == '7' ) { prnt . println ( " Yes " ) ; } else { prnt . println ( " No " ) ; } prnt . close ( ) ; } } import java . util . * ; public class ZhbBeoxVnB { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long ZhbBeoxVnB = sc . nextLong ( ) ; long ans = 100 ; long sum = 0 ; while ( ans < ZhbBeoxVnB ) { ans = ans + ( long ) ( ans / 100 ) ; sum ++ ; } System . out . println ( sum ) ; } } import java . util . * ; public class ZyUqZTOuiD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZyUqZTOuiD = sc . nextInt ( ) ; sc . close ( ) ; int sum = 0 ; int count = 0 ; while ( sum <= ZyUqZTOuiD ) { count ++ ; sum = ( int ) Math . pow ( 2 , count ) ; } System . out . println ( ( int ) Math . pow ( 2 , count - 1 ) ) ; } } import java . util . * ; class MWEgHLYUop { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MWEgHLYUop = sc . nextInt ( ) ; int count = 1 ; int Answer = 0 ; for ( int i = 0 ; i < MWEgHLYUop ; i ++ ) { if ( sc . nextInt ( ) == count ) { count ++ ; } else { Answer ++ ; } } if ( Answer == MWEgHLYUop ) { Answer = - 1 ; } System . out . println ( Answer ) ; } } import java . util . Scanner ; class buemjIVkIN { public static void main ( String [ ] ag ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; int buemjIVkIN = 0 ; int gl = a . length ( ) - 1 ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( a . charAt ( i ) == 'A' ) { buemjIVkIN = 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 - buemjIVkIN + 1 ) ; } } import java . util . Scanner ; public class ZIEeEWiZIl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String inputId = sc . nextLine ( ) ; String inputAddId = sc . nextLine ( ) ; int ZIEeEWiZIl = 0 ; for ( int i = 0 ; i < inputId . length ( ) ; i ++ ) { if ( inputId . charAt ( i ) != inputAddId . charAt ( i ) ) { ZIEeEWiZIl ++ ; } } if ( ZIEeEWiZIl == 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 tsdORPQNSY { public static void main ( String [ ] args ) { final Scanner cin = new Scanner ( System . in ) ; int tsdORPQNSY = cin . nextInt ( ) ; long [ ] arr = new long [ tsdORPQNSY ] ; for ( int i = 0 ; i < tsdORPQNSY ; 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 uKkeNYjYtt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uKkeNYjYtt = sc . nextInt ( ) ; int [ ] arr = new int [ uKkeNYjYtt ] ; for ( int i = 0 ; i < uKkeNYjYtt ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int [ ] dp = new int [ uKkeNYjYtt ] ; if ( uKkeNYjYtt == 1 ) System . out . println ( arr [ 0 ] ) ; for ( int i = 1 ; i < uKkeNYjYtt ; 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 [ uKkeNYjYtt - 1 ] ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class DtxGmiDCkz { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int DtxGmiDCkz = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int ans = 1 ; int D = 0 ; for ( int i = 0 ; i < DtxGmiDCkz ; i ++ ) { D += sc . nextInt ( ) ; if ( D <= X ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class GWTtvbyZff { public static void main ( String [ ] args ) throws Exception { String [ ] lines = getStdin ( ) ; String str1 = lines [ 0 ] ; int GWTtvbyZff = 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 = GWTtvbyZff * i ; if ( multiple >= from && multiple <= till ) { System . out . println ( " OK " ) ; return ; } else { multiple = GWTtvbyZff ; } } 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 USlJBxvFBb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int USlJBxvFBb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int result = 0 ; for ( int i = USlJBxvFBb ; 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 gCwgKPTTxn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gCwgKPTTxn = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double ans = 0 ; int times = 0 ; for ( int i = gCwgKPTTxn ; i > 0 ; -- i ) { while ( i * Math . pow ( 2 , times ) < k ) ++ times ; ans = ans + ( 1 / ( double ) gCwgKPTTxn ) * Math . pow ( 0.5 , times ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class eVRAHBUabP { public static void main ( String [ ] arg ) { Scanner scan = new Scanner ( System . in ) ; int eVRAHBUabP = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int K = 0 ; int check = 0 ; if ( ( eVRAHBUabP + B ) % 2 == 0 ) { K = ( Math . abs ( eVRAHBUabP ) + Math . abs ( B ) ) / 2 ; check ++ ; } if ( check == 0 ) { System . out . println ( " IMPOSSIBLE " ) ; } else { System . out . println ( K ) ; } } } import java . io . * ; public class SPysUuvxwN { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; int SPysUuvxwN = Integer . parseInt ( line ) ; int sec = 0 , min = 0 , hour = 0 ; if ( SPysUuvxwN >= 3600 ) { hour = SPysUuvxwN / 3600 ; SPysUuvxwN = SPysUuvxwN % 3600 ; min = SPysUuvxwN / 60 ; sec = SPysUuvxwN % 60 ; System . out . println ( hour + " : " + min + " : " + sec ) ; } else if ( SPysUuvxwN >= 60 ) { min = SPysUuvxwN / 60 ; sec = SPysUuvxwN % 60 ; System . out . println ( hour + " : " + min + " : " + sec ) ; } else { System . out . println ( hour + " : " + min + " : " + sec ) ; } } } import java . util . Scanner ; public class KxdiMXlACt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KxdiMXlACt = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; for ( int turtle = 0 ; turtle <= KxdiMXlACt ; ++ turtle ) { int crane = KxdiMXlACt - 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 HmfTFbKPyT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HmfTFbKPyT = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; String [ ] s = new String [ HmfTFbKPyT ] ; for ( int i = 0 ; i < HmfTFbKPyT ; i ++ ) { s [ i ] = sc . next ( ) ; set . add ( s [ i ] ) ; map . put ( s [ i ] , 0 ) ; } for ( int i = 0 ; i < HmfTFbKPyT ; 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 MMZljujbNe { int MMZljujbNe , 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 ) ; MMZljujbNe = sc . nextInt ( ) ; B = sc . nextInt ( ) ; S = sc . next ( ) ; cS = S . toCharArray ( ) ; len = cS . length ; } public void solve ( ) { if ( len == MMZljujbNe + B + 1 ) { if ( cS [ MMZljujbNe ] == '-' ) { for ( int i = 0 ; i < MMZljujbNe ; i ++ ) { if ( cS [ i ] >= '0' && cS [ i ] <= '9' ) { flg = true ; } else { flg = false ; break ; } } if ( flg == true ) { for ( int i = MMZljujbNe + 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 smGqkKPBlv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int smGqkKPBlv = 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 <= smGqkKPBlv ) { if ( smGqkKPBlv - a >= smGqkKPBlv - b ) { a = ( int ) b ; } } else { break ; } } } if ( smGqkKPBlv < 4 ) { System . out . println ( smGqkKPBlv ) ; } else { System . out . println ( a ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class VoXzZDabJu { 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 VoXzZDabJu = 0 ; VoXzZDabJu < string . length ( ) ; VoXzZDabJu ++ ) { lig [ VoXzZDabJu ] = string . substring ( VoXzZDabJu , VoXzZDabJu + 1 ) ; } int sum = 0 ; int [ ] v = new int [ lig . length ] ; for ( int VoXzZDabJu = 0 ; VoXzZDabJu < lig . length ; VoXzZDabJu ++ ) { v [ VoXzZDabJu ] = Integer . parseInt ( lig [ VoXzZDabJu ] ) ; sum += v [ VoXzZDabJu ] ; } 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 OtXdbNQlBL { 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 OtXdbNQlBL = Integer . parseInt ( st . nextToken ( ) ) ; int K = Integer . parseInt ( st . nextToken ( ) ) ; int [ ] prices = new int [ OtXdbNQlBL ] ; 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 kleQDLnJtw { public static void main ( String [ ] args ) { Set < Integer > set = new HashSet ( ) ; int kleQDLnJtw = getInput ( ) ; do { set . add ( kleQDLnJtw ) ; kleQDLnJtw = f ( kleQDLnJtw ) ; } while ( ! set . contains ( kleQDLnJtw ) ) ; 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 rIhPPEQvRM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rIhPPEQvRM = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int point = 0 ; int res = 1 ; for ( int i = 0 ; i < rIhPPEQvRM ; i ++ ) { point += Integer . parseInt ( sc . next ( ) ) ; if ( x < point ) break ; res ++ ; } System . out . println ( res ) ; } } import java . io . * ; public class YISttxafZl { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int YISttxafZl = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 1 ] ) ; int d = YISttxafZl / b ; int e = YISttxafZl % b ; double f = ( double ) YISttxafZl / b ; System . out . printf ( " %d %d %.5f \n " , d , e , f ) ; } } import java . util . Scanner ; import java . lang . * ; public class vQFIPHrBwk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String input = scanner . nextLine ( ) ; String [ ] inputs = input . split ( " " ) ; int vQFIPHrBwk = Integer . parseInt ( inputs [ 0 ] ) ; int Q = Integer . parseInt ( inputs [ 1 ] ) ; int R = Integer . parseInt ( inputs [ 2 ] ) ; int min1 = Math . min ( vQFIPHrBwk , Q ) ; int max1 = Math . max ( vQFIPHrBwk , 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 RgJURaSPRz { 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 RgJURaSPRz = str . RgJURaSPRz ( ) ; String firstHalf = str . substring ( 0 , ( RgJURaSPRz - 1 ) / 2 ) ; if ( ! isPalindrone ( firstHalf ) ) { return Result . No ; } String lastHalf = str . substring ( ( RgJURaSPRz + 1 ) / 2 ) ; if ( ! isPalindrone ( lastHalf ) ) { return Result . No ; } return Result . Yes ; } private static boolean isPalindrone ( String str ) { int RgJURaSPRz = str . RgJURaSPRz ( ) ; if ( RgJURaSPRz == 1 ) { return true ; } for ( int i = 0 ; i < ( RgJURaSPRz + 1 ) / 2 ; i ++ ) { if ( str . charAt ( i ) != str . charAt ( RgJURaSPRz - i - 1 ) ) { return false ; } } return true ; } public static enum Result { Yes , No } } import java . util . Scanner ; public class IvdjboJDgK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IvdjboJDgK = sc . nextInt ( ) ; int [ ] A = new int [ IvdjboJDgK + 1 ] ; int [ ] B = new int [ IvdjboJDgK ] ; long jizenSum = 0 ; for ( int i = 0 ; i < IvdjboJDgK + 1 ; i ++ ) { A [ i ] = sc . nextInt ( ) ; jizenSum += A [ i ] ; } for ( int i = 0 ; i < IvdjboJDgK ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } int tmp = 0 ; for ( int i = 0 ; i < IvdjboJDgK ; 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 < IvdjboJDgK + 1 ; i ++ ) { sum += A [ i ] ; } System . out . println ( jizenSum - sum ) ; } } import java . util . Scanner ; public class QpwnCLynjs { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int QpwnCLynjs = scanner . nextInt ( ) ; int hissatsuwazashurui = scanner . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < hissatsuwazashurui ; i ++ ) { sum += scanner . nextInt ( ) ; } if ( QpwnCLynjs > sum ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; class rcvjHaGObN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String strs = sc . next ( ) ; String strp = sc . next ( ) ; int rcvjHaGObN = strs . length ( ) ; int psum = strp . length ( ) ; for ( int p = 0 ; p < rcvjHaGObN ; p ++ ) { String str1 = " " ; String str2 = " " ; String str3 = " " ; for ( int q = p ; q < rcvjHaGObN ; 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 == rcvjHaGObN - 1 ) { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class KvYFFcTzen { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String KvYFFcTzen = sc . nextLine ( ) ; KvYFFcTzen = KvYFFcTzen . replace ( " eraser " , " " ) . replace ( " erase " , " " ) . replace ( " dreamer " , " " ) . replace ( " dream " , " " ) ; if ( KvYFFcTzen . equals ( " " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; class CMTOQDRVuG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CMTOQDRVuG = sc . nextInt ( ) ; int [ ] [ ] [ ] bill = new int [ 4 ] [ 3 ] [ 10 ] ; int b ; int f ; int r ; int v = 0 ; for ( int i = 0 ; i < CMTOQDRVuG ; 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 NEVvSruSJT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long NEVvSruSJT = sc . nextLong ( ) ; long ans = Long . MAX_VALUE ; long j = 0 ; for ( long i = 1 ; i * i <= NEVvSruSJT ; i ++ ) { if ( NEVvSruSJT % i != 0 ) { continue ; } j = NEVvSruSJT / 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 RPtXAeocak { 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 RPtXAeocak = ( int ) Math . ceil ( ( Double . parseDouble ( fight [ 0 ] ) / Double . parseDouble ( fight [ 1 ] ) ) ) ; System . out . println ( RPtXAeocak ) ; } } import java . util . Scanner ; public class IVXpMXyGEA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IVXpMXyGEA = sc . nextInt ( ) ; sc . nextLine ( ) ; String str = sc . nextLine ( ) ; if ( str . length ( ) <= IVXpMXyGEA ) { System . out . println ( str ) ; return ; } String str2 = str . substring ( 0 , IVXpMXyGEA ) + " ... " ; System . out . println ( str2 ) ; } } import java . util . * ; import java . util . Arrays ; public class YButuGJmTD { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; int YButuGJmTD = scanner . nextInt ( ) ; int S = scanner . nextInt ( ) ; int sub = 0 ; int count = 0 ; for ( int i = 0 ; i <= YButuGJmTD ; i ++ ) { if ( i != S ) { for ( int j = 0 ; j <= YButuGJmTD ; j ++ ) { if ( i + j != S ) { sub = S - ( i + j ) ; if ( sub >= 0 && sub <= YButuGJmTD ) { count ++ ; } } else if ( i + j == S ) { count ++ ; break ; } } } else if ( i == S ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class bRZMleSDSN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bRZMleSDSN = 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 ] ) ) { bRZMleSDSN ++ ; } } System . out . println ( bRZMleSDSN ) ; } } import java . util . * ; class rqBvdqGJEq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rqBvdqGJEq = sc . nextInt ( ) ; Integer [ ] num = new Integer [ rqBvdqGJEq ] ; int alice = 0 ; int bob = 0 ; for ( int i = 0 ; i < rqBvdqGJEq ; i ++ ) { num [ i ] = sc . nextInt ( ) ; } Arrays . sort ( num ) ; for ( int i = rqBvdqGJEq - 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 GnKbfPgXAR { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int GnKbfPgXAR = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] [ ] h = new int [ GnKbfPgXAR + 1 ] [ c + 1 ] ; StringBuilder sb1 = new StringBuilder ( ) ; StringBuilder sb2 = new StringBuilder ( ) ; String b = " " , n = " \n " ; for ( int i = 0 ; i < GnKbfPgXAR ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { h [ i ] [ j ] = sc . nextInt ( ) ; h [ i ] [ c ] += h [ i ] [ j ] ; h [ GnKbfPgXAR ] [ j ] += h [ i ] [ j ] ; h [ GnKbfPgXAR ] [ c ] += h [ i ] [ j ] ; sb1 . append ( h [ i ] [ j ] + b ) ; if ( i == GnKbfPgXAR - 1 ) sb2 . append ( h [ GnKbfPgXAR ] [ j ] + b ) ; } sb1 . append ( h [ i ] [ c ] + n ) ; } sb2 . append ( h [ GnKbfPgXAR ] [ c ] ) ; System . out . print ( sb1 ) ; System . out . println ( sb2 ) ; } } import static java . lang . Integer . parseInt ; public class IfjUpIMKad { public static void main ( String [ ] args ) { String IfjUpIMKad = new java . util . Scanner ( System . in ) . nextLine ( ) ; String [ ] number = IfjUpIMKad . 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 UQSnUSegRS { 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 gAhukHKqcU { 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 gAhukHKqcU = m . searchA ( ) ; int end = m . searchZ ( ) ; System . out . println ( end - gAhukHKqcU ) ; } } import java . util . Scanner ; public class IRXezuDAgq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . nextLine ( ) ; String [ ] strAry = str . split ( " " ) ; int IRXezuDAgq = Integer . parseInt ( strAry [ 0 ] ) ; int int2 = Integer . valueOf ( strAry [ 1 ] ) . intValue ( ) ; int i = 0 ; boolean b = true ; while ( b ) { if ( IRXezuDAgq < Math . pow ( int2 , i ) ) { System . out . println ( i ) ; b = false ; } i ++ ; scan . close ( ) ; } } } import java . util . * ; public class dYPBsmCxvd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dYPBsmCxvd = getInputInteger ( sc ) ; int b = getInputInteger ( sc ) ; if ( dYPBsmCxvd % 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 afhoxeuihF { 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 afhoxeuihF { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int afhoxeuihF = in . nextInt ( ) ; int D = in . nextInt ( ) ; int mans = ( int ) Math . ceil ( afhoxeuihF / ( ( D * 2 ) + 1 ) ) ; if ( afhoxeuihF % ( ( D * 2 ) + 1 ) != 0 ) { mans ++ ; } out . println ( mans ) ; } } } import java . util . * ; public class HyffhcxBtQ { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int HyffhcxBtQ = sc . nextInt ( ) ; String po = sc . next ( ) ; String po2 = po . substring ( 0 , HyffhcxBtQ / 2 ) ; String po3 = po . substring ( HyffhcxBtQ / 2 ) ; System . out . println ( ( po2 . equals ( po3 ) ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class dINPLeVVdc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dINPLeVVdc = sc . nextInt ( ) ; int [ ] array = new int [ dINPLeVVdc ] ; 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 xaVuBThUzR { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] str = new String [ 2 ] ; int xaVuBThUzR = 0 ; while ( in . hasNext ( ) ) { String buf = in . nextLine ( ) ; str [ xaVuBThUzR ] = 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 CCKVEXVZnP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CCKVEXVZnP = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { CCKVEXVZnP += sc . nextInt ( ) ; } if ( CCKVEXVZnP >= 22 ) { System . out . println ( " bust " ) ; return ; } System . out . println ( " win " ) ; } } import java . util . * ; class UzFJDXZPUe { 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 UzFJDXZPUe ; do { UzFJDXZPUe = 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 ( ) ) ; UzFJDXZPUe = true ; break ; } } } while ( UzFJDXZPUe ) ; System . out . println ( ( str . toString ( ) . equals ( " " ) ) ? " YES " : " NO " ) ; } } import java . util . * ; public class dcDfUNkbco { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dcDfUNkbco = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] A = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { A [ i ] = sc . nextInt ( ) ; dcDfUNkbco -= A [ i ] ; } if ( dcDfUNkbco <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class KDNQAieyDm { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int KDNQAieyDm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int empty = KDNQAieyDm - b ; if ( c - empty < 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( c - empty ) ; } } } import java . util . Scanner ; public class BhQWzNMTEg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BhQWzNMTEg = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String result = ( BhQWzNMTEg == b ) ? " a == b " : ( BhQWzNMTEg > b ) ? " a > b " : " a < b " ; System . out . println ( result ) ; } } import java . util . Scanner ; public class JjFjzlCRbA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; Boolean bool = true ; for ( int JjFjzlCRbA = 0 ; JjFjzlCRbA < S . length ( ) ; JjFjzlCRbA ++ ) { if ( JjFjzlCRbA % 2 == 0 ) { if ( ! ( ( S . charAt ( JjFjzlCRbA ) == 'R' ) || ( S . charAt ( JjFjzlCRbA ) == 'U' ) || ( S . charAt ( JjFjzlCRbA ) == 'D' ) ) ) { bool = false ; } } if ( JjFjzlCRbA % 2 == 1 ) { if ( ! ( ( S . charAt ( JjFjzlCRbA ) == 'L' ) || ( S . charAt ( JjFjzlCRbA ) == 'U' ) || ( S . charAt ( JjFjzlCRbA ) == 'D' ) ) ) { bool = false ; } } } if ( bool == true ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } sc . close ( ) ; } } import java . util . * ; public class eIWcYnVAzp { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String eIWcYnVAzp = in . next ( ) ; if ( eIWcYnVAzp . compareTo ( " ABC " ) == 0 ) { System . out . println ( " ARC " ) ; } else { System . out . println ( " ABC " ) ; } } } import java . util . * ; public class YDDcOVGWhq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int YDDcOVGWhq = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int z ; int count = 0 ; for ( int x = 0 ; x <= YDDcOVGWhq ; x ++ ) { for ( int y = 0 ; y <= YDDcOVGWhq ; y ++ ) { z = s - x - y ; if ( 0 <= z && z <= YDDcOVGWhq ) { count += 1 ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class aqoldeNzLt { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scanner = new Scanner ( System . in ) ; int aqoldeNzLt = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; System . out . println ( aqoldeNzLt * b ) ; } } import java . util . Scanner ; public class SCvOLJipXs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int SCvOLJipXs = scan . nextInt ( ) , b = scan . nextInt ( ) , c = scan . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= c ; i ++ ) { if ( SCvOLJipXs <= 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 TukWqdDnlr { 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 TukWqdDnlr { public void solve ( int testNumber , FastReader in , PrintWriter out ) { out . println ( in . nextInt ( ) > in . nextInt ( ) ? " safe " : " unsafe " ) ; } } static class TukWqdDnlr { 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 BHcgBfXBZd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BHcgBfXBZd = sc . nextInt ( ) ; int [ ] H = new int [ BHcgBfXBZd ] ; int [ ] Hmax = new int [ BHcgBfXBZd ] ; for ( int i = 0 ; i < BHcgBfXBZd ; 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 < BHcgBfXBZd ; i ++ ) { if ( H [ i ] >= Hmax [ i ] ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; class GfAZzuFfmn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int GfAZzuFfmn = scan . nextInt ( ) ; int [ ] r = new int [ GfAZzuFfmn ] ; int ans ; for ( int i = 0 ; i < GfAZzuFfmn ; i ++ ) { r [ i ] = scan . nextInt ( ) ; } int maxv = r [ 1 ] - r [ 0 ] ; int minv = r [ 0 ] ; for ( int i = 1 ; i < GfAZzuFfmn ; i ++ ) { maxv = Math . max ( maxv , r [ i ] - minv ) ; minv = Math . min ( minv , r [ i ] ) ; } System . out . println ( maxv ) ; } } import java . util . Scanner ; public class QEnMgGabKW { public static void main ( String [ ] args ) { int QEnMgGabKW , y , z , a , b , c ; Scanner sc = new Scanner ( System . in ) ; a = 0 ; QEnMgGabKW = sc . nextInt ( ) ; y = sc . nextInt ( ) ; y = y / 1000 ; if ( y < QEnMgGabKW ) { System . out . println ( " -1 -1 -1 " ) ; } else if ( y == QEnMgGabKW ) { System . out . println ( " 0 0 " + y ) ; } else { z = y - QEnMgGabKW ; while ( z % 9 != 0 ) { z = z - 4 ; a ++ ; } b = z / 9 ; c = QEnMgGabKW - 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 HVAUarsvsn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int HVAUarsvsn = scanner . nextInt ( ) ; int [ ] b = new int [ HVAUarsvsn ] ; int c = Integer . MAX_VALUE ; int d = Integer . MIN_VALUE ; long e = 0 ; for ( int i = 0 ; i < HVAUarsvsn ; 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 WmcPNfnXjW { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; double WmcPNfnXjW = sc . nextDouble ( ) ; double a = 3.14159265358979323846 * WmcPNfnXjW * WmcPNfnXjW ; double l = 3.14159265358979323846 * WmcPNfnXjW * 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 fjOVboUxfi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Double > list = new ArrayList < > ( ) ; Double n = sc . nextDouble ( ) ; for ( int fjOVboUxfi = 0 ; fjOVboUxfi < n ; fjOVboUxfi ++ ) { 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 brNDoTHBEg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int brNDoTHBEg = sc . nextInt ( ) ; int [ ] d = new int [ brNDoTHBEg ] ; int ans = 0 ; for ( int i = 0 ; i < brNDoTHBEg ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < brNDoTHBEg ; i ++ ) { for ( int j = i + 1 ; j < brNDoTHBEg ; 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 bcGqksJKnx { static class bcGqksJKnx { 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 bcGqksJKnx = s . nextInt ( ) ; int v = ( int ) ( bcGqksJKnx + Math . pow ( bcGqksJKnx , 2 ) + Math . pow ( bcGqksJKnx , 3 ) ) ; System . out . println ( v ) ; } } import java . util . * ; public class PSgmSzFozp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PSgmSzFozp = sc . nextInt ( ) ; int a2 = PSgmSzFozp * PSgmSzFozp ; int a3 = PSgmSzFozp * PSgmSzFozp * PSgmSzFozp ; int ans = PSgmSzFozp + a2 + a3 ; System . out . println ( ans ) ; } } import java . util . Scanner ; class jOrWmLKfmf { int jOrWmLKfmf , m , x , y ; public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; sc . useDelimiter ( " \\ s " ) ; jOrWmLKfmf = sc . nextInt ( ) ; m = sc . nextInt ( ) ; int [ ] [ ] A = new int [ jOrWmLKfmf ] [ m ] ; int [ ] b = new int [ m ] ; int [ ] c = new int [ jOrWmLKfmf ] ; for ( x = 0 ; x < jOrWmLKfmf ; 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 < jOrWmLKfmf ; x ++ ) { for ( y = 0 ; y < m ; y ++ ) { c [ x ] = c [ x ] + A [ x ] [ y ] * b [ y ] ; } } for ( x = 0 ; x < jOrWmLKfmf ; x ++ ) { System . out . println ( c [ x ] ) ; } } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . * ; public class zeLbNMFDNE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zeLbNMFDNE = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; long at = 0 ; for ( int i = 0 ; i < n ; i ++ ) at += sc . nextInt ( ) ; if ( zeLbNMFDNE <= at ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; class yJWOQjaQEe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yJWOQjaQEe = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] x = new int [ b ] ; for ( int i = 0 ; i < yJWOQjaQEe ; 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 ( yJWOQjaQEe == x [ k ] ) ret = ret + 1 ; } System . out . println ( ret ) ; } } import java . util . Scanner ; public class IYvDAPEQsb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IYvDAPEQsb = sc . nextInt ( ) ; int [ ] monsters = new int [ IYvDAPEQsb + 1 ] ; int [ ] heroes = new int [ IYvDAPEQsb ] ; for ( int i = 0 ; i < IYvDAPEQsb + 1 ; i ++ ) monsters [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < IYvDAPEQsb ; i ++ ) heroes [ i ] = sc . nextInt ( ) ; int rem = 0 ; long totalKilled = 0 ; for ( int i = 0 ; i < IYvDAPEQsb ; 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 [ IYvDAPEQsb ] ) ; System . out . println ( totalKilled ) ; } } import java . util . * ; public class kgoBXEGYKa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] s = S . toCharArray ( ) ; int kgoBXEGYKa = S . length ( ) ; boolean OK = true ; int i = 0 ; int j = ( kgoBXEGYKa - 1 ) / 2 - 1 ; while ( j - i >= 1 ) { if ( s [ i ] == s [ j ] && s [ kgoBXEGYKa - 1 - i ] == s [ kgoBXEGYKa - 1 - j ] ) { i ++ ; j -- ; } else { OK = false ; break ; } } for ( int k = 0 ; k < kgoBXEGYKa / 2 ; k ++ ) { if ( s [ k ] != s [ kgoBXEGYKa - 1 - k ] ) { OK = false ; break ; } } System . out . println ( OK ? " Yes " : " No " ) ; } } import java . util . * ; class MwtttYuRKj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long MwtttYuRKj = sc . nextLong ( ) ; long r = sc . nextLong ( ) ; long min = Long . MAX_VALUE ; int cnt = 0 ; if ( r - MwtttYuRKj >= 2018 ) { System . out . println ( 0 ) ; return ; } for ( long i = MwtttYuRKj ; 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 JAiVgBgWMh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JAiVgBgWMh = 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 kIOOMgZjfp { 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 kIOOMgZjfp { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int kIOOMgZjfp = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; out . println ( kIOOMgZjfp + b + c >= 22 ? " bust " : " win " ) ; } } } import java . math . * ; import java . util . * ; public class XiPJbRKnue { 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 axaOYmhXZW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int axaOYmhXZW = 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 ++ ; } axaOYmhXZW = Math . min ( count , axaOYmhXZW ) ; } System . out . println ( axaOYmhXZW ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class wkAUnRChaz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wkAUnRChaz = getInt ( sc ) ; int [ ] d = getIntArray ( sc ) ; Arrays . sort ( d ) ; int ARCMax = d [ wkAUnRChaz / 2 - 1 ] ; int ABCMin = d [ wkAUnRChaz / 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 BKkwVcXzHE { 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 BKkwVcXzHE = sc . nextInt ( ) ; BKkwVcXzHE > 0 ; BKkwVcXzHE -- ) { 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 LBKwCzXNsC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LBKwCzXNsC = sc . nextInt ( ) ; int [ ] value = new int [ LBKwCzXNsC ] ; for ( int i = 0 ; i < LBKwCzXNsC ; 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 ECttBjeupr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ECttBjeupr = sc . nextInt ( ) ; int a = ECttBjeupr / 100 ; int b = ( ECttBjeupr - a * 100 ) / 10 ; int c = ( ECttBjeupr - a * 100 - b * 10 ) / 1 ; System . out . println ( a + b + c ) ; } } import java . util . * ; public class wjUojFMDTs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wjUojFMDTs = sc . nextInt ( ) ; double b = sc . nextDouble ( ) ; long ans = ( long ) ( wjUojFMDTs * ( b * 100 ) ) / 100 ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . Scanner ; public class dwXocQPFcL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dwXocQPFcL = sc . nextInt ( ) ; int [ ] w = new int [ dwXocQPFcL ] ; for ( int i = 0 ; i < dwXocQPFcL ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } int ans = 100000000 ; for ( int i = 0 ; i < dwXocQPFcL ; i ++ ) { int sum1 = 0 ; int sum2 = 0 ; for ( int j = 0 ; j < i ; j ++ ) { sum1 += w [ j ] ; } for ( int k = i ; k < dwXocQPFcL ; k ++ ) { sum2 += w [ k ] ; } ans = Math . min ( ans , ( int ) Math . abs ( sum1 - sum2 ) ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class SFbvNmeVXU { void run ( ) { Scanner s = new Scanner ( System . in ) ; while ( true ) { int SFbvNmeVXU = s . nextInt ( ) ; int x = s . nextInt ( ) ; if ( SFbvNmeVXU == 0 && x == 0 ) break ; int sum = 0 ; int count = 0 ; int a = 0 ; int [ ] num = new int [ SFbvNmeVXU ] ; for ( int i = 0 ; i < SFbvNmeVXU ; i ++ ) num [ i ] = i + 1 ; for ( int i = a ; i < SFbvNmeVXU ; i ++ ) { for ( int j = i + 1 ; j < SFbvNmeVXU ; j ++ ) { for ( int k = j + 1 ; k < SFbvNmeVXU ; 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 EeFElsTROb { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int EeFElsTROb , m , ans ; EeFElsTROb = sc . nextInt ( ) ; m = sc . nextInt ( ) ; ans = ( ( EeFElsTROb + m ) * ( EeFElsTROb + m - 1 ) ) / 2 - ( EeFElsTROb * m ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class tFXKTiomcz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long tFXKTiomcz = sc . nextLong ( ) , K = sc . nextLong ( ) ; double ch = Math . log ( tFXKTiomcz ) / 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 ovpdbQswWY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ovpdbQswWY = sc . nextInt ( ) ; int sum = sc . nextInt ( ) ; int ct = 0 ; for ( int i = 0 ; i <= ovpdbQswWY ; i ++ ) { for ( int j = 0 ; j <= ovpdbQswWY ; j ++ ) { int tmp = sum - i - j ; if ( tmp <= ovpdbQswWY && tmp >= 0 ) ct ++ ; } } System . out . println ( ct ) ; } } import java . util . Scanner ; public class EPHzTGFPGT { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int EPHzTGFPGT = in . nextInt ( ) ; int T = in . nextInt ( ) ; int A = in . nextInt ( ) ; int [ ] h = new int [ EPHzTGFPGT ] ; double [ ] t = new double [ EPHzTGFPGT ] ; for ( int i = 0 ; i < EPHzTGFPGT ; 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 < EPHzTGFPGT ; i ++ ) { if ( min > t [ i ] ) { min = t [ i ] ; minn = i ; } } System . out . println ( minn + 1 ) ; } } import java . util . Scanner ; public class VkLvnqiliu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VkLvnqiliu = sc . nextInt ( ) ; boolean ok = false ; LOOP : for ( int i = 0 ; i <= VkLvnqiliu ; i += 4 ) { for ( int j = 0 ; i + j <= VkLvnqiliu ; j += 7 ) { if ( i + j == VkLvnqiliu ) { ok = true ; break LOOP ; } } } if ( ok ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class KqazDtZFtD { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] pizza = new int [ 5 ] ; int KqazDtZFtD = 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 ; KqazDtZFtD = Math . min ( KqazDtZFtD , pizza [ 0 ] * a + pizza [ 1 ] * b + pizza [ 2 ] * c ) ; } System . out . println ( KqazDtZFtD ) ; } } import java . util . * ; public class bOGnaeWGQm { private final static int bOGnaeWGQm = 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 ClPBOBiqdd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ClPBOBiqdd = sc . nextInt ( ) ; int [ ] c = new int [ 9 ] ; for ( int i = 0 ; i < ClPBOBiqdd ; 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 lqPHWtYPNr { final static long lqPHWtYPNr = 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 / lqPHWtYPNr != R / lqPHWtYPNr ) { 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 ) % lqPHWtYPNr ; min = Math . min ( min , r ) ; } } System . out . println ( min ) ; } } import java . util . Scanner ; public class jFNNrkMotV { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; String jFNNrkMotV = scanner . next ( ) ; String b = scanner . next ( ) ; if ( ( jFNNrkMotV . length ( ) + 1 == b . length ( ) ) && b . startsWith ( jFNNrkMotV ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class njxdgnjDht { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int njxdgnjDht = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; if ( njxdgnjDht <= 5 ) System . out . println ( " 0 " ) ; else if ( njxdgnjDht <= 12 ) System . out . println ( b / 2 ) ; else System . out . println ( b ) ; } } import java . io . * ; class PcGkSsPSJo { int [ ] s ; int PcGkSsPSJo ; Sta ( ) { s = new int [ 1000 ] ; PcGkSsPSJo = 0 ; } void push ( int x ) { PcGkSsPSJo ++ ; s [ PcGkSsPSJo ] = x ; } int pop ( ) { PcGkSsPSJo -- ; return s [ PcGkSsPSJo + 1 ] ; } } public class PcGkSsPSJo { 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 FVdbjZWyvi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FVdbjZWyvi = sc . nextInt ( ) ; int lowPos = sc . nextInt ( ) ; String str = sc . next ( ) ; String [ ] ary = str . split ( " " , 0 ) ; for ( int i = 0 ; i < FVdbjZWyvi ; i ++ ) { if ( i == lowPos - 1 ) ary [ i ] = ary [ i ] . toLowerCase ( ) ; System . out . print ( ary [ i ] ) ; } } } import java . util . Scanner ; class nzrhkpCZAp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nzrhkpCZAp = sc . nextInt ( ) ; int [ ] sequence = new int [ nzrhkpCZAp ] ; double denominator = 0 ; for ( int i = 0 ; i < nzrhkpCZAp ; i ++ ) { sequence [ i ] = sc . nextInt ( ) ; denominator += 1.0 / sequence [ i ] ; } System . out . println ( 1 / denominator ) ; } } import java . util . * ; public class YdjmlpSGzS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; String T = sc . nextLine ( ) ; sc . close ( ) ; boolean YdjmlpSGzS = true ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { char sVal = S . charAt ( i ) ; char tVal = T . charAt ( i ) ; if ( sVal != tVal ) { YdjmlpSGzS = false ; break ; } } if ( YdjmlpSGzS ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class JiIPXPcQIj { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int JiIPXPcQIj = in . nextInt ( ) ; int [ ] hills = new int [ JiIPXPcQIj ] ; for ( int i = 0 ; i < JiIPXPcQIj ; i ++ ) { hills [ i ] = in . nextInt ( ) ; } int counter = 1 ; int cur = hills [ 0 ] ; for ( int i = 1 ; i < JiIPXPcQIj ; i ++ ) { if ( hills [ i ] >= cur ) { counter ++ ; cur = hills [ i ] ; } } System . out . println ( counter ) ; } } import java . util . * ; public class XuxZseQEaE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XuxZseQEaE = sc . nextInt ( ) , d = sc . nextInt ( ) ; sc . close ( ) ; int tmp = 2 * d + 1 ; int r = XuxZseQEaE % tmp ; int ans = XuxZseQEaE / tmp ; if ( r != 0 ) ans ++ ; System . out . println ( ans ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class mkQmufsxji { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Set < Integer > arrays = new HashSet < > ( ) ; int mkQmufsxji = 1 ; int s = sc . nextInt ( ) ; arrays . add ( s ) ; while ( true ) { mkQmufsxji ++ ; s = result ( s ) ; if ( arrays . contains ( s ) ) { System . out . println ( mkQmufsxji ) ; 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 QrIMKaLUxx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; char QrIMKaLUxx = scan . next ( ) . charAt ( 0 ) ; System . out . println ( ++ QrIMKaLUxx ) ; } } import java . util . * ; public class DfKbaYrrBc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DfKbaYrrBc = sc . nextInt ( ) ; int a = DfKbaYrrBc % 500 ; int b = ( a - ( a % 5 ) ) ; int c = ( DfKbaYrrBc - a ) * 2 ; System . out . println ( b + c ) ; } } import java . util . * ; public class RQxUwmnIsM { public static void main ( String [ ] args ) { Scanner sc = null ; sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; String before = " " ; int RQxUwmnIsM = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( i == 0 ) { if ( s . substring ( 0 , 1 ) . equals ( " R " ) ) { RQxUwmnIsM = 1 ; } before = s . substring ( 0 , 1 ) ; } else { if ( s . substring ( i , i + 1 ) . equals ( " R " ) && before . equals ( " R " ) ) { RQxUwmnIsM += 1 ; } else if ( s . substring ( i , i + 1 ) . equals ( " R " ) && before . equals ( " S " ) ) { RQxUwmnIsM = 1 ; } before = s . substring ( i , i + 1 ) ; } } System . out . println ( RQxUwmnIsM ) ; } } import java . util . Arrays ; import java . util . Collection ; import java . util . Collections ; import java . util . Scanner ; public class zfcRmWCdGX { public static void main ( String [ ] args ) { int zfcRmWCdGX = 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 == '+' ) { zfcRmWCdGX ++ ; } else { zfcRmWCdGX -- ; } if ( b == '+' ) { zfcRmWCdGX ++ ; } else { zfcRmWCdGX -- ; } if ( c == '+' ) { zfcRmWCdGX ++ ; } else { zfcRmWCdGX -- ; } if ( d == '+' ) { zfcRmWCdGX ++ ; } else { zfcRmWCdGX -- ; } System . out . println ( zfcRmWCdGX ) ; } } import java . util . * ; public class FZTcJTIoSN { public static void main ( String [ ] args ) { boolean FZTcJTIoSN = 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 ) FZTcJTIoSN = 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 ) FZTcJTIoSN = false ; } else FZTcJTIoSN = false ; } } } else FZTcJTIoSN = false ; if ( FZTcJTIoSN ) System . out . println ( " Yes " ) ; else if ( ! FZTcJTIoSN ) System . out . println ( " No " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class xBZmJYTuzj { static long xBZmJYTuzj = 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 vmCsrXDZOZ { public static void main ( String [ ] args ) { Scanner inp = new Scanner ( System . in ) ; int vmCsrXDZOZ = inp . nextInt ( ) ; int cols = inp . nextInt ( ) ; int [ ] [ ] aMatrix = new int [ vmCsrXDZOZ ] [ cols ] ; int [ ] [ ] bMatrix = new int [ cols ] [ 1 ] ; for ( int k = 0 ; k < vmCsrXDZOZ ; 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 , vmCsrXDZOZ , cols ) ; for ( int [ ] item : total ) { for ( int secondItem : item ) { System . out . println ( secondItem ) ; } } } public static int [ ] [ ] matrixCalc ( int [ ] [ ] aMatrix , int [ ] [ ] bMatrix , int vmCsrXDZOZ , int cols ) { int [ ] [ ] totals = new int [ vmCsrXDZOZ ] [ 1 ] ; for ( int k = 0 ; k < vmCsrXDZOZ ; 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 yoRGPLoczb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int yoRGPLoczb = scan . nextInt ( ) ; long sum = 0 ; for ( int i = 1 ; i <= yoRGPLoczb ; i ++ ) { for ( int j = 1 ; j <= yoRGPLoczb ; j ++ ) { for ( int l = 1 ; l <= yoRGPLoczb ; 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 FgSMBOKmhT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FgSMBOKmhT = sc . nextInt ( ) ; int a , b , c ; a = FgSMBOKmhT / 100 ; b = ( FgSMBOKmhT - a * 100 ) / 10 ; c = FgSMBOKmhT - 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 vtDuucehXD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; sc . close ( ) ; int vtDuucehXD = S . vtDuucehXD ( ) ; boolean flag = true ; for ( int i = 1 ; i <= vtDuucehXD ; 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 dOmZYyodvF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dOmZYyodvF = sc . nextInt ( ) ; int [ ] b = new int [ dOmZYyodvF - 1 ] ; int sum = 0 ; for ( int i = 0 ; i < dOmZYyodvF - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } sum += b [ 0 ] ; for ( int j = 0 ; j < dOmZYyodvF - 2 ; j ++ ) { if ( b [ j ] >= b [ j + 1 ] ) { sum += b [ j + 1 ] ; } else { sum += b [ j ] ; } } sum += b [ dOmZYyodvF - 2 ] ; System . out . println ( sum ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class sBNvqNNMzR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String sBNvqNNMzR = sc . next ( ) ; if ( sBNvqNNMzR . charAt ( 0 ) == sBNvqNNMzR . charAt ( 1 ) && ( sBNvqNNMzR . charAt ( 2 ) == sBNvqNNMzR . charAt ( 3 ) ) && ( sBNvqNNMzR . charAt ( 0 ) != sBNvqNNMzR . charAt ( 2 ) ) ) System . out . println ( " Yes " ) ; else if ( sBNvqNNMzR . charAt ( 0 ) == sBNvqNNMzR . charAt ( 2 ) && ( sBNvqNNMzR . charAt ( 1 ) == sBNvqNNMzR . charAt ( 3 ) ) && ( sBNvqNNMzR . charAt ( 0 ) != sBNvqNNMzR . charAt ( 1 ) ) ) System . out . println ( " Yes " ) ; else if ( sBNvqNNMzR . charAt ( 0 ) == sBNvqNNMzR . charAt ( 3 ) && ( sBNvqNNMzR . charAt ( 1 ) == sBNvqNNMzR . charAt ( 2 ) ) && ( sBNvqNNMzR . charAt ( 0 ) != sBNvqNNMzR . charAt ( 1 ) ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class cWceuzJOoj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cWceuzJOoj = 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' ; cWceuzJOoj = cWceuzJOoj + b ; } if ( n % cWceuzJOoj == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class IOiOsVULHm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String IOiOsVULHm = sc . next ( ) ; if ( IOiOsVULHm . 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 oavkcFQrQw { 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 oavkcFQrQw { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { int oavkcFQrQw = in . Int ( ) ; out . println ( ( 1000 - ( oavkcFQrQw % 1000 ) ) % 1000 ) ; } } static class oavkcFQrQw { 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 NVXPylrxhL { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { while ( true ) { int NVXPylrxhL = sc . nextInt ( ) , f = sc . nextInt ( ) , r = sc . nextInt ( ) ; if ( NVXPylrxhL == - 1 && f == - 1 && r == - 1 ) { break ; } if ( NVXPylrxhL == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } else if ( NVXPylrxhL + f >= 80 ) { System . out . println ( " A " ) ; } else if ( NVXPylrxhL + f >= 65 ) { System . out . println ( " B " ) ; } else if ( NVXPylrxhL + f >= 50 ) { System . out . println ( " C " ) ; } else if ( NVXPylrxhL + 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 huKOnwLyBz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int huKOnwLyBz = sc . nextInt ( ) ; String [ ] vote = new String [ huKOnwLyBz ] ; int i = 0 ; while ( i < huKOnwLyBz ) { vote [ i ] = sc . next ( ) ; i ++ ; } Arrays . sort ( vote ) ; int maxCounter = 0 ; int [ ] a = new int [ huKOnwLyBz ] ; String [ ] b = new String [ huKOnwLyBz ] ; int j = 0 ; a [ 0 ] = 1 ; b [ 0 ] = vote [ 0 ] ; for ( i = 1 ; i < huKOnwLyBz ; 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 < huKOnwLyBz ; i ++ ) { if ( a [ i ] == maxCounter ) { System . out . println ( b [ i ] ) ; } } } } import java . util . * ; class sJQBcZRnAx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sJQBcZRnAx = Integer . parseInt ( sc . next ( ) ) ; String s = Integer . toString ( sJQBcZRnAx ) ; 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 KADUVYqeQk { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String word = sc . nextLine ( ) ; int KADUVYqeQk = 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 ) ) { KADUVYqeQk ++ ; } } } System . out . println ( KADUVYqeQk ) ; } } import java . util . Scanner ; import java . util . Arrays ; import java . lang . Math ; public class gLVeexBVeF { 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 iGLiALXVAm { 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 iGLiALXVAm = 0 ; iGLiALXVAm < in . length ; iGLiALXVAm ++ ) { char b01 = in [ iGLiALXVAm ] ; 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 iGLiALXVAm = 0 ; iGLiALXVAm < out . size ( ) ; iGLiALXVAm ++ ) { String s = out . get ( iGLiALXVAm ) ; kotae = kotae + s ; } System . out . println ( kotae ) ; } } import java . io . * ; import java . util . * ; public class vIyKtvDyhF { public static void main ( final String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; int vIyKtvDyhF = sc . nextInt ( ) ; String S = sc . next ( ) ; final Solver solver = new Solver ( ) ; solver . solve ( vIyKtvDyhF , S ) ; } } class vIyKtvDyhF { public void solve ( int vIyKtvDyhF , String S ) { int ans = 0 ; int cur = 'A' ; for ( int i = 0 ; i < vIyKtvDyhF ; 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 QZHeNDRiyj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int QZHeNDRiyj = Integer . parseInt ( a + b ) ; for ( int i = 2 ; i * i <= QZHeNDRiyj ; i ++ ) { if ( i * i == QZHeNDRiyj ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class WIRWSFltTE { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String WIRWSFltTE = sc . nextLine ( ) ; String p = sc . nextLine ( ) ; WIRWSFltTE += WIRWSFltTE ; if ( WIRWSFltTE . contains ( p ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class dxPMxBSOth { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dxPMxBSOth = sc . nextInt ( ) ; int [ ] t = new int [ dxPMxBSOth ] ; int [ ] x = new int [ dxPMxBSOth ] ; int [ ] y = new int [ dxPMxBSOth ] ; for ( int i = 0 ; i < dxPMxBSOth ; 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 < dxPMxBSOth ; 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 yyjwFgGyOo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; sc . next ( ) ; int yyjwFgGyOo = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; if ( c [ yyjwFgGyOo - 1 ] == 'A' ) { c [ yyjwFgGyOo - 1 ] = 'a' ; } else if ( c [ yyjwFgGyOo - 1 ] == 'B' ) { c [ yyjwFgGyOo - 1 ] = 'b' ; } else { c [ yyjwFgGyOo - 1 ] = 'c' ; } System . out . println ( c ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class ZqIjjRkiRs { 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 ZqIjjRkiRs = 0 ; int lastW = 0 ; do { ZqIjjRkiRs = stdIn . nextInt ( ) ; lastW = stdIn . nextInt ( ) ; H . add ( ZqIjjRkiRs ) ; W . add ( lastW ) ; } while ( ZqIjjRkiRs != 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 TQtEGySVSC { public static void main ( String [ ] args ) { Scanner key = new Scanner ( System . in ) ; double TQtEGySVSC = key . nextInt ( ) ; key . close ( ) ; System . out . println ( ( TQtEGySVSC / 3 ) * ( TQtEGySVSC / 3 ) * ( TQtEGySVSC / 3 ) ) ; } } import java . util . Scanner ; public class PTgKtzuBMW { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String S = stdIn . next ( ) ; String [ ] s = S . split ( " S " ) ; int PTgKtzuBMW = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { PTgKtzuBMW = Math . max ( PTgKtzuBMW , s [ i ] . length ( ) ) ; } System . out . println ( PTgKtzuBMW ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class fpffPMQhew { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fpffPMQhew = 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 < fpffPMQhew ; 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 ] == fpffPMQhew ) ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; class QyLVVxEfcW { private static Scanner sc ; public static void main ( final String [ ] args ) { sc = new Scanner ( System . in ) ; String QyLVVxEfcW = sc . next ( ) ; if ( QyLVVxEfcW . equals ( " ABC " ) ) System . out . println ( " ARC " ) ; else { System . out . println ( " ABC " ) ; } } } import java . util . * ; public class imAuXQwhTO { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; int imAuXQwhTO = s . length ( ) ; int sum1 = 0 ; int sum2 = 0 ; sum1 = 0 ; for ( int i = 0 ; i < imAuXQwhTO ; 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 < imAuXQwhTO ; 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 QPYHXcwLKf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QPYHXcwLKf = sc . nextInt ( ) ; double a = QPYHXcwLKf / 3.0 ; double b = QPYHXcwLKf / 3.0 ; double v = a * b * ( QPYHXcwLKf - a - b ) ; System . out . println ( v ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class hAHGOvPhNU { 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 WsbaOsfVlx { public static void main ( String [ ] args ) { int WsbaOsfVlx , b ; Scanner sc = new Scanner ( System . in ) ; do { WsbaOsfVlx = sc . nextInt ( ) ; } while ( ! ( ( WsbaOsfVlx >= 1 ) && ( WsbaOsfVlx <= 20 ) ) ) ; do { b = sc . nextInt ( ) ; } while ( ! ( ( b >= 1 ) && ( b <= 20 ) ) ) ; if ( ( WsbaOsfVlx >= 1 && WsbaOsfVlx <= 9 ) && ( b >= 1 && b <= 9 ) ) { System . out . println ( WsbaOsfVlx * b ) ; } else { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; public class UruoCzNWWp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int UruoCzNWWp = Integer . parseInt ( scanner . nextLine ( ) ) ; String s = scanner . nextLine ( ) ; if ( UruoCzNWWp % 2 == 1 || UruoCzNWWp == 0 ) { System . out . println ( " No " ) ; return ; } String s1 = s . substring ( 0 , UruoCzNWWp / 2 ) ; String s2 = s . substring ( UruoCzNWWp / 2 , UruoCzNWWp ) ; if ( s1 . startsWith ( s2 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scanner . close ( ) ; } } import java . util . Scanner ; public class bwDpMrEcdj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int bwDpMrEcdj = scan . nextInt ( ) ; for ( int i = 1 ; i <= bwDpMrEcdj ; 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 PiiaBNruIL { private static long PiiaBNruIL = 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 ] % PiiaBNruIL ; } if ( steps [ i + 1 ] != - 1 ) { steps [ i + 1 ] += steps [ i ] % PiiaBNruIL ; } } System . out . println ( steps [ count ] % PiiaBNruIL ) ; } } import java . util . Scanner ; public class SWnDtSEnAb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SWnDtSEnAb = sc . nextInt ( ) ; int maxCount = 0 ; int maxNum = 0 ; for ( int i = 0 ; i < SWnDtSEnAb ; 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 GmmLmgCAwL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long GmmLmgCAwL = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( GmmLmgCAwL > k ) { GmmLmgCAwL -= k * ( GmmLmgCAwL / k ) ; if ( k - GmmLmgCAwL < GmmLmgCAwL ) { System . out . println ( k - GmmLmgCAwL ) ; } else { System . out . println ( GmmLmgCAwL ) ; } } else { if ( k - GmmLmgCAwL < GmmLmgCAwL ) { System . out . println ( k - GmmLmgCAwL ) ; } else { System . out . println ( GmmLmgCAwL ) ; } } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class UpIERalbBh { public static void main ( String [ ] args ) throws Exception { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] natural = stdReader . readLine ( ) . split ( " " , 0 ) ; int UpIERalbBh = Integer . parseInt ( natural [ 0 ] ) ; int y = Integer . parseInt ( natural [ 1 ] ) ; if ( UpIERalbBh < y ) { UpIERalbBh = UpIERalbBh ^ y ; y = UpIERalbBh ^ y ; UpIERalbBh = UpIERalbBh ^ y ; } while ( y > 0 ) { int r = UpIERalbBh % y ; UpIERalbBh = y ; y = r ; } System . out . println ( UpIERalbBh ) ; } } import java . util . * ; public class OvedUThhOl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int OvedUThhOl = 0 ; int z = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'A' ) { OvedUThhOl = i ; break ; } } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'Z' ) { z = i + 1 ; } } System . out . println ( z - OvedUThhOl ) ; } } import java . util . Scanner ; public class LKKIStIngZ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LKKIStIngZ = 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 != LKKIStIngZ ; 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 toMRPmsMeE { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; String re = " " ; for ( int toMRPmsMeE = line . length ( ) ; toMRPmsMeE > 0 ; toMRPmsMeE -- ) { re += line . charAt ( toMRPmsMeE - 1 ) ; } System . out . println ( re ) ; } } import java . util . * ; import java . text . * ; class mNvLIKIXRP { 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 mNvLIKIXRP = s1 . length ( ) ; int l2 = s2 . length ( ) ; int l = Math . min ( mNvLIKIXRP , l2 ) ; for ( int i = 0 ; i < l ; i ++ ) { int d = s1 . charAt ( i ) - s2 . charAt ( i ) ; if ( d != 0 ) return d ; } return mNvLIKIXRP - 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 ExGQVdFcnh { public static void main ( String [ ] args ) throws IOException { long ExGQVdFcnh = 0 ; int i = 0 ; long n = 100 ; double k = 0 ; BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) ) ; ExGQVdFcnh = Long . parseLong ( r . readLine ( ) ) ; do { i ++ ; k = Math . ceil ( ( double ) ( n / 100 ) ) ; n += ( long ) k ; } while ( n < ExGQVdFcnh ) ; System . out . println ( i ) ; } } import java . util . Scanner ; public class xbmkYvTkdy { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; double xbmkYvTkdy , d , s ; d = sc . nextDouble ( ) ; xbmkYvTkdy = sc . nextDouble ( ) ; s = sc . nextDouble ( ) ; if ( ( d / s ) <= xbmkYvTkdy ) 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 oqDFUjDuAg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oqDFUjDuAg = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; Queue < Process > Q = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < oqDFUjDuAg ; 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 oqDFUjDuAg { 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 XIdDMXKTOu { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int XIdDMXKTOu = Integer . parseInt ( br . readLine ( ) ) ; int [ ] arr = new int [ XIdDMXKTOu - 1 ] ; String [ ] s = br . readLine ( ) . split ( " " ) ; int prev = 987654321 ; long sum = 0 ; for ( int i = 0 ; i < XIdDMXKTOu - 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 MzciqiAlfS { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int MzciqiAlfS = scan . nextInt ( ) ; int [ ] a = new int [ MzciqiAlfS ] ; int i = 0 ; int Alice = 0 ; int Bob = 0 ; for ( i = 0 ; i < MzciqiAlfS ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } Arrays . sort ( a ) ; for ( i = 1 ; i <= MzciqiAlfS ; i ++ ) { if ( i % 2 == 1 ) { Alice = Alice + a [ MzciqiAlfS - i ] ; } else { Bob = Bob + a [ MzciqiAlfS - i ] ; } } System . out . println ( Alice - Bob ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class xkVWvZguUq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xkVWvZguUq = sc . nextInt ( ) ; List < Long > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < xkVWvZguUq ; 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 QoyCqHhABC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QoyCqHhABC = 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 ) { QoyCqHhABC += i ; } } System . out . println ( QoyCqHhABC ) ; } private static int sum ( int i ) { int sumDigits = 0 ; while ( i != 0 ) { sumDigits += i % 10 ; i /= 10 ; } return sumDigits ; } } import java . util . * ; public class JOaMPZwyoy { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int JOaMPZwyoy = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; System . out . println ( scanner . next ( ) . matches ( String . format ( " \\ d { %d } - \\ d { %d } " , JOaMPZwyoy , b ) ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; class kwuGdfvptU { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int kwuGdfvptU = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int [ ] [ ] array ; array = new int [ kwuGdfvptU ] [ b ] ; int [ ] Vec = new int [ b ] ; int [ ] sum = new int [ kwuGdfvptU ] ; int x = 0 ; for ( int i = 0 ; i < kwuGdfvptU ; 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 < kwuGdfvptU ; 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 < kwuGdfvptU ; i ++ ) { System . out . println ( sum [ i ] ) ; } scanner . close ( ) ; } } import java . util . Scanner ; public class LyilmDapyT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String buff = " " ; int LyilmDapyT = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double count = 1 , flag = 0 ; double count1 = 0 , count2 = 0 ; int count3 = 9999999 ; int [ ] [ ] array1 = new int [ LyilmDapyT ] [ k ] ; for ( int i = 0 ; i < LyilmDapyT ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { array1 [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < LyilmDapyT - 1 ; i ++ ) { for ( int j = i + 1 ; j < LyilmDapyT ; 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 AetFuACIBR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AetFuACIBR = 0 ; int five = 0 ; while ( sc . hasNext ( ) ) { int num = sc . nextInt ( ) ; if ( num == 7 ) { AetFuACIBR ++ ; } else if ( num == 5 ) { five ++ ; } } if ( AetFuACIBR == 1 && five == 2 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; import java . lang . * ; import java . math . * ; public class zjIRpKmsap { Scanner sc = new Scanner ( System . in ) ; void run ( ) { int zjIRpKmsap = sc . nextInt ( ) ; int b = 100 ; for ( int i = 0 ; i < zjIRpKmsap ; 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 ekEZEPMXqT { 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 ekEZEPMXqT = 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 ) ) ) { ekEZEPMXqT ++ ; } } } } if ( ekEZEPMXqT > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class cJwKMEIMKM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cJwKMEIMKM = 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 ++ ) { cJwKMEIMKM = 0 ; S2 = 0 ; S3 = 0 ; for ( int k = 0 ; k <= j ; k ++ ) { cJwKMEIMKM = cJwKMEIMKM + arys [ k ] ; } for ( int k = j + 1 ; k <= N - 1 ; k ++ ) { S2 = S2 + arys [ k ] ; } S3 = Math . abs ( cJwKMEIMKM - 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 PnglDfAuHC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PnglDfAuHC = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] m = new int [ PnglDfAuHC ] ; int sumG = 0 ; int minDonut = 1001 ; for ( int i = 0 ; i < PnglDfAuHC ; i ++ ) { m [ i ] = sc . nextInt ( ) ; sumG += m [ i ] ; minDonut = Math . min ( minDonut , m [ i ] ) ; } int sumDonut = PnglDfAuHC + ( x - sumG ) / minDonut ; System . out . println ( sumDonut ) ; } } import java . util . * ; public class GOdSBJchpn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GOdSBJchpn = sc . nextInt ( ) ; double min = Math . pow ( 10 , 10 ) ; double max = 0 ; for ( int i = 0 ; i < GOdSBJchpn ; 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 NYZdhIBeGc { 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 NYZdhIBeGc = 0 ; NYZdhIBeGc < s1 . length ( ) ; NYZdhIBeGc ++ ) { if ( c [ NYZdhIBeGc ] != 'B' ) list . add ( ( int ) c [ NYZdhIBeGc ] - '0' ) ; else { if ( list . size ( ) > 0 ) list . remove ( list . size ( ) - 1 ) ; } } for ( int NYZdhIBeGc = 0 ; NYZdhIBeGc < list . size ( ) ; NYZdhIBeGc ++ ) System . out . print ( list . get ( NYZdhIBeGc ) ) ; } } import java . util . Scanner ; public class VJCADVyhls { public static void main ( String [ ] av ) { Scanner s = new Scanner ( System . in ) ; int VJCADVyhls = s . nextInt ( ) ; int [ ] a = new int [ VJCADVyhls + 1 ] ; for ( int i = 0 ; i < VJCADVyhls ; i ++ ) { a [ i ] = s . nextInt ( ) ; } for ( int i = 1 ; i < VJCADVyhls ; i ++ ) { for ( int k = 0 ; k < VJCADVyhls ; k ++ ) { System . out . print ( a [ k ] ) ; if ( k != VJCADVyhls - 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 < VJCADVyhls ; k ++ ) { System . out . print ( a [ k ] ) ; if ( k != VJCADVyhls - 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 hYCGeqXMmM { 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 hYCGeqXMmM { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int hYCGeqXMmM = Integer . parseInt ( in . next ( ) ) ; int d = Integer . parseInt ( in . next ( ) ) ; int ans = 0 ; if ( hYCGeqXMmM % ( 2 * d + 1 ) == 0 ) { ans = hYCGeqXMmM / ( 2 * d + 1 ) ; } else { ans = hYCGeqXMmM / ( 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 pWvjwEJlwt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long pWvjwEJlwt = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; System . out . println ( solve ( b , c , d ) - solve ( pWvjwEJlwt - 1 , c , d ) ) ; } static long gcd ( long pWvjwEJlwt , long b ) { if ( b == 0 ) { return pWvjwEJlwt ; } return gcd ( b , pWvjwEJlwt % 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 bCXJEYuHGo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bCXJEYuHGo = sc . nextInt ( ) ; bCXJEYuHGo = bCXJEYuHGo % 10 ; if ( bCXJEYuHGo == 2 || bCXJEYuHGo == 4 || bCXJEYuHGo == 5 || bCXJEYuHGo == 7 || bCXJEYuHGo == 9 ) { System . out . println ( " hon " ) ; } else if ( bCXJEYuHGo == 0 || bCXJEYuHGo == 1 || bCXJEYuHGo == 6 || bCXJEYuHGo == 8 ) { System . out . println ( " pon " ) ; } else { System . out . println ( " bon " ) ; } } } import java . util . * ; public class tRoYhRzDqY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tRoYhRzDqY = sc . nextInt ( ) ; String ans = " APPROVED " ; for ( int i = 0 ; i < tRoYhRzDqY ; 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 xuUqcwQXsC { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; for ( int xuUqcwQXsC = 0 ; xuUqcwQXsC < s . length ( ) - 1 ; xuUqcwQXsC ++ ) { if ( s . charAt ( xuUqcwQXsC ) != s . charAt ( xuUqcwQXsC + 1 ) ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class lAFjIwZFgA { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int lAFjIwZFgA = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int ans = ( lAFjIwZFgA + a - 1 ) / a ; System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class cLTcENifWI { 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 cLTcENifWI { public void solve ( InputReader in , PrintWriter out ) { int cLTcENifWI = in . nextInt ( ) ; int [ ] a = new int [ cLTcENifWI ] ; for ( int i = 0 ; i < cLTcENifWI ; i ++ ) a [ i ] = in . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < cLTcENifWI - 1 ; i ++ ) { for ( int j = i + 1 ; j < cLTcENifWI ; j ++ ) { int mul = a [ i ] * a [ j ] ; sum += mul ; } } out . println ( sum ) ; } } static class cLTcENifWI { 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 kQJJidFkOC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String p = sc . nextLine ( ) ; int kQJJidFkOC = s . length ( ) ; int pLen = p . length ( ) ; boolean ok = false ; for ( int i = 0 ; i < kQJJidFkOC ; i ++ ) { for ( int j = 0 ; j < pLen ; j ++ ) { if ( s . charAt ( ( i + j ) % kQJJidFkOC ) != 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 EXZUQXCpzg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long EXZUQXCpzg = sc . nextLong ( ) ; long r = sc . nextLong ( ) ; long min = 9999 ; for ( long i = EXZUQXCpzg ; 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 rGKyVAhvhL { static public void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int rGKyVAhvhL = s . nextInt ( ) ; String c = s . next ( ) ; if ( rGKyVAhvhL % 2 == 1 ) { System . out . println ( " No " ) ; } else { boolean yes = true ; for ( int i = 0 ; i < rGKyVAhvhL / 2 && yes ; i ++ ) { if ( c . charAt ( i ) != c . charAt ( i + rGKyVAhvhL / 2 ) ) yes = false ; } if ( yes ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } } import java . util . * ; import java . io . * ; public class WJmqMkJySQ { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int WJmqMkJySQ , x , t = 0 ; String [ ] brr = br . readLine ( ) . split ( " " ) ; WJmqMkJySQ = Integer . parseInt ( brr [ 0 ] ) ; x = Integer . parseInt ( brr [ 1 ] ) ; t = Integer . parseInt ( brr [ 2 ] ) ; long ans = 0 ; while ( WJmqMkJySQ > 0 ) { ans += t ; WJmqMkJySQ -= x ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class pBoIMLqtaI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long pBoIMLqtaI = sc . nextLong ( ) , min = 11 ; String a = " " , b = " " ; for ( int i = 1 ; i <= Math . sqrt ( pBoIMLqtaI ) ; i ++ ) { if ( pBoIMLqtaI % i == 0 ) { a = String . valueOf ( i ) ; b = String . valueOf ( pBoIMLqtaI / i ) ; min = Math . min ( min , Math . max ( a . length ( ) , b . length ( ) ) ) ; } } System . out . println ( min ) ; } public static List < Long > divisorEnum ( long pBoIMLqtaI ) { List < Long > l = new ArrayList < > ( ) ; for ( long i = 1 ; i <= Math . sqrt ( pBoIMLqtaI ) ; i ++ ) { if ( pBoIMLqtaI % i == 0 ) { l . add ( i ) ; if ( i != Math . sqrt ( pBoIMLqtaI ) ) l . add ( pBoIMLqtaI / i ) ; } } l . sort ( null ) ; return l ; } } import java . util . Scanner ; public class irFEVtWjIi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int irFEVtWjIi = Integer . parseInt ( ( sc . next ( ) ) ) ; long [ ] aArr = new long [ irFEVtWjIi + 1 ] ; for ( int i = 0 ; i <= irFEVtWjIi ; i ++ ) { aArr [ i ] = Long . parseLong ( sc . next ( ) ) ; } long [ ] bArr = new long [ irFEVtWjIi ] ; for ( int i = 0 ; i < irFEVtWjIi ; i ++ ) { bArr [ i ] = Long . parseLong ( sc . next ( ) ) ; } sc . close ( ) ; long ans = 0 ; for ( int i = irFEVtWjIi - 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 xxofjdFhFV { 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 xxofjdFhFV = S . length - T . length + 1 ; int [ ] cnt = new int [ xxofjdFhFV ] ; int max = 0 ; for ( int i = 0 ; i < xxofjdFhFV ; 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 TnCsntaCDj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TnCsntaCDj = sc . nextInt ( ) ; int num2 = sc . nextInt ( ) ; int num3 = sc . nextInt ( ) ; System . out . println ( num3 ) ; System . out . println ( TnCsntaCDj ) ; System . out . println ( num2 ) ; } } import java . util . * ; public class zpdVFldWiR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zpdVFldWiR = sc . nextInt ( ) ; int [ ] A = new int [ zpdVFldWiR + 1 ] ; int [ ] B = new int [ zpdVFldWiR ] ; for ( int i = 0 ; i < zpdVFldWiR + 1 ; i ++ ) A [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < zpdVFldWiR ; i ++ ) B [ i ] = sc . nextInt ( ) ; int [ ] AC = A . clone ( ) ; long cnt = 0 ; for ( int i = 0 ; i < zpdVFldWiR ; 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 < zpdVFldWiR + 1 ; i ++ ) { cnt += AC [ i ] - A [ i ] ; } System . out . println ( cnt ) ; } } import java . util . * ; public class abNcMsejjy { 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 abNcMsejjy = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { sChar [ i ] = s . charAt ( i ) ; cChar [ i ] = c . charAt ( i ) ; if ( sChar [ i ] == cChar [ i ] ) { abNcMsejjy ++ ; } } System . out . println ( abNcMsejjy ) ; } } import java . util . * ; public class wHjfvBzdLK { static boolean [ ] targetNumbers ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long wHjfvBzdLK = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long gcd = calcGcd ( wHjfvBzdLK , B ) ; System . out . println ( wHjfvBzdLK * 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 DueyttPSSP { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String DueyttPSSP = br . readLine ( ) ; Integer witdh = Integer . parseInt ( DueyttPSSP . split ( " " ) [ 0 ] ) ; Integer height = Integer . parseInt ( DueyttPSSP . split ( " " ) [ 1 ] ) ; Integer x = Integer . parseInt ( DueyttPSSP . split ( " " ) [ 2 ] ) ; Integer y = Integer . parseInt ( DueyttPSSP . split ( " " ) [ 3 ] ) ; Integer r = Integer . parseInt ( DueyttPSSP . 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 EeLXxxcIkN { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int EeLXxxcIkN = scanner . nextInt ( ) ; int [ ] p = new int [ EeLXxxcIkN ] ; for ( int i = 0 ; i < EeLXxxcIkN ; i ++ ) { p [ i ] = scanner . nextInt ( ) ; } int count = 0 ; for ( int i = 0 ; i < EeLXxxcIkN - 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 jWzVraDdsB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jWzVraDdsB = sc . nextInt ( ) ; int [ ] B = new int [ jWzVraDdsB - 1 ] ; for ( int i = 0 ; i < jWzVraDdsB - 1 ; i ++ ) B [ i ] = sc . nextInt ( ) ; int count = B [ 0 ] ; for ( int i = 0 ; i < jWzVraDdsB - 2 ; i ++ ) { if ( B [ i ] < B [ i + 1 ] ) count += B [ i ] ; else count += B [ i + 1 ] ; } count += B [ jWzVraDdsB - 2 ] ; System . out . println ( count ) ; } } import java . util . Scanner ; public class SiEzdzTKcG { public static void main ( String [ ] s ) { Scanner sc = new Scanner ( System . in ) ; int SiEzdzTKcG = 0 ; if ( sc . hasNextInt ( ) ) SiEzdzTKcG = sc . nextInt ( ) ; int cnt = 0 ; boolean res = false ; while ( SiEzdzTKcG -- != 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 BPhUzFnpIT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BPhUzFnpIT = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] a = new int [ BPhUzFnpIT ] ; 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 nUkNAiJaBU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nUkNAiJaBU = 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 JwZRsIqACs { 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 JwZRsIqACs = 0 ; JwZRsIqACs < v . length ; JwZRsIqACs ++ ) { v [ JwZRsIqACs ] = Integer . parseInt ( k [ JwZRsIqACs ] ) ; } int count = 0 ; for ( int JwZRsIqACs = v [ 0 ] ; JwZRsIqACs <= v [ 1 ] ; JwZRsIqACs ++ ) { if ( v [ 2 ] % JwZRsIqACs == 0 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class idVJpjyNki { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int idVJpjyNki = 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 ( ) != idVJpjyNki ) 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 HMGYpflwMU { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int HMGYpflwMU = Integer . parseInt ( S . substring ( 0 , 2 ) ) ; int last2 = Integer . parseInt ( S . substring ( 2 , 4 ) ) ; String result = " " ; if ( 1 <= HMGYpflwMU && HMGYpflwMU <= 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 yKbqxyopxP { 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 yKbqxyopxP = Integer . parseInt ( tmpArray [ 0 ] ) ; int b = Integer . parseInt ( tmpArray [ 1 ] ) ; if ( yKbqxyopxP == 0 && b == 0 ) { break ; } for ( int i = 0 ; i < yKbqxyopxP ; 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 ynqWMgFMbs { 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 ynqWMgFMbs { 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 WQLVuFePJa { 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 WQLVuFePJa = 0 ; WQLVuFePJa < line . length ( ) ; WQLVuFePJa ++ ) { String str = Character . toString ( line . charAt ( WQLVuFePJa ) ) . 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 dawwWTLUnk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dawwWTLUnk = 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 yPxxKYveIc { 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 yPxxKYveIc = 0 ; yPxxKYveIc < in . length ( ) ; yPxxKYveIc ++ ) x [ yPxxKYveIc ] = in . charAt ( yPxxKYveIc ) - '0' ; System . out . println ( Arrays . stream ( x ) . parallel ( ) . sum ( ) ) ; } } import java . util . * ; public class GzVMbnnyJI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String N = sc . next ( ) ; sc . close ( ) ; String [ ] arr = N . split ( " " ) ; int GzVMbnnyJI = Integer . valueOf ( N ) ; int sn = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { sn += Integer . valueOf ( arr [ i ] ) ; } if ( GzVMbnnyJI % sn == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class eseiFENoDA { private static int digitSum ( int input ) { int eseiFENoDA = 0 ; int tmp = 1 ; while ( tmp <= input ) { eseiFENoDA += ( input / tmp ) % 10 ; tmp *= 10 ; } return eseiFENoDA ; } 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 yJUOKVQEhS { public static void main ( String [ ] args ) { int [ ] a ; int yJUOKVQEhS = 0 , count = 1 ; a = new int [ 100000 ] ; a [ 0 ] = 1 ; Scanner n = new Scanner ( System . in ) ; while ( a [ yJUOKVQEhS ] != 0 ) { yJUOKVQEhS ++ ; a [ yJUOKVQEhS ] = n . nextInt ( ) ; if ( a [ yJUOKVQEhS ] != 0 ) { count += 1 ; } } yJUOKVQEhS = 1 ; while ( count > yJUOKVQEhS ) { System . out . println ( " Case " + yJUOKVQEhS + " : " + a [ yJUOKVQEhS ] ) ; yJUOKVQEhS ++ ; } } } import java . util . * ; public class rQUqWlujfD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rQUqWlujfD = sc . nextInt ( ) ; int num = 1 ; for ( int i = 0 ; i < 9 ; i ++ ) { if ( rQUqWlujfD - 111 > 0 ) { rQUqWlujfD -= 111 ; } else { num += i ; break ; } } System . out . println ( num * 111 ) ; } } import java . io . * ; import java . util . * ; public class NcWsEeAwPp { public static void main ( String [ ] args ) { int NcWsEeAwPp , q , time = 0 ; Queue < String > queueName = new ArrayDeque < String > ( ) ; Queue < Integer > queueTime = new ArrayDeque < Integer > ( ) ; Scanner sc = new Scanner ( System . in ) ; NcWsEeAwPp = sc . nextInt ( ) ; q = sc . nextInt ( ) ; sc . nextLine ( ) ; for ( int i = 0 ; i < NcWsEeAwPp ; 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 JkhFFSDzeX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JkhFFSDzeX ; String str ; while ( true ) { str = sc . next ( ) ; if ( str . equals ( " - " ) ) { break ; } String str1 ; String str2 ; int m ; m = sc . nextInt ( ) ; int h ; for ( JkhFFSDzeX = 0 ; JkhFFSDzeX < m ; JkhFFSDzeX ++ ) { 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 QuOVsixcTe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] S = sc . next ( ) . toCharArray ( ) ; String output = " Good " ; for ( int QuOVsixcTe = 0 ; QuOVsixcTe < S . length - 1 ; QuOVsixcTe ++ ) { if ( S [ QuOVsixcTe ] == S [ QuOVsixcTe + 1 ] ) { output = " Bad " ; break ; } } System . out . println ( output ) ; } } import java . util . Scanner ; public class mbAUGgtgLN { 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 mbAUGgtgLN = 0 ; int idxb = 0 ; int idxc = 0 ; char temp = 'A' ; while ( true ) { if ( temp == 'A' ) { if ( mbAUGgtgLN >= a . length ( ) ) { break ; } temp = a . charAt ( mbAUGgtgLN ) ; mbAUGgtgLN ++ ; } 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 xGKCZpUkFQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long xGKCZpUkFQ = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; long ansA , ansB ; if ( xGKCZpUkFQ - k >= 0 ) { ansA = xGKCZpUkFQ - k ; } else { ansA = 0 ; } k -= xGKCZpUkFQ ; 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 aXPpztjoeC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aXPpztjoeC = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( aXPpztjoeC == B ) { System . out . println ( " IMPOSSIBLE " ) ; } else if ( ( aXPpztjoeC + B ) % 2 == 0 ) { System . out . println ( ( aXPpztjoeC + B ) / 2 ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } sc . close ( ) ; } } import java . io . * ; public class snFGCHeBIr { 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 snFGCHeBIr = line . indexOf ( " " ) ; final int x = Integer . parseInt ( line . substring ( 0 , snFGCHeBIr ) ) ; final int y = Integer . parseInt ( line . substring ( snFGCHeBIr + 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 wUZeaRxVQJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wUZeaRxVQJ = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i <= wUZeaRxVQJ ; 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 TUpVWiZjPp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int TUpVWiZjPp = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int q = scan . nextInt ( ) ; int [ ] a = new int [ TUpVWiZjPp + 1 ] ; int i ; for ( i = 0 ; i < q ; i ++ ) a [ scan . nextInt ( ) ] ++ ; int border = q - k ; for ( i = 1 ; i <= TUpVWiZjPp ; i ++ ) { if ( a [ i ] > border ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class uPlOIvzKab { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int uPlOIvzKab = in . nextInt ( ) ; int [ ] value = new int [ uPlOIvzKab ] ; int a = 0 ; int b = 0 ; for ( int i = 0 ; i < uPlOIvzKab ; 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 < uPlOIvzKab ; 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 uywQVIvqvQ { static Scanner sc = new Scanner ( ) ; public static void main ( final String [ ] args ) throws IOException { int uywQVIvqvQ = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] c = s . toCharArray ( ) ; char temp = c [ 0 ] ; int ans = 1 ; for ( int i = 1 ; i < uywQVIvqvQ ; i ++ ) { if ( c [ i ] != temp ) { temp = c [ i ] ; ans ++ ; } } System . out . println ( ans ) ; } static class uywQVIvqvQ { 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 OVoQUFYDvH { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String s = input . nextLine ( ) ; for ( int OVoQUFYDvH = 0 ; OVoQUFYDvH < s . length ( ) ; OVoQUFYDvH ++ ) { System . out . print ( " x " ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class shwFKDjqpL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int shwFKDjqpL = 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 < shwFKDjqpL ; 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 ozIZLUYdKi { char ozIZLUYdKi ; 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 ++ ) { ozIZLUYdKi = str . charAt ( i ) ; if ( '0' > ozIZLUYdKi || ozIZLUYdKi > '9' ) { System . out . println ( " No " ) ; return ; } } if ( str . charAt ( a ) != '-' ) { System . out . println ( " No " ) ; return ; } for ( int i = a + 1 ; i <= a + b ; i ++ ) { ozIZLUYdKi = str . charAt ( i ) ; if ( '0' > ozIZLUYdKi || ozIZLUYdKi > '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 pVatxfLTHi { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; Queue < Character > [ ] queues = new Queue [ 3 ] ; for ( int pVatxfLTHi = 0 ; pVatxfLTHi < 3 ; pVatxfLTHi ++ ) { queues [ pVatxfLTHi ] = new LinkedList < > ( ) ; for ( char ch : scanner . next ( ) . toCharArray ( ) ) queues [ pVatxfLTHi ] . 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 bHwBjszvBA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bHwBjszvBA = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < bHwBjszvBA ; 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 QEZAgPhAKh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int QEZAgPhAKh = scanner . nextInt ( ) ; int [ ] flowersHeight = new int [ QEZAgPhAKh ] ; int maxFlowerHeight = 0 ; for ( int i = 0 ; i < QEZAgPhAKh ; ++ 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 < QEZAgPhAKh ; ++ 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 == QEZAgPhAKh ) break loop ; } } ++ wateringTimes ; } System . out . print ( wateringTimes ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class ZlLVouIKet { 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 ZlLVouIKet = s . nextLine ( ) ; System . out . println ( 8 - map . get ( ZlLVouIKet ) ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class CGobCnZlAE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long CGobCnZlAE = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; long c = ( b * b ) - ( CGobCnZlAE * CGobCnZlAE ) ; long d = 2 * b - 2 * CGobCnZlAE ; if ( c % d == 0 ) System . out . println ( c / d ) ; else System . out . println ( " IMPOSSIBLE " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class hbZFzuDfvq { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int hbZFzuDfvq = s . nextInt ( ) ; ArrayList < Long > list = new ArrayList < > ( ) ; long num = 1 ; while ( num != hbZFzuDfvq + 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 KZVsxArWzK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KZVsxArWzK = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( lcm ( KZVsxArWzK , B ) ) ; } public static long lcm ( int KZVsxArWzK , int B ) { int temp ; long C = KZVsxArWzK ; C *= B ; while ( ( temp = KZVsxArWzK % B ) != 0 ) { KZVsxArWzK = B ; B = temp ; } return ( C / B ) ; } } import java . util . Scanner ; public class ygJnjpyugz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( ( System . in ) ) ; int ygJnjpyugz = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) , ans = " Yes " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i == ( ygJnjpyugz ) ) { 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 jivkehTkFs { 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 QvnbKyilqz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long QvnbKyilqz = sc . nextLong ( ) ; int k = 1 ; long z = 26L ; long d = 0L ; while ( z < QvnbKyilqz ) { d = z ; k ++ ; z += ( long ) Math . pow ( 26 , k ) ; } long y = QvnbKyilqz - 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 UHDnKlirlk { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int UHDnKlirlk = sc . nextInt ( ) ; int [ ] h = new int [ UHDnKlirlk ] ; for ( int i = 0 ; i < UHDnKlirlk ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int max = h [ 0 ] ; boolean b = true ; for ( int i = 0 ; i < UHDnKlirlk ; 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 PFKwJSemvK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PFKwJSemvK = sc . nextInt ( ) ; int Sum = 0 ; List < String > listA = new ArrayList < String > ( ) ; for ( int i = 0 ; i < PFKwJSemvK ; 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 kLxPbPxTvR { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String kLxPbPxTvR = scan . next ( ) ; String b = scan . next ( ) ; String c = scan . next ( ) ; String next = " a " ; while ( true ) { if ( next . equals ( " a " ) && kLxPbPxTvR . length ( ) > 0 ) { next = kLxPbPxTvR . substring ( 0 , 1 ) ; kLxPbPxTvR = kLxPbPxTvR . 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 VwqqQrvudd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VwqqQrvudd = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int ans = 2000 ; for ( int i = 0 ; i < VwqqQrvudd ; 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 MBtZsJyrHH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int MBtZsJyrHH = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; if ( MBtZsJyrHH == 0 && w == 0 ) break ; for ( int i = 0 ; i < MBtZsJyrHH ; 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 KtRkytDIsO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = " " ; while ( sc . hasNext ( ) ) { int KtRkytDIsO = 0 ; s = sc . nextLine ( ) ; if ( s . equalsIgnoreCase ( " ssr " ) || s . equalsIgnoreCase ( " srs " ) || s . equalsIgnoreCase ( " rss " ) || s . equalsIgnoreCase ( " rsr " ) ) { KtRkytDIsO = 1 ; } else if ( s . equalsIgnoreCase ( " rrs " ) || s . equalsIgnoreCase ( " srr " ) ) { KtRkytDIsO = 2 ; } else if ( s . equalsIgnoreCase ( " rrr " ) ) { KtRkytDIsO = 3 ; } else KtRkytDIsO = 0 ; System . out . println ( KtRkytDIsO ) ; } } } import java . util . Scanner ; public class DKEkrXxbwr { public static void main ( String [ ] args ) { int DKEkrXxbwr , B , C , D ; Scanner scan = new Scanner ( System . in ) ; DKEkrXxbwr = scan . nextInt ( ) ; B = scan . nextInt ( ) ; C = scan . nextInt ( ) ; D = scan . nextInt ( ) ; while ( true ) { if ( DKEkrXxbwr <= 0 || C <= 0 ) break ; C -= B ; if ( DKEkrXxbwr <= 0 || C <= 0 ) break ; DKEkrXxbwr -= D ; } if ( C <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class pstwRYDDRV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pstwRYDDRV = sc . nextInt ( ) ; int [ ] h = new int [ pstwRYDDRV ] ; for ( int i = 0 ; i < pstwRYDDRV ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; while ( true ) { int l = pstwRYDDRV ; int r = pstwRYDDRV - 1 ; for ( int i = 0 ; i < pstwRYDDRV ; i ++ ) { if ( h [ i ] > 0 ) { l = Math . min ( l , i ) ; } else if ( l < i ) { r = i - 1 ; break ; } } if ( l == pstwRYDDRV ) 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 iNWyHsdHnS { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String str = s . next ( ) ; char [ ] alphabet = new char [ 26 ] ; char iNWyHsdHnS = 'a' ; for ( int i = 0 ; i < 26 ; i ++ ) { alphabet [ i ] = iNWyHsdHnS ++ ; 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 tpDFBKimMv { public static void main ( String [ ] arg ) { Scanner ob = new Scanner ( System . in ) ; int tpDFBKimMv = 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 BiKfFWPItO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BiKfFWPItO = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] arr = new int [ BiKfFWPItO ] ; Arrays . fill ( arr , 0 ) ; for ( int i = 0 ; i < 2 * M ; i ++ ) { int a = sc . nextInt ( ) ; for ( int j = 1 ; j <= BiKfFWPItO ; j ++ ) { if ( a == j ) { arr [ j - 1 ] ++ ; } } } for ( int i = 0 ; i < BiKfFWPItO ; i ++ ) { System . out . println ( arr [ i ] ) ; } } } import java . util . Scanner ; public class ltfVullEDg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ltfVullEDg = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int y = 0 ; for ( int x = ltfVullEDg ; x <= b ; x ++ ) { if ( c % x == 0 ) { y ++ ; } } System . out . println ( y ) ; } } import java . util . Scanner ; class jOENQqawWH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int jOENQqawWH = 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 " ) ) { jOENQqawWH ++ ; } else { jOENQqawWH = 0 ; } if ( maxCount < jOENQqawWH ) { maxCount = jOENQqawWH ; } } System . out . println ( maxCount ) ; } } import java . io . * ; import java . util . * ; public class rTgjQWqDCD { public static void main ( final String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; long rTgjQWqDCD ; rTgjQWqDCD = sc . nextLong ( ) ; long B ; B = sc . nextLong ( ) ; final Solver solver = new Solver ( ) ; solver . solve ( rTgjQWqDCD , B ) ; } } class rTgjQWqDCD { public void solve ( long rTgjQWqDCD , long B ) { System . out . println ( rTgjQWqDCD * B / lcd ( rTgjQWqDCD , B ) ) ; } private long lcd ( long rTgjQWqDCD , long B ) { if ( B == 0 ) { return rTgjQWqDCD ; } return lcd ( B , rTgjQWqDCD % B ) ; } } import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; import java . util . TreeMap ; public class xvONxrFvsu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xvONxrFvsu = sc . nextInt ( ) ; Map < String , Integer > m = new TreeMap < String , Integer > ( ) ; int max = 0 ; for ( int i = 0 ; i < xvONxrFvsu ; 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 wFkzmIBdgs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int wFkzmIBdgs = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] lots = new int [ wFkzmIBdgs ] ; for ( int i = 1 ; i <= wFkzmIBdgs ; ++ 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 < wFkzmIBdgs ; ++ 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 bvmIcPZxDu { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int bvmIcPZxDu = in . nextInt ( ) ; for ( int n = bvmIcPZxDu ; n < 1000 ; n ++ ) { if ( n % 111 == 0 ) { System . out . println ( n ) ; return ; } } } } } import java . util . Scanner ; public class meKGBAjzQM { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int meKGBAjzQM = scan . nextInt ( ) ; for ( int h = 0 ; h < 241 ; h ++ ) { if ( meKGBAjzQM >= 3600 ) { meKGBAjzQM = meKGBAjzQM - 3600 ; } else { System . out . print ( h + " : " ) ; break ; } } for ( int m = 0 ; m < 60 ; m ++ ) { if ( meKGBAjzQM >= 60 ) { meKGBAjzQM = meKGBAjzQM - 60 ; } else { System . out . println ( m + " : " + meKGBAjzQM ) ; break ; } } } } import java . io . * ; import java . util . StringTokenizer ; public class DkxWTZuTPf { public static void main ( String [ ] args ) { final FastScanner fs = new FastScanner ( ) ; final int [ ] arr = fs . nextIntArray ( ) ; int DkxWTZuTPf = 0 ; for ( int i : arr ) { DkxWTZuTPf += countDiv ( i ) ; } System . out . println ( DkxWTZuTPf ) ; } static int countDiv ( int n ) { int i = 0 ; while ( n != 0 && n % 2 == 0 ) { n /= 2 ; i ++ ; } return i ; } public static class DkxWTZuTPf { 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 IYztwEimaG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IYztwEimaG = sc . nextInt ( ) ; long co = 0 ; HashMap < String , Long > l = new HashMap < String , Long > ( ) ; for ( int i = 0 ; i < IYztwEimaG ; 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 lDUhGYDIcK { 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 lDUhGYDIcK ; for ( lDUhGYDIcK = 0 ; lDUhGYDIcK < 25 ; lDUhGYDIcK ++ ) { if ( alp [ lDUhGYDIcK ] . equals ( str ) ) { break ; } } System . out . println ( alp [ lDUhGYDIcK + 1 ] ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; class JwCmuGGiQz { public static void main ( String [ ] args ) throws IOException { int JwCmuGGiQz , 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 ] ) ; JwCmuGGiQz = getD ( a , b ) ; r = getR ( a , b ) ; f = getF ( a , b ) ; System . out . printf ( " %d %d %.5f " , JwCmuGGiQz , 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 dUBHYiZvUP { 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 dUBHYiZvUP = parseInt ( scan . nextLine ( ) ) ; for ( int i = 0 ; i < dUBHYiZvUP ; 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 fIvbleoCCB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fIvbleoCCB = Integer . parseInt ( sc . next ( ) ) ; int L = Integer . parseInt ( sc . next ( ) ) ; int [ ] data = new int [ fIvbleoCCB ] ; int sum = 0 ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < fIvbleoCCB ; 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 ioTBARRvCX { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long ioTBARRvCX = scanner . nextLong ( ) ; long a = scanner . nextLong ( ) ; long b = scanner . nextLong ( ) ; if ( a == 0 ) { System . out . println ( " 0 " ) ; return ; } long d = a + b ; long q = ioTBARRvCX / d ; long r = ioTBARRvCX % d ; long blue = ( q * a ) + ( a < r ? a : r ) ; System . out . println ( blue ) ; } } import java . util . Scanner ; public class vCufSKbSjv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vCufSKbSjv = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int count = 0 ; for ( int x = 0 ; x <= vCufSKbSjv ; x ++ ) { for ( int y = 0 ; y <= vCufSKbSjv ; y ++ ) { int z = S - ( x + y ) ; if ( 0 <= z && z <= vCufSKbSjv ) { count ++ ; } } } System . out . print ( count ) ; } } import java . util . Scanner ; class GDftISSKkC { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int GDftISSKkC = in . nextInt ( ) ; if ( GDftISSKkC == 0 ) break ; int [ ] numbers = new int [ GDftISSKkC ] ; long double_sum = 0 ; long sum_double = 0 ; for ( int i = 0 ; i < GDftISSKkC ; i ++ ) { numbers [ i ] = in . nextInt ( ) ; double_sum += numbers [ i ] ; } double_sum = double_sum * double_sum ; for ( int i = 0 ; i < GDftISSKkC ; i ++ ) sum_double += ( numbers [ i ] * numbers [ i ] ) ; double sd = Math . sqrt ( ( sum_double - double_sum / ( double ) GDftISSKkC ) / ( double ) GDftISSKkC ) ; System . out . printf ( " %5.8f " , sd ) ; System . out . println ( ) ; } } } import java . util . Scanner ; public class uGMPpJOYjF { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int uGMPpJOYjF = sc . nextInt ( ) ; int tt = 0 ; int tx = 0 ; int ty = 0 ; for ( int i = 0 ; i < uGMPpJOYjF ; 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 SKTFnUXcAt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SKTFnUXcAt = sc . nextInt ( ) ; long [ ] h = new long [ SKTFnUXcAt ] ; for ( int i = 0 ; i < SKTFnUXcAt ; i ++ ) { h [ i ] = sc . nextLong ( ) ; } long max = 0 , count = 0 ; for ( int i = 0 ; i < SKTFnUXcAt - 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 anCxzgiNSz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long anCxzgiNSz = sc . nextLong ( ) ; String alphabet = " abcdefghijklmnopqrstuvwxyz " ; String name = " " ; while ( anCxzgiNSz > 0 ) { anCxzgiNSz -- ; long remain = anCxzgiNSz % 26l ; name = alphabet . charAt ( ( int ) remain ) + name ; anCxzgiNSz = anCxzgiNSz / 26l ; } System . out . println ( name ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class wzbMGJIhCj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int wzbMGJIhCj = Integer . parseInt ( br . readLine ( ) ) ; int sum = ( int ) ( wzbMGJIhCj + Math . pow ( ( double ) wzbMGJIhCj , 2.0 ) + Math . pow ( ( double ) wzbMGJIhCj , 3.0 ) ) ; System . out . println ( sum ) ; } } import java . io . * ; import java . util . * ; public class SLNsriyxvr { 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 SLNsriyxvr = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '+' ) SLNsriyxvr ++ ; else SLNsriyxvr -- ; } out . println ( SLNsriyxvr ) ; out . flush ( ) ; out . close ( ) ; } static class SLNsriyxvr { 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 ImlvOihAMb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ImlvOihAMb = sc . nextLong ( ) ; double b = sc . nextDouble ( ) ; int c = ( int ) Math . round ( 100 * b ) ; System . out . println ( ( long ) ( ImlvOihAMb * c ) / 100 ) ; } } public class elCClCbKWn { public static void main ( String [ ] args ) { int elCClCbKWn = new java . util . Scanner ( System . in ) . nextInt ( ) ; int pay = 0 ; while ( pay < elCClCbKWn ) { pay += 1000 ; } System . out . println ( pay - elCClCbKWn ) ; } } import java . util . * ; class YeDWzECJLI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YeDWzECJLI = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int count = 0 ; for ( int ca = 0 ; ca < YeDWzECJLI + 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 LcHgMJcEmW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = " " ; String [ ] data = a . split ( " " ) ; for ( int LcHgMJcEmW = 0 ; data . length > LcHgMJcEmW ; LcHgMJcEmW ++ ) { if ( LcHgMJcEmW == 3 ) { data [ LcHgMJcEmW ] = " 8 " ; b = b + data [ LcHgMJcEmW ] ; } else { b = b + data [ LcHgMJcEmW ] ; } } 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 wSjfKuZGlp { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wSjfKuZGlp = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; int count = 0 ; if ( b + c - wSjfKuZGlp <= 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( b + c - wSjfKuZGlp ) ; } } } import java . util . Scanner ; public class MKSzJXNNsS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MKSzJXNNsS = Integer . parseInt ( sc . next ( ) ) ; int N = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; if ( N != 100 ) { int answer = ( int ) ( N * Math . pow ( 100 , MKSzJXNNsS ) ) ; System . out . println ( answer ) ; return ; } else { int answer = ( int ) ( 101 * Math . pow ( 100 , MKSzJXNNsS ) ) ; System . out . println ( answer ) ; return ; } } } import java . util . Scanner ; class QgLesjyfCl { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int QgLesjyfCl = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = ( int ) Math . log10 ( QgLesjyfCl + b ) + 1 ; System . out . println ( c ) ; } } } import java . util . Scanner ; public class NeqMTfvNbc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NeqMTfvNbc = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; for ( int i = 1 ; i <= NeqMTfvNbc ; i ++ ) { if ( y == ( i * 2 ) + ( ( NeqMTfvNbc - i ) * 4 ) ) { System . out . println ( " Yes " ) ; return ; } } for ( int i = 1 ; i <= NeqMTfvNbc ; i ++ ) { if ( y == ( i * 4 ) + ( ( NeqMTfvNbc - i ) * 2 ) ) { System . out . println ( " Yes " ) ; return ; } } for ( int i = 1 ; i <= NeqMTfvNbc / 2 ; i ++ ) { if ( y == i * 2 ) { System . out . println ( " Yes " ) ; return ; } } for ( int i = 1 ; i <= NeqMTfvNbc / 4 ; i ++ ) { if ( y == i * 4 ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class VSLLScGAEM { int VSLLScGAEM ; int ans ; public void shori ( ) { Scanner sc = new Scanner ( System . in ) ; VSLLScGAEM = sc . nextInt ( ) ; ans = VSLLScGAEM * VSLLScGAEM * VSLLScGAEM ; System . out . println ( ans ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { Main obj = new Main ( ) ; obj . shori ( ) ; } } import java . util . * ; public class zEyOpQBfXo { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int zEyOpQBfXo = 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 = zEyOpQBfXo - j ; int max = zEyOpQBfXo + j ; String mi = String . valueOf ( min ) ; String ma = String . valueOf ( max ) ; if ( ! Arrays . asList ( p ) . contains ( mi ) ) { System . out . println ( zEyOpQBfXo - j ) ; return ; } if ( ! Arrays . asList ( p ) . contains ( ma ) ) { System . out . println ( zEyOpQBfXo + j ) ; return ; } } scn . close ( ) ; } } import java . util . Scanner ; public class JnFRmfeqpV { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int JnFRmfeqpV = scan . nextInt ( ) ; int alpha = 0 ; int sum = 0 ; for ( int i = 1 ; i <= JnFRmfeqpV ; i ++ ) { for ( int j = 1 ; j <= JnFRmfeqpV ; j ++ ) { for ( int k = 1 ; k <= JnFRmfeqpV ; k ++ ) { alpha = gcd ( i , j ) ; sum += gcd ( alpha , k ) ; } } } System . out . println ( sum ) ; } public static int fac ( int JnFRmfeqpV ) { if ( JnFRmfeqpV == 1 ) { return 1 ; } else { return fac ( JnFRmfeqpV - 1 ) * JnFRmfeqpV ; } } public static int pow ( int JnFRmfeqpV ) { return JnFRmfeqpV * JnFRmfeqpV * JnFRmfeqpV ; } 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 HeaaFjvgHH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HeaaFjvgHH = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; int max = 0 ; for ( int i = 0 ; i < HeaaFjvgHH ; 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 kUFvlBUqxI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kUFvlBUqxI = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int ninzuu = 0 ; D = D * 2 + 1 ; do { kUFvlBUqxI = kUFvlBUqxI - D ; ninzuu ++ ; } while ( kUFvlBUqxI > 0 ) ; System . out . println ( ninzuu ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; public class QABwRvGOfm { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int QABwRvGOfm = sc . nextInt ( ) ; int [ ] s = new int [ QABwRvGOfm ] ; for ( int i = 0 ; i < QABwRvGOfm ; 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 , QABwRvGOfm , t ) >= 0 ) ans ++ ; } System . out . println ( ans ) ; } static int binarySearch ( int [ ] a , int QABwRvGOfm , int key ) { int left = 0 ; int right = QABwRvGOfm ; 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 QABwRvGOfm { 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 ujJDummWvX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ujJDummWvX = sc . nextLong ( ) ; List < Long > divisor = divisor ( ujJDummWvX ) ; long min = 1000000000001L ; for ( Long elm : divisor ) { min = Math . min ( min , elm + ( ujJDummWvX / elm ) ) ; } long ans = min - 2 ; System . out . println ( ans ) ; } static List < Long > divisor ( long ujJDummWvX ) { Set < Long > ret = new HashSet < > ( ) ; for ( long i = 1 ; i * i <= ujJDummWvX ; i ++ ) { if ( ujJDummWvX % i == 0 ) { ret . add ( i ) ; if ( i != ujJDummWvX / i ) ret . add ( ujJDummWvX / i ) ; } } return ret . stream ( ) . sorted ( Comparator . naturalOrder ( ) ) . collect ( Collectors . toList ( ) ) ; } } import java . util . * ; import java . math . * ; import java . io . * ; public class KRThRmvmNo { 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 KRThRmvmNo { public long KRThRmvmNo ; public long second ; public Pair ( ) { this ( 0 , 0 ) ; } public Pair ( final long KRThRmvmNo , final long second ) { this . KRThRmvmNo = KRThRmvmNo ; this . second = second ; } } } import java . util . Arrays ; import java . util . Scanner ; public class ApidzWXRaG { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ApidzWXRaG = scanner . nextInt ( ) ; int A2 = scanner . nextInt ( ) ; int A3 = scanner . nextInt ( ) ; scanner . close ( ) ; int [ ] A = { ApidzWXRaG , A2 , A3 } ; Arrays . sort ( A ) ; System . out . println ( A [ 2 ] - A [ 0 ] ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class ZCnhWOCUCN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ZCnhWOCUCN = sc . next ( ) ; String tmpS = " " ; while ( ! ZCnhWOCUCN . equals ( tmpS ) ) { if ( ZCnhWOCUCN . endsWith ( " dreamer " + tmpS ) ) { tmpS = " dreamer " + tmpS ; } else if ( ZCnhWOCUCN . endsWith ( " dream " + tmpS ) ) { tmpS = " dream " + tmpS ; } else if ( ZCnhWOCUCN . endsWith ( " eraser " + tmpS ) ) { tmpS = " eraser " + tmpS ; } else if ( ZCnhWOCUCN . 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 zPqeHVnLZs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int zPqeHVnLZs = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int ans = 0 ; for ( ; 0 < k ; k -- ) { if ( zPqeHVnLZs > 0 ) { zPqeHVnLZs -- ; ans ++ ; } else if ( b > 0 ) { b -- ; } else { ans -- ; } } System . out . println ( ans ) ; } } import java . util . * ; class dCUXUCghKt { 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 dCUXUCghKt = 0 ; for ( int i = 1 ; i < str . length ( ) ; i ++ ) { if ( tmp . equals ( str . substring ( i , i + 1 ) ) ) { dCUXUCghKt ++ ; tmp = tmp . equals ( " 0 " ) ? " 1 " : " 0 " ; } else { tmp = str . substring ( i , i + 1 ) ; } } return dCUXUCghKt ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class ZUPogsPwPC { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strAry = br . readLine ( ) . split ( " " ) ; int ZUPogsPwPC = Integer . parseInt ( strAry [ 0 ] ) ; int y = Integer . parseInt ( strAry [ 1 ] ) ; int z = Integer . parseInt ( strAry [ 2 ] ) ; String result ; result = ZUPogsPwPC >= y ? " No " : y < z ? " Yes " : " No " ; System . out . println ( result ) ; } } import java . util . Scanner ; public class rhsaZZaACZ { public static void main ( String [ ] args ) { int rhsaZZaACZ , M , ans = 0 ; int [ ] [ ] Food ; Scanner scan = new Scanner ( System . in ) ; rhsaZZaACZ = scan . nextInt ( ) ; M = scan . nextInt ( ) ; Food = new int [ rhsaZZaACZ + 1 ] [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { Food [ rhsaZZaACZ ] [ i ] = 1 ; } int A , K ; for ( int i = 0 ; i < rhsaZZaACZ ; 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 < rhsaZZaACZ ; j ++ ) { Food [ rhsaZZaACZ ] [ i ] *= Food [ j ] [ i ] ; } } for ( int i = 0 ; i < M ; i ++ ) { ans += Food [ rhsaZZaACZ ] [ i ] ; } System . out . print ( ans ) ; } } import java . util . * ; public class hLNlWNvhBR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hLNlWNvhBR = sc . nextInt ( ) ; int [ ] card = new int [ hLNlWNvhBR ] ; int alice = 0 ; int bob = 0 ; for ( int i = 0 ; i < hLNlWNvhBR ; i ++ ) { card [ i ] = sc . nextInt ( ) ; } Arrays . sort ( card ) ; for ( int i = ( hLNlWNvhBR - 1 ) ; i >= 0 ; i -= 2 ) { alice += card [ i ] ; } for ( int j = ( hLNlWNvhBR - 2 ) ; j >= 0 ; j -= 2 ) { bob += card [ j ] ; } int division = alice - bob ; System . out . println ( division ) ; } } import java . util . * ; class rjrFRhRbvI { Scanner sc ; int rjrFRhRbvI ; private void calc ( ) { sc = new Scanner ( System . in ) ; rjrFRhRbvI = sc . nextInt ( ) ; double l = rjrFRhRbvI / 3d ; System . out . println ( l * l * l ) ; } public static void main ( String [ ] args ) { new Main ( ) . calc ( ) ; } } import java . util . * ; public class eHPgrWUwCp { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; int eHPgrWUwCp = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; if ( b + c <= eHPgrWUwCp ) { System . out . println ( " 0 " ) ; } else { System . out . println ( b + c - eHPgrWUwCp ) ; } } } import java . util . Scanner ; import java . util . List ; import java . util . ArrayList ; import java . util . Objects ; import java . lang . StringBuilder ; public class NZJnJGpsFn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int NZJnJGpsFn = 0 ; NZJnJGpsFn < 5 ; NZJnJGpsFn ++ ) { int a = sc . nextInt ( ) ; list . add ( a ) ; } int k = sc . nextInt ( ) ; boolean cantConnect = false ; for ( int NZJnJGpsFn = 0 ; NZJnJGpsFn < list . size ( ) ; NZJnJGpsFn ++ ) { for ( int j = NZJnJGpsFn + 1 ; j < list . size ( ) ; j ++ ) { if ( list . get ( j ) - list . get ( NZJnJGpsFn ) > k ) cantConnect = true ; } } System . out . println ( cantConnect ? " :( " : " Yay! " ) ; } } import java . io . BufferedInputStream ; import java . io . IOException ; import java . util . Scanner ; public class qvEfiAdWip { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( new BufferedInputStream ( System . in ) ) ; int qvEfiAdWip = scanner . nextInt ( ) ; int t = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; double need = ( double ) qvEfiAdWip / s ; System . out . println ( need <= t ? " Yes " : " No " ) ; } } import java . util . * ; import java . io . * ; public class dXLrIyIgit { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dXLrIyIgit = sc . nextInt ( ) ; int max = 0 ; int total = 0 ; for ( int i = 0 ; i < dXLrIyIgit ; 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 rCfFSUhOUX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rCfFSUhOUX = sc . nextInt ( ) ; int point = sc . nextInt ( ) ; int seikai = sc . nextInt ( ) ; int [ ] array = new int [ rCfFSUhOUX ] ; for ( int i = 0 ; i < rCfFSUhOUX ; i ++ ) { array [ i ] = point - seikai ; } for ( int i = 0 ; i < seikai ; i ++ ) { array [ sc . nextInt ( ) - 1 ] ++ ; } for ( int i = 0 ; i < rCfFSUhOUX ; i ++ ) { if ( array [ i ] <= 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } } import java . util . * ; import java . io . * ; public class gFKWdrhbBD { 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 gFKWdrhbBD = Integer . parseInt ( br . readLine ( ) ) ; int a = 0 ; int b = 0 ; String [ ] input = br . readLine ( ) . split ( " " ) ; Integer [ ] numbers = new Integer [ gFKWdrhbBD ] ; for ( int i = 0 ; i < gFKWdrhbBD ; i ++ ) { numbers [ i ] = Integer . valueOf ( input [ i ] ) ; } Arrays . sort ( numbers , Collections . reverseOrder ( ) ) ; for ( int i = 0 ; i < gFKWdrhbBD ; i ++ ) { if ( i % 2 == 0 ) { a += numbers [ i ] ; } else { b += numbers [ i ] ; } } out . println ( a - b ) ; out . close ( ) ; } } import java . util . Scanner ; public class dLlgPJiQMC { 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 dLlgPJiQMC = 0 ; dLlgPJiQMC < s . length ; dLlgPJiQMC ++ ) { if ( s [ dLlgPJiQMC ] != t [ dLlgPJiQMC ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class EdzhDqAaoN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EdzhDqAaoN = sc . nextInt ( ) ; int [ ] a = new int [ EdzhDqAaoN ] ; for ( int i = 0 ; i < EdzhDqAaoN ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; int x = 0 ; int y = 0 ; for ( int i = 0 ; i < EdzhDqAaoN ; i ++ ) { if ( i % 2 == 0 ) { x += a [ i ] ; } else { y += a [ i ] ; } } System . out . println ( Math . abs ( x - y ) ) ; } } import java . util . * ; public class WgmitFWlEs { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } long WgmitFWlEs ; long b ; long c ; long k ; long ans ; public void run ( ) { Scanner sc = new Scanner ( System . in ) ; WgmitFWlEs = sc . nextLong ( ) ; b = sc . nextLong ( ) ; c = sc . nextLong ( ) ; k = sc . nextLong ( ) ; sc . close ( ) ; solve ( ) ; } private void solve ( ) { if ( WgmitFWlEs < k ) { ans = WgmitFWlEs ; k -= WgmitFWlEs ; } 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 GdXJiJjTEB { public static void main ( String [ ] args ) { int GdXJiJjTEB = 0 ; Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . nextLine ( ) . toCharArray ( ) ; for ( int cnt = 0 ; cnt < s . length ; cnt ++ ) { if ( s [ cnt ] == '1' ) { GdXJiJjTEB ++ ; } } System . out . println ( GdXJiJjTEB ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class VTkmqOPtPI { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int VTkmqOPtPI = sc . nextInt ( ) ; double [ ] v = new double [ VTkmqOPtPI ] ; for ( int i = 0 ; i < VTkmqOPtPI ; i ++ ) { v [ i ] = sc . nextDouble ( ) ; } sc . close ( ) ; Arrays . sort ( v ) ; double s = ( v [ 0 ] + v [ 1 ] ) / 2 ; if ( VTkmqOPtPI >= 3 ) { for ( int i = 2 ; i < VTkmqOPtPI ; i ++ ) { s = ( s + v [ i ] ) / 2 ; } } System . out . println ( s ) ; } } import java . util . * ; public class nyRTRkMouY { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int nyRTRkMouY = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int res = 0 ; if ( ( nyRTRkMouY >= 10 ) || ( B >= 10 ) ) { res = - 1 ; } else { res = nyRTRkMouY * B ; } System . out . println ( res ) ; } } import java . util . Scanner ; class OxOOdPsJmn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; boolean OxOOdPsJmn = false ; for ( int i = 0 ; i < 3 ; i ++ ) { OxOOdPsJmn |= ( str . charAt ( i ) == str . charAt ( i + 1 ) ) ; } if ( OxOOdPsJmn ) { System . out . println ( " Bad " ) ; } else { System . out . println ( " Good " ) ; } } } import java . util . * ; public class FFLYHDEmgg { 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 FFLYHDEmgg = 0 ; for ( int i = 0 ; i < S1 . length ; i ++ ) { if ( S1 [ i ] == S2 [ i ] ) { FFLYHDEmgg ++ ; } } if ( FFLYHDEmgg == S1 . length ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class HhLpiIXDZY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] lines = line . split ( " " ) ; boolean HhLpiIXDZY = true ; int before = Integer . parseInt ( lines [ 0 ] ) ; for ( int i = 1 ; i < lines . length ; i ++ ) { int after = Integer . parseInt ( lines [ i ] ) ; if ( before == after ) { HhLpiIXDZY = false ; break ; } before = after ; } if ( HhLpiIXDZY ) { System . out . println ( " Good " ) ; } else { System . out . println ( " Bad " ) ; } } } import java . util . * ; public class gbCQxXUIgl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gbCQxXUIgl = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( 0 <= gbCQxXUIgl && gbCQxXUIgl <= 5 ) { B = 0 ; System . out . print ( B ) ; } else if ( 6 <= gbCQxXUIgl && gbCQxXUIgl <= 12 ) { B = B / 2 ; System . out . print ( B ) ; } else if ( 13 <= gbCQxXUIgl && gbCQxXUIgl <= 100 ) { System . out . print ( B ) ; } } } import java . io . * ; public class KqIgWTtFla { 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 KqIgWTtFla = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; int [ ] [ ] matrix = new int [ KqIgWTtFla ] [ m ] ; int [ ] vector = new int [ m ] ; int [ ] result = new int [ KqIgWTtFla ] ; for ( int i = 0 ; i < KqIgWTtFla ; 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 < KqIgWTtFla ; i ++ ) { for ( int k = 0 ; k < m ; k ++ ) { result [ i ] += matrix [ i ] [ k ] * vector [ k ] ; } } for ( int i = 0 ; i < KqIgWTtFla ; i ++ ) { System . out . println ( result [ i ] ) ; } } } public class hGSlBaZAIJ { 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 hGSlBaZAIJ = 0 ; while ( hGSlBaZAIJ != s . length ( ) ) { if ( s . contains ( p ) ) { System . out . println ( " Yes " ) ; return ; } s = s . substring ( 1 ) + s . charAt ( 0 ) ; hGSlBaZAIJ ++ ; } System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class mWfFIEVuWs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int mWfFIEVuWs = s . length ( ) ; String str1 = s . substring ( 0 , ( mWfFIEVuWs - 1 ) / 2 ) ; String str2 = s . substring ( ( ( mWfFIEVuWs + 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 qfwEmHGzHs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] data = new int [ 10 ] ; for ( int qfwEmHGzHs = 0 ; qfwEmHGzHs < 10 ; qfwEmHGzHs ++ ) { data [ qfwEmHGzHs ] = scan . nextInt ( ) ; } int afterData , beforeIndex ; for ( int qfwEmHGzHs = 1 ; qfwEmHGzHs < 10 ; qfwEmHGzHs ++ ) { afterData = data [ qfwEmHGzHs ] ; beforeIndex = qfwEmHGzHs - 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 iyElRZnxgr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double iyElRZnxgr = sc . nextDouble ( ) ; sc . close ( ) ; long ret = ( long ) ( iyElRZnxgr + Math . pow ( iyElRZnxgr , 2 ) + Math . pow ( iyElRZnxgr , 3 ) ) ; System . out . println ( ret ) ; } } import java . util . * ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; class jMJtYPLuCP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long jMJtYPLuCP = sc . nextLong ( ) ; long R = sc . nextLong ( ) ; long ans = Long . MAX_VALUE ; loop : for ( long i = jMJtYPLuCP ; 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 cZwApRTzvB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int cZwApRTzvB = 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' ) { cZwApRTzvB ++ ; } else { cZwApRTzvB = 0 ; } if ( max < cZwApRTzvB ) { max = cZwApRTzvB ; } } System . out . println ( max ) ; } } import java . util . Scanner ; public class JyBscHJfCi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double JyBscHJfCi = scan . nextDouble ( ) ; scan . close ( ) ; System . out . println ( 2 * JyBscHJfCi * Math . PI ) ; } } import java . util . Scanner ; public class zGolypPpYZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zGolypPpYZ = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int cap1 = zGolypPpYZ - B ; int use = 0 ; if ( cap1 < C ) { use = cap1 ; } else { use = C ; } System . out . println ( C - use ) ; } } import java . util . * ; public class yhbdmcfOvc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yhbdmcfOvc = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int ans = 0 ; aLoop : for ( int a = 0 ; a <= yhbdmcfOvc ; a ++ ) { bLoop : for ( int b = 0 ; b <= yhbdmcfOvc ; b ++ ) { int abSum = a + b ; if ( abSum > s ) { continue aLoop ; } else if ( s - abSum <= yhbdmcfOvc ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . io . * ; public class TqoASCtOAD { 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 TqoASCtOAD = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { TqoASCtOAD = 0 ; for ( int j = 0 ; j < p . length ( ) ; j ++ ) { if ( s . charAt ( ( i + j ) % s . length ( ) ) == p . charAt ( j ) ) { TqoASCtOAD ++ ; } else { break ; } } if ( TqoASCtOAD == p . length ( ) ) { break ; } } if ( TqoASCtOAD == p . length ( ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class gxGMBsapvK { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int gxGMBsapvK = scan . nextInt ( ) ; long b = gxGMBsapvK * gxGMBsapvK * gxGMBsapvK ; System . out . println ( ( double ) b / 27 ) ; } } import java . util . Scanner ; class BnWINZnZoj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BnWINZnZoj = sc . nextInt ( ) ; double x = ( double ) BnWINZnZoj / 3 ; double V = x * x * x ; System . out . println ( V ) ; } } import java . util . Scanner ; public class RCDliaqoFY { public static void main ( String [ ] args ) throws Exception { try ( Scanner sc = new Scanner ( System . in ) ) { String S = sc . next ( ) ; for ( int RCDliaqoFY = 1 ; RCDliaqoFY <= S . length ( ) ; RCDliaqoFY ++ ) { char c = S . charAt ( RCDliaqoFY - 1 ) ; if ( RCDliaqoFY % 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 aEfdNvslFZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aEfdNvslFZ = sc . nextInt ( ) ; boolean flg = true ; for ( int i = 0 ; i < aEfdNvslFZ ; 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 IzyVfGFEDc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IzyVfGFEDc = sc . nextInt ( ) ; int [ ] h = new int [ IzyVfGFEDc ] ; for ( int i = 0 ; i < IzyVfGFEDc ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int cnt = 1 ; int max = h [ 0 ] ; for ( int i = 0 ; i < IzyVfGFEDc - 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 AIZOtvDRIp { public static void main ( String [ ] args ) throws NumberFormatException , IOException { int AIZOtvDRIp , task2 , task3 ; int [ ] cost = new int [ 6 ] ; int ans = 1000 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; AIZOtvDRIp = Integer . parseInt ( str [ 0 ] ) ; task2 = Integer . parseInt ( str [ 1 ] ) ; task3 = Integer . parseInt ( str [ 2 ] ) ; cost [ 0 ] = Math . abs ( AIZOtvDRIp - task2 ) + Math . abs ( task2 - task3 ) ; cost [ 1 ] = Math . abs ( AIZOtvDRIp - task3 ) + Math . abs ( task3 - task2 ) ; cost [ 2 ] = Math . abs ( task2 - AIZOtvDRIp ) + Math . abs ( AIZOtvDRIp - task3 ) ; cost [ 3 ] = Math . abs ( task2 - task3 ) + Math . abs ( task3 - AIZOtvDRIp ) ; cost [ 4 ] = Math . abs ( task3 - AIZOtvDRIp ) + Math . abs ( AIZOtvDRIp - task2 ) ; cost [ 5 ] = Math . abs ( task3 - task2 ) + Math . abs ( task2 - AIZOtvDRIp ) ; for ( int i = 0 ; i < 6 ; i ++ ) { if ( ans > cost [ i ] ) { ans = cost [ i ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class NXEHKAEtcg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NXEHKAEtcg = sc . nextInt ( ) ; int Ri = sc . nextInt ( ) ; int Rj = 1 ; int minv = Ri ; int maxv = Integer . MIN_VALUE ; for ( int i = 1 ; i < NXEHKAEtcg ; 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 IZcRVIkxrV { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . nextLine ( ) ; long IZcRVIkxrV = 0 ; int l = s . length ( ) ; for ( int i = 0 ; i < l ; i ++ ) { int num = Character . getNumericValue ( s . charAt ( i ) ) ; IZcRVIkxrV += num ; } if ( IZcRVIkxrV % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; } } import java . util . * ; class bNofPGOoUY { 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 bNofPGOoUY = 1 ; a += b ; while ( a >= 10 ) { bNofPGOoUY ++ ; a /= 10 ; } return bNofPGOoUY ; } } import java . util . Scanner ; public class RGgfZOjlBk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RGgfZOjlBk = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = 0 ; for ( int i = 0 ; i < RGgfZOjlBk - 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 zZpbljOcri { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] C = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; int zZpbljOcri = 0 ; int oneCnt = 0 ; for ( int i = 0 ; i < C . length ; i ++ ) { if ( C [ i ] == '0' ) { zZpbljOcri ++ ; } else { oneCnt ++ ; } } System . out . println ( Math . min ( zZpbljOcri , oneCnt ) * 2 ) ; } } import java . util . Scanner ; public class lCPgwJCxah { public static void main ( String [ ] args ) { long lCPgwJCxah = 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 ) { lCPgwJCxah = lCPgwJCxah + tmp ; array [ i ] = array [ i ] - ( int ) tmp ; } else { lCPgwJCxah = lCPgwJCxah + array [ i ] ; array [ i ] = 0 ; } tmp = 0 ; } if ( i == n ) { continue ; } if ( array [ i ] >= array2 [ i ] ) { lCPgwJCxah = lCPgwJCxah + array2 [ i ] ; tmp = 0 ; } else { lCPgwJCxah = lCPgwJCxah + array [ i ] ; tmp = ( array2 [ i ] - array [ i ] ) ; } } System . out . println ( lCPgwJCxah ) ; sc . close ( ) ; } } import java . util . * ; public class ceZXzPhcsb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ceZXzPhcsb = sc . nextInt ( ) ; long r = sc . nextInt ( ) ; long min = ceZXzPhcsb * ( ceZXzPhcsb + 1 ) % 2019 ; if ( ( ceZXzPhcsb % 2019 == 0 ) || ( r % 2019 == 0 ) ) { System . out . println ( 0 ) ; } else if ( ( ceZXzPhcsb / 2019 ) != ( r / 2019 ) ) { System . out . println ( 0 ) ; } else if ( ( ceZXzPhcsb / 2019 ) == ( r / 2019 ) ) { for ( long i = ceZXzPhcsb ; 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 HcycuBdyeK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HcycuBdyeK = sc . nextInt ( ) ; boolean f = true ; for ( int i = 0 ; i < HcycuBdyeK ; 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 iGoSjgQgqQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int iGoSjgQgqQ = 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 ++ ; } iGoSjgQgqQ = Math . min ( iGoSjgQgqQ , diff ) ; } System . iGoSjgQgqQ . println ( iGoSjgQgqQ ) ; } } import java . util . Scanner ; public class EuYgnxacZn { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int EuYgnxacZn = 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 > EuYgnxacZn + b ) { t = 1 ; } else { t = 2 ; } if ( t == 2 ) { sum += Math . min ( x , y ) * a_b ; if ( x > y ) { sum += ( x - y ) * EuYgnxacZn ; } else { sum += ( y - x ) * b ; } sum = Math . min ( sum , a_b * ( Math . max ( x , y ) ) ) ; } else { sum += ( x * EuYgnxacZn ) + ( y * b ) ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class LwXJHSZETn { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int LwXJHSZETn = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i <= LwXJHSZETn ; 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 EhYPfYbWBT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EhYPfYbWBT = sc . nextInt ( ) ; int y = EhYPfYbWBT ; if ( EhYPfYbWBT == 2 ) { System . out . println ( 2 ) ; System . exit ( 0 ) ; } else if ( EhYPfYbWBT == 3 ) { System . out . println ( 3 ) ; System . exit ( 0 ) ; } if ( y % 2 == 0 ) { y ++ ; } int n = 3 ; while ( n <= EhYPfYbWBT ) { 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 gICerQrpWm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gICerQrpWm = sc . nextInt ( ) ; int [ ] nlist = new int [ gICerQrpWm ] ; for ( int i = 1 ; i <= gICerQrpWm ; i ++ ) { int a = sc . nextInt ( ) ; nlist [ a - 1 ] = i ; } for ( int i = 0 ; i < gICerQrpWm ; i ++ ) { System . out . print ( nlist [ i ] + " " ) ; } sc . close ( ) ; } } import java . util . Scanner ; class nmMYnOjzpG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int nmMYnOjzpG = scan . nextInt ( ) ; int [ ] [ ] [ ] OffHouse = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int i = 0 ; i < nmMYnOjzpG ; 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 qpuWpwnFrN { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qpuWpwnFrN = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; System . out . println ( ans ( qpuWpwnFrN , b , c , x ) ) ; } static int ans ( int qpuWpwnFrN , int b , int c , int x ) { int ans = 0 ; for ( int i = 0 ; i <= qpuWpwnFrN ; 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 nvBzbQqgmL { public static void main ( String [ ] args ) { Scanner a = new Scanner ( System . in ) ; int nvBzbQqgmL = a . nextInt ( ) ; int [ ] A = new int [ nvBzbQqgmL ] ; for ( int i = 0 ; i < nvBzbQqgmL ; i ++ ) { A [ i ] = a . nextInt ( ) ; } int flag = 1 ; int count = 0 ; while ( flag == 1 ) { flag = 0 ; for ( int i = nvBzbQqgmL - 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 < nvBzbQqgmL ; i ++ ) { System . out . print ( A [ i ] ) ; if ( i < nvBzbQqgmL - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; System . out . println ( count ) ; } } import java . util . * ; class IhAVPfUlsN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] values = new int [ 3 ] [ 3 ] ; for ( int IhAVPfUlsN = 0 ; IhAVPfUlsN < 3 ; IhAVPfUlsN ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { values [ IhAVPfUlsN ] [ j ] = sc . nextInt ( ) ; } } boolean ok = false ; for ( int IhAVPfUlsN = 0 ; IhAVPfUlsN < 101 ; IhAVPfUlsN ++ ) { for ( int j = 0 ; j < 101 ; j ++ ) { for ( int k = 0 ; k < 101 ; k ++ ) { int b1 = values [ 0 ] [ 0 ] - IhAVPfUlsN ; int b2 = values [ 0 ] [ 1 ] - IhAVPfUlsN ; int b3 = values [ 0 ] [ 2 ] - IhAVPfUlsN ; 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 YDgdppVcqV { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . nextLine ( ) ; long YDgdppVcqV = scanner . nextLong ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < YDgdppVcqV ; i ++ ) { if ( S . charAt ( i ) == '1' ) { continue ; } System . out . println ( S . charAt ( i ) ) ; return ; } System . out . println ( 1 ) ; scanner . close ( ) ; } } import java . util . * ; class fepvHoNsXe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int fepvHoNsXe = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; String j = sc . next ( ) ; if ( a . equals ( j ) ) { fepvHoNsXe = fepvHoNsXe - 1 ; } else if ( b . equals ( j ) ) { d = d - 1 ; } System . out . println ( fepvHoNsXe ) ; 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 mmkwRQieux { static long mmkwRQieux = 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 cBNoxmZMax { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String strn = sc . next ( ) ; sc . close ( ) ; String [ ] str = strn . split ( " " ) ; int cBNoxmZMax = 0 ; for ( int i = 0 ; i < strn . length ( ) ; i ++ ) { cBNoxmZMax += Integer . parseInt ( str [ i ] ) ; } String ans = " No " ; if ( cBNoxmZMax % 9 == 0 ) { ans = " Yes " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class gCoqKMWSUL { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int gCoqKMWSUL = scanner . nextInt ( ) ; int divValue , modValue , totalHp ; divValue = gCoqKMWSUL / 500 ; totalHp = divValue * 1000 ; modValue = gCoqKMWSUL % 500 ; if ( modValue != 0 ) { divValue = modValue / 5 ; totalHp = totalHp + divValue * 5 ; } System . out . println ( totalHp ) ; } } import java . util . * ; public class GqlJMXVGPN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GqlJMXVGPN = sc . nextInt ( ) ; int [ ] ai = new int [ GqlJMXVGPN ] ; for ( int i = 0 ; i < GqlJMXVGPN ; i ++ ) ai [ i ] = sc . nextInt ( ) ; int [ ] ans = new int [ GqlJMXVGPN ] ; for ( int i = 0 ; i < GqlJMXVGPN ; i ++ ) ans [ ai [ i ] - 1 ] = i + 1 ; for ( int i = 0 ; i < GqlJMXVGPN ; i ++ ) System . out . print ( ans [ i ] + " " ) ; } } import java . util . * ; public class yZeUfXfGkZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yZeUfXfGkZ = sc . nextInt ( ) ; int l = 1 ; int r = 1_000_000_007 ; for ( int i = yZeUfXfGkZ ; 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 PQGMIwcMaU { 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 PQGMIwcMaU = Integer . parseInt ( str2 [ 0 ] ) ; int b = Integer . parseInt ( str2 [ 1 ] ) ; int digits = Integer . toString ( PQGMIwcMaU + b ) . length ( ) ; System . out . println ( digits ) ; } } } import java . util . Scanner ; public class pkBkiIhZif { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int pkBkiIhZif = scn . nextInt ( ) ; int [ ] A1 = new int [ pkBkiIhZif + 1 ] , A2 = new int [ pkBkiIhZif + 1 ] ; for ( int i = 1 ; i < pkBkiIhZif + 1 ; i ++ ) { A1 [ i ] = A1 [ i - 1 ] + scn . nextInt ( ) ; } for ( int i = 1 ; i < pkBkiIhZif + 1 ; i ++ ) { A2 [ i ] = A2 [ i - 1 ] + scn . nextInt ( ) ; } int ans = 0 ; for ( int i = 0 ; i < pkBkiIhZif ; i ++ ) { ans = Math . max ( ans , A1 [ i + 1 ] - A1 [ 0 ] + A2 [ pkBkiIhZif ] - A2 [ i ] ) ; } System . out . println ( ans ) ; } } import java . util . * ; class ZaYwhUupXG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int [ ] rec = new int [ 26 ] ; for ( int ZaYwhUupXG = 0 ; ZaYwhUupXG < s . length ( ) ; ZaYwhUupXG ++ ) { rec [ s . charAt ( ZaYwhUupXG ) - 'a' ] ++ ; } String ans = " Yes " ; for ( int ZaYwhUupXG = 0 ; ZaYwhUupXG < 26 ; ZaYwhUupXG ++ ) { if ( rec [ ZaYwhUupXG ] % 2 == 1 ) ans = " No " ; } System . out . println ( ans ) ; } } import java . util . * ; public class iyODWLbgoi { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int iyODWLbgoi = scn . nextInt ( ) ; int m = scn . nextInt ( ) ; int [ ] [ ] a = new int [ iyODWLbgoi ] [ m ] ; int [ ] b = new int [ m ] ; int [ ] c = new int [ iyODWLbgoi ] ; Arrays . fill ( c , 0 ) ; for ( int i = 0 ; i < iyODWLbgoi ; 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 < iyODWLbgoi ; 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 YqRQVAEtuU { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int YqRQVAEtuU = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) { sum += scan . nextInt ( ) ; } if ( YqRQVAEtuU - sum < 0 ) { System . out . println ( - 1 ) ; } else { System . out . println ( YqRQVAEtuU - sum ) ; } } } import java . util . Scanner ; public class cHLMENEsKi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cHLMENEsKi = Integer . parseInt ( sc . nextLine ( ) ) ; String strings = sc . nextLine ( ) ; if ( strings . length ( ) <= cHLMENEsKi ) { System . out . println ( strings ) ; } else { System . out . println ( strings . substring ( 0 , cHLMENEsKi ) + " ... " ) ; } } } import java . util . * ; public class uldQlVQnrp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uldQlVQnrp = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( uldQlVQnrp % 2 == 0 ) { int h = uldQlVQnrp / 2 - 1 ; String bs = S . substring ( 0 , h + 1 ) ; String as = S . substring ( h + 1 , uldQlVQnrp ) ; 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 ChxgWTyeTs { 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 ChxgWTyeTs = Integer . parseInt ( reader . readLine ( ) ) ; int cnt = 0 ; while ( true ) { inputData = reader . readLine ( ) ; cardMap . put ( String . valueOf ( cnt ) , inputData ) ; cnt ++ ; if ( cnt == ChxgWTyeTs ) { 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 yQthHfTSno { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String yQthHfTSno = sc . next ( ) ; String ans = " " ; if ( yQthHfTSno . equals ( " ABC " ) ) { ans = " ARC " ; } else { ans = " ABC " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; class iTVBvEWCzT { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; boolean iTVBvEWCzT = true ; int a = 0 , b = 0 ; while ( iTVBvEWCzT ) { 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 hmuRBbXGtO { 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 hmuRBbXGtO = 0 ; hmuRBbXGtO < c . length ; hmuRBbXGtO ++ ) { for ( int m = 0 ; m < c . length ; m ++ ) { if ( c [ hmuRBbXGtO ] == c [ m ] ) { count [ hmuRBbXGtO ] ++ ; } } } for ( int hmuRBbXGtO = 0 ; hmuRBbXGtO < c . length ; hmuRBbXGtO ++ ) { if ( count [ hmuRBbXGtO ] % 2 != 0 ) { show = " No " ; break ; } else { show = " Yes " ; } } System . out . println ( show ) ; } } import java . util . * ; public class GphbTlbpWu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GphbTlbpWu = sc . nextInt ( ) ; int digitNum = ( int ) Math . log10 ( GphbTlbpWu ) + 1 ; int ans = 0 ; if ( digitNum == 6 ) { ans = 9 + 900 + 90000 ; } else if ( digitNum == 5 ) { ans = 9 + 900 + GphbTlbpWu - 10000 + 1 ; } else if ( digitNum == 4 ) { ans = 9 + 900 ; } else if ( digitNum == 3 ) { ans = 9 + GphbTlbpWu - 100 + 1 ; } else if ( digitNum == 2 ) { ans = 9 ; } else if ( digitNum == 1 ) { ans = GphbTlbpWu ; } System . out . println ( " " + ans ) ; } } import java . io . * ; import java . util . * ; import java . math . * ; import java . lang . * ; class AhTsZDusjP { public static void PrintIntArray ( int [ ] Arr ) { for ( int AhTsZDusjP = 0 ; AhTsZDusjP < Arr . length ; AhTsZDusjP ++ ) { System . out . print ( Arr [ AhTsZDusjP ] + " " ) ; } 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 AhTsZDusjP { 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 MuUwpdkOzI { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; int MuUwpdkOzI = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; for ( int i = 1 ; i < 2 * Math . abs ( MuUwpdkOzI ) ; i ++ ) { System . out . print ( x - MuUwpdkOzI + i + " " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class txRItmCNWo { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int txRItmCNWo = sc . nextInt ( ) ; int [ ] d = new int [ txRItmCNWo ] ; for ( int i = 0 ; i < txRItmCNWo ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; System . out . print ( d [ txRItmCNWo / 2 ] - d [ txRItmCNWo / 2 - 1 ] ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class IJRJCosRJL { 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 IJRJCosRJL = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == t [ i ] ) { IJRJCosRJL ++ ; } } System . out . println ( IJRJCosRJL ) ; } } import java . util . * ; import java . lang . * ; public class runJfEOfsS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; String s1 = str . substring ( 0 ) ; char runJfEOfsS = str . charAt ( 0 ) ; char c2 = str . charAt ( 1 ) ; char c3 = str . charAt ( 2 ) ; if ( runJfEOfsS == c2 && c2 == c3 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . Scanner ; class dmbIwrlgLY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int result [ ] = new int [ 1000000 ] , dmbIwrlgLY = 0 ; while ( true ) { result [ dmbIwrlgLY ] = sc . nextInt ( ) ; if ( result [ dmbIwrlgLY ] == 0 ) break ; dmbIwrlgLY ++ ; } for ( int j = 0 ; j < dmbIwrlgLY ; j ++ ) { System . out . println ( " Case " + ( j + 1 ) + " : " + result [ j ] ) ; } } } import java . util . * ; public class oMHYWAOOUx { public static void main ( String [ ] args ) { int oMHYWAOOUx = 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 iSatDwYLBH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iSatDwYLBH = sc . nextInt ( ) ; int [ ] a = new int [ 1000000 ] ; int Answer = 0 ; a [ 0 ] = iSatDwYLBH ; 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 HwqdOskgcF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] array = new int [ 100 ] ; int HwqdOskgcF = sc . nextInt ( ) ; for ( int i = 0 ; i < HwqdOskgcF ; i ++ ) array [ i ] = sc . nextInt ( ) ; doInsertionSort ( array , HwqdOskgcF ) ; printArray ( array , HwqdOskgcF ) ; } public static void doInsertionSort ( int [ ] array , int HwqdOskgcF ) { for ( int i = 1 ; i < HwqdOskgcF ; i ++ ) { printArray ( array , HwqdOskgcF ) ; 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 HwqdOskgcF ) { for ( int i = 0 ; i < HwqdOskgcF ; i ++ ) { if ( i != 0 ) System . out . print ( " " ) ; System . out . print ( array [ i ] ) ; } System . out . print ( " \n " ) ; } } import java . util . * ; public class nYMQToFeuK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nYMQToFeuK = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < nYMQToFeuK ; 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 daFVkSkkqC { 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 daFVkSkkqC = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; if ( daFVkSkkqC == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < daFVkSkkqC ; i ++ ) { char p ; if ( i == 0 || i == daFVkSkkqC - 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 kKfzqsbZtf { public static void main ( String [ ] args ) { new Main ( ) . exec ( ) ; } void exec ( ) { Scanner sc = new Scanner ( System . in ) ; int kKfzqsbZtf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = Math . min ( kKfzqsbZtf , b ) ; i >= 1 ; -- i ) { if ( kKfzqsbZtf % i == 0 && b % i == 0 ) { -- k ; if ( k == 0 ) { System . out . println ( i ) ; sc . close ( ) ; return ; } } } sc . close ( ) ; } } import java . util . Scanner ; public class YSHWXUOIqU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YSHWXUOIqU = 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 ) YSHWXUOIqU ++ ; } System . out . println ( YSHWXUOIqU ) ; } } import java . util . * ; public class wMdNHrNoGN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wMdNHrNoGN , b , c ; wMdNHrNoGN = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; int n = wMdNHrNoGN - 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 AIRikvXdpw { Scanner sc = new Scanner ( System . in ) ; void solve ( ) { String [ ] rawInputs = sc . nextLine ( ) . split ( " " ) ; Stack < String > stack = new Stack < > ( ) ; for ( String AIRikvXdpw : rawInputs ) { switch ( AIRikvXdpw ) { 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 ( AIRikvXdpw ) ; } } } String result = stack . pop ( ) ; System . out . println ( result ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class NncUvhSLtW { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int NncUvhSLtW = scan . nextInt ( ) ; for ( int i = 1 ; i <= NncUvhSLtW ; i ++ ) { if ( NncUvhSLtW >= 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 kypKUsCmqf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " Yes " ; int kypKUsCmqf = s . length ( ) ; for ( int i = 0 ; i < ( kypKUsCmqf - 1 ) / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( kypKUsCmqf - 1 - i ) ) ans = " No " ; } kypKUsCmqf = kypKUsCmqf / 2 ; if ( ! ans . equals ( " No " ) ) { for ( int i = 0 ; i < kypKUsCmqf / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( kypKUsCmqf - 1 - i ) ) ans = " No " ; } } System . out . print ( ans ) ; } } import java . util . Scanner ; public class NXmzNQpyVV { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int NXmzNQpyVV = sc . nextInt ( ) ; String op = sc . next ( ) ; int b = sc . nextInt ( ) ; for ( ; ! op . equals ( " ? " ) ; ) { int ans = 0 ; switch ( op ) { case " + " : ans = NXmzNQpyVV + b ; break ; case " - " : ans = NXmzNQpyVV - b ; break ; case " * " : ans = NXmzNQpyVV * b ; break ; case " / " : if ( NXmzNQpyVV == 0 ) { break ; } ans = NXmzNQpyVV / b ; } System . out . println ( ans ) ; NXmzNQpyVV = sc . nextInt ( ) ; op = sc . next ( ) ; b = sc . nextInt ( ) ; } } } import java . util . HashMap ; import java . util . Scanner ; class TeGCpqJwWQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TeGCpqJwWQ = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] k = new int [ TeGCpqJwWQ ] ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < TeGCpqJwWQ ; 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 == TeGCpqJwWQ ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class AvJNIyFIia { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String AvJNIyFIia = sc . next ( ) ; String t = sc . next ( ) ; String S = AvJNIyFIia + AvJNIyFIia ; if ( S . contains ( t ) == true ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class AwsxaqoBJV { 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 AwsxaqoBJV = 0 ; AwsxaqoBJV < s . length ( ) ; AwsxaqoBJV ++ ) { if ( s . charAt ( AwsxaqoBJV ) >= 'a' && s . charAt ( AwsxaqoBJV ) <= 'z' ) { a [ s . charAt ( AwsxaqoBJV ) - 'a' ] ++ ; } } } for ( char AwsxaqoBJV = 'a' ; AwsxaqoBJV <= 'z' ; AwsxaqoBJV ++ ) { System . out . println ( AwsxaqoBJV + " : " + a [ AwsxaqoBJV - 'a' ] ) ; } } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class KMCXjxgqCc { public static void main ( String [ ] args ) throws Exception { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = in . readLine ( ) ; int KMCXjxgqCc = Integer . parseInt ( W ) ; W = in . readLine ( ) ; String [ ] Ws = W . split ( " " ) ; int [ ] P = new int [ KMCXjxgqCc ] ; for ( int i = 0 ; i < KMCXjxgqCc ; i ++ ) { P [ i ] = Integer . parseInt ( Ws [ i ] ) ; } int ans = 0 ; int Pj = Integer . MAX_VALUE ; for ( int i = 0 ; i < KMCXjxgqCc ; i ++ ) { if ( P [ i ] <= Pj ) { ans ++ ; Pj = P [ i ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class wxfoYBUdbI { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . next ( ) ; String t = scanner . next ( ) ; int wxfoYBUdbI = 0 ; for ( int i = 0 ; i < s . length ( ) && i < t . length ( ) ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) wxfoYBUdbI ++ ; } System . out . println ( wxfoYBUdbI ) ; } } import java . util . * ; public class DUlyDTgXLm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DUlyDTgXLm = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int a3 = sc . nextInt ( ) ; if ( DUlyDTgXLm + 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 DUlyDTgXLm { int a , b ; Pair ( int a , int b ) { this . a = a ; this . b = b ; } } import java . util . Scanner ; public class dXxeAKHSTF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; int dXxeAKHSTF = 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 ++ ; } dXxeAKHSTF = Math . min ( dXxeAKHSTF , cnt ) ; } System . out . println ( dXxeAKHSTF ) ; } } import java . util . Scanner ; public class QKUxHQeskW { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QKUxHQeskW = scan . nextInt ( ) ; String s = Integer . toString ( QKUxHQeskW ) ; 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 HtFmQvjaNr { public static void main ( String [ ] args ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; try { String [ ] list = br . readLine ( ) . split ( " " ) ; int HtFmQvjaNr = Integer . parseInt ( list [ 0 ] ) ; int b = Integer . parseInt ( list [ 1 ] ) ; int d = HtFmQvjaNr / b ; int r = HtFmQvjaNr % b ; double f = ( double ) HtFmQvjaNr / b ; System . out . println ( d + " " + r + " " + String . format ( " %.5f " , f ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class EazwebhXcM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EazwebhXcM = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int a = 0 ; for ( int i = 0 ; i < N ; i ++ ) a += sc . nextInt ( ) ; if ( a >= EazwebhXcM ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . * ; import java . util . * ; public class DzDBdFaLPk { 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 DzDBdFaLPk = 0 ; for ( char c : cs ) { DzDBdFaLPk += c ; } DzDBdFaLPk -= cs . length * '0' ; System . out . println ( DzDBdFaLPk % 9 == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class kBuVtgTxIu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kBuVtgTxIu = sc . nextInt ( ) ; sc . close ( ) ; System . out . println ( ( kBuVtgTxIu + 1 ) / 2 * 1.0 / kBuVtgTxIu ) ; } } import java . util . Arrays ; import java . util . Scanner ; import java . util . stream . Stream ; public class DGirFHInTs { public static void main ( final String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; final String DGirFHInTs = sc . next ( ) ; StringBuffer sb = new StringBuffer ( DGirFHInTs ) ; sb . setCharAt ( 3 , '8' ) ; System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; public class REgtTAJayb { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; int REgtTAJayb = scan . nextInt ( ) ; int [ ] p = new int [ REgtTAJayb ] ; int a = 0 ; for ( int i = 0 ; i < REgtTAJayb ; i ++ ) { p [ i ] = scan . nextInt ( ) ; } for ( int i = 1 ; i < REgtTAJayb - 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 yYBHtsQUbi { public static void main ( String [ ] args ) { int [ ] n ; n = new int [ 3 ] ; int yYBHtsQUbi , 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 ] ; yYBHtsQUbi = ( n [ 1 ] < n [ 2 ] ) ? n [ 1 ] : n [ 2 ] ; yYBHtsQUbi = ( n [ 0 ] < yYBHtsQUbi ) ? n [ 0 ] : yYBHtsQUbi ; max = ( n [ 1 ] < n [ 2 ] ) ? n [ 2 ] : n [ 1 ] ; max = ( n [ 0 ] < max ) ? max : n [ 0 ] ; mid = mid - ( yYBHtsQUbi + max ) ; System . out . println ( yYBHtsQUbi + " " + mid + " " + max ) ; scan . close ( ) ; } } import java . util . * ; import java . io . * ; import java . math . BigInteger ; public class ZwOtYOQbCX { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; int ZwOtYOQbCX = Integer . parseInt ( br . readLine ( ) ) ; int [ ] arr = new int [ ZwOtYOQbCX ] ; StringTokenizer st1 = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < ZwOtYOQbCX ; i ++ ) { arr [ i ] = Integer . parseInt ( st1 . nextToken ( ) ) ; } int [ ] cnt = new int [ ZwOtYOQbCX ] ; int max = 0 ; for ( int i = ZwOtYOQbCX - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] >= arr [ i + 1 ] ) { cnt [ i ] = cnt [ i + 1 ] + 1 ; } } for ( int i = 0 ; i < ZwOtYOQbCX ; 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 cdsXOeGRrI { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int cdsXOeGRrI = Integer . parseInt ( br . readLine ( ) ) ; int [ ] num = new int [ cdsXOeGRrI ] ; 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 VnOyoSdaGn { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; char [ ] c = str . toCharArray ( ) ; for ( int VnOyoSdaGn = 0 ; VnOyoSdaGn < c . length ; VnOyoSdaGn ++ ) { int count = 0 ; for ( int j = 0 ; j < c . length ; j ++ ) { if ( c [ VnOyoSdaGn ] == c [ j ] ) { count ++ ; } } if ( count % 2 != 0 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class ftBCUUogiZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ftBCUUogiZ = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = 0 ; for ( int i = ftBCUUogiZ ; 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 jayNQNstUy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jayNQNstUy = sc . nextInt ( ) ; int [ ] x = new int [ jayNQNstUy ] ; int l = Integer . MAX_VALUE / 2 , r = - 1 ; for ( int i = 0 ; i < jayNQNstUy ; 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 < jayNQNstUy ; j ++ ) { d += Math . pow ( i - x [ j ] , 2 ) ; } min = Math . min ( min , d ) ; } System . out . println ( min ) ; } } import java . util . * ; public class qSjdBtwFRx { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int qSjdBtwFRx = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; long z = qSjdBtwFRx + y ; System . out . println ( ( qSjdBtwFRx + y ) % 2 == 0 ? ( qSjdBtwFRx + y ) / 2 : " IMPOSSIBLE " ) ; } } import java . io . * ; public class HrHUBynCnG { public static void main ( String [ ] args ) { try { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int HrHUBynCnG = Integer . parseInt ( in . readLine ( ) ) ; int [ ] iArr = new int [ HrHUBynCnG ] ; 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 CMDdxtHNHU { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int CMDdxtHNHU = sc . nextInt ( ) ; ArrayList < String > result = new ArrayList < > ( ) ; result . add ( sc . next ( ) ) ; for ( int i = 1 ; i < CMDdxtHNHU ; i ++ ) { result . add ( sc . next ( ) ) ; } ArrayList < String > ans = new ArrayList < String > ( new HashSet < > ( result ) ) ; System . out . println ( ans . size ( ) ) ; } } import java . util . * ; public class kytFsITnrC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kytFsITnrC = 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 <= kytFsITnrC ; 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 xqKFDWOFkS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long xqKFDWOFkS = sc . nextLong ( ) ; long h = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; double ans = 0.5 * xqKFDWOFkS * h ; StringBuilder builder = new StringBuilder ( String . valueOf ( ans ) ) ; int flag = 0.5 * xqKFDWOFkS == x && 0.5 * h == y ? 1 : 0 ; builder . append ( " " + flag ) ; System . out . println ( builder ) ; } } import java . util . Scanner ; public class BRzQmjmPMv { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; int BRzQmjmPMv = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; scanner . close ( ) ; int c = BRzQmjmPMv * b ; if ( c % 2 == 1 ) { System . out . println ( " Odd " ) ; } else if ( c % 2 == 0 ) { System . out . println ( " Even " ) ; } } } import java . util . * ; public class sLxjYlTCzb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sLxjYlTCzb = 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 [ sLxjYlTCzb ] ; int [ ] wa = new int [ sLxjYlTCzb ] ; 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 < sLxjYlTCzb ; 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 OiKhBpIMED { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int OiKhBpIMED = scanner . nextInt ( ) ; final Set < Integer > appeared = new HashSet < > ( ) ; int m = 1 ; do { appeared . add ( OiKhBpIMED ) ; if ( OiKhBpIMED % 2 == 0 ) { OiKhBpIMED = OiKhBpIMED / 2 ; } else { OiKhBpIMED = 3 * OiKhBpIMED + 1 ; } m ++ ; } while ( ! appeared . contains ( OiKhBpIMED ) ) ; System . out . println ( m ) ; } } import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class PZIgiNJvFZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; String Sa = sc . next ( ) ; String Sb = sc . next ( ) ; String Sc = sc . next ( ) ; int PZIgiNJvFZ = Sa . length ( ) , b = Sb . length ( ) , c = Sc . length ( ) ; char p = Sa . charAt ( Sa . length ( ) - PZIgiNJvFZ ) ; PZIgiNJvFZ -- ; while ( true ) { switch ( p ) { case 'a' : if ( PZIgiNJvFZ == 0 ) { out . println ( " A " ) ; exit ( 0 ) ; } p = Sa . charAt ( Sa . length ( ) - PZIgiNJvFZ ) ; PZIgiNJvFZ -- ; 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 EATYbJTrjv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long EATYbJTrjv = scan . nextLong ( ) ; long syou = 0 ; long a = 0 , b = 0 ; long re = Long . MAX_VALUE ; for ( int i = 1 ; i <= Math . sqrt ( EATYbJTrjv ) ; i ++ ) { if ( EATYbJTrjv % i == 0 ) { a = i ; b = EATYbJTrjv / 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 AQIhZSzLPb { 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 AQIhZSzLPb = Integer . parseInt ( reader . readLine ( ) ) ; int n = Integer . parseInt ( reader . readLine ( ) ) ; int [ ] numbers = new int [ AQIhZSzLPb ] ; for ( int i = 0 ; i < AQIhZSzLPb ; 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 < AQIhZSzLPb ; i ++ ) { out . println ( numbers [ i ] ) ; } } } import java . util . Scanner ; public class RckhhdDhuW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; long RckhhdDhuW = sc . nextLong ( ) ; int ans = 0 ; int n = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { n = s . charAt ( i ) - '0' ; RckhhdDhuW -- ; if ( RckhhdDhuW == 0 || n > 1 ) break ; } System . out . println ( n ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class pAASzOUBHW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pAASzOUBHW = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean [ ] broken = new boolean [ pAASzOUBHW + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { broken [ sc . nextInt ( ) ] = true ; } int [ ] dp = new int [ pAASzOUBHW + 1 ] ; Arrays . fill ( dp , 0 ) ; dp [ 0 ] = 1 ; dp [ 1 ] = broken [ 1 ] ? 0 : 1 ; for ( int i = 2 ; i <= pAASzOUBHW ; 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 zilMPkGfbe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zilMPkGfbe = sc . nextInt ( ) ; int num2 = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( zilMPkGfbe < num2 ) { sum += num2 ; num2 -- ; } else { sum += zilMPkGfbe ; zilMPkGfbe -- ; } } 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 jgbhcBtxyj { 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 jgbhcBtxyj { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int jgbhcBtxyj = 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 jgbhcBtxyj { 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 HJbhnRRwLA { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int HJbhnRRwLA = Integer . parseInt ( scan . next ( ) ) ; if ( HJbhnRRwLA <= 111 ) { System . out . println ( 111 ) ; } else if ( HJbhnRRwLA <= 222 ) { System . out . println ( 222 ) ; } else if ( HJbhnRRwLA <= 333 ) { System . out . println ( 333 ) ; } else if ( HJbhnRRwLA <= 444 ) { System . out . println ( 444 ) ; } else if ( HJbhnRRwLA <= 555 ) { System . out . println ( 555 ) ; } else if ( HJbhnRRwLA <= 666 ) { System . out . println ( 666 ) ; } else if ( HJbhnRRwLA <= 777 ) { System . out . println ( 777 ) ; } else if ( HJbhnRRwLA <= 888 ) { System . out . println ( 888 ) ; } else if ( HJbhnRRwLA <= 999 ) { System . out . println ( 999 ) ; } } } import java . util . * ; public class yBCUCyygup { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yBCUCyygup = sc . nextInt ( ) ; int result = 100000 ; for ( int i = 0 ; i < yBCUCyygup ; i ++ ) { result += result * 0.05 ; result = ( int ) Math . ceil ( ( double ) result / 1000 ) * 1000 ; } System . out . println ( result ) ; } } import java . util . * ; public class TtYftBXReD { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; String TtYftBXReD = sc . next ( ) ; TtYftBXReD = " 2018 " + TtYftBXReD . substring ( 4 , TtYftBXReD . length ( ) ) ; System . out . println ( TtYftBXReD ) ; } public static void main ( String [ ] args ) { solve ( ) ; } } import java . util . * ; public class edObMuUoba { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int edObMuUoba = Integer . parseInt ( sc . nextLine ( ) ) ; String sTaro ; String sHanako ; int iTaro = 0 ; int iHanako = 0 ; for ( int i = 0 ; i < edObMuUoba ; 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 gXQVLknkNh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gXQVLknkNh = sc . nextInt ( ) ; System . out . println ( ( ( gXQVLknkNh + 1 ) / 2 ) ) ; } } import java . util . * ; public class PuhplphTWR { static String Rort ( String s , String t ) { String PuhplphTWR = s + s ; PuhplphTWR = PuhplphTWR . replaceFirst ( t , " " ) ; if ( PuhplphTWR . 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 UARNwjuslQ { public static void main ( String [ ] args ) throws IOException { int UARNwjuslQ = 0 , f = 0 , r = 0 ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { String str = br . readLine ( ) ; String [ ] i = str . split ( " " ) ; UARNwjuslQ = Integer . parseInt ( i [ 0 ] ) ; f = Integer . parseInt ( i [ 1 ] ) ; r = Integer . parseInt ( i [ 2 ] ) ; if ( UARNwjuslQ == ( - 1 ) && f == ( - 1 ) && r == ( - 1 ) ) { break ; } if ( UARNwjuslQ == ( - 1 ) || f == ( - 1 ) ) { System . out . println ( " F " ) ; } else if ( UARNwjuslQ + f >= 80 ) { System . out . println ( " A " ) ; } else if ( UARNwjuslQ + f >= 65 ) { System . out . println ( " B " ) ; } else if ( UARNwjuslQ + f >= 50 ) { System . out . println ( " C " ) ; } else if ( UARNwjuslQ + 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 dTUpzisvky { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int dTUpzisvky = 0 ; int n ; while ( true ) { dTUpzisvky ++ ; n = Integer . parseInt ( br . readLine ( ) ) ; if ( n == 0 ) break ; System . out . println ( " Case " + dTUpzisvky + " : " + n ) ; } } } import java . util . Scanner ; public class bPBqrQcTEC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bPBqrQcTEC = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; boolean ok = true ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i == bPBqrQcTEC && s . charAt ( bPBqrQcTEC ) != '-' ) { ok = false ; } if ( i != bPBqrQcTEC && s . charAt ( i ) == '-' ) { ok = false ; } } if ( ok ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class PtAacaLafm { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( true ) { String s = in . nextLine ( ) ; if ( s . equals ( " 0 " ) ) return ; long PtAacaLafm = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { PtAacaLafm += Integer . parseInt ( " " + s . charAt ( i ) ) ; } System . out . println ( PtAacaLafm ) ; } } } import java . util . * ; public class uRlzeLebgk { 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 uRlzeLebgk = 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 + uRlzeLebgk ) % 26 ) ) ; } } } System . out . print ( " \n " ) ; } } import java . util . * ; public class zNtpbTzVYE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int zNtpbTzVYE = str . length ( ) ; String leftStr = str . substring ( 0 , ( zNtpbTzVYE - 1 ) / 2 ) ; String rightStr = str . substring ( ( zNtpbTzVYE + 1 ) / 2 , zNtpbTzVYE ) ; 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 tXpvthvrew { 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 tXpvthvrew = Long . MIN_VALUE ; for ( int i = 0 ; i < 2 ; ++ i ) { for ( int j = 0 ; j < 2 ; ++ j ) { long tmp = a [ i ] * b [ j ] ; tXpvthvrew = Math . tXpvthvrew ( tmp , tXpvthvrew ) ; } } System . out . println ( tXpvthvrew ) ; sc . close ( ) ; } } import java . util . Scanner ; public class xngguGtOHW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xngguGtOHW = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; long p = 1 ; int r = 0 ; while ( p <= xngguGtOHW ) { p *= k ; r ++ ; } System . out . println ( r ) ; } } import java . util . Scanner ; public class psUBtfTgdj { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int psUBtfTgdj = stdIn . nextInt ( ) ; int [ ] A = new int [ psUBtfTgdj ] ; int count = 0 ; int ans = 0 ; for ( int i = 0 ; i < psUBtfTgdj ; 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 qoEsLWYYJj { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int qoEsLWYYJj = gi ( ) ; int [ ] A = new int [ qoEsLWYYJj ] ; for ( int i = 0 ; i < qoEsLWYYJj ; i ++ ) { A [ i ] = gi ( ) ; } int max = 0 ; int t = 0 ; for ( int i = 0 ; i < qoEsLWYYJj ; 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 GDlbtSUJmL { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GDlbtSUJmL = 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 = ( GDlbtSUJmL * GDlbtSUJmL ) + ( B * B ) - ( 2 * GDlbtSUJmL * B * Math . cos ( rad ) ) ; System . out . println ( Math . sqrt ( rsq ) ) ; } } import java . util . * ; public class kBnHjzNKFS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kBnHjzNKFS = sc . nextInt ( ) ; int check = 0 ; String [ ] W = new String [ kBnHjzNKFS ] ; for ( int i = 0 ; i < kBnHjzNKFS ; i ++ ) { W [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < kBnHjzNKFS - 1 ; i ++ ) { if ( W [ i ] . charAt ( W [ i ] . length ( ) - 1 ) != W [ i + 1 ] . charAt ( 0 ) ) { check ++ ; break ; } for ( int j = i + 1 ; j < kBnHjzNKFS ; 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 bxTfLtSYJJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double bxTfLtSYJJ = 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 = bxTfLtSYJJ * bxTfLtSYJJ + B * B - 2 * bxTfLtSYJJ * B * co ; System . out . println ( Math . sqrt ( ans ) ) ; } } import java . util . * ; public class uGjUrVqOOs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uGjUrVqOOs = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int a = x - ( uGjUrVqOOs - 1 ) ; for ( int i = 0 ; i < uGjUrVqOOs * 2 - 1 ; i ++ ) { if ( a < - 1000000 || a > 1000000 ) continue ; System . out . print ( a + " " ) ; a ++ ; } } } import java . util . * ; public class HNtjYKdTNG { public static void main ( String [ ] args ) { Scanner yomi = new Scanner ( System . in ) ; int HNtjYKdTNG = yomi . nextInt ( ) ; boolean tf = true ; int [ ] n = new int [ HNtjYKdTNG ] ; for ( int i = 0 ; i < HNtjYKdTNG ; i ++ ) { n [ i ] = yomi . nextInt ( ) ; } for ( int i = 0 ; i < HNtjYKdTNG ; 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 zsALRznnkE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zsALRznnkE = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] ar = new int [ zsALRznnkE ] ; int sum = 0 ; int res = 114514 ; for ( int i = 0 ; i < zsALRznnkE ; 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 zsALRznnkE { 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 zsALRznnkE { public static boolean isOdd ( int zsALRznnkE ) { return zsALRznnkE % 2 == 1 ; } public static boolean isEven ( int zsALRznnkE ) { return zsALRznnkE % 2 == 0 ; } } import java . util . Scanner ; public class fkmcEXmETQ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int fkmcEXmETQ = scan . nextInt ( ) ; int sum = scan . nextInt ( ) ; int ans = 0 ; for ( int x = 0 ; x <= fkmcEXmETQ ; ++ x ) { for ( int y = 0 ; y <= fkmcEXmETQ ; ++ y ) { int z = sum - x - y ; if ( 0 <= z && z <= fkmcEXmETQ ) { ans = ans + 1 ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; class xWMZrrKvUX { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int xWMZrrKvUX = cin . nextInt ( ) ; int res = sol ( xWMZrrKvUX ) ; System . out . println ( res ) ; } private static int sol ( int xWMZrrKvUX ) { return ( xWMZrrKvUX * xWMZrrKvUX * xWMZrrKvUX ) ; } } import java . util . Scanner ; public class RKyfhjHldv { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int RKyfhjHldv = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c ; int k = scanner . nextInt ( ) ; if ( RKyfhjHldv > b ) c = RKyfhjHldv ; else c = b ; for ( int i = c ; i >= 1 ; i -- ) { if ( RKyfhjHldv % i == 0 && b % i == 0 ) { -- k ; if ( k == 0 ) { System . out . println ( i ) ; } } } } } import java . util . * ; import java . io . * ; public class LhONKCeUsm { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int LhONKCeUsm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( ( LhONKCeUsm * b ) % 2 == 0 ) System . out . println ( " Even " ) ; else System . out . println ( " Odd " ) ; } } import java . util . * ; public class OfoFRxTuEb { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int OfoFRxTuEb = sc . nextInt ( ) ; int [ ] [ ] nums = new int [ 4 ] [ 13 ] ; for ( int i = 0 ; i < OfoFRxTuEb ; 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 UoEkBGdafD { 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 ZbCGcuyXWJ { public static void main ( String [ ] a ) throws IOException { java . io . BufferedReader r = new java . io . BufferedReader ( new java . io . InputStreamReader ( System . in ) ) ; try { int ZbCGcuyXWJ = Integer . parseInt ( r . readLine ( ) ) ; String [ ] ans = new String [ ZbCGcuyXWJ ] ; for ( int i = 0 ; i < ZbCGcuyXWJ ; 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 < ZbCGcuyXWJ ; i ++ ) { System . out . println ( ans [ i ] ) ; } } catch ( Exception ex ) { System . exit ( 0 ) ; } } } import java . util . * ; public class sxsxEKQULq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int sxsxEKQULq = Integer . parseInt ( sc . next ( ) ) ; String str = sc . next ( ) ; if ( sxsxEKQULq % 2 == 1 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } String m = str . substring ( sxsxEKQULq / 2 ) ; if ( str . substring ( 0 , sxsxEKQULq / 2 ) . equals ( m ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class hQdiKPqkPe { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int hQdiKPqkPe = Integer . parseInt ( sc . next ( ) ) ; if ( hQdiKPqkPe % 2 == 0 ) { System . out . println ( hQdiKPqkPe / 2 ) ; } else { System . out . println ( ( hQdiKPqkPe + 1 ) / 2 ) ; } } } import java . util . Scanner ; class eogQLnZiVF { 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 eogQLnZiVF = 0 ; for ( int i = 0 ; i < input . length ( ) ; ++ i ) { char ch = input . charAt ( i ) ; eogQLnZiVF += Character . getNumericValue ( ch ) ; } System . out . println ( eogQLnZiVF ) ; } } } import java . util . * ; public class xzPZjgBUuH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] nt = line . split ( " " ) ; int xzPZjgBUuH = Integer . parseInt ( nt [ 0 ] ) ; int t = Integer . parseInt ( nt [ 1 ] ) ; String rel = " TLE " ; for ( int i = 0 ; i < xzPZjgBUuH ; 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 jhtwVISUhB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jhtwVISUhB = 0 ; String s = sc . nextLine ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '+' ) { jhtwVISUhB ++ ; } else if ( s . charAt ( i ) == '-' ) { jhtwVISUhB -- ; } } System . out . println ( jhtwVISUhB ) ; } } import java . util . * ; public class fBdIntcwxw { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String fBdIntcwxw = sc . next ( ) ; if ( fBdIntcwxw . toUpperCase ( ) . equals ( fBdIntcwxw ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . Scanner ; public class hMcZGDsnQT { public static void main ( String [ ] args ) { Diagram diagram = new Diagram ( ) ; try ( Scanner stdin = new Scanner ( System . in ) ) { int hMcZGDsnQT , w ; while ( stdin . hasNext ( ) ) { hMcZGDsnQT = Integer . parseInt ( stdin . next ( ) ) ; w = Integer . parseInt ( stdin . next ( ) ) ; if ( hMcZGDsnQT < 0 || hMcZGDsnQT > 300 || w < 0 || w > 300 ) { throw new RuntimeException ( " Input Error:Range 0 to 300 " ) ; } if ( hMcZGDsnQT == 0 && w == 0 ) { break ; } diagram . draw ( hMcZGDsnQT , w ) ; System . out . println ( " " ) ; } } catch ( RuntimeException e ) { e . printStackTrace ( ) ; } } } abstract class hMcZGDsnQT { abstract void draw ( int height , int width ) ; } class hMcZGDsnQT extends AbstractDiagram { @ Override void draw ( int hMcZGDsnQT , int w ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i <= hMcZGDsnQT ; i ++ ) { for ( int j = 1 ; j <= w ; j ++ ) { if ( ( i == 1 || i == hMcZGDsnQT ) || ( j == 1 || j == w ) ) { sb . append ( '#' ) ; } else { sb . append ( '.' ) ; } } System . out . println ( sb ) ; sb . setLength ( 0 ) ; } } } import java . util . Scanner ; public class TwkevoUTLX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TwkevoUTLX = sc . nextInt ( ) ; int point = sc . nextInt ( ) ; int min = point - TwkevoUTLX + 1 ; int max = point + TwkevoUTLX - 1 ; for ( int i = min ; i <= max ; i ++ ) { System . out . print ( i + " " ) ; } } } import java . util . * ; import java . io . * ; import java . math . * ; public class XQhOTILUQH { public static void main ( String [ ] omkar ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; String XQhOTILUQH = st . nextToken ( ) ; if ( XQhOTILUQH . charAt ( 2 ) == XQhOTILUQH . charAt ( 3 ) && XQhOTILUQH . charAt ( 4 ) == XQhOTILUQH . charAt ( 5 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class nHTDxKGpMG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nHTDxKGpMG = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int LMax = 0 ; int RMin = nHTDxKGpMG ; 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 NyNbtVihSd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NyNbtVihSd = sc . nextInt ( ) ; int cnt = 0 ; while ( NyNbtVihSd -- > 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 CumIoSTmTI { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int CumIoSTmTI = 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 <= CumIoSTmTI ; 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 ( CumIoSTmTI ) % 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 GFFIgmUADk { static class GFFIgmUADk { 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 GFFIgmUADk = ( int ) n . charAt ( 0 ) ; GFFIgmUADk ++ ; System . out . println ( ( char ) GFFIgmUADk ) ; } } import java . util . Scanner ; public class IrVaAWekDk { public static void main ( String ... nui ) { Scanner sc = new Scanner ( System . in ) ; int IrVaAWekDk = sc . nextInt ( ) ; int min = ( int ) 1e9 ; for ( int i = 0 ; i < IrVaAWekDk ; 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 KuBKnLLnQw { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int KuBKnLLnQw = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] ints = new int [ KuBKnLLnQw ] [ m ] ; int [ ] line = new int [ KuBKnLLnQw ] ; int [ ] row = new int [ m ] ; int sum = 0 ; for ( int i = 0 ; i < KuBKnLLnQw ; 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 < KuBKnLLnQw + 1 ; i ++ ) { for ( int j = 0 ; j < m + 1 ; j ++ ) { if ( i == KuBKnLLnQw && j == m ) { System . out . print ( sum ) ; } else if ( j == m ) { System . out . print ( line [ i ] ) ; } else if ( i == KuBKnLLnQw ) { 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 UXzRzuvZxW { 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 UXzRzuvZxW = Integer . parseInt ( tok [ 0 ] ) ; int B = Integer . parseInt ( tok [ 1 ] ) ; System . out . println ( UXzRzuvZxW * B ) ; } void calc ( ) { } void showResult ( ) { } } import java . util . Scanner ; public class iBshPuUmqm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iBshPuUmqm = Integer . parseInt ( sc . next ( ) ) ; int b = iBshPuUmqm + ( iBshPuUmqm * iBshPuUmqm ) + ( iBshPuUmqm * iBshPuUmqm * iBshPuUmqm ) ; System . out . println ( b ) ; } } import java . util . Scanner ; public class uBwFcasYfL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uBwFcasYfL = sc . nextInt ( ) ; long [ ] a = new long [ uBwFcasYfL ] ; for ( int i = 0 ; i < uBwFcasYfL ; i ++ ) { a [ i ] = sc . nextLong ( ) ; if ( a [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } long prod = 1 ; for ( int i = 0 ; i < uBwFcasYfL ; 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 lRLooZcyII { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int lRLooZcyII = scan . nextInt ( ) ; int [ ] a = new int [ lRLooZcyII + 1 ] ; for ( int i = 1 ; i < lRLooZcyII ; i ++ ) { int j = scan . nextInt ( ) ; a [ j ] ++ ; } for ( int i = 1 ; i < lRLooZcyII + 1 ; i ++ ) { System . out . println ( a [ i ] ) ; } } } import java . io . * ; class sHWnaEBUuC { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String input = br . readLine ( ) ; double sHWnaEBUuC = Double . parseDouble ( input ) ; double s = sHWnaEBUuC * sHWnaEBUuC * Math . PI ; double l = sHWnaEBUuC * 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 MQCocpstES { public static void main ( String [ ] Args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int MQCocpstES = 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 ) { MQCocpstES = 1 ; } } if ( MQCocpstES == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class NPaznMZJxO { public static void main ( String [ ] args ) { try { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line ; while ( ( line = stdReader . readLine ( ) ) != null ) { int NPaznMZJxO = Integer . parseInt ( line ) ; System . out . println ( NPaznMZJxO * NPaznMZJxO * NPaznMZJxO ) ; } stdReader . close ( ) ; } catch ( Exception e ) { e . getStackTrace ( ) ; System . exit ( 0 ) ; } } } import java . util . * ; import java . text . * ; public class zqiEYGEXTq { 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 zqiEYGEXTq = formatDate2 . after ( formatDate ) ; if ( ! zqiEYGEXTq ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } } } import java . util . * ; public class OnqDMDxOla { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OnqDMDxOla = 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 [ OnqDMDxOla ] [ 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 WEKhyQeXVN { 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 WEKhyQeXVN = scan . nextInt ( ) ; int A = scan . nextInt ( ) ; int ans = ( int ) Math . ceil ( ( double ) WEKhyQeXVN / A ) ; os . println ( ans ) ; } } import java . util . Scanner ; public class TgfBWmkUZW { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int TgfBWmkUZW = 0 ; int ans = 0 ; for ( int i = 1 ; i < 6 ; i ++ ) { TgfBWmkUZW = scan . nextInt ( ) ; if ( TgfBWmkUZW == 0 ) { ans = i ; } } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class rjrtjZnlfM { public static void main ( String ... args ) { Scanner scanner = new Scanner ( System . in ) ; int rjrtjZnlfM = scanner . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; int cnt = 1 ; for ( int i = 0 ; i < rjrtjZnlfM ; i ++ ) { int sc = scanner . nextInt ( ) ; if ( sc == cnt ) { list . add ( cnt ++ ) ; } } int rst = rjrtjZnlfM - list . size ( ) ; System . out . println ( rst == rjrtjZnlfM ? - 1 : rst ) ; } } import java . util . * ; public class KoBaHXgwnJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KoBaHXgwnJ = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] b = new int [ KoBaHXgwnJ ] [ 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 < KoBaHXgwnJ ; i ++ ) { if ( b [ i ] [ 0 ] > 0 ) { ok ++ ; ng += b [ i ] [ 1 ] ; } } System . out . println ( ok + " " + ng ) ; } } import java . util . Scanner ; public class VUNiXOTTZi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VUNiXOTTZi = 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 QtdhMtNJyR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QtdhMtNJyR = 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 >= QtdhMtNJyR ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class uiuMjrNeGZ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] n = new int [ 3 ] ; for ( int uiuMjrNeGZ = 0 ; uiuMjrNeGZ < 3 ; uiuMjrNeGZ ++ ) { n [ uiuMjrNeGZ ] = scan . nextInt ( ) ; } int k = scan . nextInt ( ) ; Arrays . sort ( n ) ; for ( int uiuMjrNeGZ = 0 ; uiuMjrNeGZ < k ; uiuMjrNeGZ ++ ) { n [ 2 ] *= 2 ; } int a = 0 ; for ( int uiuMjrNeGZ = 0 ; uiuMjrNeGZ < 3 ; uiuMjrNeGZ ++ ) { a += n [ uiuMjrNeGZ ] ; } System . out . println ( a ) ; } } import java . util . Scanner ; public class mhnGlfNTLK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int mhnGlfNTLK = 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 { mhnGlfNTLK ++ ; } } } System . out . println ( mhnGlfNTLK ) ; } } } import java . util . * ; public class AHwrIuQXFY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AHwrIuQXFY = sc . nextInt ( ) ; int [ ] a = new int [ AHwrIuQXFY + 1 ] ; for ( int i = 1 ; i <= AHwrIuQXFY ; 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 qxceqHqNVL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qxceqHqNVL = sc . nextInt ( ) ; int [ ] k = new int [ qxceqHqNVL ] ; Boolean allZero = false ; int count = 0 ; for ( int i = 0 ; i < qxceqHqNVL ; i ++ ) { k [ i ] = sc . nextInt ( ) ; } while ( ! allZero ) { allZero = true ; int now = 0 ; Boolean isZero = true ; while ( now < qxceqHqNVL ) { 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 BUiBLMCOoO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long BUiBLMCOoO = Long . parseLong ( sc . next ( ) ) ; long r = Long . parseLong ( sc . next ( ) ) ; long ans = Long . MAX_VALUE ; long num = 0 ; for ( long i = BUiBLMCOoO ; 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 tcuSdeevSf { 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 tcuSdeevSf { int tcuSdeevSf = - 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 - tcuSdeevSf + 1 < K ) { start = tcuSdeevSf ; 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 bNeseMBoVF { 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 bNeseMBoVF = sc . nextInt ( ) ; Arrays . parallelSort ( A ) ; System . out . println ( A [ 0 ] + A [ 1 ] + ( int ) ( A [ 2 ] * Math . pow ( 2 , bNeseMBoVF ) ) ) ; } } import java . util . Scanner ; class dgictWILbW { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int dgictWILbW = 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 ) == dgictWILbW && ( int ) ( pc * 0.1 ) == b ) { while ( ( int ) ( pc * 0.08 ) == dgictWILbW && ( int ) ( pc * 0.1 ) == b ) { pc -- ; } pc ++ ; System . out . println ( pc ) ; return ; } else if ( ( int ) ( pc * 0.08 ) < dgictWILbW || ( int ) ( pc * 0.1 ) < b ) { pl = pc + 1 ; } else if ( ( int ) ( pc * 0.08 ) > dgictWILbW || ( int ) ( pc * 0.1 ) > b ) { pr = pc - 1 ; } } while ( pl <= pr ) ; System . out . println ( - 1 ) ; } } import java . util . * ; class REeBlJsyjf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int REeBlJsyjf = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; String tmp = sc . nextLine ( ) ; for ( int i = 0 ; i < REeBlJsyjf ; ++ 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 UoezZAhbcL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UoezZAhbcL = sc . nextInt ( ) ; int [ ] n = new int [ UoezZAhbcL ] ; for ( int i = 0 ; i < UoezZAhbcL ; i ++ ) { n [ i ] = sc . nextInt ( ) ; } Arrays . sort ( n ) ; int sum = 0 ; for ( int i = 0 ; i < UoezZAhbcL - 1 ; i ++ ) { sum += n [ i ] ; } if ( n [ UoezZAhbcL - 1 ] < sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class hCKJahbBKX { public static void main ( String [ ] args ) { solve_149_B ( ) ; return ; } private static void solve_149_B ( ) { Scanner sc = new Scanner ( System . in ) ; long hCKJahbBKX = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; if ( hCKJahbBKX >= K ) { hCKJahbBKX = hCKJahbBKX - K ; } else { if ( B >= ( K - hCKJahbBKX ) ) { B = B - ( K - hCKJahbBKX ) ; } else { B = 0 ; } hCKJahbBKX = 0 ; } System . out . println ( hCKJahbBKX + " " + B ) ; } } import java . util . Scanner ; public class lHXRgpPzQh { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int lHXRgpPzQh = scanner . nextInt ( ) ; int i = 0 ; int m = 0 ; i = lHXRgpPzQh / 500 ; lHXRgpPzQh = lHXRgpPzQh - 500 * i ; m = lHXRgpPzQh / 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 OgregdYsmk { 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 OgregdYsmk = date . compareTo ( today ) ; if ( OgregdYsmk <= 0 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } catch ( DateTimeParseException e ) { System . out . println ( " 堥力値がyyyy/mm/dd形式ではありません"); } } } import java . util . * ; public class zzLgHzdxsi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zzLgHzdxsi = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; String s = sc . next ( ) ; StringBuffer buf = new StringBuffer ( ) ; for ( int i = 0 ; i < zzLgHzdxsi ; 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 xbXRWLewsm { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int xbXRWLewsm = scn . nextInt ( ) ; float temp = ( float ) xbXRWLewsm / 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 TFKPYAXtOW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TFKPYAXtOW = sc . nextInt ( ) ; sc . close ( ) ; int c = TFKPYAXtOW / 4 ; int d = TFKPYAXtOW / 7 ; for ( int i = 0 ; i <= c ; i ++ ) { for ( int j = 0 ; j <= d ; j ++ ) { if ( 4 * i + 7 * j == TFKPYAXtOW ) { System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } } import java . util . * ; public class FQSiFghVXg { 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 FQSiFghVXg = sortedString . length ( ) ; int cnt = 0 ; char tmpVal = sortedString . charAt ( 0 ) ; if ( FQSiFghVXg <= 1 ) { System . out . println ( " No " ) ; return ; } for ( int i = 0 ; i < FQSiFghVXg ; 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 JtyRhpFBTJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int JtyRhpFBTJ = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; int m = JtyRhpFBTJ * y ; int n = 2 * JtyRhpFBTJ + 2 * y ; System . out . println ( m + " " + n ) ; } } import java . util . * ; public class LtVDLVzwDF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LtVDLVzwDF = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = LtVDLVzwDF * 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 ToUgAzzSYU { public static int prime ( int x ) { int ToUgAzzSYU = 0 ; if ( x == 1 ) { ToUgAzzSYU = 1 ; } else if ( x % 2 == 0 ) { ToUgAzzSYU = 1 ; } for ( int i = 3 ; i <= Math . sqrt ( x ) ; i += 2 ) { if ( x % i == 0 ) { ToUgAzzSYU = 1 ; break ; } } if ( x == 2 ) { ToUgAzzSYU = 0 ; } return ToUgAzzSYU ; } 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 fhLeBWxzdZ { 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 fhLeBWxzdZ = Integer . parseInt ( st . nextToken ( ) ) ; int y = Integer . parseInt ( st . nextToken ( ) ) ; System . out . print ( fhLeBWxzdZ * y ) ; System . out . print ( " " ) ; System . out . println ( 2 * fhLeBWxzdZ + 2 * y ) ; } } import java . io . * ; import java . util . * ; class lLrZgjavup { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int lLrZgjavup = Integer . parseInt ( st . nextToken ( ) ) ; int T = Integer . parseInt ( st . nextToken ( ) ) ; int S = Integer . parseInt ( st . nextToken ( ) ) ; float tmp = ( float ) lLrZgjavup / T ; if ( S >= tmp ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class SREwVgSKge { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SREwVgSKge = 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 ( SREwVgSKge - sum >= 0 ) { System . out . print ( ( SREwVgSKge - sum ) ) ; } else { System . out . print ( - 1 ) ; } } } import java . util . * ; public class mMxclhyHDm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mMxclhyHDm = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; double sum = 0 ; int cnt = 0 ; Integer [ ] items = new Integer [ mMxclhyHDm ] ; for ( int i = 0 ; i < mMxclhyHDm ; 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 zqqlezGMKY { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int zqqlezGMKY = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; int K = in . nextInt ( ) ; int sum = zqqlezGMKY + B + C ; int max = Math . max ( zqqlezGMKY , Math . max ( B , C ) ) ; sum += - max + ( max << K ) ; System . out . println ( sum ) ; } } } import java . util . Scanner ; public class prRavaMsUM { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int prRavaMsUM = input . nextInt ( ) ; int [ ] level = new int [ prRavaMsUM ] ; int count = 1 ; int min = 0 ; for ( int i = 0 ; i < prRavaMsUM ; 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 gzaRotxExR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gzaRotxExR = sc . nextInt ( ) ; int strength1 = sc . nextInt ( ) ; int health2 = sc . nextInt ( ) ; int strength2 = sc . nextInt ( ) ; while ( true ) { health2 -= strength1 ; if ( health2 <= 0 ) break ; gzaRotxExR -= strength2 ; if ( gzaRotxExR <= 0 ) break ; } if ( gzaRotxExR > health2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class ScSeNAqwal { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int ScSeNAqwal = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; if ( ScSeNAqwal == - 1 && f == - 1 && r == - 1 ) { break ; } else { int x ; x = ScSeNAqwal + f ; if ( ScSeNAqwal == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } if ( x >= 80 && ScSeNAqwal != - 1 && f != - 1 ) { System . out . println ( " A " ) ; } if ( x < 80 && x >= 65 && ScSeNAqwal != - 1 && f != - 1 ) { System . out . println ( " B " ) ; } if ( x < 65 && x >= 50 && ScSeNAqwal != - 1 && f != - 1 ) { System . out . println ( " C " ) ; } if ( x < 50 && x >= 30 && ScSeNAqwal != - 1 && f != - 1 && r >= 50 ) { System . out . println ( " C " ) ; } if ( x >= 30 && x < 50 && ScSeNAqwal != - 1 && f != - 1 && r < 50 ) { System . out . println ( " D " ) ; } if ( x < 30 && ScSeNAqwal != - 1 && f != - 1 ) { System . out . println ( " F " ) ; } } } } } import java . util . Scanner ; public class fkksdwdiqN { static Scanner scanner ; public static void main ( String [ ] args ) { scanner = new Scanner ( System . in ) ; int fkksdwdiqN = gi ( ) ; int M = gi ( ) ; int a = ( int ) Math . ceil ( ( double ) ( M - 1 ) / ( double ) ( fkksdwdiqN - 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 OaJAUDWljU { static final Scanner stdin = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { while ( stdin . hasNext ( ) ) { int OaJAUDWljU = stdin . nextInt ( ) ; int b = stdin . nextInt ( ) ; int comp_val = OaJAUDWljU - b ; int num , aval , m , n , ans1 ; if ( comp_val > 0 ) { for ( int i = 0 ; i <= OaJAUDWljU ; i ++ ) { aval = OaJAUDWljU - i ; if ( OaJAUDWljU % aval == 0 && b % aval == 0 ) { m = OaJAUDWljU / 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 ( OaJAUDWljU % aval == 0 && b % aval == 0 ) { m = OaJAUDWljU / aval ; n = b / aval ; ans1 = m * n * aval ; System . out . println ( aval + " " + ans1 ) ; break ; } } } } } } import java . util . Scanner ; public class JllzHzYXKn { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String S = input . next ( ) ; long JllzHzYXKn = 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 ) ; JllzHzYXKn -= ( long ) Math . pow ( n , days ) ; if ( JllzHzYXKn <= 0 ) { System . out . println ( c ) ; return ; } } } } import java . util . Scanner ; public class jhwmMZlWKE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jhwmMZlWKE = sc . nextInt ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) for ( int a = 1 ; a <= 9 ; a ++ ) { if ( i * a == jhwmMZlWKE ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class fgTUDuznjg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String fgTUDuznjg = sc . next ( ) ; char [ ] wordStr = fgTUDuznjg . 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 CYCkETvkjg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int CYCkETvkjg = 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 ( CYCkETvkjg - studyDay >= 0 ) { playable = CYCkETvkjg - studyDay ; System . out . println ( playable ) ; } else { System . out . println ( " -1 " ) ; } scanner . close ( ) ; } } import java . util . * ; public class iEJyQNOWjD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iEJyQNOWjD = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] c = new int [ iEJyQNOWjD ] ; int [ ] t = new int [ iEJyQNOWjD ] ; int cmin = 1001 ; int twithin = 1001 ; for ( int i = 0 ; i < iEJyQNOWjD ; 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 HWTQfJBtaG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HWTQfJBtaG = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; String ss = s ; ss = ss . substring ( HWTQfJBtaG , HWTQfJBtaG + 1 ) ; if ( ss . equals ( " - " ) ) { s = s . replace ( " - " , " " ) ; int slen = s . length ( ) ; if ( slen == HWTQfJBtaG + b ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class iqngzUAQmP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iqngzUAQmP = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; if ( C - ( iqngzUAQmP - B ) < 0 ) { System . out . println ( 0 ) ; } else { System . out . println ( C - ( iqngzUAQmP - B ) ) ; } } } import java . util . * ; public class JNUbVDWkhD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JNUbVDWkhD = sc . nextInt ( ) ; int [ ] arr = new int [ JNUbVDWkhD ] ; for ( int i = 0 ; i < JNUbVDWkhD ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int [ ] leftSum = new int [ JNUbVDWkhD ] ; leftSum [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < JNUbVDWkhD ; i ++ ) leftSum [ i ] = leftSum [ i - 1 ] + arr [ i ] ; int [ ] rightSum = new int [ JNUbVDWkhD ] ; rightSum [ JNUbVDWkhD - 1 ] = arr [ JNUbVDWkhD - 1 ] ; for ( int i = JNUbVDWkhD - 2 ; i >= 0 ; i -- ) { rightSum [ i ] += rightSum [ i + 1 ] + arr [ i ] ; } int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < JNUbVDWkhD - 1 ; i ++ ) min = Math . min ( min , Math . abs ( leftSum [ i ] - rightSum [ i + 1 ] ) ) ; System . out . println ( min ) ; } } import java . util . * ; public class osdVAnmtGR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int osdVAnmtGR = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] [ ] a = new int [ osdVAnmtGR ] [ m ] ; int [ ] [ ] b = new int [ m ] [ l ] ; for ( int i = 0 ; i < osdVAnmtGR ; 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 < osdVAnmtGR ; 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 lDOXNeCgtF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int lDOXNeCgtF = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == '1' ) { lDOXNeCgtF += 1 ; } } System . out . println ( lDOXNeCgtF ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; public class srphpPqTXT { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] parts = br . readLine ( ) . split ( " " ) ; long srphpPqTXT = 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 yVZnsiOthc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yVZnsiOthc = sc . nextInt ( ) ; int [ ] x = new int [ yVZnsiOthc ] ; for ( int i = 0 ; i < yVZnsiOthc ; i ++ ) x [ i ] = sc . nextInt ( ) ; Arrays . sort ( x ) ; int alice = 0 ; int bob = 0 ; if ( yVZnsiOthc % 2 == 0 ) { for ( int i = yVZnsiOthc - 1 ; i >= 0 ; i -= 2 ) { alice += x [ i ] ; bob += x [ i - 1 ] ; } } if ( yVZnsiOthc % 2 != 0 ) { if ( yVZnsiOthc == 1 ) alice += x [ 0 ] ; else { for ( int i = 0 ; i < yVZnsiOthc ; i += 2 ) alice += x [ i ] ; for ( int i = 1 ; i < yVZnsiOthc ; i += 2 ) bob += x [ i ] ; } } System . out . println ( alice - bob ) ; } } import java . util . * ; public class KGlqCwLtqH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KGlqCwLtqH = 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 <= KGlqCwLtqH ; ++ i ) { if ( KGlqCwLtqH % 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 ZezhLMPhkY { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int ZezhLMPhkY = s . nextInt ( ) ; int [ ] arr = new int [ ZezhLMPhkY ] ; for ( int i = 0 ; i < ZezhLMPhkY ; i ++ ) { arr [ i ] = s . nextInt ( ) ; } long [ ] dp = new long [ ZezhLMPhkY ] ; dp [ 0 ] = 0 ; for ( int i = 1 ; i < ZezhLMPhkY ; 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 [ ZezhLMPhkY - 1 ] ) ; } } import java . util . * ; class jsEjlFLhdj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long jsEjlFLhdj = sc . nextLong ( ) ; double B = sc . nextDouble ( ) ; long ans = 0 ; ans = jsEjlFLhdj * ( Math . round ( B * 100 ) ) / 100 ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class QonijAGydw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QonijAGydw = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int count = 0 ; while ( QonijAGydw != 0 || x != 0 ) { for ( int i = 1 ; i <= QonijAGydw ; i ++ ) { for ( int j = i + 1 ; j <= QonijAGydw ; j ++ ) { for ( int k = j + 1 ; k <= QonijAGydw ; k ++ ) { if ( i + j + k == x ) { count ++ ; } } } } System . out . println ( count ) ; QonijAGydw = scan . nextInt ( ) ; x = scan . nextInt ( ) ; count = 0 ; } } } import java . util . * ; public class joRaWvsWeC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char [ ] a = s . toCharArray ( ) ; for ( int joRaWvsWeC = a . length - 1 ; joRaWvsWeC >= 0 ; joRaWvsWeC -- ) System . out . print ( a [ joRaWvsWeC ] ) ; System . out . println ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; class ThHIxQEwda { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String name ; int ThHIxQEwda ; 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 qBCFlXioaN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] n = sc . nextLine ( ) . toCharArray ( ) ; int qBCFlXioaN = 0 ; for ( char c : n ) { qBCFlXioaN += Character . getNumericValue ( c ) ; } if ( qBCFlXioaN % 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 lOspRUSgAo { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int lOspRUSgAo = 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 vSHjweJIMB { public static void main ( String [ ] args ) throws IOException { int vSHjweJIMB = 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 ) vSHjweJIMB = Integer . parseInt ( current ) ; if ( i == 1 ) b = Integer . parseInt ( current ) ; if ( i == 2 ) c = Integer . parseInt ( current ) ; i ++ ; } if ( vSHjweJIMB < 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 fHtMYLpMBg { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int fHtMYLpMBg = s . nextInt ( ) ; int numn = s . nextInt ( ) ; if ( numn == 0 ) { System . out . println ( fHtMYLpMBg ) ; 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 ( fHtMYLpMBg ) ) { ans = fHtMYLpMBg ; flg_con = false ; } int count = 0 ; while ( flg_con ) { count ++ ; int mnx = fHtMYLpMBg - count ; int plx = fHtMYLpMBg + 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 xwEnASfjdv { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xwEnASfjdv = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = 0 ; if ( xwEnASfjdv % 2 == 1 ) { count ++ ; } char [ ] work = new char [ s . length ( ) ] ; for ( int i = 0 ; i < xwEnASfjdv ; i ++ ) { work [ i ] = s . charAt ( i ) ; } for ( int i = 0 ; i < xwEnASfjdv / 2 ; i ++ ) { if ( work [ i ] == work [ i + xwEnASfjdv / 2 ] ) { } else { count ++ ; } } if ( count == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class TEOJmvZiFM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TEOJmvZiFM = 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 < TEOJmvZiFM + 1 ; k ++ ) { int W = Z - 500 * k ; if ( W == 0 ) { cnt ++ ; continue ; } } } } System . out . println ( cnt ) ; } } import java . util . * ; public class YkkZchbLhX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YkkZchbLhX = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ 101 ] ; for ( int i = 1 ; i <= 100 ; i ++ ) { if ( ( YkkZchbLhX % 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 xEGiyeMBMa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int xEGiyeMBMa = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { xEGiyeMBMa += str . charAt ( i ) - '0' ; } System . out . println ( Integer . parseInt ( str ) % xEGiyeMBMa == 0 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class soxchkRbou { 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 soxchkRbou = 0 ; soxchkRbou < str . length ; soxchkRbou ++ ) a [ soxchkRbou ] = Integer . parseInt ( str [ soxchkRbou ] ) ; 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 oUHclPmYVZ { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] nums = br . readLine ( ) . split ( " " ) ; br . close ( ) ; int oUHclPmYVZ = Integer . parseInt ( nums [ 0 ] ) ; int b = Integer . parseInt ( nums [ 1 ] ) ; if ( oUHclPmYVZ > 9 || b > 9 ) System . out . println ( - 1 ) ; else System . out . println ( oUHclPmYVZ * b ) ; } } import java . util . * ; class wxkPUvpifZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wxkPUvpifZ = sc . nextInt ( ) ; int [ ] T = new int [ wxkPUvpifZ + 1 ] ; int [ ] X = new int [ wxkPUvpifZ + 1 ] ; int [ ] Y = new int [ wxkPUvpifZ + 1 ] ; T [ 0 ] = X [ 0 ] = Y [ 0 ] = 0 ; boolean yes = true ; for ( int i = 1 ; i <= wxkPUvpifZ ; 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 tWTubIgkvM { 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 tWTubIgkvM = true ; int size = sc . nextInt ( ) ; if ( size > 100 ) { tWTubIgkvM = 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 ) { tWTubIgkvM = true ; } else { tWTubIgkvM = false ; break ; } } if ( ! slist . contains ( word ) ) { if ( tWTubIgkvM ) { slist . add ( word ) ; beforeWord = word ; } } else { tWTubIgkvM = false ; break ; } } if ( tWTubIgkvM ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class RjmhBJNFnl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int RjmhBJNFnl = Integer . parseInt ( sc . next ( ) ) ; int W = Integer . parseInt ( sc . next ( ) ) ; if ( RjmhBJNFnl == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < RjmhBJNFnl ; i ++ ) { if ( i == 0 || i == RjmhBJNFnl - 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 drrcwLtTrT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int drrcwLtTrT = sc . nextInt ( ) ; int ans = drrcwLtTrT + drrcwLtTrT * drrcwLtTrT + ( int ) Math . pow ( drrcwLtTrT , 3 ) ; System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; import java . math . BigInteger ; class TjyYwERvry { 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 rPDflaffPx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rPDflaffPx = Integer . parseInt ( sc . nextLine ( ) ) ; int result = 0 ; for ( int i = 0 ; i < rPDflaffPx ; 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 aZkewmhVrD { 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 aZkewmhVrD = 0 ; int b = 0 ; for ( int i = 0 ; i < inputArray . length ; i ++ ) { if ( inputArray [ i ] . equals ( " + " ) ) { aZkewmhVrD = stack . pop ( ) ; b = stack . pop ( ) ; stack . add ( b + aZkewmhVrD ) ; continue ; } if ( inputArray [ i ] . equals ( " - " ) ) { aZkewmhVrD = stack . pop ( ) ; b = stack . pop ( ) ; stack . add ( b - aZkewmhVrD ) ; continue ; } if ( inputArray [ i ] . equals ( " * " ) ) { aZkewmhVrD = stack . pop ( ) ; b = stack . pop ( ) ; stack . add ( b * aZkewmhVrD ) ; continue ; } stack . push ( Integer . parseInt ( inputArray [ i ] ) ) ; } System . out . println ( stack . pop ( ) ) ; } } import java . util . Arrays ; import java . util . Scanner ; class UXFWOVBwOi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UXFWOVBwOi = sc . nextInt ( ) ; long [ ] A = new long [ UXFWOVBwOi ] ; for ( long i = 0L ; i < UXFWOVBwOi ; i ++ ) { long t = sc . nextLong ( ) * 100000000L + ( i + 1L ) ; A [ ( int ) i ] = t ; } Arrays . sort ( A ) ; for ( int i = 0 ; i < UXFWOVBwOi - 1 ; i ++ ) { System . out . print ( A [ i ] % 100000000 + " " ) ; } System . out . println ( A [ UXFWOVBwOi - 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 rbdZhZjhFQ { public static int [ ] sorted ( int [ ] inputs ) { int [ ] res = Arrays . copyOf ( inputs , inputs . length ) ; for ( int rbdZhZjhFQ = 0 ; rbdZhZjhFQ < res . length ; rbdZhZjhFQ ++ ) { for ( int j = 1 ; j < res . length - rbdZhZjhFQ ; j ++ ) { if ( res [ j - 1 ] > res [ j ] ) { int tmp = res [ j - 1 ] ; res [ j - 1 ] = res [ j ] ; res [ j ] = tmp ; } } } return res ; } } public class rbdZhZjhFQ { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] inputs = new int [ 3 ] ; int rbdZhZjhFQ = 0 ; while ( scan . hasNext ( ) ) { inputs [ rbdZhZjhFQ ] = scan . nextInt ( ) ; rbdZhZjhFQ ++ ; } 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 gczeWgvlGj { public static void main ( String [ ] args ) throws IOException { int gczeWgvlGj = 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 ) gczeWgvlGj = Integer . parseInt ( current ) ; if ( i == 1 ) b = Integer . parseInt ( current ) ; if ( i == 2 ) c = Integer . parseInt ( current ) ; i ++ ; } if ( gczeWgvlGj > c ) { tmp = gczeWgvlGj ; gczeWgvlGj = c ; c = tmp ; } if ( gczeWgvlGj > b ) { tmp = gczeWgvlGj ; gczeWgvlGj = b ; b = tmp ; } if ( b > c ) { tmp = b ; b = c ; c = tmp ; } System . out . println ( gczeWgvlGj + " " + b + " " + c ) ; } } import java . util . * ; public class sCxFoYDcLU { 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 sCxFoYDcLU = a . charAt ( 0 ) ; a . deleteCharAt ( 0 ) ; Main . nextTurn ( sCxFoYDcLU ) ; } public static void nextTurn ( char card ) { if ( card == 'a' ) { if ( a . length ( ) == 0 ) { System . out . println ( " A " ) ; return ; } char sCxFoYDcLU = a . charAt ( 0 ) ; a . deleteCharAt ( 0 ) ; Main . nextTurn ( sCxFoYDcLU ) ; } else if ( card == 'b' ) { if ( b . length ( ) == 0 ) { System . out . println ( " B " ) ; return ; } char sCxFoYDcLU = b . charAt ( 0 ) ; b . deleteCharAt ( 0 ) ; Main . nextTurn ( sCxFoYDcLU ) ; } else if ( card == 'c' ) { if ( c . length ( ) == 0 ) { System . out . println ( " C " ) ; return ; } char sCxFoYDcLU = c . charAt ( 0 ) ; c . deleteCharAt ( 0 ) ; Main . nextTurn ( sCxFoYDcLU ) ; } } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class VUYRLHUofl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VUYRLHUofl = Integer . parseInt ( sc . nextLine ( ) ) ; Map < String , Long > m = new HashMap < > ( ) ; for ( int i = 0 ; i < VUYRLHUofl ; 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 hHVRAtAnrG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hHVRAtAnrG = sc . nextInt ( ) ; System . out . println ( ( 10000 - hHVRAtAnrG ) % 1000 ) ; sc . close ( ) ; } } import java . util . * ; public class RIMZgoKoIS { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int RIMZgoKoIS = sc . nextInt ( ) ; long A = ( long ) ( Math . pow ( 10 , 18 ) ) ; long [ ] B = new long [ RIMZgoKoIS ] ; boolean chk_0 = false ; for ( int i = 0 ; i < RIMZgoKoIS ; 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 FAuZNTRVRc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FAuZNTRVRc = sc . nextInt ( ) ; int [ ] [ ] t = new int [ FAuZNTRVRc ] [ 3 ] ; for ( int i = 0 ; i < FAuZNTRVRc ; 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 oBlyQiQTbY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oBlyQiQTbY = Integer . parseInt ( sc . next ( ) ) ; Integer [ ] d1 = new Integer [ oBlyQiQTbY ] ; Integer [ ] d2 = new Integer [ oBlyQiQTbY ] ; for ( int i = 0 ; i < oBlyQiQTbY ; 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 < oBlyQiQTbY ; 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 eBDPxUPGTG { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int eBDPxUPGTG = scanner . nextInt ( ) ; String s = scanner . next ( ) ; System . out . println ( ( eBDPxUPGTG - s . replaceAll ( " ABC " , " " ) . length ( ) ) / 3 ) ; } } import java . util . * ; import java . util . Map . Entry ; import java . util . stream . Collectors ; public class awMnCqKJTP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int awMnCqKJTP = sc . nextInt ( ) ; String [ ] S = new String [ awMnCqKJTP ] ; for ( int i = 0 ; i < awMnCqKJTP ; 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 xfCarOPVOd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xfCarOPVOd = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = 0 ; int [ ] d = new int [ xfCarOPVOd ] ; for ( int i = 0 ; i < xfCarOPVOd ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < xfCarOPVOd ; i ++ ) { if ( d [ i ] >= b ) { c ++ ; } } System . out . println ( c ) ; } } import java . util . * ; import java . io . * ; public class cnBTexYLLi { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; long cnBTexYLLi = sc . nextLong ( ) ; long m = sc . nextLong ( ) ; if ( cnBTexYLLi > m ) System . out . println ( cnBTexYLLi * m / gcd ( cnBTexYLLi , m ) ) ; else System . out . println ( cnBTexYLLi * m / gcd ( m , cnBTexYLLi ) ) ; } 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 WfCAoiLKnJ { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { long WfCAoiLKnJ = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; long c = gcd ( WfCAoiLKnJ , b ) ; long d = WfCAoiLKnJ * b / c ; System . out . println ( c + " " + d ) ; } sc . close ( ) ; } public long gcd ( long WfCAoiLKnJ , long b ) { if ( b == 0 ) { return WfCAoiLKnJ ; } else { return gcd ( b , WfCAoiLKnJ % b ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class nTmjWYcpaE { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int nTmjWYcpaE ; int result ; String readLine = br . readLine ( ) ; nTmjWYcpaE = Integer . parseInt ( readLine ) ; result = nTmjWYcpaE * nTmjWYcpaE * nTmjWYcpaE ; System . out . println ( result ) ; } } import java . util . Scanner ; public class hwvKSWPLbx { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int hwvKSWPLbx = in . nextInt ( ) ; int [ ] order = new int [ hwvKSWPLbx + 1 ] ; for ( int i = 1 ; i <= hwvKSWPLbx ; i ++ ) { order [ in . nextInt ( ) ] = i ; } for ( int i = 1 ; i <= hwvKSWPLbx ; i ++ ) { System . out . print ( order [ i ] + " " ) ; } in . close ( ) ; } } import java . util . * ; class NyVgecEvRi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NyVgecEvRi = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] a = new int [ NyVgecEvRi ] ; for ( int i = 0 ; i < NyVgecEvRi ; 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 DVzQjmDmUV { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s , t ; int DVzQjmDmUV , b ; String u ; s = scan . next ( ) ; t = scan . next ( ) ; DVzQjmDmUV = scan . nextInt ( ) ; b = scan . nextInt ( ) ; u = scan . next ( ) ; if ( u . equals ( s ) ) DVzQjmDmUV -= 1 ; else b -= 1 ; System . out . printf ( DVzQjmDmUV + " " + b ) ; } } import java . util . * ; class PCLbNjYYqN { public static void main ( String [ ] g ) { Scanner S = new Scanner ( System . in ) ; for ( int PCLbNjYYqN = S . nextInt ( ) , j , x , y , z , a [ ] = new int [ 3 ] ; PCLbNjYYqN -- > 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 ARJObwGqdT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ARJObwGqdT = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; ArrayList < Integer > aList = new ArrayList < Integer > ( ARJObwGqdT ) ; ArrayList < Integer > bList = new ArrayList < Integer > ( B ) ; for ( int i = 1 ; i <= ARJObwGqdT ; i ++ ) { if ( ARJObwGqdT % 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 SDgHhxaEHw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long SDgHhxaEHw = sc . nextInt ( ) ; long h = sc . nextInt ( ) ; long x = sc . nextInt ( ) ; long y = sc . nextInt ( ) ; long area = SDgHhxaEHw * h ; int multi ; if ( SDgHhxaEHw / 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 rREdbPhWxs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; String ans = " " ; String x = " 1 " ; for ( int rREdbPhWxs = 0 ; rREdbPhWxs < 3 ; rREdbPhWxs ++ ) { if ( n . charAt ( rREdbPhWxs ) == x . charAt ( 0 ) ) { ans += " 9 " ; } else { ans += " 1 " ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class fUNWqAeZmM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String x = sc . next ( ) ; int fUNWqAeZmM = 0 ; for ( int i = 0 ; i < x . length ( ) ; i ++ ) { fUNWqAeZmM += Character . getNumericValue ( x . charAt ( i ) ) ; } if ( fUNWqAeZmM % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . * ; class qaSaWNqeoc { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int qaSaWNqeoc = Integer . parseInt ( buf . readLine ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; int num = 0 ; for ( int j = 3 ; j <= qaSaWNqeoc ; 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 KUlERZiswk { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int KUlERZiswk = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int max = KUlERZiswk + b ; if ( max < KUlERZiswk - b ) { max = KUlERZiswk - b ; } if ( max < KUlERZiswk * b ) { max = KUlERZiswk * b ; } System . out . println ( max ) ; } } import java . io . * ; class OJOjDaVADw { public static void main ( String [ ] arg ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String keyword = br . readLine ( ) ; int OJOjDaVADw = 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 ) ) { OJOjDaVADw ++ ; } } } System . out . println ( OJOjDaVADw ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; public class XzwyhncYIH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XzwyhncYIH = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ XzwyhncYIH + 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 <= XzwyhncYIH ; i ++ ) { if ( arr [ i ] == 0 ) count ++ ; } count -- ; System . out . println ( count ) ; } } import java . util . Scanner ; public class KfuRlPWfAa { private static final Scanner SC = new Scanner ( System . in ) ; private static final int KfuRlPWfAa = SC . nextInt ( ) ; private static final int [ ] VALUE = load ( SC ) ; private static int [ ] load ( Scanner sc ) { int [ ] value = new int [ KfuRlPWfAa ] ; for ( int i = 0 ; i < KfuRlPWfAa ; 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 xNIwOrUslJ { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String a = scanner . next ( ) ; String b = scanner . next ( ) ; int xNIwOrUslJ = Math . min ( a . xNIwOrUslJ ( ) , b . xNIwOrUslJ ( ) ) ; int pos = 0 ; while ( pos < xNIwOrUslJ ) { if ( 0 != ( a . charAt ( pos ) ^ b . charAt ( pos ) ) ) { break ; } pos ++ ; } if ( a . substring ( pos ) . xNIwOrUslJ ( ) == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class msLYHcRwCt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int msLYHcRwCt = scan . nextInt ( ) ; int sum = msLYHcRwCt / 1000 ; if ( msLYHcRwCt % 1000 == 0 ) { System . out . println ( 0 ) ; } else { sum += 1 ; int goukei = ( 1000 * sum ) - msLYHcRwCt ; System . out . println ( goukei ) ; } } } import java . util . Scanner ; public class dnYPICMATZ { 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 dnYPICMATZ = 0 ; int cIndex = 0 ; for ( int i = 2 ; i < s . length ( ) - 1 ; i ++ ) { char c = s . charAt ( i ) ; if ( c == 'C' ) { dnYPICMATZ ++ ; cIndex = i ; } } if ( dnYPICMATZ != 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 HJaaKCAOCO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HJaaKCAOCO = sc . nextInt ( ) ; int [ ] arrayOishi = new int [ HJaaKCAOCO ] ; for ( int i = 0 ; i < arrayOishi . length ; i ++ ) { arrayOishi [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int j = 0 ; j < HJaaKCAOCO ; j ++ ) { for ( int k = j + 1 ; k < HJaaKCAOCO ; k ++ ) { result += arrayOishi [ j ] * arrayOishi [ k ] ; } } System . out . println ( result ) ; sc . close ( ) ; } } import java . io . IOException ; import java . util . Scanner ; public class tJMtnxvJMX { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int tJMtnxvJMX = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int [ ] [ ] a = new int [ tJMtnxvJMX ] [ y ] ; int [ ] [ ] b = new int [ y ] [ z ] ; for ( int i = 0 ; i < tJMtnxvJMX ; 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 < tJMtnxvJMX ; 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 UgmmvVlaUs { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int [ ] cnt = new int [ 26 ] ; int UgmmvVlaUs = 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 SGwWkshwzk { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int SGwWkshwzk = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] a = new int [ SGwWkshwzk ] ; for ( int i = 0 ; i < SGwWkshwzk ; 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 IMyXqLyZMO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IMyXqLyZMO = sc . nextInt ( ) ; int d = IMyXqLyZMO % 10 ; int c = IMyXqLyZMO / 10 % 10 ; int b = IMyXqLyZMO / 10 / 10 % 10 ; int a = IMyXqLyZMO / 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 tiQCoPwcjN { public static void main ( String [ ] args ) { Scanner scan ; int tiQCoPwcjN ; int B ; int C ; int K ; int Aa ; int Bb ; int Cc ; scan = new Scanner ( System . in ) ; tiQCoPwcjN = scan . nextInt ( ) ; B = scan . nextInt ( ) ; C = scan . nextInt ( ) ; K = scan . nextInt ( ) ; if ( K >= tiQCoPwcjN ) { Aa = tiQCoPwcjN ; 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 sDABQVQFPW { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( scan . hasNext ( ) ) { int sDABQVQFPW = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; while ( sDABQVQFPW != 0 && y != 0 ) { int t = y ; y = sDABQVQFPW ; sDABQVQFPW = t % sDABQVQFPW ; } System . out . println ( ( sDABQVQFPW == 0 ) ? y : sDABQVQFPW ) ; } } } import java . util . Scanner ; public class OtpUEeMQZI { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int OtpUEeMQZI = sc . nextInt ( ) ; int min = 1000000000 ; int max = - 1000000000 ; for ( int i = 0 ; i < OtpUEeMQZI ; 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 jZFEyXXcSc { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int jZFEyXXcSc = Integer . parseInt ( br . readLine ( ) ) ; int i ; String [ ] su = br . readLine ( ) . split ( " " ) ; StringBuilder outArray = new StringBuilder ( ) ; for ( i = jZFEyXXcSc - 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 aDpvSJsCzn { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int aDpvSJsCzn = in . nextInt ( ) ; long [ ] a = new long [ aDpvSJsCzn ] ; for ( int i = 0 ; i < aDpvSJsCzn ; i ++ ) a [ i ] = in . nextLong ( ) ; long curr = a [ 0 ] ; long total = 0 ; for ( int i = 1 ; i < aDpvSJsCzn ; i ++ ) { if ( a [ i ] >= curr ) curr = a [ i ] ; else { total += ( curr - a [ i ] ) ; } } System . out . println ( total ) ; } } class bgeoJlNGUj { public static void main ( String [ ] g ) throws Exception { double bgeoJlNGUj = 1e5 ; int n = 0 , i ; for ( ; ( i = System . in . read ( ) ) > 32 ; n = n * 10 + i - 48 ) ; for ( i = 1000 ; n -- > 0 ; bgeoJlNGUj += bgeoJlNGUj % i > 0 ? i - bgeoJlNGUj % i : 0 ) bgeoJlNGUj *= 1.05 ; System . out . println ( ( int ) bgeoJlNGUj ) ; } } import java . util . * ; public class JmAYPLtnDE { static final String ascii = " ABCDEFGHIJKLMNOPQRSTUVWXYZ " ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JmAYPLtnDE = sc . nextInt ( ) ; String str = sc . next ( ) ; if ( JmAYPLtnDE == 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 + JmAYPLtnDE ; if ( ri >= ascii . length ( ) ) { ri = ri - ascii . length ( ) ; } replaced = replaced + String . valueOf ( ascii . charAt ( ri ) ) ; } System . out . println ( replaced ) ; } } } import java . util . * ; public class kTpnnpTwIz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kTpnnpTwIz = sc . nextInt ( ) ; int [ ] a = new int [ kTpnnpTwIz + 1 ] ; int [ ] b = new int [ kTpnnpTwIz + 1 ] ; int [ ] c = new int [ kTpnnpTwIz ] ; String dm = " " ; for ( int i = 1 ; i <= kTpnnpTwIz ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= kTpnnpTwIz ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < kTpnnpTwIz ; i ++ ) { c [ i ] = sc . nextInt ( ) ; } int ans = 0 ; for ( int i = 1 ; i <= kTpnnpTwIz ; i ++ ) { ans += b [ a [ i ] ] ; if ( i < kTpnnpTwIz && a [ i + 1 ] == a [ i ] + 1 ) ans += c [ a [ i ] ] ; } System . out . println ( ans ) ; } } import java . io . * ; class iorfxNigyT { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = br . readLine ( ) ; String [ ] T ; int iorfxNigyT = 0 ; while ( true ) { T = br . readLine ( ) . split ( " " ) ; if ( T [ 0 ] . equals ( " END_OF_TEXT " ) ) break ; for ( String str : T ) { if ( str . equalsIgnoreCase ( W ) ) iorfxNigyT ++ ; } } System . out . println ( iorfxNigyT ) ; } } import java . util . * ; class EMWlnJTLzG { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int EMWlnJTLzG = sc . nextInt ( ) , m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ EMWlnJTLzG ] [ m ] ; for ( int i = 0 ; i < EMWlnJTLzG ; 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 < EMWlnJTLzG ; 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 PkhYGphOPD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long PkhYGphOPD = 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 ( PkhYGphOPD * c , PkhYGphOPD * 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 JQWJHFKSUv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JQWJHFKSUv = Integer . parseInt ( sc . next ( ) ) ; int [ ] ary = new int [ JQWJHFKSUv ] ; for ( int i = 0 ; i < JQWJHFKSUv ; i ++ ) { ary [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int ans = 0 ; for ( int i = 0 ; i < JQWJHFKSUv ; i ++ ) { for ( int j = i + 1 ; j < JQWJHFKSUv ; j ++ ) { ans += ary [ i ] * ary [ j ] ; } } System . out . println ( ans ) ; } } import java . util . * ; public class gtHEdGYfTa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gtHEdGYfTa = sc . nextInt ( ) ; int sum = 0 ; sum = gtHEdGYfTa / 2 ; if ( gtHEdGYfTa % 2 == 0 ) { System . out . print ( gtHEdGYfTa / 2 ) ; } else { sum = gtHEdGYfTa / 2 ; System . out . print ( sum + 1 ) ; } } } import java . util . * ; public class yvENOMaMUM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yvENOMaMUM = sc . nextInt ( ) ; int count = 0 ; int tens = ( ( yvENOMaMUM / 10 ) - ( ( int ) ( yvENOMaMUM / 100 ) ) * 10 ) * 10 ; int ones = yvENOMaMUM % 10 ; if ( ( yvENOMaMUM / 100 ) <= 12 && ( yvENOMaMUM / 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 mmZtHDxhaZ { public static void main ( String [ ] args ) throws NumberFormatException , IOException { Scanner scan = new Scanner ( System . in ) ; int mmZtHDxhaZ = 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 < mmZtHDxhaZ ; 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 < mmZtHDxhaZ ; 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 qwuaeYAuSR { static final long qwuaeYAuSR = 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 ] ) % qwuaeYAuSR ; } System . out . println ( dp [ n ] ) ; sc . close ( ) ; } } import java . util . Scanner ; import java . util . InputMismatchException ; class gVEnPaFWwE { public static void main ( String [ ] args ) { int gVEnPaFWwE = 0 , y = 0 , z = 0 ; int sum = 0 ; try { Scanner scanner = new Scanner ( System . in ) ; gVEnPaFWwE = scanner . nextInt ( ) ; y = scanner . nextInt ( ) ; z = scanner . nextInt ( ) ; scanner . close ( ) ; } catch ( InputMismatchException e ) { System . out . println ( " error " ) ; } for ( int i = gVEnPaFWwE ; i < z + 1 ; i = i + gVEnPaFWwE ) { sum = sum + y ; } System . out . println ( sum ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class azqJhakIfA { public static void main ( String [ ] args ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; try { String input = br . readLine ( ) ; int azqJhakIfA = Integer . parseInt ( input ) ; int i , x ; String ret = " " ; for ( i = 2 ; i <= azqJhakIfA ; 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 MfLJcBskUX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long MfLJcBskUX = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long t1 = ( MfLJcBskUX / ( a + b ) ) * a ; long t2 = MfLJcBskUX % ( a + b ) > a ? a : MfLJcBskUX % ( a + b ) ; sc . close ( ) ; System . out . println ( t1 + t2 ) ; } } import java . util . Scanner ; public class ChZGykUtXc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ChZGykUtXc = sc . nextInt ( ) ; int min = sc . nextInt ( ) ; int max = sc . nextInt ( ) ; int [ ] a = new int [ ChZGykUtXc ] ; int sum = 0 ; for ( int i = 0 ; i < ChZGykUtXc ; 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 vQztAKDNmX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long vQztAKDNmX = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( vQztAKDNmX >= k ) { System . out . println ( ( vQztAKDNmX - k ) + " " + b ) ; } else if ( b >= k - vQztAKDNmX ) { System . out . println ( " 0 " + " " + ( b - ( k - vQztAKDNmX ) ) ) ; } else { System . out . println ( " 0 0 " ) ; } } } import java . util . * ; public class KOyMUjNOij { static boolean [ ] targetNumbers ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KOyMUjNOij = sc . nextInt ( ) ; printPrimeNumbers2 ( 1000000 ) ; for ( int i = KOyMUjNOij ; 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 VWIaxaZXjF { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int VWIaxaZXjF = s . nextInt ( ) , B = s . nextInt ( ) , C = s . nextInt ( ) ; int temp = VWIaxaZXjF ; VWIaxaZXjF = B ; B = temp ; temp = VWIaxaZXjF ; VWIaxaZXjF = C ; C = temp ; System . out . println ( VWIaxaZXjF + " " + B + " " + C ) ; } } import java . util . Scanner ; public class WxvGyKenML { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WxvGyKenML = sc . nextInt ( ) ; int [ ] p = new int [ WxvGyKenML ] ; for ( int i = 0 ; i < WxvGyKenML ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } if ( isAsc ( p ) ) { System . out . println ( " YES " ) ; return ; } for ( int i = 0 ; i < WxvGyKenML - 1 ; i ++ ) { for ( int j = i + 1 ; j < WxvGyKenML ; 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 BSwmwEtUqb { 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 BSwmwEtUqb = 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 < ( BSwmwEtUqb - 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 zHBVEOCtNB { private void solve ( ) { Scanner in = new Scanner ( System . in ) ; int zHBVEOCtNB = in . nextInt ( ) ; int B = in . nextInt ( ) ; System . out . println ( Math . max ( zHBVEOCtNB + B , Math . max ( zHBVEOCtNB - B , zHBVEOCtNB * B ) ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class UpsRuFovzD { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int UpsRuFovzD = sc . nextInt ( ) ; int [ ] S = new int [ UpsRuFovzD ] ; for ( int i = 0 ; i < UpsRuFovzD ; 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 vSckvxjaXw { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int vSckvxjaXw = fs . nextInt ( ) ; if ( vSckvxjaXw == 0 ) { System . out . println ( 1 ) ; } else if ( vSckvxjaXw == 1 ) { System . out . println ( 0 ) ; } else { } } static class vSckvxjaXw { 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 vSckvxjaXw ) { int [ ] a = new int [ vSckvxjaXw ] ; for ( int i = 0 ; i < vSckvxjaXw ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } } import java . util . * ; public class TpuMrXgxMY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TpuMrXgxMY = sc . nextInt ( ) ; int m = 0 ; int t = 1 ; while ( TpuMrXgxMY > 0 ) { if ( TpuMrXgxMY % 10 == 1 ) { m += 9 * t ; } else if ( TpuMrXgxMY % 10 == 9 ) { m += t ; } else { m += TpuMrXgxMY % 10 * t ; } TpuMrXgxMY /= 10 ; t *= 10 ; } System . out . println ( m ) ; } } import java . util . Scanner ; public class lrLkCIijrV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lrLkCIijrV = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; int count = 0 ; for ( int i = lrLkCIijrV ; 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 kAAUmwNWye { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kAAUmwNWye = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int a , b , c ; a = kAAUmwNWye + y ; b = kAAUmwNWye - y ; c = kAAUmwNWye * 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 BlvEeCXhsl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BlvEeCXhsl = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < BlvEeCXhsl ; i ++ ) { long l = Long . parseLong ( sc . next ( ) ) ; while ( l % 2 == 0 ) { l /= 2 ; count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class ezoHnkTRau { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ezoHnkTRau = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ ezoHnkTRau ] [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < ezoHnkTRau ; 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 < ezoHnkTRau ; 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 BGrOeIIPew { 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 BGrOeIIPew = Integer . parseInt ( st . nextToken ( ) ) + Integer . parseInt ( st . nextToken ( ) ) ; System . out . println ( ( int ) Math . log10 ( BGrOeIIPew ) + 1 ) ; s = in . readLine ( ) ; } } catch ( Exception ex ) { System . exit ( 0 ) ; } } } } import java . util . Scanner ; public class qWNhLNSXNP { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int qWNhLNSXNP = scanner . nextInt ( ) ; int N = scanner . nextInt ( ) ; System . out . print ( ( qWNhLNSXNP * ( qWNhLNSXNP - 1 ) + N * ( N - 1 ) ) / 2 ) ; } } import java . util . Scanner ; public class DtzLqdnrYQ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String passS = scan . nextLine ( ) ; String passT = scan . nextLine ( ) ; int DtzLqdnrYQ = passS . length ( ) ; String passTa = passT . substring ( 0 , DtzLqdnrYQ ) ; if ( passS . equals ( passTa ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class MjuWGotntX { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int MjuWGotntX = 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 PUeWPmicJf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String PUeWPmicJf = sc . next ( ) ; Map < String , String > map = new HashMap < String , String > ( ) ; map . put ( " ABC " , " ARC " ) ; map . put ( " ARC " , " ABC " ) ; if ( map . containsKey ( PUeWPmicJf ) ) { System . out . println ( map . get ( PUeWPmicJf ) ) ; } else { System . out . println ( " もう一度やり直して下さい"); } } } import java . util . Scanner ; class bSitDwUhCO { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String S = scan . next ( ) ; String T = scan . next ( ) ; int bSitDwUhCO = 0 ; int j = 0 ; int count = 0 ; while ( bSitDwUhCO < S . length ( ) && j < T . length ( ) ) { if ( S . charAt ( bSitDwUhCO ) != T . charAt ( j ) ) { count ++ ; } bSitDwUhCO ++ ; j ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class hkxQGAeQFk { public static int hkxQGAeQFk ; public static int [ ] arr ; public static int [ ] dp ; public static int minCost ( int pos ) { if ( pos >= hkxQGAeQFk - 1 ) return 0 ; if ( dp [ pos ] != - 1 ) return dp [ pos ] ; int onestep = Integer . MAX_VALUE ; int twostep = Integer . MAX_VALUE ; if ( pos + 1 < hkxQGAeQFk ) { onestep = Math . abs ( arr [ pos ] - arr [ pos + 1 ] ) + minCost ( pos + 1 ) ; } if ( pos + 2 < hkxQGAeQFk ) { 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 ) ; hkxQGAeQFk = in . nextInt ( ) ; arr = new int [ hkxQGAeQFk ] ; dp = new int [ hkxQGAeQFk ] ; for ( int i = 0 ; i < hkxQGAeQFk ; i ++ ) arr [ i ] = in . nextInt ( ) ; Arrays . fill ( dp , - 1 ) ; System . out . println ( minCost ( 0 ) ) ; } } import java . util . Scanner ; public class pSXRikIToj { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int pSXRikIToj = Integer . parseInt ( scanner . nextLine ( ) ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; int [ ] z = new int [ pSXRikIToj ] ; 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 < pSXRikIToj ; 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 < pSXRikIToj ; i ++ ) { System . out . println ( z [ i ] ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class WwCVzJlWup { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int WwCVzJlWup = Integer . parseInt ( br . readLine ( ) ) ; String [ ] line = br . readLine ( ) . split ( " " ) ; int [ ] a = new int [ WwCVzJlWup ] ; for ( int i = 0 ; i < WwCVzJlWup ; i ++ ) { a [ i ] = Integer . parseInt ( line [ i ] ) ; } insertionSort ( a , WwCVzJlWup ) ; } } 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 ttauRbguOd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] str = s . split ( " " ) ; int ttauRbguOd = str . ttauRbguOd ; boolean easiness = true ; for ( int i = 0 ; i < ttauRbguOd ; i += 2 ) { if ( str [ i ] . equals ( " L " ) ) { easiness = false ; break ; } } for ( int i = 1 ; i < ttauRbguOd ; 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 lAHxEkOUrW { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int lAHxEkOUrW = scan . nextInt ( ) ; int [ ] x = new int [ lAHxEkOUrW ] ; for ( int i = 0 ; i < lAHxEkOUrW ; 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 < lAHxEkOUrW ; i ++ ) { System . out . println ( x [ i ] ) ; } } } import java . util . * ; public class HpqQfhHsPO { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int HpqQfhHsPO = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; sc . close ( ) ; int ans = 0 ; if ( B <= C || D <= HpqQfhHsPO ) { } else if ( ( B > C ) && ( HpqQfhHsPO < C ) ) { ans = B <= D ? B - C : D - C ; } else { ans = D <= B ? D - HpqQfhHsPO : B - HpqQfhHsPO ; } System . out . println ( ans ) ; } } import java . util . * ; public class cwMAyrYFde { public static void main ( String [ ] args ) { exec ( ) ; } static void exec ( ) { Scanner sc = new Scanner ( System . in ) ; long cwMAyrYFde = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; int ans = 0 ; for ( int i = 0 ; i < cwMAyrYFde ; 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 BpZQmctHjw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BpZQmctHjw = sc . nextInt ( ) ; int [ ] d = new int [ BpZQmctHjw ] ; for ( int i = 0 ; i < BpZQmctHjw ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( d ) ; int [ ] a = new int [ BpZQmctHjw / 2 ] ; int [ ] b = new int [ BpZQmctHjw / 2 ] ; for ( int i = 0 ; i < BpZQmctHjw / 2 ; i ++ ) { a [ i ] = d [ i ] ; } int j = 0 ; for ( int i = BpZQmctHjw / 2 ; i < BpZQmctHjw ; i ++ ) { b [ j ] = d [ i ] ; j ++ ; } int count = 0 ; if ( a [ BpZQmctHjw / 2 - 1 ] < b [ 0 ] ) { count = b [ 0 ] - a [ BpZQmctHjw / 2 - 1 ] ; } System . out . println ( count ) ; } } import java . util . * ; class gsFfOlbkUO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gsFfOlbkUO = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= gsFfOlbkUO ; i ++ ) { for ( int j = 1 ; j <= gsFfOlbkUO ; 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 <= gsFfOlbkUO ; 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 GswsZKyzwq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int GswsZKyzwq = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int [ ] [ ] root = new int [ GswsZKyzwq ] [ GswsZKyzwq ] ; 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 < GswsZKyzwq ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < GswsZKyzwq ; j ++ ) { sum += root [ i ] [ j ] ; } System . out . println ( sum ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class cYQOulkerW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] abc = { sc . nextInt ( ) , sc . nextInt ( ) , sc . nextInt ( ) } ; int cYQOulkerW = sc . nextInt ( ) ; Arrays . sort ( abc ) ; for ( int i = 0 ; i < cYQOulkerW ; 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 YgqHnTyZwq { 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 YgqHnTyZwq = 0 ; YgqHnTyZwq < 4 ; YgqHnTyZwq ++ ) { String keyword = keywords [ YgqHnTyZwq ] ; String ts = s . replaceAll ( keyword , " " ) ; if ( s . length ( ) > ts . length ( ) ) queue . add ( ts ) ; } } System . out . println ( " NO " ) ; } } import java . util . Scanner ; public class jlWfuLTRep { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jlWfuLTRep = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int j = 0 ; while ( jlWfuLTRep <= y ) { if ( z % jlWfuLTRep == 0 ) { j ++ ; } jlWfuLTRep ++ ; } System . out . println ( j ) ; sc . close ( ) ; } } import java . util . Scanner ; class LhwGpQLLPo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LhwGpQLLPo = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int d = LhwGpQLLPo / b ; int r = LhwGpQLLPo % b ; double f = ( ( double ) LhwGpQLLPo / ( double ) b ) ; System . out . print ( d + " " + r + " " ) ; System . out . printf ( " %.5f " , f ) ; } } import java . util . * ; import java . lang . * ; public class aGAjkCDDOR { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int aGAjkCDDOR = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int [ ] ans = new int [ aGAjkCDDOR ] ; for ( int i = 0 ; i < aGAjkCDDOR ; 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 lJjDzqSqoJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lJjDzqSqoJ = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= lJjDzqSqoJ ; i ++ ) { double p = 1 ; int tmp = i ; while ( tmp < k ) { p *= 0.5 ; tmp *= 2 ; } ans += p / lJjDzqSqoJ ; } System . out . println ( ans ) ; } } import java . util . * ; public class iGjEhHCuoE { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String iGjEhHCuoE = stdIn . next ( ) ; if ( iGjEhHCuoE . equals ( " Sunny " ) ) { System . out . println ( " Cloudy " ) ; } if ( iGjEhHCuoE . equals ( " Cloudy " ) ) { System . out . println ( " Rainy " ) ; } if ( iGjEhHCuoE . equals ( " Rainy " ) ) { System . out . println ( " Sunny " ) ; } } } import java . util . * ; public class ZetGrYwOOI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZetGrYwOOI = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( ZetGrYwOOI % 2 == 0 ) { for ( int i = 0 ; i < ZetGrYwOOI / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( ZetGrYwOOI / 2 + i ) ) { System . out . println ( " No " ) ; break ; } else if ( i < ZetGrYwOOI / 2 - 1 ) { continue ; } System . out . println ( " Yes " ) ; } } else if ( ZetGrYwOOI % 2 != 0 ) { System . out . println ( " No " ) ; } } } import java . util . * ; public class OtXJjcADcO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OtXJjcADcO = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int res = 0 ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < OtXJjcADcO ; 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 BGPkXwfNuP { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String BGPkXwfNuP = scan . nextLine ( ) ; String weather = " Sunny " ; if ( " Sunny " . equals ( BGPkXwfNuP ) ) { weather = " Cloudy " ; } else if ( " Cloudy " . equals ( BGPkXwfNuP ) ) { weather = " Rainy " ; } System . out . println ( weather ) ; } } import java . util . Scanner ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Iterator ; public class IqzbSnugwu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < String > list = new ArrayList < > ( ) ; ArrayList < String > anslist = new ArrayList < > ( ) ; int IqzbSnugwu = sc . nextInt ( ) ; String [ ] a = new String [ IqzbSnugwu ] ; int max = 1 ; int count = 1 ; for ( int i = 0 ; i < IqzbSnugwu ; i ++ ) { a [ i ] = sc . next ( ) ; list . add ( a [ i ] ) ; } Collections . sort ( list ) ; for ( int j = 1 ; j < IqzbSnugwu ; j ++ ) { if ( list . get ( j - 1 ) . equals ( list . get ( j ) ) ) { count ++ ; if ( j == IqzbSnugwu - 1 ) max = Math . max ( max , count ) ; } else { max = Math . max ( max , count ) ; count = 1 ; } } for ( int x = 0 ; x < IqzbSnugwu - 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 lZrMTFVoZg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lZrMTFVoZg = sc . nextInt ( ) ; int [ ] sum1 = new int [ lZrMTFVoZg + 1 ] ; int [ ] sum2 = new int [ lZrMTFVoZg + 1 ] ; for ( int i = 1 ; i <= lZrMTFVoZg ; i ++ ) { sum1 [ i ] = sum1 [ i - 1 ] + sc . nextInt ( ) ; } for ( int i = 1 ; i <= lZrMTFVoZg ; i ++ ) { sum2 [ i ] = sum2 [ i - 1 ] + sc . nextInt ( ) ; } int max = 0 ; for ( int i = 1 ; i <= lZrMTFVoZg ; i ++ ) { max = Math . max ( max , sum1 [ i ] + sum2 [ lZrMTFVoZg ] - sum2 [ i - 1 ] ) ; } System . out . println ( max ) ; } } import java . util . Scanner ; public class lNlHRQMKVB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lNlHRQMKVB = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( ( lNlHRQMKVB <= 9 ) && ( b <= 9 ) ? lNlHRQMKVB * b : " -1 " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class MvMhPCVFjG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MvMhPCVFjG = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . printf ( " %d %d %.10f " , MvMhPCVFjG / b , MvMhPCVFjG % b , ( double ) MvMhPCVFjG / b ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class KUZXBccybt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] [ ] arr = new int [ 3 ] [ ] ; for ( int KUZXBccybt = 0 ; KUZXBccybt < 3 ; KUZXBccybt ++ ) arr [ KUZXBccybt ] = new int [ 3 ] ; for ( int KUZXBccybt = 0 ; KUZXBccybt < 3 ; KUZXBccybt ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) arr [ KUZXBccybt ] [ j ] = scan . nextInt ( ) ; } int [ ] diff = new int [ 9 ] ; for ( int KUZXBccybt = 0 ; KUZXBccybt < 3 ; KUZXBccybt ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) diff [ KUZXBccybt * 3 + j ] = arr [ KUZXBccybt ] [ j ] - arr [ KUZXBccybt ] [ ( j + 1 ) % 3 ] ; } for ( int KUZXBccybt = 0 ; KUZXBccybt < 3 ; KUZXBccybt ++ ) { if ( diff [ KUZXBccybt ] != diff [ KUZXBccybt + 3 ] || diff [ KUZXBccybt + 3 ] != diff [ KUZXBccybt + 6 ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . HashMap ; import java . util . Scanner ; public class iVmgItFwMQ { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int iVmgItFwMQ = sc . nextInt ( ) ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < iVmgItFwMQ ; i ++ ) { map . put ( sc . nextInt ( ) , i + 1 ) ; } for ( int i = 1 ; i <= iVmgItFwMQ ; i ++ ) { if ( i != 1 ) { System . out . print ( " " ) ; } System . out . print ( map . get ( i ) ) ; } sc . close ( ) ; } } import java . util . * ; class sxRItZyWxG { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int sxRItZyWxG = in . nextInt ( ) ; int k = in . nextInt ( ) ; in . nextLine ( ) ; int [ ] N = new int [ sxRItZyWxG ] ; 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 < sxRItZyWxG ; i ++ ) { if ( N [ i ] == 0 ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class TrkvSmMAUk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TrkvSmMAUk = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; Long [ ] in = new Long [ TrkvSmMAUk ] ; for ( int i = 0 ; i < TrkvSmMAUk ; i ++ ) { in [ i ] = sc . nextLong ( ) ; } Arrays . sort ( in ) ; Long c = in [ 0 ] - in [ 0 ] ; for ( int i = 0 ; i < TrkvSmMAUk - b ; i ++ ) { c += in [ i ] ; } System . out . println ( c ) ; } } import java . util . * ; public class zzWyCEnbWl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] sp ; int zzWyCEnbWl = 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 ( zzWyCEnbWl < num ) zzWyCEnbWl = num ; num = 0 ; } } if ( zzWyCEnbWl < num ) zzWyCEnbWl = num ; System . out . println ( zzWyCEnbWl ) ; } } import java . util . Scanner ; public class MbgHrOeUrq { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int MbgHrOeUrq = Integer . parseInt ( scanner . next ( ) ) ; int B = Integer . parseInt ( scanner . next ( ) ) ; scanner . close ( ) ; if ( MbgHrOeUrq == 1 && B == 2 ) { System . out . println ( " 3 " ) ; } else if ( MbgHrOeUrq == 1 && B == 3 ) { System . out . println ( " 2 " ) ; } else if ( MbgHrOeUrq == 2 && B == 1 ) { System . out . println ( " 3 " ) ; } else if ( MbgHrOeUrq == 2 && B == 3 ) { System . out . println ( " 1 " ) ; } else if ( MbgHrOeUrq == 3 && B == 1 ) { System . out . println ( " 2 " ) ; } else if ( MbgHrOeUrq == 3 && B == 2 ) { System . out . println ( " 1 " ) ; } } } import java . util . Scanner ; class ADDCYPYQXb { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ADDCYPYQXb = scan . nextInt ( ) ; int [ ] data = new int [ ADDCYPYQXb ] ; int sum = 0 ; for ( int i = 0 ; i < ADDCYPYQXb ; i ++ ) { data [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < ADDCYPYQXb ; 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 SlnnshXxYv { 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 SlnnshXxYv = nextInt ( ) ; int [ ] K = new int [ SlnnshXxYv ] ; for ( int i = 0 ; i < SlnnshXxYv ; i ++ ) { K [ nextInt ( ) - 1 ] = i ; } for ( int i = 0 ; i < SlnnshXxYv ; 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 twsZgvhLBE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] list = sc . nextLine ( ) . split ( " " , 0 ) ; int twsZgvhLBE = Integer . parseInt ( list [ 0 ] ) ; int B = Integer . parseInt ( list [ 1 ] ) ; int T = Integer . parseInt ( list [ 2 ] ) ; System . out . println ( B * ( T / twsZgvhLBE ) ) ; sc . close ( ) ; } } import java . util . * ; public class gPCGQOjmEA { 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 kwSKNpKQVH { public static void main ( String [ ] args ) throws Exception { BufferedReader breader = getReader ( ) ; int [ ] ary = getAry ( breader ) ; while ( ary [ 0 ] != 0 || ary [ 1 ] != 0 ) { for ( int kwSKNpKQVH = 0 ; kwSKNpKQVH < ary [ 0 ] ; kwSKNpKQVH ++ ) { 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 kwSKNpKQVH = 0 ; kwSKNpKQVH < nstr . length ; kwSKNpKQVH ++ ) { n [ kwSKNpKQVH ] = Integer . valueOf ( nstr [ kwSKNpKQVH ] ) ; } return n ; } } import java . util . Scanner ; public class RPDOQUwvsZ { 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 RPDOQUwvsZ = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int [ ] h = new int [ RPDOQUwvsZ ] ; for ( int i = 0 ; i < RPDOQUwvsZ ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } double minDiff = Math . abs ( a - temp ( t , h [ 0 ] ) ) ; int num = 0 ; for ( int i = 1 ; i < RPDOQUwvsZ ; 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 CcBeRMkTRm { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int CcBeRMkTRm = Integer . parseInt ( s . next ( ) ) ; int k = Integer . parseInt ( s . next ( ) ) ; int count = 1 ; for ( int i = 1 ; i < CcBeRMkTRm ; ) { i = i * k ; if ( CcBeRMkTRm / i >= 1 ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class yZuQYxECBf { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int yZuQYxECBf = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int ans ; if ( K <= yZuQYxECBf ) { ans = K ; } else if ( K <= yZuQYxECBf + B ) { ans = yZuQYxECBf ; } else { ans = yZuQYxECBf - ( K - ( yZuQYxECBf + B ) ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class divIqdJltK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int divIqdJltK = sc . nextInt ( ) ; int ac = 0 ; int wa = 0 ; int tle = 0 ; int re = 0 ; for ( int i = 0 ; i < divIqdJltK + 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 mLrLaTTlyC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mLrLaTTlyC = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int count = 1 ; while ( true ) { if ( mLrLaTTlyC / ( int ) ( Math . pow ( k , count ) ) == 0 ) break ; count ++ ; } System . out . println ( " " + count ) ; } } import java . util . Scanner ; public class xbnuGyTTvP { 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 xbnuGyTTvP ; int [ ] [ ] D ; Main ( Scanner sc ) { this . sc = sc ; this . xbnuGyTTvP = sc . nextInt ( ) ; this . D = new int [ xbnuGyTTvP ] [ 2 ] ; for ( int i = 0 ; i < xbnuGyTTvP ; 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 < xbnuGyTTvP - 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 EOeSZLQWYK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long EOeSZLQWYK = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; boolean flag = true ; long d = 0 ; EOeSZLQWYK = EOeSZLQWYK % k ; d = Math . min ( EOeSZLQWYK , Math . abs ( EOeSZLQWYK - k ) ) ; System . out . println ( d ) ; } } import java . util . Scanner ; class IYBKDPVnER { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int IYBKDPVnER = scanner . nextInt ( ) ; int numB = scanner . nextInt ( ) ; int numC = scanner . nextInt ( ) ; int ans = 0 ; for ( int val = IYBKDPVnER ; val <= numB ; val ++ ) { if ( numC % val == 0 ) ans ++ ; } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; public class wIrxcmlKqm { static class wIrxcmlKqm { 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 wIrxcmlKqm = scanner . nextInt ( ) ; int [ ] A = new int [ wIrxcmlKqm ] ; for ( int i = 0 ; i < wIrxcmlKqm ; i ++ ) { A [ i ] = scanner . nextInt ( ) ; } int [ ] DP = new int [ wIrxcmlKqm ] ; DP [ 1 ] = Math . abs ( A [ 1 ] - A [ 0 ] ) ; for ( int i = 2 ; i < wIrxcmlKqm ; 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 [ wIrxcmlKqm - 1 ] ) ; } } import java . util . Scanner ; public class IQPtgLNQkb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long [ ] dd = new long [ 10000 ] ; int IQPtgLNQkb = 9 ; long r = 0 ; long su ; for ( int i = 0 ; IQPtgLNQkb == 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 xBxTVOzbUl { 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 xBxTVOzbUl { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int xBxTVOzbUl = in . nextInt ( ) ; boolean ret = true ; for ( int i = 0 ; i < xBxTVOzbUl ; 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 nmvGyeFPdS { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int nmvGyeFPdS = sc . nextInt ( ) , t = 0 ; while ( nmvGyeFPdS -- > 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 iifaoOGcsT { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int iifaoOGcsT = scn . nextInt ( ) ; HashSet < Integer > arr = new HashSet < Integer > ( ) ; boolean yes = true ; for ( int i = 0 ; i < iifaoOGcsT ; 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 JrnTiKmcqv { 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 JrnTiKmcqv = 0 ; JrnTiKmcqv < list . size ( ) - 1 ; JrnTiKmcqv ++ ) { String s = list . get ( JrnTiKmcqv ) ; String [ ] ary = s . split ( " " ) ; data [ JrnTiKmcqv ] [ 0 ] = Integer . parseInt ( ary [ 0 ] ) ; data [ JrnTiKmcqv ] [ 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 gvMqoiEwlS { public static void main ( String [ ] argv ) { Scanner scan = new Scanner ( System . in ) ; int gvMqoiEwlS = scan . nextInt ( ) ; int h = 0 , m = 0 , s = 0 ; while ( true ) { if ( gvMqoiEwlS - 3600 >= 0 ) { gvMqoiEwlS = gvMqoiEwlS - 3600 ; h ++ ; } else if ( gvMqoiEwlS - 60 >= 0 ) { gvMqoiEwlS = gvMqoiEwlS - 60 ; m ++ ; } else { if ( gvMqoiEwlS == 0 ) break ; s ++ ; gvMqoiEwlS -- ; } } System . out . println ( h + " : " + m + " : " + s ) ; } } import java . util . * ; public class ACKaXQpZpc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ACKaXQpZpc = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < String > ( ) ; char last = 'X' ; boolean flag = true ; for ( int i = 0 ; i < ACKaXQpZpc ; 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 iGFxFlbZpO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iGFxFlbZpO = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int ANS = 0 ; if ( iGFxFlbZpO == 0 ) { if ( N != 100 ) { ANS = N ; } else { ANS = N + 1 ; } } else if ( iGFxFlbZpO == 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 tmMLFwcmvg { 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 tmMLFwcmvg = 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 ( tmMLFwcmvg > b && tmMLFwcmvg > c ) { tmMLFwcmvg *= 2 ; } else if ( b > c ) { b *= 2 ; } else { c *= 2 ; } } System . out . println ( tmMLFwcmvg + b + c ) ; } } } import java . util . Scanner ; public class FzUKlsEwXe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FzUKlsEwXe = sc . nextInt ( ) ; int [ ] h = new int [ FzUKlsEwXe ] ; for ( int i = 0 ; i < FzUKlsEwXe ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < ( FzUKlsEwXe - 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 WQQGkQCVyj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int WQQGkQCVyj = Integer . parseInt ( br . readLine ( ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; int [ ] array = new int [ WQQGkQCVyj ] ; for ( int i = 0 ; i < WQQGkQCVyj ; 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 afmVOZNYAn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int afmVOZNYAn = Integer . parseInt ( str ) ; int h_point = 0 , t_point = 0 ; for ( int i = 0 ; i < afmVOZNYAn ; 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 lWAkdhNCOH { 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 lWAkdhNCOH = Integer . parseInt ( num [ 0 ] ) ; int w = Integer . parseInt ( num [ 1 ] ) ; if ( lWAkdhNCOH == 0 && w == 0 ) { break ; } for ( int i = 0 ; i < lWAkdhNCOH ; i ++ ) { if ( i == 0 || i == lWAkdhNCOH - 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 crvEdzgEyQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int crvEdzgEyQ = 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 ( crvEdzgEyQ > b && crvEdzgEyQ > c ) { answer = crvEdzgEyQ * powk + b + c ; } else if ( b > crvEdzgEyQ && b > c ) { answer = b * powk + crvEdzgEyQ + c ; } else { answer = c * powk + crvEdzgEyQ + b ; } System . out . println ( answer ) ; } } import java . util . Scanner ; class eHoIdEuQhc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int eHoIdEuQhc = scan . nextInt ( ) ; int str2 = scan . nextInt ( ) ; System . out . println ( eHoIdEuQhc * str2 + " " + ( eHoIdEuQhc * 2 + str2 * 2 ) ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class DyVFIZtclN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DyVFIZtclN = sc . nextInt ( ) ; int [ ] s = new int [ DyVFIZtclN ] ; for ( int i = 0 ; i < DyVFIZtclN ; 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 < DyVFIZtclN && 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 TtGiZcKAqI { public static void main ( String ... args ) { final Scanner sc = new Scanner ( System . in ) ; final int TtGiZcKAqI = sc . nextInt ( ) ; System . out . println ( TtGiZcKAqI * TtGiZcKAqI * TtGiZcKAqI ) ; } } public class TtGiZcKAqI { 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 BqtPCuOoOb { 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 BqtPCuOoOb = 0 ; for ( int si = 0 ; si < s . length ; si ++ ) { if ( c . equals ( s [ si ] ) ) { BqtPCuOoOb = si ; break ; } } System . out . println ( s [ BqtPCuOoOb + 1 ] ) ; sc . close ( ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; class EoCykZmiIC { static class EoCykZmiIC { 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 EoCykZmiIC = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = 0 ; for ( int i = a ; i <= b ; i ++ ) { if ( i % EoCykZmiIC == 0 ) { sum = 1 ; } } if ( sum == 1 ) { System . out . println ( " OK " ) ; } else { System . out . println ( " NG " ) ; } } } import java . util . Scanner ; public class ILukPsblqt { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long ILukPsblqt = s . nextLong ( ) ; long a = s . nextLong ( ) ; long b = s . nextLong ( ) ; long set = ILukPsblqt / ( a + b ) ; long rem = ILukPsblqt % ( 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 hrdCJneuMU { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int hrdCJneuMU = scan . nextInt ( ) ; BigDecimal [ ] an = new BigDecimal [ hrdCJneuMU ] ; for ( int i = 0 ; i < hrdCJneuMU ; 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 VcltTrtwHo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int VcltTrtwHo = 0 ; VcltTrtwHo < 3 ; VcltTrtwHo ++ ) a [ VcltTrtwHo ] = sc . nextInt ( ) ; int [ ] b = new int [ 3 ] ; for ( int VcltTrtwHo = 0 ; VcltTrtwHo < 3 ; VcltTrtwHo ++ ) { b [ VcltTrtwHo ] = a [ ( VcltTrtwHo + 2 ) % 3 ] ; System . out . print ( b [ VcltTrtwHo ] + " " ) ; } } } import java . util . * ; public class gleyYOkzCg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int gleyYOkzCg = sc . nextInt ( ) ; int answer = gleyYOkzCg + gleyYOkzCg * gleyYOkzCg + gleyYOkzCg * gleyYOkzCg * gleyYOkzCg ; System . out . println ( answer ) ; } } import java . util . Scanner ; class iMuKMYbhTa { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String key = in . next ( ) . toLowerCase ( ) ; int iMuKMYbhTa = 0 ; while ( true ) { String input = in . next ( ) ; if ( input . equals ( " END_OF_TEXT " ) ) break ; if ( input . equalsIgnoreCase ( key ) ) iMuKMYbhTa ++ ; } System . out . println ( iMuKMYbhTa ) ; } } import java . util . * ; public class NVneIofKXf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NVneIofKXf = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] S = sc . nextLine ( ) . split ( " " ) ; int ans = 0 ; for ( int i = 0 ; i < NVneIofKXf ; i ++ ) { int n = Integer . parseInt ( S [ i ] ) ; while ( n % 2 == 0 ) { n /= 2 ; ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; class wTCsziIfcO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wTCsziIfcO = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = s . length ( ) ; String add = " ... " ; if ( count <= wTCsziIfcO ) { System . out . println ( s ) ; } else if ( count > wTCsziIfcO ) { String result = s . substring ( 0 , wTCsziIfcO ) + add ; System . out . println ( result ) ; } } } import java . util . * ; import static java . lang . Math . * ; import java . math . BigInteger ; public class HMudnPXjIa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String result = " No " ; int HMudnPXjIa = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { HMudnPXjIa += s . charAt ( i ) - '0' ; } if ( Integer . valueOf ( s ) % HMudnPXjIa == 0 ) result = " Yes " ; System . out . println ( result ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class niczDQHoCc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int niczDQHoCc = sc . nextInt ( ) ; Integer [ ] d = new Integer [ niczDQHoCc ] ; for ( int i = 0 ; i < niczDQHoCc ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( d , Collections . reverseOrder ( ) ) ; int ans = 1 ; for ( int i = 0 ; i < niczDQHoCc - 1 ; i ++ ) { if ( d [ i ] > d [ i + 1 ] ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class WpfcblvwoQ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int WpfcblvwoQ = Integer . parseInt ( scan . next ( ) ) ; int counter = 0 ; int min = Integer . MAX_VALUE ; ArrayList < Integer > pi = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < WpfcblvwoQ ; ++ 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 AZiTMGpsWE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String W = sc . next ( ) . toLowerCase ( ) ; String T ; int AZiTMGpsWE = 0 ; while ( ! ( T = sc . next ( ) ) . equals ( " END_OF_TEXT " ) ) { if ( T . toLowerCase ( ) . equals ( W ) ) { AZiTMGpsWE ++ ; } } sc . close ( ) ; System . out . println ( AZiTMGpsWE ) ; } } import java . util . * ; public class kstzCHLjnE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int kstzCHLjnE = 0 ; boolean flag = false ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( str . charAt ( i ) == 'R' ) { kstzCHLjnE ++ ; flag = true ; } else { if ( flag == true ) break ; } } System . out . println ( kstzCHLjnE ) ; } } import java . util . Scanner ; public class FourxYiHTz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char FourxYiHTz = ' ' ; for ( int i = 0 ; i < S . length ( ) ; i = i + 2 ) { FourxYiHTz = S . charAt ( i ) ; if ( FourxYiHTz != 'R' && FourxYiHTz != 'U' && FourxYiHTz != 'D' ) { System . out . println ( " No " ) ; return ; } } for ( int k = 1 ; k < S . length ( ) ; k = k + 2 ) { FourxYiHTz = S . charAt ( k ) ; if ( FourxYiHTz != 'L' && FourxYiHTz != 'U' && FourxYiHTz != 'D' ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . * ; public class nupPrEjPJy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nupPrEjPJy = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] L = new int [ M ] ; int [ ] R = new int [ M ] ; int max = nupPrEjPJy + 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 HYpiYbGHch { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long HYpiYbGHch = sc . nextLong ( ) ; if ( HYpiYbGHch == 1 || HYpiYbGHch == 2 || HYpiYbGHch == 3 ) { System . out . println ( HYpiYbGHch ) ; return ; } while ( true ) { boolean prime = true ; for ( int i = 2 ; i <= HYpiYbGHch / 2 ; i ++ ) { if ( HYpiYbGHch % i == 0 ) { prime = false ; break ; } } if ( prime ) { System . out . println ( HYpiYbGHch ) ; return ; } HYpiYbGHch ++ ; } } } import java . util . Scanner ; public class ClgwBUQJjW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ClgwBUQJjW = Integer . parseInt ( sc . next ( ) ) ; int [ ] d = new int [ ClgwBUQJjW ] ; for ( int i = 0 ; i < ClgwBUQJjW ; i ++ ) { d [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int ans = 0 ; for ( int a = 0 ; a < ClgwBUQJjW - 1 ; a ++ ) { for ( int b = 0 ; b < ClgwBUQJjW - 1 - a ; b ++ ) { ans += d [ a ] * d [ a + 1 + b ] ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; class SssWefhEkr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SssWefhEkr = sc . nextInt ( ) ; int numCol = sc . nextInt ( ) ; int [ ] [ ] mat = new int [ SssWefhEkr ] [ numCol ] ; int [ ] vecIn = new int [ numCol ] ; int [ ] vecOut = new int [ SssWefhEkr ] ; int i , j ; for ( i = 0 ; i < SssWefhEkr ; 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 < SssWefhEkr ; 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 MjmnvoDJmi { static int MjmnvoDJmi = 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 ckJhkcgvHh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ckJhkcgvHh = sc . nextInt ( ) ; String [ ] s = new String [ ckJhkcgvHh ] ; for ( int i = 0 ; i < ckJhkcgvHh ; 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 < ckJhkcgvHh ; i ++ ) { if ( ! map . containsKey ( s [ i ] ) ) { ans ++ ; map . put ( s [ i ] , 1 ) ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class pxVbilUClz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String pxVbilUClz = scan . next ( ) ; if ( pxVbilUClz . length ( ) == 3 ) { if ( pxVbilUClz . contains ( " 7 " ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; class irTaoGVfGl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int irTaoGVfGl = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int value ; int rowTotal ; int [ ] colTotal = new int [ c ] ; for ( int i = 0 ; i < irTaoGVfGl ; 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 VQmqyLkJxd { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String S = s . next ( ) ; String T = s . next ( ) ; int VQmqyLkJxd = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) != T . charAt ( i ) ) VQmqyLkJxd ++ ; } System . out . println ( VQmqyLkJxd ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class IdoiYkGooJ { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringBuilder sb = new StringBuilder ( ) ; int IdoiYkGooJ = 1 ; while ( true ) { int n = Integer . parseInt ( br . readLine ( ) ) ; if ( n == 0 ) { break ; } sb . append ( " Case " ) . append ( IdoiYkGooJ ) . append ( " : " ) . append ( n ) . append ( " \n " ) ; IdoiYkGooJ ++ ; } System . out . print ( sb ) ; } } import java . util . * ; public class puqkJjGQUJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int puqkJjGQUJ = sc . nextInt ( ) ; int [ ] a = new int [ puqkJjGQUJ ] ; for ( int i = 0 ; i < puqkJjGQUJ ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int bigTall = a [ 0 ] ; long count = 0 ; for ( int i = 1 ; i < puqkJjGQUJ ; 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 sYMVLvGGiy { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String sYMVLvGGiy = scan . next ( ) ; String result = " No " ; if ( String . valueOf ( sYMVLvGGiy . charAt ( 2 ) ) . equals ( String . valueOf ( sYMVLvGGiy . charAt ( 3 ) ) ) && ( String . valueOf ( sYMVLvGGiy . charAt ( 4 ) ) . equals ( String . valueOf ( sYMVLvGGiy . charAt ( 5 ) ) ) ) ) { result = " Yes " ; } System . out . println ( result ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class tYXfBgYPdP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tYXfBgYPdP = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] key = new int [ tYXfBgYPdP ] ; 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 wPlsKjjJLG { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long [ ] line = new long [ 4 ] ; for ( int wPlsKjjJLG = 0 ; wPlsKjjJLG < 4 ; wPlsKjjJLG ++ ) { line [ wPlsKjjJLG ] = sc . nextLong ( ) ; } long max = Long . MIN_VALUE ; for ( int wPlsKjjJLG = 0 ; wPlsKjjJLG < 2 ; wPlsKjjJLG ++ ) { for ( int j = 2 ; j < 4 ; j ++ ) { max = Math . max ( max , line [ wPlsKjjJLG ] * line [ j ] ) ; } } System . out . println ( max ) ; sc . close ( ) ; } } import java . util . Scanner ; public class VDNYLevGoU { int VDNYLevGoU , 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 mQGebLVxeH { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; String mQGebLVxeH = sc . next ( ) . replace ( " 2017 " , " 2018 " ) ; System . out . println ( mQGebLVxeH ) ; sc . close ( ) ; } } import java . util . Scanner ; class oPxQLhaeAB { public static void main ( String [ ] argv ) { Scanner sc = new Scanner ( System . in ) ; boolean oPxQLhaeAB = false ; for ( int i = 0 ; i < 2 ; i ++ ) { int x = sc . nextInt ( ) ; if ( ( x % 2 ) == 0 ) { oPxQLhaeAB = true ; } } sc . close ( ) ; if ( oPxQLhaeAB == true ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Scanner ; public class asDJPnsIuT { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int asDJPnsIuT = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int result = 0 ; if ( asDJPnsIuT == B ) { result = asDJPnsIuT + B ; } else if ( asDJPnsIuT > B ) { result = asDJPnsIuT + asDJPnsIuT - 1 ; } else if ( B > asDJPnsIuT ) { result = B + B - 1 ; } System . out . println ( result ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class ntlmfyCwbE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ntlmfyCwbE = sc . nextLong ( ) ; ArrayList < Integer > numList = new ArrayList < Integer > ( ) ; while ( true ) { int digit = ( int ) ( ntlmfyCwbE % 26L ) ; if ( digit == 0 ) { digit = 26 ; } numList . add ( digit + 96 ) ; ntlmfyCwbE = ( ntlmfyCwbE - digit ) / 26L ; if ( ntlmfyCwbE == 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 mcKjIBjdnQ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long mcKjIBjdnQ , b1 , r1 , r2 , temp , a2 , b2 ; while ( scan . hasNext ( ) ) { mcKjIBjdnQ = scan . nextInt ( ) ; a2 = mcKjIBjdnQ ; b1 = scan . nextInt ( ) ; b2 = b1 ; while ( a2 % b2 != 0 ) { if ( a2 < b2 ) { temp = a2 ; a2 = b2 ; b2 = temp ; } a2 = a2 % b2 ; } r1 = b2 ; r2 = ( mcKjIBjdnQ * b1 ) / r1 ; System . out . println ( r1 + " " + r2 ) ; } } } import java . util . LinkedHashSet ; import java . util . Scanner ; import java . util . Set ; public class NSOLKIMver { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int NSOLKIMver = scan . nextInt ( ) ; String [ ] list = new String [ NSOLKIMver ] ; for ( int i = 0 ; i < NSOLKIMver ; 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 BBqhiwdfzP { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int BBqhiwdfzP = Integer . parseInt ( in . readLine ( ) ) ; long [ ] a = new long [ BBqhiwdfzP ] ; long sum = 1 ; long lastSum = 1 ; boolean over = false ; String [ ] str = in . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < BBqhiwdfzP ; 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 WZmrleZgix { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int WZmrleZgix = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; boolean flg = false ; for ( int i = 1 ; i < 1269 ; i ++ ) { if ( Math . floor ( i * 0.08 ) == WZmrleZgix && 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 NMzjGJPyVc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NMzjGJPyVc = Integer . parseInt ( sc . next ( ) ) ; int [ ] A = new int [ NMzjGJPyVc ] ; int [ ] B = new int [ NMzjGJPyVc - 1 ] ; for ( int i = 0 ; i < NMzjGJPyVc ; i ++ ) A [ i ] = 100_000 ; for ( int i = 0 ; i < NMzjGJPyVc - 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 yIdsBbFnYQ { public static void main ( final String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int yIdsBbFnYQ = sc . nextInt ( ) ; int [ ] [ ] route = new int [ 2 ] [ yIdsBbFnYQ ] ; for ( int i = 0 ; i < 2 ; i ++ ) { route [ i ] = new int [ yIdsBbFnYQ ] ; for ( int j = 0 ; j < yIdsBbFnYQ ; j ++ ) { route [ i ] [ j ] = sc . nextInt ( ) ; } } int maxCandy = Integer . MIN_VALUE ; for ( int i = 0 ; i < yIdsBbFnYQ ; i ++ ) { int tmp = 0 ; int h = 0 ; for ( int j = 0 ; j < yIdsBbFnYQ ; 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 uCwnDqINRp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uCwnDqINRp = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < uCwnDqINRp ; i ++ ) { int a = sc . nextInt ( ) ; while ( ( a % 2 ) == 0 ) { cnt ++ ; a /= 2 ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class HNMAvrlnVb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HNMAvrlnVb = sc . nextInt ( ) ; double ans1 = 0 ; for ( int i = 0 ; i < HNMAvrlnVb ; 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 UyAoUvPKOy { static int getMorePrime ( int n ) { if ( n == 2 ) return n ; ArrayList < Integer > primes = new ArrayList < Integer > ( ) ; primes . add ( 2 ) ; int UyAoUvPKOy = 2 ; while ( true ) { for ( int j = 0 ; j < primes . size ( ) ; j ++ ) if ( UyAoUvPKOy % primes . get ( j ) == 0 ) { ++ UyAoUvPKOy ; j = 0 ; } if ( UyAoUvPKOy >= n ) return UyAoUvPKOy ; primes . add ( UyAoUvPKOy ) ; ++ UyAoUvPKOy ; } } 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 SBPLPFvJWu { public static void main ( String [ ] args ) throws IOException { int SBPLPFvJWu = 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 ) { SBPLPFvJWu ++ ; } } System . out . println ( SBPLPFvJWu ) ; } } import java . util . Scanner ; import java . util . Arrays ; public class AqGfefObmd { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int AqGfefObmd = sc . nextInt ( ) ; int ans = 1 ; lavel : for ( int i = 2 ; i < AqGfefObmd ; i ++ ) { for ( int j = 2 ; ; j ++ ) { if ( ( int ) Math . pow ( i , j ) > AqGfefObmd ) { 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 HlsMVAuhuJ { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int HlsMVAuhuJ = 0 ; String n = sc . next ( ) ; for ( char ch : n . toCharArray ( ) ) { HlsMVAuhuJ += ch - '0' ; HlsMVAuhuJ %= 9 ; } if ( HlsMVAuhuJ == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class NnOLIPHmPt { public static void main ( String [ ] argsp ) { Scanner sc = new Scanner ( System . in ) ; int NnOLIPHmPt = 0 ; String s = sc . next ( ) , t = sc . next ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) { NnOLIPHmPt ++ ; } } System . out . print ( NnOLIPHmPt ) ; } } import java . util . * ; public class aylXxEzAaR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aylXxEzAaR = sc . nextInt ( ) ; if ( aylXxEzAaR % 2 == 1 ) { System . out . println ( ( double ) ( ( aylXxEzAaR - 1 ) / 2 + 1 ) / aylXxEzAaR ) ; } else { System . out . println ( 0.5 ) ; } } } import java . util . * ; import java . lang . Integer ; public class GNrOrmLZzq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double GNrOrmLZzq = sc . nextInt ( ) ; double y = sc . nextInt ( ) ; double crane = - ( y / 2 ) + 2 * GNrOrmLZzq ; double turtle = GNrOrmLZzq - 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 xPWyXBPtTE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xPWyXBPtTE = sc . nextInt ( ) ; int result = 0 ; result += xPWyXBPtTE / 100 ; result = result * 111 ; System . out . println ( xPWyXBPtTE <= result ? result : result == 999 ? result + 112 : result + 111 ) ; } } import java . util . * ; public class oFmlhrWTJP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int oFmlhrWTJP = str . length ( ) ; char [ ] c = new char [ oFmlhrWTJP ] ; 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 fgNgRjAPjJ { public static void main ( String [ ] args ) { Scanner sn = new Scanner ( System . in ) ; ArrayList < Integer > a = new ArrayList < Integer > ( ) ; for ( int fgNgRjAPjJ = 0 ; fgNgRjAPjJ < 10 ; fgNgRjAPjJ ++ ) { a . add ( sn . nextInt ( ) ) ; } Collections . sort ( a ) ; for ( int fgNgRjAPjJ = 0 ; fgNgRjAPjJ < 3 ; fgNgRjAPjJ ++ ) { System . out . println ( a . get ( a . size ( ) - fgNgRjAPjJ - 1 ) ) ; } } } import java . math . BigInteger ; import java . util . Scanner ; public class LSjjzsbPfy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LSjjzsbPfy = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; BigInteger c = BigInteger . valueOf ( LSjjzsbPfy ) . multiply ( BigInteger . valueOf ( b ) ) ; int d = LSjjzsbPfy % b ; while ( d != 0 ) { LSjjzsbPfy = b ; b = d ; d = LSjjzsbPfy % b ; } System . out . println ( c . divide ( BigInteger . valueOf ( b ) ) ) ; } } import java . util . Scanner ; public class bEMSLxSISj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String bEMSLxSISj = sc . next ( ) ; char [ ] c = bEMSLxSISj . toCharArray ( ) ; c [ 3 ] = '8' ; String st = new String ( c ) ; System . out . println ( st ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class MomoybPzQr { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] values = new int [ 5 ] ; for ( int MomoybPzQr = 0 ; MomoybPzQr < 5 ; MomoybPzQr ++ ) { values [ MomoybPzQr ] = Integer . parseInt ( input . readLine ( ) ) ; } int k = Integer . parseInt ( input . readLine ( ) ) ; for ( int MomoybPzQr = 0 ; MomoybPzQr < 5 ; MomoybPzQr ++ ) { for ( int j = MomoybPzQr + 1 ; j < 5 ; j ++ ) { if ( Math . abs ( values [ MomoybPzQr ] - values [ j ] ) > k ) { System . out . println ( " :( " ) ; return ; } } } System . out . println ( " Yay! " ) ; } } import java . util . * ; public class UvUObVYwii { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UvUObVYwii = sc . nextInt ( ) ; String f = sc . next ( ) ; if ( UvUObVYwii % 2 == 0 ) { if ( f . substring ( 0 , UvUObVYwii / 2 ) . equals ( f . substring ( UvUObVYwii / 2 , UvUObVYwii ) ) ) { 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 lPgPdXmDoU { 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 lPgPdXmDoU = Integer . parseInt ( input ) - 1 ; lPgPdXmDoU >= 0 ; lPgPdXmDoU -- ) { System . out . print ( inputan [ lPgPdXmDoU ] ) ; if ( lPgPdXmDoU > 0 ) System . out . print ( " " ) ; if ( lPgPdXmDoU == 0 ) System . out . println ( ) ; } } } import java . util . Scanner ; public class gnoCiLQLEd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int gnoCiLQLEd = S . length ( ) ; String ans = " " ; for ( int i = 0 ; i < gnoCiLQLEd ; i ++ ) { ans = ans . concat ( " x " ) ; } System . out . println ( ans ) ; } } import java . util . * ; import java . lang . * ; public class CMyfpFPlos { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long CMyfpFPlos = 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 ( CMyfpFPlos >= 1 ) { long a = CMyfpFPlos % 26 ; int b = ( int ) a ; if ( b != 0 ) { ans . add ( alpha [ b - 1 ] ) ; } else if ( b == 0 ) { ans . add ( alpha [ 25 ] ) ; } if ( CMyfpFPlos % 26 != 0 ) { CMyfpFPlos = CMyfpFPlos / 26 ; } else { CMyfpFPlos = CMyfpFPlos / 26 - 1 ; } } for ( int i = ans . size ( ) - 1 ; i >= 0 ; i -- ) { System . out . print ( ans . get ( i ) ) ; } } } import java . util . Scanner ; public class psSktuJMYr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int psSktuJMYr = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += Integer . parseInt ( sc . next ( ) ) ; System . out . println ( psSktuJMYr > sum ? " No " : " Yes " ) ; } } import java . util . Scanner ; class YZXZIuKWCm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int YZXZIuKWCm = scan . nextInt ( ) ; int [ ] a = new int [ YZXZIuKWCm ] ; for ( int i = 0 ; i < YZXZIuKWCm ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } boolean flag = true ; int swap ; int count = 0 ; int min ; for ( int i = 0 ; i < YZXZIuKWCm ; i ++ ) { min = i ; for ( int j = i ; j < YZXZIuKWCm ; 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 < YZXZIuKWCm ; i ++ ) { System . out . print ( a [ i ] ) ; if ( i != YZXZIuKWCm - 1 ) System . out . print ( " " ) ; } System . out . println ( ) ; System . out . println ( count ) ; } } import java . util . Scanner ; public class jXYjeVqclH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int jXYjeVqclH = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s [ i ] - '0' == 1 ) jXYjeVqclH ++ ; } System . out . println ( jXYjeVqclH ) ; } } import java . util . * ; public class YmVfeGSdmt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YmVfeGSdmt = sc . nextInt ( ) ; int [ ] result = new int [ 4 ] ; for ( int i = 0 ; i < YmVfeGSdmt ; 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 zOVdeZQucT { public static void main ( String [ ] args ) { long zOVdeZQucT = 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 PbNsvxyZCY { 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 VeLoEAEbPp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VeLoEAEbPp = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String [ ] s = sc . next ( ) . split ( " " ) ; String ans = " Yes " ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( i == VeLoEAEbPp ) { if ( ! s [ VeLoEAEbPp ] . equals ( " - " ) ) { ans = " No " ; break ; } } else { if ( s [ i ] . equals ( " - " ) ) { ans = " No " ; break ; } } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; class mjRYvCCrWL { void solve ( ) { int mjRYvCCrWL = in . nextInt ( ) ; if ( mjRYvCCrWL % 2 == 0 ) System . out . println ( 0.5 ) ; else { double b = mjRYvCCrWL / 2 + 1 ; double c = mjRYvCCrWL ; 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 ETjBlYnNBO { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; while ( true ) { int ETjBlYnNBO = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; if ( ETjBlYnNBO == - 1 && b == - 1 && c == - 1 ) break ; if ( ETjBlYnNBO == - 1 || b == - 1 ) System . out . println ( " F " ) ; else if ( ETjBlYnNBO + b >= 80 ) System . out . println ( " A " ) ; else if ( ETjBlYnNBO + b >= 65 ) System . out . println ( " B " ) ; else if ( ETjBlYnNBO + b >= 50 ) System . out . println ( " C " ) ; else if ( ETjBlYnNBO + 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 apbYjfolws { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int apbYjfolws , b ; Scanner sc = new Scanner ( System . in ) ; while ( true ) { String [ ] input = sc . nextLine ( ) . split ( " " ) ; apbYjfolws = Integer . parseInt ( input [ 0 ] ) ; b = Integer . parseInt ( input [ 1 ] ) ; if ( apbYjfolws == 0 && b == 0 ) { break ; } System . out . println ( Math . min ( apbYjfolws , b ) + " " + Math . max ( apbYjfolws , b ) ) ; } } } import java . util . Scanner ; public class vGHjUCowpU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vGHjUCowpU = sc . nextInt ( ) ; int [ ] a = new int [ vGHjUCowpU ] ; for ( int i = 0 ; i < vGHjUCowpU ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int t ; int j = 1 ; for ( int i = 0 ; i < vGHjUCowpU ; i ++ ) { for ( int k = 0 ; k < vGHjUCowpU ; 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 < vGHjUCowpU ; i ++ ) { if ( max > a [ i ] ) { j ++ ; max = a [ i ] ; } } System . out . println ( j ) ; } } import java . util . Scanner ; public class aJGdQlOuol { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aJGdQlOuol = sc . nextInt ( ) ; int [ ] a = new int [ aJGdQlOuol ] ; int [ ] b = new int [ aJGdQlOuol - 1 ] ; for ( int i = 0 ; i < aJGdQlOuol - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } a [ 0 ] = b [ 0 ] ; int score = a [ 0 ] ; for ( int i = 1 ; i < aJGdQlOuol - 1 ; i ++ ) { a [ i ] = Math . min ( b [ i - 1 ] , b [ i ] ) ; score += a [ i ] ; } if ( aJGdQlOuol != 1 ) { a [ aJGdQlOuol - 1 ] = b [ aJGdQlOuol - 2 ] ; score += a [ aJGdQlOuol - 1 ] ; } System . out . println ( score ) ; } } import java . util . Scanner ; public class YqZEsqkIQR { 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 YqZEsqkIQR = 0 , l = c . length ; YqZEsqkIQR < l ; ++ YqZEsqkIQR ) { char _c = c [ YqZEsqkIQR ] ; if ( 97 <= _c && _c <= 122 ) ++ a [ _c - 'a' ] ; else if ( 65 <= _c && _c <= 90 ) ++ a [ _c - 'A' ] ; } } for ( int YqZEsqkIQR = 0 ; YqZEsqkIQR < 26 ; ++ YqZEsqkIQR ) System . out . printf ( " %c : %d \n " , 'a' + YqZEsqkIQR , a [ YqZEsqkIQR ] ) ; } } import java . util . Scanner ; public class ElwXRzjnJQ { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ElwXRzjnJQ = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; if ( ElwXRzjnJQ * B > C ) { System . out . println ( C ) ; } else { System . out . println ( ElwXRzjnJQ * B ) ; } } } import java . io . * ; import java . util . * ; public class MaRKgdUAfR { public static void main ( String [ ] args ) { new Main ( ) ; } Scanner in = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int MaRKgdUAfR , b ; Main ( ) { MaRKgdUAfR = in . nextInt ( ) ; b = in . nextInt ( ) ; if ( ( MaRKgdUAfR % 2 ) != ( b % 2 ) ) out . println ( " IMPOSSIBLE " ) ; else out . println ( ( MaRKgdUAfR + b ) / 2 ) ; out . close ( ) ; } } import java . util . * ; import java . lang . * ; public class hsYBXzxdcs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hsYBXzxdcs = sc . nextInt ( ) ; if ( hsYBXzxdcs < 105 ) { System . out . println ( 0 ) ; } else if ( hsYBXzxdcs >= 105 && hsYBXzxdcs < 135 ) { System . out . println ( 1 ) ; } else if ( hsYBXzxdcs >= 135 && hsYBXzxdcs < 165 ) { System . out . println ( 2 ) ; } else if ( hsYBXzxdcs >= 165 && hsYBXzxdcs < 189 ) { System . out . println ( 3 ) ; } else if ( hsYBXzxdcs >= 189 && hsYBXzxdcs < 195 ) { System . out . println ( 4 ) ; } else if ( hsYBXzxdcs >= 195 ) { System . out . println ( 5 ) ; } } } import java . util . Scanner ; public class LdUalLQozd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LdUalLQozd = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int s = LdUalLQozd / a ; if ( LdUalLQozd % 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 GnmgEUujrt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int GnmgEUujrt = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < GnmgEUujrt ; 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 bhYyzlIeCY { 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 bhYyzlIeCY = m . length ; for ( int i = 0 ; i < bhYyzlIeCY / 2 ; i ++ ) { int tmp = m [ i ] ; m [ i ] = m [ bhYyzlIeCY - i - 1 ] ; m [ bhYyzlIeCY - i - 1 ] = tmp ; } } private static final void output ( int [ ] m , int bhYyzlIeCY ) { for ( int i = 0 ; i < bhYyzlIeCY ; i ++ ) { System . out . println ( m [ i ] ) ; } } private static final void input ( int [ ] m , int bhYyzlIeCY ) { Scanner cin = new Scanner ( System . in ) ; for ( int i = 0 ; i < bhYyzlIeCY ; i ++ ) { m [ i ] = cin . nextInt ( ) ; } } } import java . util . * ; public class EAFicBGBRQ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EAFicBGBRQ = 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 ++ ) { EAFicBGBRQ -= attack . remove ( 0 ) ; if ( EAFicBGBRQ <= 0 ) { flag = true ; break ; } } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class tqMODRyvdJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long tqMODRyvdJ = scan . nextLong ( ) ; long ans = 0 ; for ( int i = 1 ; i < tqMODRyvdJ + 1 ; i ++ ) { if ( ( i % 3 ) == 0 || ( i % 5 ) == 0 ) { ans += 0 ; } else { ans += i ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class QwvVtPuBkY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QwvVtPuBkY = 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 = QwvVtPuBkY ; for ( int i = 0 ; i <= 101 ; i ++ ) { if ( q [ i ] == 0 ) { if ( Math . abs ( QwvVtPuBkY - i ) < minDif ) { ans = i ; minDif = Math . abs ( QwvVtPuBkY - i ) ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class zQZTwrSyLG { Scanner sc ; int zQZTwrSyLG , D ; public Main ( ) { sc = new Scanner ( System . in ) ; } void out ( Object o ) { System . out . println ( o ) ; System . out . flush ( ) ; } public void exec ( ) throws Exception { zQZTwrSyLG = sc . nextInt ( ) ; D = sc . nextInt ( ) ; int n = ( zQZTwrSyLG + 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 cPkcyexlyC { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int cPkcyexlyC = scanner . nextInt ( ) ; int w = scanner . nextInt ( ) ; while ( cPkcyexlyC + w > 0 ) { for ( int i = 0 ; i < cPkcyexlyC ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( j == 0 || j == w - 1 || i == 0 || i == cPkcyexlyC - 1 ) System . out . print ( " # " ) ; else System . out . print ( " . " ) ; } System . out . println ( ) ; } System . out . println ( ) ; cPkcyexlyC = scanner . nextInt ( ) ; w = scanner . nextInt ( ) ; } } } import java . util . * ; public class LpTLTFZnsL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LpTLTFZnsL = sc . nextInt ( ) ; int [ ] l = new int [ LpTLTFZnsL ] ; int max = 0 ; int pnt = - 1 ; for ( int i = 0 ; i < LpTLTFZnsL ; i ++ ) { l [ i ] = sc . nextInt ( ) ; if ( max < l [ i ] ) { max = l [ i ] ; pnt = i ; } } int total = 0 ; for ( int i = 0 ; i < LpTLTFZnsL ; 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 EbsiFWQlin { public static void main ( String [ ] arge ) { Scanner sc = new Scanner ( System . in ) ; int EbsiFWQlin = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int men = EbsiFWQlin * b ; int syu = ( EbsiFWQlin + 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 unjlFqaCbq { public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( System . in ) ; long unjlFqaCbq = sc . nextLong ( ) ; long D = sc . nextLong ( ) ; long ans = 0 ; for ( long i = 0 ; i < unjlFqaCbq ; 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 unjlFqaCbq { 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 humegkhYyj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int humegkhYyj = sc . nextInt ( ) ; int numX = sc . nextInt ( ) ; int initNum = numX - humegkhYyj + 1 ; String retStr = " " + initNum ; for ( int i = initNum + 1 ; i < numX + humegkhYyj ; i ++ ) { retStr = retStr + " " + i ; } System . out . println ( retStr ) ; } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class vTNWuOUAFK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vTNWuOUAFK = sc . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; int res = 0 ; for ( int i = 0 ; i < vTNWuOUAFK ; 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 bJEMcJtWjb { static final Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] __ ) { D [ ] deques = new D [ 3 ] ; for ( int bJEMcJtWjb = 0 ; bJEMcJtWjb < 3 ; bJEMcJtWjb ++ ) { deques [ bJEMcJtWjb ] = new D ( ) ; for ( char c : s . next ( ) . toCharArray ( ) ) deques [ bJEMcJtWjb ] . add ( c ) ; } char next = 'a' ; while ( ! deques [ next - 'a' ] . isEmpty ( ) ) { next = deques [ next - 'a' ] . poll ( ) ; } System . out . println ( Character . toUpperCase ( next ) ) ; } static class bJEMcJtWjb extends ArrayDeque < Character > { } } import java . util . Scanner ; public class CTQPKhcFub { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String CTQPKhcFub = s . nextLine ( ) ; if ( CTQPKhcFub . charAt ( 0 ) == CTQPKhcFub . charAt ( 1 ) && CTQPKhcFub . charAt ( 0 ) == CTQPKhcFub . charAt ( 2 ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } s . close ( ) ; } } import java . util . Scanner ; public class LfrostFcXK { private int LfrostFcXK ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int LfrostFcXK = 0 ; if ( N % 2 == 1 ) { LfrostFcXK = ( N / 2 ) + 1 ; } else { LfrostFcXK = ( N / 2 ) ; } System . out . print ( LfrostFcXK ) ; } } import java . util . * ; public class grkFuVgDhv { public static void main ( String [ ] args ) { int grkFuVgDhv ; Scanner sc = new Scanner ( System . in ) ; for ( ; ; ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( x == 0 && y == 0 ) break ; if ( x > y ) { grkFuVgDhv = x ; x = y ; y = grkFuVgDhv ; } System . out . println ( x + " " + y ) ; } } } import java . math . BigDecimal ; import java . util . Scanner ; class vwNVIFjPWV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vwNVIFjPWV = sc . nextInt ( ) ; long ans = 1 ; long [ ] A = new long [ vwNVIFjPWV ] ; for ( int i = 0 ; i < vwNVIFjPWV ; i ++ ) { A [ i ] = sc . nextLong ( ) ; if ( A [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } for ( int i = 0 ; i < vwNVIFjPWV ; 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 ntItEiXSeG { private static final int ntItEiXSeG = 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 RFSsStaSin { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long RFSsStaSin = sc . nextLong ( ) ; sc . close ( ) ; long ret = RFSsStaSin ; while ( true ) { if ( isPrime ( ret ) ) { break ; } ret ++ ; } System . out . println ( ret ) ; } public static boolean isPrime ( long RFSsStaSin ) { if ( RFSsStaSin == 1 || RFSsStaSin == 2 ) { return true ; } if ( RFSsStaSin % 2 == 0 ) { return false ; } boolean ret = false ; for ( long i = 2 ; i <= Math . sqrt ( RFSsStaSin ) ; i ++ ) { if ( RFSsStaSin % i == 0 ) { ret = false ; break ; } ret = true ; } return ret ; } } import java . io . FileNotFoundException ; import java . util . Arrays ; import java . util . Scanner ; public class DpwqQmnENt { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int DpwqQmnENt = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] p = new int [ DpwqQmnENt + 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 <= DpwqQmnENt ; i ++ ) { if ( p [ i ] > border ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class QgRkaLCmvc { static Scanner scan ; static int QgRkaLCmvc = 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 ( QgRkaLCmvc ) ; } 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 ) { QgRkaLCmvc ++ ; 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 uygCtwTlHS { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; int uygCtwTlHS = 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 [ uygCtwTlHS ] ; for ( int i = 0 ; i < q ; i ++ ) { int c = as [ i ] ; cp [ c ] ++ ; } int [ ] dp = new int [ uygCtwTlHS ] ; Arrays . fill ( dp , k ) ; long [ ] sum = new long [ uygCtwTlHS ] ; long all = Arrays . stream ( cp ) . sum ( ) ; for ( int i = 0 ; i < uygCtwTlHS ; i ++ ) { sum [ i ] = all - cp [ i ] ; } for ( int i = 0 ; i < uygCtwTlHS ; i ++ ) { if ( k > sum [ i ] ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class TiySjuvxtE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TiySjuvxtE = sc . nextInt ( ) ; String S = sc . next ( ) ; int count = 1 ; char [ ] slime = S . toCharArray ( ) ; for ( int i = 1 ; i < TiySjuvxtE ; i ++ ) { if ( slime [ i ] != slime [ i - 1 ] ) { count += 1 ; } } System . out . println ( count ) ; } } import java . util . * ; import java . text . DecimalFormat ; public class QKJquNmBce { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String QKJquNmBce = sc . nextLine ( ) ; if ( QKJquNmBce . equals ( " SUN " ) ) System . out . println ( 7 ) ; else if ( QKJquNmBce . equals ( " MON " ) ) System . out . println ( 6 ) ; else if ( QKJquNmBce . equals ( " TUE " ) ) System . out . println ( 5 ) ; else if ( QKJquNmBce . equals ( " WED " ) ) System . out . println ( 4 ) ; else if ( QKJquNmBce . equals ( " THU " ) ) System . out . println ( 3 ) ; else if ( QKJquNmBce . equals ( " FRI " ) ) System . out . println ( 2 ) ; else System . out . println ( 1 ) ; } } import java . util . Scanner ; public class qmMqyuZkIE { public static void main ( String [ ] args ) { long qmMqyuZkIE = 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 ) { qmMqyuZkIE = 0 ; ans2 = 0 ; } else { if ( k <= n ) { qmMqyuZkIE = n - k ; ans2 = m ; } else { qmMqyuZkIE = 0 ; ans2 = m - ( k - n ) ; } } System . out . println ( qmMqyuZkIE ) ; System . out . println ( ans2 ) ; sc . close ( ) ; } } import java . util . * ; public class YZZBLLQsRD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YZZBLLQsRD = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; String dummy = sc . nextLine ( ) ; int [ ] [ ] x = new int [ YZZBLLQsRD ] [ d ] ; for ( int i = 0 ; i < YZZBLLQsRD ; 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 < YZZBLLQsRD - 1 ; i ++ ) { for ( int j = i + 1 ; j < YZZBLLQsRD ; 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 pKnbMVLItP { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int pKnbMVLItP = sc . nextInt ( ) ; String S = sc . next ( ) ; if ( S . length ( ) <= pKnbMVLItP ) { System . out . println ( S ) ; } else { System . out . println ( S . substring ( 0 , pKnbMVLItP ) + " ... " ) ; } } 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 CRMQNaxnan { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) throws Exception { new Main ( ) . run ( ) ; } void run ( ) { int CRMQNaxnan = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; Pattern ptn = Pattern . compile ( " \\ d { " + CRMQNaxnan + " } - \\ d { " + b + " } " ) ; String s = sc . next ( ) ; System . out . println ( ptn . matcher ( s ) . matches ( ) ? " Yes " : " No " ) ; } } import java . io . * ; import java . util . * ; public class MFdMTVhADL { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int MFdMTVhADL = in . nextInt ( ) ; boolean [ ] rate = new boolean [ 8 ] ; int free = 0 ; int a ; for ( int i = 0 ; i < MFdMTVhADL ; 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 FOIvXkGIiV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FOIvXkGIiV = sc . nextInt ( ) ; int [ ] button = new int [ FOIvXkGIiV + 1 ] ; for ( int i = 1 ; i <= FOIvXkGIiV ; i ++ ) { button [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int count = 0 ; int nextButton = 1 ; boolean success = false ; for ( int j = 0 ; j < FOIvXkGIiV ; 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 WwGvDvVLfk { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int WwGvDvVLfk = 124 ; int max = - 1 ; for ( int i = 0 ; i < 5 ; i ++ ) { int n = in . nextInt ( ) ; if ( n < WwGvDvVLfk ) WwGvDvVLfk = n ; if ( n > max ) max = n ; } int k = in . nextInt ( ) ; System . out . println ( ( max - WwGvDvVLfk <= k ) ? " Yay! " : " :( " ) ; in . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class eCTyUdstxx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eCTyUdstxx = sc . nextInt ( ) ; int [ ] array = new int [ eCTyUdstxx ] ; boolean b = true ; int i ; for ( i = 0 ; i < eCTyUdstxx ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } Arrays . sort ( array ) ; for ( i = 0 ; i < eCTyUdstxx ; 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 vPgjwTsuZp { public static void main ( String [ ] args ) { TreeSet < Integer > numerosUtiles = new TreeSet < > ( ) ; Scanner in = new Scanner ( System . in ) ; int vPgjwTsuZp = in . nextInt ( ) ; int [ ] numbers = new int [ vPgjwTsuZp ] ; for ( int i = 0 ; i < vPgjwTsuZp ; i ++ ) { numbers [ i ] = in . nextInt ( ) ; } for ( int i = 1 ; i < ( vPgjwTsuZp - 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 fMiVCXbmyW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fMiVCXbmyW = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] variation = new int [ fMiVCXbmyW ] ; int count = 0 ; int i , j , k = 0 ; int [ ] max = new int [ fMiVCXbmyW ] ; for ( i = 0 ; i < fMiVCXbmyW ; i ++ ) { variation [ i ] = sc . nextInt ( ) ; } for ( j = 0 ; j < fMiVCXbmyW ; j ++ ) { X = X - variation [ j ] ; count ++ ; } for ( k = 0 ; k < fMiVCXbmyW ; k ++ ) { max [ k ] = X / variation [ k ] ; } for ( j = 0 ; j < fMiVCXbmyW ; j ++ ) { for ( k = j + 1 ; k < fMiVCXbmyW ; 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 nbIHgIsRMf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nbIHgIsRMf = sc . nextInt ( ) ; int happy500 = 0 ; int happy5 = 0 ; happy500 = nbIHgIsRMf / 500 * 1000 ; happy5 = ( nbIHgIsRMf % 500 ) / 5 * 5 ; System . out . println ( happy500 + happy5 ) ; } } import java . util . Scanner ; class ilwyzoCAjT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ilwyzoCAjT = sc . nextInt ( ) ; int [ ] a = new int [ ilwyzoCAjT ] ; int [ ] b = new int [ ilwyzoCAjT - 1 ] ; for ( int i = 0 ; i < ilwyzoCAjT ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int j = 0 ; j < ilwyzoCAjT - 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 < ilwyzoCAjT - 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 LLkSbrGxGd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long LLkSbrGxGd = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; long A = LLkSbrGxGd % K ; long ans = 0 ; if ( LLkSbrGxGd % K == 0 ) { ans = 0 ; } else { ans = Math . min ( A , K - A ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class ZXJVPKxecO { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ZXJVPKxecO = scanner . nextInt ( ) ; if ( ZXJVPKxecO == 0 ) { System . out . println ( " 1 " ) ; } else if ( ZXJVPKxecO == 1 ) { System . out . println ( " 0 " ) ; } } } import java . util . Scanner ; public class pVEzsupQzQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String pVEzsupQzQ = sc . next ( ) ; String s1 = pVEzsupQzQ . substring ( 2 , 3 ) ; String s2 = pVEzsupQzQ . substring ( 3 , 4 ) ; String s3 = pVEzsupQzQ . substring ( 4 , 5 ) ; String s4 = pVEzsupQzQ . 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 QylzoimgPf { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int QylzoimgPf = sc . nextInt ( ) ; int min = 1_000_000_000 ; int max = 1 ; for ( int i = 0 ; i < QylzoimgPf ; 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 kqSupFTODH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kqSupFTODH = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( ( b - 1 + kqSupFTODH - 2 ) / ( kqSupFTODH - 1 ) ) ; } } import java . util . Scanner ; public class uIIbEcjObn { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; String uIIbEcjObn = std . next ( ) ; String first = uIIbEcjObn . substring ( 0 , 2 ) ; String last = uIIbEcjObn . 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 RxrhVGJPpl { public static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int RxrhVGJPpl = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int max = RxrhVGJPpl ; 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 : RxrhVGJPpl *= 2 ; break ; case 1 : b *= 2 ; break ; case 2 : c *= 2 ; break ; } } System . out . println ( RxrhVGJPpl + b + c ) ; } } import java . util . * ; class DnmWFIOAnc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String DnmWFIOAnc = sc . next ( ) ; switch ( DnmWFIOAnc ) { case " ABC " : System . out . println ( " ARC " ) ; break ; case " ARC " : System . out . println ( " ABC " ) ; break ; } sc . close ( ) ; } } import java . util . Scanner ; public class eumEAwxfoM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eumEAwxfoM , n , j , S = 0 ; double avr , O = 0 , s ; for ( eumEAwxfoM = 0 ; ; eumEAwxfoM ++ ) { 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 tOSdNqSdgo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String x = sc . next ( ) ; if ( x . equals ( " 0 " ) ) break ; int tOSdNqSdgo = 0 , i ; for ( i = 0 ; i < x . length ( ) ; i ++ ) { tOSdNqSdgo = tOSdNqSdgo + x . charAt ( i ) - 48 ; } System . out . printf ( " %d \n " , tOSdNqSdgo ) ; } } } import java . util . Scanner ; public class EAyuOwWRJI { public static void main ( String [ ] args ) { int EAyuOwWRJI , b ; Scanner scanner = new Scanner ( System . in ) ; while ( scanner . hasNext ( ) ) { EAyuOwWRJI = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; System . out . println ( ( String . valueOf ( EAyuOwWRJI + b ) . length ( ) ) ) ; } scanner . close ( ) ; } } import java . util . Scanner ; public class rXzjCMErDN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rXzjCMErDN = sc . nextInt ( ) ; int [ ] value = new int [ rXzjCMErDN ] ; int [ ] cost = new int [ rXzjCMErDN ] ; int [ ] trueValue = new int [ rXzjCMErDN ] ; int max = 0 ; for ( int i = 0 ; i < rXzjCMErDN ; i ++ ) { value [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < rXzjCMErDN ; i ++ ) { cost [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < rXzjCMErDN ; 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 kgVxtWALqV { public static void main ( String [ ] args ) { int kgVxtWALqV = 0 ; int i = 0 ; String outputNum = " " ; String [ ] NumList ; try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; kgVxtWALqV = Integer . parseInt ( line ) ; line = br . readLine ( ) ; if ( line != null ) { NumList = line . split ( " " , 0 ) ; int Count = kgVxtWALqV - 1 ; for ( i = 0 ; i < NumList . length ; i ++ ) { if ( Count != kgVxtWALqV - 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 CXRkCDUxDR { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int [ ] arr = new int [ 101010 ] ; int CXRkCDUxDR ; int n ; int cnt = 0 ; n = reader . nextInt ( ) ; CXRkCDUxDR = reader . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= CXRkCDUxDR ) { cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; class nZtxKeoyzN { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int nZtxKeoyzN = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; if ( nZtxKeoyzN == b || b == c || nZtxKeoyzN == c ) { System . out . println ( " No " ) ; } else if ( nZtxKeoyzN > b || nZtxKeoyzN > 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 dpqigDQKev { public static void main ( String [ ] args ) { Scanner as = new Scanner ( System . in ) ; double dpqigDQKev , t , s ; dpqigDQKev = as . nextDouble ( ) ; s = 3.141592653589 * dpqigDQKev * dpqigDQKev ; t = 2.0 * 3.141592653589 * dpqigDQKev ; 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 YWMOVabkQP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YWMOVabkQP = Integer . parseInt ( sc . next ( ) ) ; int taro = 0 ; int hanako = 0 ; for ( int i = 0 ; i < YWMOVabkQP ; 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 sSsCOajxmU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sSsCOajxmU = sc . nextInt ( ) ; int result = 0 ; int ahead ; int current = 100000 ; for ( int i = 0 ; i < sSsCOajxmU - 1 ; i ++ ) { ahead = current ; current = sc . nextInt ( ) ; result += Math . min ( ahead , current ) ; } result += current ; System . out . println ( result ) ; } } import java . util . Scanner ; public class rjOOrgwZyt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rjOOrgwZyt = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i <= rjOOrgwZyt ; 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 MuHaUQqkFt { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; int MuHaUQqkFt = scanner . nextInt ( ) ; int i = 0 ; int X ; int hantei = 0 ; int ans = 0 ; while ( hantei == 0 ) { X = MuHaUQqkFt + 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 VAZQjEfZUn { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int VAZQjEfZUn = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; sc . close ( ) ; int sum = 0 ; for ( int i = 1 ; i < VAZQjEfZUn ; i ++ ) { sum += i ; } for ( int i = 1 ; i < M ; i ++ ) { sum += i ; } System . out . println ( sum ) ; } } import java . util . * ; public class htUdGpPLMF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int htUdGpPLMF = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int gugu = htUdGpPLMF * ( htUdGpPLMF - 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 RzeeCwbKuU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RzeeCwbKuU = 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 [ RzeeCwbKuU ] ; for ( int i = 0 ; i < q ; i ++ ) { int ans = a [ i ] - 1 ; point [ ans ] ++ ; } for ( int i = 0 ; i < RzeeCwbKuU ; i ++ ) { if ( k - q + point [ i ] > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; public class MtNVtiAOSn { static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int MtNVtiAOSn = scanner . nextInt ( ) ; int max = 1 ; for ( int i = 2 ; i <= MtNVtiAOSn ; i ++ ) { int j = i ; while ( true ) { j *= i ; if ( j > MtNVtiAOSn ) { break ; } max = Math . max ( max , j ) ; } } System . out . println ( max ) ; } } import java . util . * ; class lVUDIKGZjG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lVUDIKGZjG = sc . nextInt ( ) ; int res = 0 ; for ( int a = 1 ; a <= lVUDIKGZjG ; ++ a ) { for ( int b = 1 ; b <= lVUDIKGZjG ; ++ b ) { for ( int c = 1 ; c <= lVUDIKGZjG ; ++ 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 NogcrZfIJB { 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 NogcrZfIJB ; double rad = Math . PI * 2 * ( ( double ) h / 12 + ( ( double ) m / 60 ) / 12 - ( double ) m / 60 ) ; NogcrZfIJB = Math . sqrt ( Math . pow ( a , 2 ) + Math . pow ( b , 2 ) - 2 * a * b * Math . cos ( rad ) ) ; System . out . printf ( " %.20f " , NogcrZfIJB ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class EUlpKJsXyb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EUlpKJsXyb = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; Integer [ ] a = new Integer [ EUlpKJsXyb ] ; for ( int i = 0 ; i < EUlpKJsXyb ; 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 fpjfFDNsJJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] nyu = sc . nextLine ( ) . split ( " " ) ; int fpjfFDNsJJ = Integer . parseInt ( nyu [ 0 ] ) ; int numnext = Integer . parseInt ( nyu [ 1 ] ) ; int numend = Integer . parseInt ( nyu [ 2 ] ) ; int count = 0 ; if ( numend - ( fpjfFDNsJJ - numnext ) < 0 ) { count = 0 ; } else { count = numend - ( fpjfFDNsJJ - numnext ) ; } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; import java . nio . charset . StandardCharsets ; public class IQPvJoxhNX { 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 IQPvJoxhNX = 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 , IQPvJoxhNX ) ; String str = valid ? " Yes " : " No " ; System . out . println ( str ) ; } static boolean isValid ( String S , Set < Character > numbers , int IQPvJoxhNX ) { for ( int i = 0 ; i < S . length ( ) ; ++ i ) { if ( i == IQPvJoxhNX ) { 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 CctmNEGblz { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String CctmNEGblz = br . readLine ( ) ; Integer num = Integer . parseInt ( CctmNEGblz ) ; System . out . println ( num * num * num ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class qubBfQSkDD { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int qubBfQSkDD = Integer . parseInt ( br . readLine ( ) ) ; String [ ] sNumbers = br . readLine ( ) . split ( " " ) ; int [ ] numbers = new int [ qubBfQSkDD ] ; for ( int i = 0 ; i < qubBfQSkDD ; 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 hlqyoWLwYh { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int hlqyoWLwYh = Integer . parseInt ( in . readLine ( ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int [ ] a = new int [ hlqyoWLwYh ] ; int hantei = 1 ; int cntContinuous = 0 ; for ( int i = 0 ; i < hlqyoWLwYh ; i ++ ) { a [ i ] = Integer . parseInt ( str [ i ] ) ; if ( hantei == a [ i ] ) { cntContinuous ++ ; hantei ++ ; } } System . out . println ( cntContinuous == 0 ? - 1 : hlqyoWLwYh - cntContinuous ) ; } } import java . util . Scanner ; public class zKohyGetPP { public static void main ( String [ ] args ) { final int zKohyGetPP = 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 ] [ zKohyGetPP ] - 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 ] [ zKohyGetPP ] ; } 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 nrfapuAvlZ { static BigInteger limit = new BigInteger ( " 1000000000000000000 " ) ; public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int nrfapuAvlZ = sc . nextInt ( ) ; List < BigInteger > values = new ArrayList < BigInteger > ( ) ; for ( int i = 0 ; i < nrfapuAvlZ ; 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 vCmHzGCvfW { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int vCmHzGCvfW = scanner . nextInt ( ) , B = scanner . nextInt ( ) , C = scanner . nextInt ( ) ; System . out . println ( C / vCmHzGCvfW * B ) ; } } import java . util . * ; public class VxkhcoKWdd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VxkhcoKWdd = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int res = 9999 ; for ( int i = 0 ; i < VxkhcoKWdd ; 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 eJELdzxdaL { public static void main ( String [ ] args ) { StringBuilder sb = new StringBuilder ( ) ; Scanner as = new Scanner ( System . in ) ; int eJELdzxdaL = 0 ; int tre = 0 ; int count = 0 ; int [ ] A ; Boolean flag = true ; eJELdzxdaL = Integer . parseInt ( as . next ( ) ) ; A = new int [ eJELdzxdaL ] ; for ( int i = 0 ; i < eJELdzxdaL ; i ++ ) { A [ i ] = Integer . parseInt ( as . next ( ) ) ; } while ( flag ) { flag = false ; for ( int j = eJELdzxdaL - 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 < eJELdzxdaL ; i ++ ) { if ( i != eJELdzxdaL - 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 XjrdqfVYCE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XjrdqfVYCE = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int time = t ; int x1 = x ; while ( x < XjrdqfVYCE ) { t = t + time ; x = x + x1 ; } System . out . println ( t ) ; sc . close ( ) ; } } import java . util . * ; public class tIGyyDKhoK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tIGyyDKhoK = sc . nextInt ( ) ; long min = sc . nextInt ( ) ; long ret = - 1000000001 ; for ( int i = 1 ; i < tIGyyDKhoK ; 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 MIUbijLTgC { 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 MIUbijLTgC = sc . nextInt ( ) ; for ( int i = 0 ; MIUbijLTgC > 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 ; MIUbijLTgC > i ; i ++ ) { System . out . println ( list_in_max ) ; } System . exit ( 0 ) ; } else { for ( int i = 0 ; MIUbijLTgC > 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 OcAuQdYZzx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OcAuQdYZzx = 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 >= OcAuQdYZzx ) { 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 LaSMIGVPbU { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String LaSMIGVPbU = reader . readLine ( ) ; String p = reader . readLine ( ) ; String ss = LaSMIGVPbU + LaSMIGVPbU ; 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 qaxtUXpcuF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String answer = " Good " ; for ( int qaxtUXpcuF = 0 ; qaxtUXpcuF < 3 ; qaxtUXpcuF ++ ) { if ( s . charAt ( qaxtUXpcuF ) == s . charAt ( qaxtUXpcuF + 1 ) ) { answer = " Bad " ; break ; } } System . out . println ( answer ) ; sc . close ( ) ; } } import java . util . Scanner ; public class AlzUbMFZMT { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int AlzUbMFZMT = scanner . nextInt ( ) ; System . out . println ( AlzUbMFZMT / 2 + AlzUbMFZMT % 2 ) ; } } import java . util . Scanner ; public class qxExwcDcBw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; final int qxExwcDcBw = scan . nextInt ( ) ; final int M = scan . nextInt ( ) ; int [ ] [ ] codes = new int [ qxExwcDcBw ] [ 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 < qxExwcDcBw ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { codes [ i ] [ j ] = scan . nextInt ( ) ; } } int count = 0 ; for ( int i = 0 ; i < qxExwcDcBw ; 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 JwhuwAoSMG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JwhuwAoSMG = sc . nextInt ( ) ; String ans = " No " ; for ( int i = 1 ; i < 10 ; i ++ ) { for ( int j = 1 ; j < 10 ; j ++ ) { if ( i * j == JwhuwAoSMG ) { ans = " Yes " ; break ; } } } System . out . println ( ans ) ; } } import identifier . identifier . * ; import identifier . identifier . * ; public class MEQuOLoKvl { 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 KQLPYfIWPX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KQLPYfIWPX = sc . nextInt ( ) ; int [ ] a = new int [ KQLPYfIWPX ] ; int sum = 0 ; for ( int i = 0 ; i < KQLPYfIWPX ; i ++ ) { a [ i ] = sc . nextInt ( ) ; sum += a [ i ] ; } Arrays . parallelSort ( a ) ; sum -= a [ KQLPYfIWPX - 1 ] ; if ( sum > a [ KQLPYfIWPX - 1 ] ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class OgUirzmeSI { 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 OgUirzmeSI = 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 tbPuGAAPpV { 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 tbPuGAAPpV = 0 ; for ( int i = 0 ; i <= 6 ; i ++ ) { if ( input . equals ( s [ i ] ) ) tbPuGAAPpV = 7 - i ; } System . out . println ( tbPuGAAPpV ) ; } } import java . util . * ; public class uhisluROcM { 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 uhisluROcM = 0 ; for ( int i = 0 ; i < s1 . length ; i ++ ) { if ( s1 [ i ] != t1 [ i ] ) { uhisluROcM ++ ; } } System . out . println ( uhisluROcM ) ; sc . close ( ) ; } } import java . util . Scanner ; public class WrZZqjjVZD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WrZZqjjVZD = 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 ) * WrZZqjjVZD + Math . max ( 0 , y - i ) * b ) ; } System . out . println ( min ) ; } } import java . lang . Math ; import java . util . Scanner ; class LLMjLzZrkm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long LLMjLzZrkm = sc . nextLong ( ) ; double interest = 100 ; int year = 0 ; while ( interest < LLMjLzZrkm ) { year += 1 ; interest *= 1.01 ; interest = Math . floor ( interest ) ; if ( interest >= LLMjLzZrkm ) { break ; } } System . out . println ( year ) ; } } import java . util . Scanner ; public class vnnvkeLxNF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; char [ ] c = S . toCharArray ( ) ; int vnnvkeLxNF = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( c [ i ] == '+' ) { vnnvkeLxNF ++ ; } else { vnnvkeLxNF -- ; } } System . out . println ( vnnvkeLxNF ) ; } } import java . util . * ; public class xdUNxyREeM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xdUNxyREeM = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int tasu = xdUNxyREeM + B ; int hiku = xdUNxyREeM - B ; int kakeru = xdUNxyREeM * B ; System . out . println ( Math . max ( kakeru , Math . max ( tasu , hiku ) ) ) ; } } import java . util . Scanner ; public class vtMoVjphae { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vtMoVjphae = 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 <= vtMoVjphae ; 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 rGFZvWgzkr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rGFZvWgzkr = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int divideAns = rGFZvWgzkr / b ; int modAns = rGFZvWgzkr % b ; double fewAns = ( double ) rGFZvWgzkr / b ; out . printf ( " %d %d %f%n " , divideAns , modAns , fewAns ) ; } } import java . util . * ; public class qlKJHhBZpw { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int qlKJHhBZpw = s . nextInt ( ) ; String yvgubhij = s . nextLine ( ) ; HashSet < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < qlKJHhBZpw ; i ++ ) { String b = s . nextLine ( ) ; set . add ( b ) ; } System . out . println ( set . size ( ) ) ; } } import java . util . Scanner ; public class ueBJReUSWQ { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ueBJReUSWQ = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; int d = scanner . nextInt ( ) ; int ans = 0 ; if ( c < ueBJReUSWQ && d < ueBJReUSWQ ) { ans = 0 ; } if ( c <= ueBJReUSWQ && d >= ueBJReUSWQ && d <= b ) { ans = d - ueBJReUSWQ ; } if ( c >= ueBJReUSWQ && d <= b ) { ans = d - c ; } if ( c >= ueBJReUSWQ && d >= b && c <= b ) { ans = b - c ; } if ( b < c ) { ans = 0 ; } if ( c <= ueBJReUSWQ && b <= d ) { ans = b - ueBJReUSWQ ; } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; import static java . lang . Math . * ; public class hIkIkHsBWy { static PrintWriter out = new PrintWriter ( System . out ) ; public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( System . in ) ; int hIkIkHsBWy = sc . nextInt ( ) , q = sc . nextInt ( ) ; String s = sc . next ( ) ; int [ ] AC = new int [ hIkIkHsBWy + 1 ] ; for ( int i = 1 ; i < hIkIkHsBWy ; i ++ ) { if ( s . charAt ( i - 1 ) == 'A' && s . charAt ( i ) == 'C' ) { AC [ i ] = 1 ; } } for ( int i = 1 ; i < hIkIkHsBWy + 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 < hIkIkHsBWy && 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 oaXMNaKiUb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oaXMNaKiUb = sc . nextInt ( ) ; int [ ] tako = new int [ oaXMNaKiUb ] ; for ( int i = 0 ; i < oaXMNaKiUb ; i ++ ) { tako [ i ] = sc . nextInt ( ) ; } int sum = 0 ; for ( int i = 0 ; i < oaXMNaKiUb ; i ++ ) { for ( int k = i + 1 ; k < oaXMNaKiUb ; k ++ ) { sum += tako [ i ] * tako [ k ] ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; class FRUYiSMGrI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int FRUYiSMGrI = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String ans = sc . next ( ) ; int sum = 0 ; if ( ans . equals ( s ) ) { sum = FRUYiSMGrI - 1 ; System . out . println ( sum + " " + b ) ; } if ( ans . equals ( t ) ) { sum = b - 1 ; System . out . println ( FRUYiSMGrI + " " + sum ) ; } sc . close ( ) ; } } import java . util . * ; public class CrpKhUdYEl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " " ; int CrpKhUdYEl = Integer . parseInt ( s . substring ( 0 , 2 ) ) ; int l = Integer . parseInt ( s . substring ( 2 , 4 ) ) ; if ( CrpKhUdYEl < 1 || 12 < CrpKhUdYEl ) { 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 GyGhHXzEAt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GyGhHXzEAt = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; List < Integer > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < GyGhHXzEAt ; 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 SuKmJiAGvL { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strAry ; long SuKmJiAGvL , max , min , sum ; SuKmJiAGvL = 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 < SuKmJiAGvL ; 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 NtmGzNyPCs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NtmGzNyPCs = sc . nextInt ( ) ; int [ ] r = new int [ NtmGzNyPCs ] ; for ( int i = 1 ; i <= NtmGzNyPCs ; i ++ ) r [ sc . nextInt ( ) - 1 ] = i ; for ( int rr : r ) System . out . print ( rr + " " ) ; } } import java . util . Scanner ; public class QjdiezZisu { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; while ( true ) { String a = scanner . nextLine ( ) ; if ( a . equals ( " 0 " ) ) break ; int QjdiezZisu = 0 ; for ( char b : a . toCharArray ( ) ) { QjdiezZisu += Integer . parseInt ( String . valueOf ( b ) ) ; } System . out . println ( QjdiezZisu ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class XJxekWWSXE { public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( System . in ) ; int XJxekWWSXE = sc . nextInt ( ) ; int ans = 0 ; ans = XJxekWWSXE + ( int ) Math . pow ( XJxekWWSXE , 2 ) + ( int ) Math . pow ( XJxekWWSXE , 3 ) ; System . out . println ( ans ) ; } private static class XJxekWWSXE { 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 vBWDGnBaUE { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; Map < String , Integer > tV = new TreeMap < > ( ) ; int vBWDGnBaUE = scn . nextInt ( ) ; int [ ] VList = new int [ vBWDGnBaUE ] ; for ( int i = 0 ; i < vBWDGnBaUE ; 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 [ vBWDGnBaUE - 1 ] == VList [ 0 ] ) { for ( Map . Entry < String , Integer > vote : tV . entrySet ( ) ) { System . out . println ( vote . getKey ( ) . toString ( ) ) ; } } else { if ( VList [ 0 ] != VList [ vBWDGnBaUE - 1 ] ) { for ( Map . Entry < String , Integer > vote : tV . entrySet ( ) ) { if ( vote . getValue ( ) == VList [ vBWDGnBaUE - 1 ] ) { System . out . println ( vote . getKey ( ) . toString ( ) ) ; } } } } scn . close ( ) ; } } import java . util . Scanner ; import java . util . Arrays ; class qrFZIYNPoA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long qrFZIYNPoA = sc . nextLong ( ) ; int i = 0 ; for ( i = 1 ; qrFZIYNPoA > 1 ; i ++ ) { qrFZIYNPoA = qrFZIYNPoA / 2 ; } System . out . println ( ( long ) ( Math . pow ( 2 , i - 1 ) + Math . pow ( 2 , i - 1 ) - 1 ) ) ; } } import java . util . Scanner ; public class HYqJIYmADL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HYqJIYmADL = sc . nextInt ( ) ; double pi = 3.141592653558209749448214808651 ; double l = 2 * pi * HYqJIYmADL ; System . out . println ( l ) ; } } import java . io . FileNotFoundException ; import java . util . Scanner ; public class OXeobmGsNP { @ SuppressWarnings ( " deprecation " ) public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int OXeobmGsNP = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; System . out . println ( OXeobmGsNP * ( OXeobmGsNP - 1 ) / 2 + M * ( M - 1 ) / 2 ) ; } } import java . util . * ; public class uERvqQlXMm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uERvqQlXMm = sc . nextInt ( ) ; String s = sc . next ( ) ; int b = 0 ; for ( int i = 0 ; i < uERvqQlXMm - 2 ; i ++ ) { if ( s . substring ( i , i + 3 ) . equals ( " ABC " ) ) { b ++ ; } } System . out . println ( b ) ; } } import java . util . Scanner ; public class CljbXfEnGh { static public void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CljbXfEnGh = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] counts = new int [ CljbXfEnGh ] ; 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 mTbqMtzrfs { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int mTbqMtzrfs = Integer . parseInt ( scanner . next ( ) ) ; double [ ] S = new double [ mTbqMtzrfs ] ; for ( int i = 0 ; i < mTbqMtzrfs ; i ++ ) { S [ i ] = Double . parseDouble ( scanner . next ( ) ) ; } Arrays . parallelSort ( S ) ; double m = ( S [ 0 ] + S [ 1 ] ) / 2 ; for ( int i = 2 ; i < mTbqMtzrfs ; i ++ ) { m = ( m + S [ i ] ) / 2 ; } System . out . print ( m ) ; } } import java . util . ArrayList ; import java . util . HashMap ; import java . util . Scanner ; public class SZuDqBztJb { public static void main ( String [ ] args ) { HashMap < Integer , Integer > num = new HashMap < > ( ) ; Scanner sc = new Scanner ( System . in ) ; int SZuDqBztJb = sc . nextInt ( ) ; for ( int i = 1 ; i < SZuDqBztJb ; 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 <= SZuDqBztJb ; i ++ ) { if ( num . containsKey ( i ) ) { System . out . println ( num . get ( i ) ) ; } else { System . out . println ( 0 ) ; } } } } import java . util . Scanner ; public class WjRilXCoQP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WjRilXCoQP = sc . nextInt ( ) ; sc . nextLine ( ) ; String [ ] array = new String [ WjRilXCoQP ] ; for ( int i = 0 ; i < WjRilXCoQP ; i ++ ) { array [ i ] = sc . nextLine ( ) ; if ( i == 0 ) { continue ; } if ( ! ( array [ i ] . substring ( 0 , 1 ) ) . equals ( array [ i - 1 ] . substring ( array [ i - 1 ] . WjRilXCoQP ( ) - 1 ) ) ) { System . out . println ( " No " ) ; return ; } } for ( int i = 0 ; i < WjRilXCoQP - 1 ; i ++ ) { for ( int j = i + 1 ; j < WjRilXCoQP ; j ++ ) { if ( array [ i ] . equals ( array [ j ] ) ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class xXMgQtTaRt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xXMgQtTaRt = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int min = x - xXMgQtTaRt + 1 ; int max = x + xXMgQtTaRt - 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 jUYiWAYTVT { 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 jUYiWAYTVT = 0 ; jUYiWAYTVT < 3 ; jUYiWAYTVT ++ ) { ODD_STEP . add ( ODD_STEP_STR . charAt ( jUYiWAYTVT ) ) ; EVEN_STEP . add ( EVEN_STEP_STR . charAt ( jUYiWAYTVT ) ) ; } int current_step = 0 ; String steps = sc . next ( ) ; for ( int jUYiWAYTVT = 0 ; jUYiWAYTVT < steps . length ( ) ; jUYiWAYTVT ++ ) { char step = steps . charAt ( jUYiWAYTVT ) ; if ( ( jUYiWAYTVT + 1 ) % 2 == 0 && ! EVEN_STEP . contains ( step ) ) { break ; } else if ( ( jUYiWAYTVT + 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 bamRtMaBWZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bamRtMaBWZ = 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 < bamRtMaBWZ ; 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 HgZKCJmGHW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int HgZKCJmGHW = 1 ; int count = 0 ; if ( S . length ( ) % 2 == 0 ) { HgZKCJmGHW = S . length ( ) ; } else { HgZKCJmGHW = S . length ( ) - 1 ; } for ( int i = 0 ; i < HgZKCJmGHW / 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 TDvBhqehqH { 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 TDvBhqehqH = reader . readLine ( ) ; while ( TDvBhqehqH != null ) { mylist . add ( TDvBhqehqH ) ; TDvBhqehqH = 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 tCgPPGtNio { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tCgPPGtNio = 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 [ tCgPPGtNio ] ; 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 < tCgPPGtNio ; i ++ ) { rightResult = rightResult + flag [ i ] ; } if ( leftResult < rightResult ) { System . out . println ( leftResult ) ; } else { System . out . println ( rightResult ) ; } } } import java . util . * ; public class xkwUepNUWp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xkwUepNUWp = sc . nextInt ( ) ; int [ ] hights = new int [ xkwUepNUWp ] ; boolean reach = false ; String answer = " Yes " ; for ( int i = 0 ; i < xkwUepNUWp ; i ++ ) { hights [ i ] = sc . nextInt ( ) ; } for ( int i = xkwUepNUWp - 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 uUIRBVjSxZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uUIRBVjSxZ = sc . nextInt ( ) ; int xx = uUIRBVjSxZ / 2 ; int ans = 0 ; for ( int i = 1 ; i <= uUIRBVjSxZ ; i ++ ) { for ( int j = 2 ; j <= uUIRBVjSxZ + 1 ; j ++ ) { if ( Math . pow ( i , j ) > ans && Math . pow ( i , j ) <= uUIRBVjSxZ ) { 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 jzMJOMaemV { 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 jzMJOMaemV = 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 > jzMJOMaemV ) { System . out . println ( " -1 " ) ; } else { System . out . println ( ( jzMJOMaemV - sum ) ) ; } } void calc ( ) { } void showResult ( ) { } } import java . io . * ; import java . util . * ; class veNfCBwHsz { 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 veNfCBwHsz = Integer . parseInt ( st . nextToken ( ) ) ; int w = Integer . parseInt ( st . nextToken ( ) ) ; if ( w == 0 && veNfCBwHsz == 0 ) break ; for ( int i = 0 ; i < veNfCBwHsz ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } System . out . println ( ) ; } } } import java . util . * ; class ggzWmuwOrT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ggzWmuwOrT = sc . nextInt ( ) ; long [ ] a = new long [ ggzWmuwOrT ] ; for ( int i = 0 ; i < ggzWmuwOrT ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long num = lcm ( a , ggzWmuwOrT ) ; long deno = sum ( a , ggzWmuwOrT , 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 ggzWmuwOrT ) { long lc = 1 ; for ( int i = 0 ; i < ggzWmuwOrT ; i ++ ) { lc = ( lc * a [ i ] ) / gcd ( lc , a [ i ] ) ; } return lc ; } public static long sum ( long [ ] a , int ggzWmuwOrT , long num ) { long count = 0 ; for ( int i = 0 ; i < ggzWmuwOrT ; i ++ ) { count += ( num / a [ i ] ) ; } return count ; } } import java . util . * ; public class TfsiIPdzgX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TfsiIPdzgX = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int min = 0 ; int min2 = 0 ; if ( TfsiIPdzgX < b ) { min = TfsiIPdzgX ; if ( b < c ) { min2 = b ; } else { min2 = c ; } } else { min = b ; if ( TfsiIPdzgX < c ) { min2 = TfsiIPdzgX ; } else { min2 = c ; } } System . out . println ( min + min2 ) ; } } import java . io . * ; public class BZDIaPgXkH { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long BZDIaPgXkH = Long . parseLong ( reader . readLine ( ) ) ; System . out . println ( calc ( 1 , BZDIaPgXkH ) - calc ( 3 , BZDIaPgXkH ) - calc ( 5 , BZDIaPgXkH ) + calc ( 15 , BZDIaPgXkH ) ) ; return ; } static long calc ( long n , long BZDIaPgXkH ) { return ( n + BZDIaPgXkH / n * n ) * ( BZDIaPgXkH / n ) / 2 ; } } import java . util . Scanner ; public class DJXqTdHRHf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; char [ ] chars = s . toCharArray ( ) ; int DJXqTdHRHf = 0 ; for ( int i = 0 ; i < chars . length / 2 ; i ++ ) { if ( chars [ i ] != chars [ chars . length - 1 - i ] ) { DJXqTdHRHf ++ ; } } System . out . println ( DJXqTdHRHf ) ; } } import java . io . * ; public class eYFzOYmjYw { public static void main ( String ... args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String [ ] line = br . readLine ( ) . split ( " " ) ; int eYFzOYmjYw = Integer . parseInt ( line [ 0 ] ) ; int k = Integer . parseInt ( line [ 1 ] ) ; int q = Integer . parseInt ( line [ 2 ] ) ; int [ ] point = new int [ eYFzOYmjYw ] ; for ( int i = 0 ; i < q ; i ++ ) { point [ Integer . parseInt ( br . readLine ( ) ) - 1 ] += 1 ; } for ( int i = 0 ; i < eYFzOYmjYw ; 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 kDDbuXmsHM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kDDbuXmsHM = sc . nextInt ( ) ; int kari = kDDbuXmsHM + 1 ; int keta = 1 ; while ( ( int ) ( kari / 10 ) != 0 ) { keta ++ ; kari = ( int ) ( kari / 10 ) ; } if ( keta == 1 ) { System . out . println ( kDDbuXmsHM ) ; } else if ( keta == 2 ) { System . out . println ( 9 ) ; } else if ( keta == 3 ) { System . out . println ( ( 10 + kDDbuXmsHM - 100 ) ) ; } else if ( keta == 4 ) { System . out . println ( 909 ) ; } else if ( keta == 5 ) { System . out . println ( ( 910 + kDDbuXmsHM - 10000 ) ) ; } else { System . out . println ( 90909 ) ; } sc . close ( ) ; } } import java . util . Map ; import java . util . Scanner ; import java . util . TreeMap ; public class HubKDKpyuf { 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 HubKDKpyuf : A ) { if ( maplst . containsKey ( HubKDKpyuf ) ) { maplst . put ( HubKDKpyuf , maplst . get ( HubKDKpyuf ) + 1 ) ; } else { maplst . put ( HubKDKpyuf , 1 ) ; } } boolean judge = true ; if ( maplst . keySet ( ) . size ( ) == 2 ) { for ( char HubKDKpyuf : maplst . keySet ( ) ) { if ( maplst . get ( HubKDKpyuf ) != 2 ) { judge = ! judge ; break ; } } } else { judge = ! judge ; } if ( judge ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class CPDFwfPKVz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CPDFwfPKVz = sc . nextInt ( ) ; int break_count = 0 ; int next = 1 ; for ( int i = 0 ; i < CPDFwfPKVz ; 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 rfyHiPKCxz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rfyHiPKCxz = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int sta = d * 2 + 1 ; for ( int i = 0 ; i < 20 ; i ++ ) { if ( sta * i >= rfyHiPKCxz ) { System . out . println ( i ) ; break ; } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class tYUjIXYTDR { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int tYUjIXYTDR , b , w ; String str ; String [ ] s ; str = br . readLine ( ) ; while ( str != null ) { StringBuilder out = new StringBuilder ( ) ; s = str . split ( " " ) ; tYUjIXYTDR = Integer . parseInt ( s [ 0 ] ) ; b = Integer . parseInt ( s [ 1 ] ) ; w = tYUjIXYTDR + b ; out . append ( w ) ; System . out . println ( out . length ( ) ) ; str = br . readLine ( ) ; } } } import java . util . Scanner ; public class IvqGSHxKhu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IvqGSHxKhu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = ( IvqGSHxKhu + b ) / 2 ; String ans = " " ; if ( ( IvqGSHxKhu + b ) % 2 == 0 && Math . abs ( IvqGSHxKhu - k ) == Math . abs ( b - k ) ) { ans = String . valueOf ( k ) ; } else { ans = " IMPOSSIBLE " ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class INZttybXCP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int INZttybXCP = sc . nextInt ( ) ; int [ ] h = new int [ INZttybXCP ] ; for ( int i = 0 ; i < INZttybXCP ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int number = 0 ; int ans = 0 ; for ( int i = 0 ; i < INZttybXCP ; i ++ ) { if ( number > h [ i ] ) ans += number - h [ i ] ; number = h [ i ] ; } ans += number ; System . out . println ( ans ) ; } } import java . util . * ; public class McWyjovkVZ { 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 McWyjovkVZ = Integer . MAX_VALUE ; for ( int i = 0 ; i <= s . length ( ) - t . length ( ) ; i ++ ) { if ( McWyjovkVZ > helper ( s . substring ( i , i + t . length ( ) ) , t ) ) { McWyjovkVZ = helper ( s . substring ( i , i + t . length ( ) ) , t ) ; } } System . out . println ( McWyjovkVZ ) ; } } 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 ZsCQmsbClU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZsCQmsbClU = sc . nextInt ( ) ; int [ ] B = new int [ ZsCQmsbClU ] ; for ( int i = 1 ; i < ZsCQmsbClU ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int [ ] A = new int [ ZsCQmsbClU + 1 ] ; A [ 1 ] = B [ 1 ] ; for ( int i = 1 ; i < ZsCQmsbClU ; i ++ ) { if ( B [ i ] < A [ i ] ) { A [ i ] = B [ i ] ; } A [ i + 1 ] = B [ i ] ; } int max = 0 ; for ( int i = 1 ; i <= ZsCQmsbClU ; i ++ ) { max += A [ i ] ; } System . out . println ( max ) ; } } import java . io . * ; import java . util . * ; public class LGGMGFeZHT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Question question = new Question ( ) ; question . solve ( sc ) ; } static class LGGMGFeZHT { public void solve ( Scanner sc ) { int LGGMGFeZHT = 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 ) , LGGMGFeZHT - Math . abs ( dist ) ) ) ; } System . out . println ( LGGMGFeZHT - m ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class vwSJSAIGuh { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] Alph = new int [ 26 ] ; for ( int vwSJSAIGuh = 0 ; vwSJSAIGuh < 26 ; vwSJSAIGuh ++ ) { Alph [ vwSJSAIGuh ] = 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 gWRHZeHYwI { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int gWRHZeHYwI = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int count = 0 ; for ( int i = gWRHZeHYwI ; 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 kyGFpuKfmA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double kyGFpuKfmA = 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 ( kyGFpuKfmA , 2 ) + Math . pow ( b , 2 ) - 2 * kyGFpuKfmA * b * Math . cos ( Math . toRadians ( rad ) ) ) ; System . out . println ( len ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class YJkFIdbsAc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YJkFIdbsAc = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; HashSet < Integer > sunuke = new HashSet < > ( ) ; for ( int i = 0 ; i < YJkFIdbsAc ; 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 fuuAqmyHPL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fuuAqmyHPL = sc . nextInt ( ) ; int standard = 1 ; while ( true ) { int target = standard * 2 ; if ( target <= fuuAqmyHPL ) { standard = target ; } else { break ; } } System . out . println ( standard ) ; } } import java . lang . * ; import java . util . * ; public class iVsGQnzmaq { public static void main ( String [ ] args ) { Scanner stdId = new Scanner ( System . in ) ; int iVsGQnzmaq = stdId . nextInt ( ) ; iVsGQnzmaq = iVsGQnzmaq * iVsGQnzmaq * iVsGQnzmaq ; System . out . println ( String . valueOf ( iVsGQnzmaq ) ) ; } } import java . util . Scanner ; public class npbVHVyZnQ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String npbVHVyZnQ = scan . nextLine ( ) ; String str2 = scan . nextLine ( ) ; String c = str2 . substring ( 0 , npbVHVyZnQ . length ( ) ) ; if ( npbVHVyZnQ . equals ( c ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scan . close ( ) ; } } import java . util . Scanner ; public class OqNCvVtmrC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OqNCvVtmrC = Integer . parseInt ( sc . next ( ) ) ; int d = Integer . parseInt ( sc . next ( ) ) ; int range = 2 * d + 1 ; System . out . println ( ( OqNCvVtmrC + range - 1 ) / range ) ; System . out . flush ( ) ; sc . close ( ) ; } } import java . util . * ; public class NNZPjMnwPU { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int NNZPjMnwPU = s . lastIndexOf ( " Z " ) - s . indexOf ( " A " ) + 1 ; System . out . println ( NNZPjMnwPU ) ; } } import java . util . Scanner ; class PWMIfXPDMD { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; char [ ] S ; int PWMIfXPDMD = 0 ; S = input . next ( ) . toCharArray ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( S [ i ] == S [ i + 1 ] ) { System . out . println ( " Bad " ) ; PWMIfXPDMD ++ ; break ; } } if ( PWMIfXPDMD == 0 ) { System . out . println ( " Good " ) ; } } } import java . util . Scanner ; public class kmNeVLLJLM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kmNeVLLJLM = sc . nextInt ( ) ; int [ ] h = new int [ kmNeVLLJLM ] ; int viewableCnt = 0 ; for ( int i = 0 ; i < kmNeVLLJLM ; 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 uQyjQRoQoU { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String uQyjQRoQoU = sc . next ( ) ; if ( Character . isUpperCase ( uQyjQRoQoU . charAt ( 0 ) ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . Scanner ; public class XwtvXqlTDQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; boolean XwtvXqlTDQ = S . contains ( " A " ) ; boolean containsB = S . contains ( " B " ) ; System . out . println ( ( XwtvXqlTDQ && containsB ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class tGTNwOquqH { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; while ( true ) { int tGTNwOquqH = Integer . parseInt ( std . next ( ) ) ; if ( tGTNwOquqH == 0 ) { break ; } double [ ] score = new double [ tGTNwOquqH ] ; double ave = 0 ; for ( int i = 0 ; i < tGTNwOquqH ; i ++ ) { score [ i ] = Double . parseDouble ( std . next ( ) ) ; ave += score [ i ] ; } ave /= tGTNwOquqH ; double sd = 0 ; for ( int i = 0 ; i < tGTNwOquqH ; i ++ ) { sd += Math . pow ( ( score [ i ] - ave ) , 2 ) ; } sd /= tGTNwOquqH ; sd = Math . pow ( sd , 0.5 ) ; System . out . println ( String . format ( " %.5f " , sd ) ) ; } } } import java . io . * ; import java . util . * ; public class kdLAhKJhir { private void solve ( ) { int kdLAhKJhir = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; for ( int i = A ; i <= B ; ++ i ) { if ( i % kdLAhKJhir == 0 ) { out . println ( " OK " ) ; return ; } } out . println ( " NG " ) ; } private static PrintWriter out ; private static MyScanner sc ; private static class kdLAhKJhir { 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 ccVMjGljwy { public static void main ( String [ ] a ) { Scanner c = new Scanner ( System . in ) ; String s = c . next ( ) ; String t = c . next ( ) ; int ccVMjGljwy = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != t . charAt ( i ) ) ccVMjGljwy ++ ; } System . out . println ( ccVMjGljwy ) ; } } import java . util . Scanner ; public class EpBRNtGXWK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EpBRNtGXWK = sc . nextInt ( ) ; int [ ] result = new int [ EpBRNtGXWK ] ; for ( int i = 1 ; sc . hasNextInt ( ) ; i ++ ) { result [ sc . nextInt ( ) - 1 ] = i ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < EpBRNtGXWK ; i ++ ) { sb . append ( result [ i ] ) ; if ( i != EpBRNtGXWK ) { sb . append ( " " ) ; } else { sb . append ( " \n " ) ; } } System . out . println ( sb . toString ( ) ) ; } } import java . util . * ; public class NsmURkuHKF { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int NsmURkuHKF = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int l = scan . nextInt ( ) ; int [ ] [ ] vectorA = new int [ NsmURkuHKF ] [ m ] ; int [ ] [ ] vectorB = new int [ m ] [ l ] ; long [ ] [ ] vectorC = new long [ NsmURkuHKF ] [ l ] ; for ( int i = 0 ; i < NsmURkuHKF ; 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 < NsmURkuHKF ; 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 uYKzXnoBSX { public long getTotalHeightOfStools ( int n , int [ ] arr ) { long uYKzXnoBSX = 0 ; int prevHeight = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( prevHeight > arr [ i ] ) { uYKzXnoBSX += prevHeight - arr [ i ] ; arr [ i ] = prevHeight ; } prevHeight = arr [ i ] ; } return uYKzXnoBSX ; } 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 GSmYfkCHNZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GSmYfkCHNZ = sc . nextInt ( ) ; String [ ] a = new String [ GSmYfkCHNZ ] ; for ( int i = 0 ; i < GSmYfkCHNZ ; 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 zGgLbBXPhr { private static Scanner sc ; private static Printer pr ; private static void solve ( ) { int zGgLbBXPhr = 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 == zGgLbBXPhr ) { 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 zGgLbBXPhr extends PrintWriter { Printer ( OutputStream out ) { super ( out ) ; } } } import java . util . Scanner ; public class FNBTFPLyOB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FNBTFPLyOB = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int result = 0 ; for ( int i = 0 ; i < FNBTFPLyOB ; 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 rBdpZmfhAw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rBdpZmfhAw = scan . nextInt ( ) ; int intH = scan . nextInt ( ) ; int intX = scan . nextInt ( ) ; int intY = scan . nextInt ( ) ; int intR = scan . nextInt ( ) ; if ( intX <= rBdpZmfhAw - 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 zQXjCQrJSO { public static void main ( String [ ] args ) { int zQXjCQrJSO ; double sum = 0.0 , m , v , t = 0.0 ; Scanner sc = new Scanner ( System . in ) ; while ( true ) { zQXjCQrJSO = sc . nextInt ( ) ; if ( zQXjCQrJSO == 0 ) break ; double [ ] A = new double [ zQXjCQrJSO ] ; 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 lywLwcOlIS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > List = new ArrayList < > ( ) ; for ( int lywLwcOlIS = 0 ; lywLwcOlIS < 5 ; lywLwcOlIS ++ ) { int j = sc . nextInt ( ) ; List . add ( j ) ; } int k = sc . nextInt ( ) ; int num = 0 ; for ( int lywLwcOlIS = 0 ; lywLwcOlIS < 4 ; lywLwcOlIS ++ ) { for ( int j = lywLwcOlIS + 1 ; j < 5 ; j ++ ) { if ( List . get ( j ) - List . get ( lywLwcOlIS ) > k ) num ++ ; } } if ( num == 0 ) System . out . println ( " Yay! " ) ; else System . out . println ( " :( " ) ; } } import java . util . * ; public class bUVdzipxOL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Long > List = new ArrayList < > ( ) ; long bUVdzipxOL = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; for ( int i = 0 ; i < bUVdzipxOL ; 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 fMSASixHwl { 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 fMSASixHwl = Integer . parseInt ( st . nextToken ( ) ) + Integer . parseInt ( st . nextToken ( ) ) ; System . out . println ( ( int ) Math . log10 ( fMSASixHwl ) + 1 ) ; s = br . readLine ( ) ; } } catch ( Exception ex ) { System . exit ( 0 ) ; } } } import java . util . * ; public class VzrLxhxmUB { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int VzrLxhxmUB = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; boolean [ ] bool = new boolean [ VzrLxhxmUB + 1 ] ; for ( int i = 0 ; i <= VzrLxhxmUB ; i ++ ) { bool [ i ] = true ; } for ( int i = 0 ; i < m ; i ++ ) { bool [ scanner . nextInt ( ) ] = false ; } int [ ] b = new int [ VzrLxhxmUB + 1 ] ; b [ 0 ] = 1 ; b [ 1 ] = 1 ; int mod = 1000000007 ; for ( int i = 2 ; i <= VzrLxhxmUB ; 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 [ VzrLxhxmUB ] ) ; } } import java . util . Scanner ; public class fohqdmgWpf { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String numbers = " 1 " ; int fohqdmgWpf ; while ( true ) { numbers = scanner . nextLine ( ) ; if ( numbers . equals ( " 0 " ) ) break ; fohqdmgWpf = 0 ; for ( int i = 0 ; i < numbers . length ( ) ; ++ i ) { fohqdmgWpf += Character . getNumericValue ( numbers . charAt ( i ) ) ; } System . out . println ( fohqdmgWpf ) ; } } } import java . util . * ; public class LwrKwdgLfr { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long LwrKwdgLfr = in . nextLong ( ) , c = 0 , s = 0 ; long k = in . nextLong ( ) ; long [ ] arr = new long [ ( int ) LwrKwdgLfr ] ; for ( int i = 0 ; i < LwrKwdgLfr ; i ++ ) { arr [ i ] = in . nextInt ( ) ; s = s + arr [ i ] ; } if ( k >= LwrKwdgLfr ) { System . out . println ( " 0 " ) ; System . exit ( 0 ) ; } Arrays . sort ( arr ) ; long mid = LwrKwdgLfr - 1 ; while ( c != k ) { s = s - arr [ ( int ) mid ] ; mid -- ; c ++ ; } System . out . println ( s ) ; } } import java . util . * ; public class CkZtWPwBOM { public static void main ( String [ ] args ) { PriorityQueue < String > caca = new PriorityQueue < String > ( ) ; Scanner scn = new Scanner ( System . in ) ; int CkZtWPwBOM = scn . nextInt ( ) ; int n2 = scn . nextInt ( ) ; for ( int i = 0 ; i < CkZtWPwBOM ; i ++ ) caca . add ( scn . next ( ) ) ; for ( int i = 0 ; i < CkZtWPwBOM ; 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 RpJyQdctnw { public static void main ( String [ ] args ) throws Exception { Scanner fr = new Scanner ( System . in ) ; int RpJyQdctnw = fr . nextInt ( ) ; int x = fr . nextInt ( ) ; int xx = x ; int t = fr . nextInt ( ) ; int tt = t ; if ( RpJyQdctnw < x ) { System . out . println ( t ) ; } else { while ( x < RpJyQdctnw ) { x += xx ; t += tt ; } System . out . println ( t ) ; } } } import java . util . Scanner ; public class hrGOdubPMF { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int hrGOdubPMF = Integer . parseInt ( scanner . next ( ) ) ; int s = Integer . parseInt ( scanner . next ( ) ) ; if ( hrGOdubPMF < 10 && s < 10 ) { System . out . println ( hrGOdubPMF * s ) ; } else { System . out . println ( - 1 ) ; } scanner . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class RbJHjPWDwa { public static void main ( String [ ] args ) throws IOException { BufferedReader bis = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = bis . readLine ( ) ; int RbJHjPWDwa = s . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < RbJHjPWDwa ; 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 nNaejhUgRG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nNaejhUgRG = sc . nextInt ( ) , a = sc . nextInt ( ) ; if ( nNaejhUgRG % a == 0 ) System . out . println ( nNaejhUgRG / a ) ; else System . out . println ( nNaejhUgRG / a + 1 ) ; } } import java . util . * ; public class seTWhREmZm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int seTWhREmZm = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int ans = 0 ; int b = K - seTWhREmZm ; int c = K - seTWhREmZm - B ; if ( seTWhREmZm == 0 && C == 0 ) { System . out . println ( " 0 " ) ; } else if ( K >= seTWhREmZm && c < 1 ) { System . out . println ( seTWhREmZm ) ; } else if ( K >= seTWhREmZm && c >= 1 ) { System . out . println ( seTWhREmZm + ( c * - 1 ) ) ; } else if ( K < seTWhREmZm ) { System . out . println ( K ) ; } } } import java . util . Scanner ; public class UhqhSLSeFs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UhqhSLSeFs = sc . nextInt ( ) ; int [ ] a = new int [ UhqhSLSeFs ] ; 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 fwVHeFtGXk { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int fwVHeFtGXk = sc . nextInt ( ) ; int [ ] d = new int [ 100001 ] ; for ( int i = 0 ; i < fwVHeFtGXk ; i ++ ) { d [ sc . nextInt ( ) ] ++ ; } int tmp = 0 ; int cnt = 0 ; for ( int i = 0 ; i < 100001 ; i ++ ) { tmp += d [ i ] ; if ( fwVHeFtGXk == tmp * 2 ) { cnt ++ ; } else if ( fwVHeFtGXk < tmp * 2 ) { break ; } } System . out . println ( cnt ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class AeiXlOnQXu { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] best = { 0 , 0 , 0 } ; for ( int AeiXlOnQXu = 0 ; AeiXlOnQXu < 10 ; AeiXlOnQXu ++ ) { 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 rtANQIpaAc { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int rtANQIpaAc = in . nextInt ( ) ; String [ ] array = new String [ rtANQIpaAc ] ; for ( int i = 0 ; i < rtANQIpaAc ; 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 < rtANQIpaAc ; 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 ZNDGqlNwPG { private static int prime ( int a ) { if ( a == 2 || a == 3 ) return 1 ; for ( int ZNDGqlNwPG = 2 ; ZNDGqlNwPG < Math . sqrt ( a ) + 1 ; ZNDGqlNwPG ++ ) { if ( a % ZNDGqlNwPG == 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 CmCQLfweIi { public static long gcd ( long a , long b ) { while ( a % b != 0 ) { long CmCQLfweIi = a % b ; a = b ; b = CmCQLfweIi ; } 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 qkFsMgGzDV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qkFsMgGzDV = sc . nextInt ( ) ; int result = 0 ; for ( int i = 1 ; i <= qkFsMgGzDV ; 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 anTDfLGADT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int anTDfLGADT = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = Integer . parseInt ( anTDfLGADT + " " + 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 rOHJKnvKQf { public static void main ( String [ ] args ) { Scanner Ent = new Scanner ( System . in ) ; int rOHJKnvKQf = Ent . nextInt ( ) ; int Q = Ent . nextInt ( ) ; int R = Ent . nextInt ( ) ; int res1 = rOHJKnvKQf + Q ; int res2 = R + Q ; int res3 = R + rOHJKnvKQf ; System . out . println ( Math . min ( res1 , Math . min ( res2 , res3 ) ) ) ; } } import java . util . Scanner ; public class nmzDIhwKuT { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int nmzDIhwKuT = scan . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= nmzDIhwKuT ; i ++ ) { String mozi = String . valueOf ( i ) ; if ( mozi . length ( ) % 2 == 1 ) { count ++ ; } } System . out . println ( count ) ; scan . close ( ) ; } } import java . util . * ; public class JjRLuHZZBN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JjRLuHZZBN = sc . nextInt ( ) ; Integer [ ] list = new Integer [ JjRLuHZZBN ] ; for ( int i = 0 ; i < JjRLuHZZBN ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } Integer [ ] sorted = Arrays . copyOf ( list , JjRLuHZZBN ) ; Arrays . sort ( sorted ) ; String ans = " YES " ; int count = 0 ; for ( int i = 0 ; i < JjRLuHZZBN ; 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 tTvISfLOTj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tTvISfLOTj = Integer . parseInt ( scan . next ( ) ) ; int m = Integer . parseInt ( scan . next ( ) ) ; Integer [ ] a = new Integer [ tTvISfLOTj ] ; for ( int i = 0 ; i < tTvISfLOTj ; 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 UQZNpGymtJ { private static int gcd ( int UQZNpGymtJ , int b ) { if ( ( UQZNpGymtJ % b ) == 0 ) return b ; return gcd ( b , UQZNpGymtJ % b ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UQZNpGymtJ = sc . nextInt ( ) ; int tmp ; int count = 0 ; for ( int i = 1 ; i < UQZNpGymtJ + 1 ; i ++ ) { for ( int j = 1 ; j < UQZNpGymtJ + 1 ; j ++ ) { tmp = gcd ( i , j ) ; for ( int k = 1 ; k < UQZNpGymtJ + 1 ; k ++ ) { count += gcd ( k , tmp ) ; } } } System . out . println ( count ) ; } } import java . util . * ; public class UkaedLvbbM { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int UkaedLvbbM = scanner . nextInt ( ) ; String s = scanner . next ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { System . out . print ( ( char ) ( ( s . charAt ( i ) - 'A' + UkaedLvbbM ) % 26 + 'A' ) ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class qetJXoCnTb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qetJXoCnTb = sc . nextInt ( ) ; int hp = 0 ; List < Integer > takoyaki = new ArrayList < Integer > ( ) ; takoyaki . add ( sc . nextInt ( ) ) ; for ( int i = 1 ; i < qetJXoCnTb ; 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 tsDwCmHXPW { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] ab = scanner . nextLine ( ) . split ( " " , 2 ) ; int tsDwCmHXPW = Integer . parseInt ( ab [ 0 ] ) ; int b = Integer . parseInt ( ab [ 1 ] ) ; String s = scanner . nextLine ( ) ; if ( tsDwCmHXPW + b + 1 != s . length ( ) ) { System . out . println ( " No " ) ; return ; } for ( int i = 0 ; i <= tsDwCmHXPW + b ; i ++ ) { char ch = s . charAt ( i ) ; if ( i == tsDwCmHXPW ) { 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 FjxkBhnKZI { static boolean FjxkBhnKZI = 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 RHmnGIFUxf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RHmnGIFUxf = sc . nextInt ( ) ; int sp = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int [ ] point = new int [ RHmnGIFUxf ] ; 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 xQbivyZkkT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int xQbivyZkkT = s . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < xQbivyZkkT ; i ++ ) { for ( int j = i + 1 ; j <= xQbivyZkkT ; 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 nfUAxUcvbm { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { int nfUAxUcvbm = Integer . parseInt ( reader . readLine ( ) ) ; int n = Integer . parseInt ( reader . readLine ( ) ) ; int [ ] x = new int [ nfUAxUcvbm ] ; for ( int i = 0 ; i < nfUAxUcvbm ; 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 < nfUAxUcvbm ; i ++ ) { System . out . println ( x [ i ] ) ; } } catch ( IOException e ) { } } } import java . util . * ; public class NDAtGocCFt { static long NDAtGocCFt = 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 LWDmYfrQnk { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; char [ ] s = in . next ( ) . toCharArray ( ) ; boolean LWDmYfrQnk = false ; boolean B = false ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == 'A' ) LWDmYfrQnk = true ; if ( s [ i ] == 'B' ) B = true ; } if ( LWDmYfrQnk && B ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class WCLDMmiNZa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WCLDMmiNZa = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] tmp = s . toCharArray ( ) ; for ( int i = 0 ; i < tmp . length ; i ++ ) { int j = WCLDMmiNZa ; 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 kzMlOojzff { long kzMlOojzff = 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 jmkJoWzYHs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jmkJoWzYHs = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( method ( jmkJoWzYHs , b , c ) ) ; } static int method ( int jmkJoWzYHs , int b , int c ) { int divisor = 0 ; for ( int i = jmkJoWzYHs ; i < b + 1 ; i ++ ) { if ( c % i == 0 ) { divisor ++ ; } } return divisor ; } } import java . util . Scanner ; public class EsOiPEVgnS { public static void main ( String [ ] args ) { Main2 cc = new Main2 ( ) ; cc . yesNo ( ) ; } } class EsOiPEVgnS { public void yesNo ( ) { Scanner scan = new Scanner ( System . in ) ; int [ ] abc = new int [ 3 ] ; for ( int EsOiPEVgnS = 0 ; EsOiPEVgnS < 3 ; EsOiPEVgnS ++ ) { abc [ EsOiPEVgnS ] = 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 LVmSwhucQJ { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int [ ] arr = new int [ 3 ] ; for ( int LVmSwhucQJ = 0 ; LVmSwhucQJ < 3 ; LVmSwhucQJ ++ ) { arr [ LVmSwhucQJ ] = 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 eTnhbxwOvN { 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 eTnhbxwOvN = readInt ( ) ; long D = readInt ( ) ; long D_squared = D * D ; int count = 0 ; for ( int i = 0 ; i < eTnhbxwOvN ; i ++ ) { long dx = readInt ( ) ; long dy = readInt ( ) ; if ( dx * dx + dy * dy <= D_squared ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class lofEEjBMLx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lofEEjBMLx = sc . nextInt ( ) ; String [ ] a = new String [ lofEEjBMLx ] ; for ( int i = 0 ; i < lofEEjBMLx ; i ++ ) { a [ i ] = sc . next ( ) ; } sc . close ( ) ; Arrays . sort ( a ) ; int yono = 1 ; for ( int i = 1 ; i < lofEEjBMLx ; i ++ ) { if ( ! a [ i - 1 ] . equals ( a [ i ] ) ) yono ++ ; } System . out . println ( yono ) ; } } import java . util . Scanner ; public class jSwYQQOcPQ { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int jSwYQQOcPQ = 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 == jSwYQQOcPQ ? " " : s . substring ( k ) ) ; System . out . println ( pre + conv + next ) ; } } import java . util . * ; class PxzZzVyuOk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PxzZzVyuOk = sc . nextInt ( ) ; int [ ] a = new int [ PxzZzVyuOk + 1 ] ; int [ ] w = new int [ PxzZzVyuOk + 1 ] ; int [ ] s = new int [ PxzZzVyuOk + 1 ] ; int [ ] indice = new int [ PxzZzVyuOk ] ; a [ 0 ] = 0 ; for ( int i = 1 ; i <= PxzZzVyuOk ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int nr_breaks = 0 ; int cur = 1 ; for ( int i = 1 ; i <= PxzZzVyuOk ; i ++ ) { if ( a [ i ] == cur ) { cur ++ ; } else { nr_breaks ++ ; } } if ( nr_breaks == PxzZzVyuOk ) { System . out . println ( - 1 ) ; } else { System . out . println ( nr_breaks ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class SDaPLkzKjb { 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 SDaPLkzKjb , b , t , gdc ; long lcm ; StringBuilder result = new StringBuilder ( ) ; while ( true ) { if ( ( ( line = br . readLine ( ) ) == null ) || line . isEmpty ( ) ) break ; num = line . split ( " " ) ; SDaPLkzKjb = Integer . parseInt ( num [ 0 ] ) ; b = Integer . parseInt ( num [ 1 ] ) ; if ( SDaPLkzKjb < b ) { t = SDaPLkzKjb ; SDaPLkzKjb = b ; b = t ; } gdc = gdc ( SDaPLkzKjb , b ) ; lcm = lcm ( SDaPLkzKjb , 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 ejNjozLcha { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ejNjozLcha = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= ejNjozLcha ; 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 DiowCcOIRJ { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; String ans = " " ; for ( int DiowCcOIRJ = 0 ; DiowCcOIRJ < line . length ( ) ; DiowCcOIRJ ++ ) { String str = line . substring ( DiowCcOIRJ , DiowCcOIRJ + 1 ) ; if ( str . equals ( str . toUpperCase ( ) ) ) { ans += str . toLowerCase ( ) ; } else { ans += str . toUpperCase ( ) ; } } System . out . println ( ans ) ; } } import java . util . * ; public class SwtuBlqCPF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String o = " " ; long SwtuBlqCPF = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; k = k - SwtuBlqCPF ; SwtuBlqCPF = Math . max ( - k , 0 ) ; if ( k > 0 ) b = Math . max ( b - k , 0 ) ; o = Long . toString ( SwtuBlqCPF , 10 ) + " " + Long . toString ( b , 10 ) ; System . out . println ( o ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class ptLBQcgpfO { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int ptLBQcgpfO , b ; ArrayList < String > str = new ArrayList < String > ( ) ; String [ ] result ; while ( s . hasNext ( ) ) { ptLBQcgpfO = s . nextInt ( ) ; b = s . nextInt ( ) ; System . out . println ( String . valueOf ( ptLBQcgpfO + b ) . length ( ) ) ; } } } import java . util . ArrayList ; import java . util . Comparator ; import java . util . List ; import java . util . Scanner ; class IAuafTvSYJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IAuafTvSYJ = Integer . parseInt ( sc . next ( ) ) ; List < Integer > numList = new ArrayList < > ( ) ; for ( int i = 0 ; i < IAuafTvSYJ ; 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 JAajohoFlj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JAajohoFlj = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; sc . close ( ) ; int result = JAajohoFlj * b ; System . out . println ( result ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class GVUQmbsGmD { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int GVUQmbsGmD = stdIn . nextInt ( ) ; int [ ] a = new int [ GVUQmbsGmD ] ; int [ ] b = new int [ GVUQmbsGmD ] ; int high = 0 ; for ( int i = 0 ; i < GVUQmbsGmD ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; b [ i ] = a [ i ] ; high = Math . max ( high , a [ i ] ) ; } Arrays . sort ( b ) ; for ( int i = 0 ; i < GVUQmbsGmD ; i ++ ) { if ( a [ i ] != high ) { System . out . println ( high ) ; } else { System . out . println ( b [ GVUQmbsGmD - 2 ] ) ; } } } } import java . util . Scanner ; public class GjutRfHEsi { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int GjutRfHEsi = sc . nextInt ( ) ; for ( int i = GjutRfHEsi ; 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 gXluZbKWbw { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int gXluZbKWbw = Integer . parseInt ( sc . nextLine ( ) ) ; int counter = 0 ; int [ ] [ ] result = new int [ gXluZbKWbw ] [ 2 ] ; for ( int i = 0 ; i < gXluZbKWbw ; i ++ ) { result [ i ] [ 0 ] = sc . nextInt ( ) ; result [ i ] [ 1 ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < gXluZbKWbw ; 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 iscjcKCWRE { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int iscjcKCWRE = scan . nextInt ( ) ; int S = scan . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i <= iscjcKCWRE ; i ++ ) { for ( int j = 0 ; j <= iscjcKCWRE ; j ++ ) { if ( S - i - j >= 0 && S - i - j <= iscjcKCWRE ) 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 RVzzyLyvsB { static Scanner scn = new Scanner ( System . in ) ; static long RVzzyLyvsB = 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 ) { RVzzyLyvsB ++ ; 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 MgzpLvRmbj { 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 MgzpLvRmbj = Integer . parseInt ( tmpArray [ 0 ] ) ; int b = Integer . parseInt ( tmpArray [ 1 ] ) ; if ( MgzpLvRmbj == 0 && b == 0 ) { break ; } for ( int i = 0 ; i < MgzpLvRmbj ; i ++ ) { for ( int j = 0 ; j < b ; j ++ ) { if ( i != 0 && i != MgzpLvRmbj - 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 GZdhjgSKIg { 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 GZdhjgSKIg = 0 ; boolean doContinue = true ; for ( int i = 0 ; doContinue ; i ++ ) { if ( s % 2 == 0 ) { if ( list . contains ( s / 2 ) ) { GZdhjgSKIg = i + 2 ; doContinue = false ; } else { s = s / 2 ; list . add ( s ) ; } } else { if ( list . contains ( 3 * s + 1 ) ) { GZdhjgSKIg = i + 2 ; doContinue = false ; } else { s = 3 * s + 1 ; list . add ( s ) ; } } } System . out . println ( GZdhjgSKIg ) ; sc . close ( ) ; } } import java . util . Scanner ; public class jlBCdpJSHQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jlBCdpJSHQ = Integer . parseInt ( sc . next ( ) ) ; int D = Integer . parseInt ( sc . next ( ) ) ; int [ ] [ ] arrayTwoDimension = new int [ jlBCdpJSHQ ] [ D ] ; for ( int i = 0 ; i < jlBCdpJSHQ ; i ++ ) { for ( int j = 0 ; j < D ; j ++ ) { arrayTwoDimension [ i ] [ j ] = sc . nextInt ( ) ; } } sc . close ( ) ; int count = 0 ; for ( int i = 0 ; i < jlBCdpJSHQ ; i ++ ) { for ( int j = i + 1 ; j < jlBCdpJSHQ ; 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 oVHcyJcprI { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String input = stdIn . nextLine ( ) ; String [ ] a = input . split ( " " ) ; int oVHcyJcprI = Integer . parseInt ( a [ 0 ] ) ; int y = Integer . parseInt ( a [ 1 ] ) ; if ( oVHcyJcprI > 0 && oVHcyJcprI < 101 && y > 0 && y < 101 ) { int ans = y - oVHcyJcprI * 2 ; if ( ans == 0 ) { System . out . println ( " Yes " ) ; } else if ( ans > 0 && ( ans % 2 ) == 0 ) { for ( int i = 0 ; i < oVHcyJcprI ; 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 wjJETAXVwV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wjJETAXVwV = 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 < wjJETAXVwV ; 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 GuizGieBoQ { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int GuizGieBoQ = scanner . nextInt ( ) ; String N = scanner . next ( ) ; if ( N . length ( ) <= GuizGieBoQ ) { System . out . println ( N ) ; } else { System . out . println ( N . substring ( 0 , GuizGieBoQ ) + " ... " ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class PZthwmYyik { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PZthwmYyik = Integer . parseInt ( sc . next ( ) ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Math . min ( PZthwmYyik * a , b ) ; System . out . println ( c ) ; } } import java . util . * ; public class igidmJISXE { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int igidmJISXE = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = igidmJISXE * a ; if ( ans >= b ) { ans = b ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class kQqlxADiox { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int kQqlxADiox = reader . nextInt ( ) ; int [ ] arr = new int [ kQqlxADiox ] ; int a = 0 ; int b = 0 ; for ( int i = 0 ; i < kQqlxADiox ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; } Arrays . sort ( arr ) ; for ( int i = kQqlxADiox - 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 ymgLmaicGu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ymgLmaicGu = 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 ( ymgLmaicGu + b , c * 2 ) ; x -= xymin ; y -= xymin ; if ( x == 0 ) { ans += y * Math . min ( b , c * 2 ) ; } else { ans += x * Math . min ( ymgLmaicGu , c * 2 ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class qsOXZqTGii { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qsOXZqTGii = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = qsOXZqTGii * ( qsOXZqTGii - 1 ) / 2 ; int d = b * ( b - 1 ) / 2 ; System . out . println ( c + d ) ; } } import java . util . Scanner ; class RERRqGbLyC { public static void main ( String [ ] arg ) { Scanner in = new Scanner ( System . in ) ; String input = in . nextLine ( ) ; while ( ! input . equals ( " - " ) ) { String tmp = in . nextLine ( ) ; int RERRqGbLyC = Integer . parseInt ( tmp ) ; StringBuffer sb = new StringBuffer ( input ) ; for ( int i = 0 ; i < RERRqGbLyC ; 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 EzbqGdDQdL { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int EzbqGdDQdL = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; int [ ] cnts = new int [ M ] ; for ( int i = 0 ; i < EzbqGdDQdL ; 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 ] == EzbqGdDQdL ) { cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class sKZCMeLzcB { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int sKZCMeLzcB = scanner . nextInt ( ) ; if ( sKZCMeLzcB < 105 ) { sKZCMeLzcB = 0 ; } else if ( sKZCMeLzcB < 135 ) { sKZCMeLzcB = 1 ; } else if ( sKZCMeLzcB < 165 ) { sKZCMeLzcB = 2 ; } else if ( sKZCMeLzcB < 189 ) { sKZCMeLzcB = 3 ; } else if ( sKZCMeLzcB < 195 ) { sKZCMeLzcB = 4 ; } else { sKZCMeLzcB = 5 ; } System . out . println ( sKZCMeLzcB ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class KHOjOJclce { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KHOjOJclce = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int [ ] times = new int [ 3 ] ; times [ 0 ] = KHOjOJclce + q ; times [ 1 ] = q + r ; times [ 2 ] = r + KHOjOJclce ; 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 nTbUdTUsds { public static void main ( String [ ] args ) { Scanner s1 = new Scanner ( System . in ) ; int nTbUdTUsds = s1 . nextInt ( ) ; int A = s1 . nextInt ( ) ; int B = s1 . nextInt ( ) ; for ( int i = A ; i <= B ; i ++ ) { if ( i % nTbUdTUsds == 0 ) { System . out . println ( " OK " ) ; return ; } } System . out . println ( " NG " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class QiOXRJASHK { 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 QiOXRJASHK = 0 ; QiOXRJASHK < table . length ; QiOXRJASHK ++ ) { table [ QiOXRJASHK ] = key . length ( ) ; } for ( int QiOXRJASHK = 0 ; QiOXRJASHK < key . length ( ) ; QiOXRJASHK ++ ) { table [ key . charAt ( QiOXRJASHK ) ] = key . length ( ) - QiOXRJASHK - 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 rAFhkjMEGZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rAFhkjMEGZ = sc . nextInt ( ) ; int [ ] a = new int [ rAFhkjMEGZ ] ; for ( int i = 0 ; i < rAFhkjMEGZ ; i ++ ) { a [ i ] = sc . nextInt ( ) - 1 ; } int x = 0 ; int c = 0 ; for ( int i = 0 ; i < rAFhkjMEGZ ; i ++ ) { c ++ ; x = a [ x ] ; if ( x == 1 ) { System . out . println ( c ) ; return ; } } System . out . println ( " -1 " ) ; } } import java . util . Scanner ; class ZGcjnJnNnU { 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 wZeOJPpQxJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] num = new int [ 3000 ] ; int [ ] num2 = new int [ 3000 ] ; for ( int wZeOJPpQxJ = 0 ; wZeOJPpQxJ < 3000 ; wZeOJPpQxJ ++ ) { String line = sc . nextLine ( ) ; String [ ] ss = line . split ( " " ) ; num [ wZeOJPpQxJ ] = Integer . parseInt ( ss [ 0 ] ) ; num2 [ wZeOJPpQxJ ] = Integer . parseInt ( ss [ 1 ] ) ; if ( num [ wZeOJPpQxJ ] == 0 && num2 [ wZeOJPpQxJ ] == 0 ) { break ; } } for ( int wZeOJPpQxJ = 0 ; wZeOJPpQxJ < num . length ; wZeOJPpQxJ ++ ) { if ( num [ wZeOJPpQxJ ] == 0 && num2 [ wZeOJPpQxJ ] == 0 ) { break ; } if ( num [ wZeOJPpQxJ ] < num2 [ wZeOJPpQxJ ] ) { System . out . println ( num [ wZeOJPpQxJ ] + " " + num2 [ wZeOJPpQxJ ] ) ; } if ( num [ wZeOJPpQxJ ] > num2 [ wZeOJPpQxJ ] ) { System . out . println ( num2 [ wZeOJPpQxJ ] + " " + num [ wZeOJPpQxJ ] ) ; } if ( num [ wZeOJPpQxJ ] == num2 [ wZeOJPpQxJ ] ) { System . out . println ( num [ wZeOJPpQxJ ] + " " + num2 [ wZeOJPpQxJ ] ) ; } } } } import java . util . * ; public class OvvHboPKHb { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " Yes " ; for ( int OvvHboPKHb = 0 ; OvvHboPKHb < s . length ( ) ; OvvHboPKHb ++ ) { if ( OvvHboPKHb % 2 == 0 && s . charAt ( OvvHboPKHb ) == 'L' ) { ans = " No " ; break ; } else if ( OvvHboPKHb % 2 == 1 && s . charAt ( OvvHboPKHb ) == 'R' ) { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; class UuZdnDvpEu { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int UuZdnDvpEu = scanner . nextInt ( ) ; int t = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; System . out . print ( t * s >= UuZdnDvpEu ? " Yes " : " No " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class FckqdgmGRi { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int FckqdgmGRi = s . nextInt ( ) ; int b = s . nextInt ( ) ; int c = s . nextInt ( ) ; int d = s . nextInt ( ) ; int ans1 = 0 , ans2 = 0 ; if ( FckqdgmGRi % d == 0 ) { ans1 = FckqdgmGRi / d ; } else { ans1 = FckqdgmGRi / 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 PwKHEBFsAU { public static void main ( String [ ] args ) { int PwKHEBFsAU = 0 ; int x = 0 ; Scanner scan = new Scanner ( System . in ) ; PwKHEBFsAU = scan . nextInt ( ) ; for ( int i = 1 ; i != PwKHEBFsAU + 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 kCgJwgVCPO { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int kCgJwgVCPO = s . nextInt ( ) ; String a = s . next ( ) , b = s . next ( ) ; char [ ] c = new char [ kCgJwgVCPO * 2 ] ; for ( int i = 0 ; i < kCgJwgVCPO ; ++ 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 tZKxWcjecs { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long tZKxWcjecs = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long ans = a * ( tZKxWcjecs / ( a + b ) ) ; tZKxWcjecs %= ( a + b ) ; if ( tZKxWcjecs >= a ) { System . out . println ( ans + a ) ; } else { System . out . println ( ans + tZKxWcjecs ) ; } } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class fWOqpgSmjJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fWOqpgSmjJ = sc . nextInt ( ) ; Integer [ ] arrays = new Integer [ fWOqpgSmjJ ] ; 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 GwnBBKCEAg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GwnBBKCEAg = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( solve ( GwnBBKCEAg , B ) ) ; sc . close ( ) ; } static int solve ( int GwnBBKCEAg , int B ) { if ( GwnBBKCEAg >= 13 ) { return B ; } else if ( GwnBBKCEAg >= 6 ) { return B / 2 ; } else { return 0 ; } } } import java . util . * ; public class OgKXHQEmKq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OgKXHQEmKq = sc . nextInt ( ) ; int [ ] arr = new int [ OgKXHQEmKq ] ; for ( int i = 0 ; i < OgKXHQEmKq ; 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 BZbrFnWHap { 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 BZbrFnWHap = 0 ; for ( int i = 0 ; i < str_split . length ; i ++ ) { switch ( str_split [ i ] . charAt ( 0 ) ) { case '+' : BZbrFnWHap -- ; nums [ BZbrFnWHap - 1 ] = nums [ BZbrFnWHap - 1 ] + nums [ BZbrFnWHap ] ; break ; case '-' : BZbrFnWHap -- ; nums [ BZbrFnWHap - 1 ] = nums [ BZbrFnWHap - 1 ] - nums [ BZbrFnWHap ] ; break ; case '*' : BZbrFnWHap -- ; nums [ BZbrFnWHap - 1 ] = nums [ BZbrFnWHap - 1 ] * nums [ BZbrFnWHap ] ; break ; default : nums [ BZbrFnWHap ] = Integer . parseInt ( str_split [ i ] ) ; BZbrFnWHap ++ ; break ; } } System . out . println ( nums [ 0 ] ) ; } } import java . util . Scanner ; public class IwvWzPZpoo { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long IwvWzPZpoo , 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 bOBanrnOoY { 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 bOBanrnOoY = Integer . parseInt ( input [ 0 ] ) ; int a = Integer . parseInt ( input [ 1 ] ) ; int b = Integer . parseInt ( input [ 2 ] ) ; int ans = 0 ; for ( int i = 1 ; i <= bOBanrnOoY ; 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 lrAlQOADfO { 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 lrAlQOADfO = 0 ; lrAlQOADfO < s . length ; lrAlQOADfO ++ ) { if ( n == s . length ) { System . out . println ( " No " ) ; break ; } else if ( s [ lrAlQOADfO + n >= s . length ? lrAlQOADfO + n - s . length : lrAlQOADfO + n ] != p [ lrAlQOADfO ] ) { n ++ ; func ( s , p , n ) ; break ; } else if ( lrAlQOADfO == p . length - 1 ) { System . out . println ( " Yes " ) ; break ; } } } } import java . util . * ; public class ijyvRNGXXF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ijyvRNGXXF = sc . nextInt ( ) ; long [ ] b = new long [ ijyvRNGXXF ] ; long MAX = ( long ) Math . pow ( 10 , 18 ) ; long result = 1 ; for ( int i = 0 ; i < ijyvRNGXXF ; i ++ ) { b [ i ] = sc . nextLong ( ) ; if ( b [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } for ( int i = 0 ; i < ijyvRNGXXF ; 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 rrdIXBiJpG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rrdIXBiJpG = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; Integer [ ] button = { rrdIXBiJpG , b , rrdIXBiJpG - 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 gPpzoqwHqY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( new BufferedInputStream ( System . in ) ) ; int gPpzoqwHqY = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( gPpzoqwHqY + 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 HtIPheHFMN { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int HtIPheHFMN = in . nextInt ( ) ; int B = in . nextInt ( ) ; String S = in . next ( ) ; char [ ] s_chars = S . toCharArray ( ) ; int flag = 0 ; if ( s_chars [ HtIPheHFMN ] == '-' ) { for ( int i = 0 ; i < HtIPheHFMN + 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 jQkUKrEnPD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double jQkUKrEnPD = sc . nextDouble ( ) ; double H = sc . nextDouble ( ) ; double x = sc . nextDouble ( ) ; double y = sc . nextDouble ( ) ; System . out . printf ( " %.6f " , jQkUKrEnPD * H / 2 ) ; if ( x == jQkUKrEnPD / 2 && y == H / 2 ) { System . out . println ( 1 ) ; } else { System . out . println ( 0 ) ; } } } import java . util . * ; class jipUhcVWDR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String jipUhcVWDR = sc . next ( ) ; jipUhcVWDR = jipUhcVWDR . replace ( " 1 " , " * " ) . replace ( " 9 " , " 1 " ) . replace ( " * " , " 9 " ) ; System . out . println ( jipUhcVWDR ) ; } } import java . util . Scanner ; public class odNurOZNOQ { public static void main ( String ... args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int odNurOZNOQ = 0 ; String [ ] s = sc . next ( ) . split ( " " ) ; for ( String i : s ) { if ( i . equals ( " + " ) ) { odNurOZNOQ ++ ; } else { odNurOZNOQ -- ; } } System . out . println ( odNurOZNOQ ) ; } } } import java . math . BigDecimal ; import java . math . RoundingMode ; import java . util . HashMap ; import java . util . Scanner ; public class svKfkmDIBH { 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 OmZjxYonvt { public static void main ( String [ ] args ) { solve ( ) ; } public static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int OmZjxYonvt = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] ans = new int [ OmZjxYonvt ] ; 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 < OmZjxYonvt ; i ++ ) { out . println ( ans [ i ] ) ; } out . flush ( ) ; } static class OmZjxYonvt { 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 hfYxgwxfmw { 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 hfYxgwxfmw { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String x = in . next ( ) ; for ( int hfYxgwxfmw = 0 ; hfYxgwxfmw < 3 ; hfYxgwxfmw ++ ) { if ( x . charAt ( hfYxgwxfmw ) != x . charAt ( ( hfYxgwxfmw + 1 ) % 3 ) ) { out . println ( " Yes " ) ; return ; } } out . println ( " No " ) ; } } static class hfYxgwxfmw { 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 KjlSSTgfaL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String KjlSSTgfaL = sc . next ( ) ; if ( KjlSSTgfaL . equals ( " MON " ) ) { System . out . println ( 6 ) ; } else if ( KjlSSTgfaL . equals ( " TUE " ) ) { System . out . println ( 5 ) ; } else if ( KjlSSTgfaL . equals ( " WED " ) ) { System . out . println ( 4 ) ; } else if ( KjlSSTgfaL . equals ( " THU " ) ) { System . out . println ( 3 ) ; } else if ( KjlSSTgfaL . equals ( " FRI " ) ) { System . out . println ( 2 ) ; } else if ( KjlSSTgfaL . equals ( " SAT " ) ) { System . out . println ( 1 ) ; } else if ( KjlSSTgfaL . equals ( " SUN " ) ) { System . out . println ( 7 ) ; } } } import java . util . * ; public class cDDyAhSeQK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cDDyAhSeQK = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; int min = 300 , total = 0 ; for ( int i = 1 ; i <= cDDyAhSeQK ; i ++ ) { total += L + i - 1 ; } if ( L >= 0 ) { System . out . println ( total - L ) ; } else if ( L < 0 ) { if ( L + cDDyAhSeQK > 0 ) { System . out . println ( total ) ; } else { System . out . println ( total - ( L + cDDyAhSeQK - 1 ) ) ; } } } } import java . io . * ; import java . util . * ; import java . lang . * ; class sQJIekmNnj { 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 sQJIekmNnj = 'a' ; sQJIekmNnj <= 'z' ; sQJIekmNnj ++ ) { int count = 0 ; for ( int j = 0 ; j < input . length ( ) ; j ++ ) { if ( input . toString ( ) . charAt ( j ) == sQJIekmNnj || Character . toUpperCase ( input . toString ( ) . charAt ( j ) ) == Character . toUpperCase ( sQJIekmNnj ) ) { count ++ ; } } System . out . println ( sQJIekmNnj + " : " + count ) ; } } } import java . util . * ; public class vGfneqrSAb { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int vGfneqrSAb = Integer . MAX_VALUE ; int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < 5 ; i ++ ) { int n = sc . nextInt ( ) ; vGfneqrSAb = Math . vGfneqrSAb ( vGfneqrSAb , n ) ; max = Math . max ( max , n ) ; } int k = sc . nextInt ( ) ; if ( max - vGfneqrSAb > k ) System . out . println ( " :( " ) ; else System . out . println ( " Yay! " ) ; } } import java . util . * ; class LbdByJRpDJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long LbdByJRpDJ = sc . nextInt ( ) ; long quo = LbdByJRpDJ / 15 ; long rem = LbdByJRpDJ % 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 zRBgYhWyuh { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { while ( sc . hasNext ( ) ) { int zRBgYhWyuh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . println ( digit ( zRBgYhWyuh , b ) ) ; } } private static int digit ( int zRBgYhWyuh , int b ) { int dg = Integer . toString ( zRBgYhWyuh + b ) . length ( ) ; return dg ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class PpDNTvVcwu { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = reader . readLine ( ) . split ( " " ) ; int PpDNTvVcwu = Integer . parseInt ( str [ 0 ] ) ; int B = Integer . parseInt ( str [ 1 ] ) ; if ( 1 <= PpDNTvVcwu && PpDNTvVcwu <= 9 && 1 <= B && B <= 9 ) { System . out . println ( PpDNTvVcwu * B ) ; } else { System . out . println ( " -1 " ) ; } } } import java . util . Scanner ; public class yKeazLhKxf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yKeazLhKxf = sc . nextInt ( ) ; int [ ] a = new int [ yKeazLhKxf ] ; for ( int i = 0 ; i < yKeazLhKxf ; 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 qjiLnTwIJS { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qjiLnTwIJS = scan . nextInt ( ) ; int money = scan . nextInt ( ) ; if ( qjiLnTwIJS >= 13 ) { System . out . print ( money ) ; } else if ( qjiLnTwIJS >= 6 ) { System . out . print ( money / 2 ) ; } else if ( qjiLnTwIJS >= 0 ) { System . out . print ( 0 ) ; } } } import java . util . Scanner ; public class kwwczAPQYo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kwwczAPQYo = sc . nextInt ( ) ; int [ ] array = new int [ kwwczAPQYo ] ; for ( int i = 1 ; i < kwwczAPQYo ; i ++ ) array [ sc . nextInt ( ) - 1 ] ++ ; sc . close ( ) ; for ( int i = 0 ; i < kwwczAPQYo ; i ++ ) System . out . println ( array [ i ] ) ; } } import java . util . * ; public class QQJpNzQyPm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; int QQJpNzQyPm = 0 ; int count1 = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '1' ) count1 ++ ; if ( S . charAt ( i ) == '0' ) QQJpNzQyPm ++ ; } System . out . println ( 2 * Math . min ( count1 , QQJpNzQyPm ) ) ; } } import java . util . * ; public class AMqKcnoTvF { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String [ ] line = sc . nextLine ( ) . split ( " " ) ; int AMqKcnoTvF = Integer . parseInt ( line [ 0 ] ) ; int buttonB = Integer . parseInt ( line [ 1 ] ) ; int ans = 0 ; if ( AMqKcnoTvF > buttonB ) { ans += AMqKcnoTvF ; AMqKcnoTvF -- ; } else { ans += buttonB ; buttonB -- ; } if ( AMqKcnoTvF > buttonB ) { ans += AMqKcnoTvF ; } else { ans += buttonB ; } System . out . println ( ans ) ; } } import java . math . BigInteger ; import java . util . * ; public class fruPHcojQT { 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 MsUfDSBEuk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MsUfDSBEuk = sc . nextInt ( ) ; double a = 2 * MsUfDSBEuk * 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 BhMdAnKtNl { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] tmp = br . readLine ( ) . split ( " " ) ; int BhMdAnKtNl = 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 RSXhJIxliG { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int RSXhJIxliG = sc . nextInt ( ) ; int debt = 100000 ; int roundUpNum = 1000 ; for ( int i = 0 ; i < RSXhJIxliG ; 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 cImbDrGygV { public static void main ( String [ ] args ) { execute16_4 ( ) ; } private static void execute16_4 ( ) { try ( Scanner sc = new Scanner ( System . in ) ) { int cImbDrGygV = sc . nextInt ( ) ; System . out . println ( cImbDrGygV + cImbDrGygV * cImbDrGygV + cImbDrGygV * cImbDrGygV * cImbDrGygV ) ; } } } import java . util . Scanner ; public class pqZkSYTOEb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pqZkSYTOEb = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; if ( pqZkSYTOEb >= 10 || B >= 10 ) { System . out . println ( - 1 ) ; } else { System . out . println ( pqZkSYTOEb * B ) ; } } } import java . util . Scanner ; public class DZjBPLDjws { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DZjBPLDjws = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; if ( N <= 99 ) { System . out . print ( N * ( int ) Math . pow ( 100 , DZjBPLDjws ) ) ; } else if ( N == 100 ) { System . out . print ( 101 * ( int ) Math . pow ( 100 , DZjBPLDjws ) ) ; } } } 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 sLuRmhPdwW { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; MyScanner in = new MyScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; sLuRmhPdwW solver = new sLuRmhPdwW ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class sLuRmhPdwW { public void solve ( int testNumber , MyScanner in , PrintWriter out ) { int sLuRmhPdwW = in . Int ( ) ; int B = in . Int ( ) ; out . println ( sLuRmhPdwW * B ) ; } } static class sLuRmhPdwW { 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 MhAqSCNkrm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MhAqSCNkrm = sc . nextInt ( ) ; String s = sc . next ( ) ; sc . close ( ) ; boolean sa = false ; boolean sine = false ; if ( MhAqSCNkrm % 2 != 0 ) { System . out . println ( " No " ) ; sine = true ; } else { int [ ] a = new int [ MhAqSCNkrm / 2 ] ; int [ ] b = new int [ MhAqSCNkrm / 2 ] ; for ( int i = 0 ; i < MhAqSCNkrm / 2 ; i ++ ) { a [ i ] = s . charAt ( i ) ; b [ i ] = s . charAt ( i + MhAqSCNkrm / 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 jkfEKItKXY { static int jkfEKItKXY ; static int [ ] w ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; jkfEKItKXY = scanner . nextInt ( ) ; w = new int [ jkfEKItKXY ] ; for ( int i = 0 ; i < jkfEKItKXY ; i ++ ) { w [ i ] = scanner . nextInt ( ) ; } scanner . close ( ) ; int ans = Integer . MAX_VALUE ; int s1 = 0 ; for ( int i = 0 ; i < jkfEKItKXY - 1 ; i ++ ) { int s2 = 0 ; for ( int j = jkfEKItKXY - 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 YyTpDrqBOl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YyTpDrqBOl = sc . nextInt ( ) ; long a = 0 ; for ( int i = 0 ; i <= YyTpDrqBOl ; 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 NEbrhvdreB { public static void main ( String [ ] args ) { Scanner sca = new Scanner ( System . in ) ; String c = sca . next ( ) ; char NEbrhvdreB = c . charAt ( 0 ) ; System . out . println ( ( char ) ( NEbrhvdreB + 1 ) ) ; sca . close ( ) ; } } import java . util . Scanner ; public class GNqbcmVeZv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GNqbcmVeZv = sc . nextInt ( ) ; int strLen = sc . nextInt ( ) ; sc . nextLine ( ) ; String [ ] strs = new String [ GNqbcmVeZv ] ; for ( int i = 0 ; i < GNqbcmVeZv ; i ++ ) { strs [ i ] = sc . nextLine ( ) ; } for ( int i = 0 ; i < GNqbcmVeZv ; i ++ ) { for ( int j = i + 1 ; j < GNqbcmVeZv ; 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 AxibqJrEFF { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int AxibqJrEFF = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] m = new int [ AxibqJrEFF ] ; for ( int i = 0 ; i < AxibqJrEFF ; 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 MYfsSlvhjy { 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 LsCUdKlVcm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LsCUdKlVcm = 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 RClKYDsWiw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long RClKYDsWiw = sc . nextLong ( ) ; long start = 100 ; int answer = 0 ; while ( RClKYDsWiw > start ) { start += start / 100 ; answer ++ ; } System . out . println ( answer ) ; sc . close ( ) ; } } import java . util . Scanner ; class IUkRIrmIff { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IUkRIrmIff = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int ans = ( ( IUkRIrmIff + ( 2 * K + 1 ) - 1 ) ) / ( 2 * K + 1 ) ; System . out . print ( ans ) ; } } import java . util . * ; class OqrRKUJuda { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OqrRKUJuda = sc . nextInt ( ) ; int [ ] a = new int [ OqrRKUJuda ] ; for ( int i = 0 ; i < OqrRKUJuda ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; System . out . println ( a [ ( OqrRKUJuda - 1 ) / 2 + 1 ] - a [ ( OqrRKUJuda - 1 ) / 2 ] ) ; } } import java . util . Scanner ; public class ZXoIJffaYY { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ZXoIJffaYY = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; boolean [ ] judge = new boolean [ ZXoIJffaYY ] ; 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 SYFkRoYNDs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String number ; char [ ] ca ; int SYFkRoYNDs ; for ( ; ; ) { number = scan . next ( ) ; ca = number . toCharArray ( ) ; SYFkRoYNDs = 0 ; if ( ca [ 0 ] == '0' ) { break ; } for ( int i = 0 ; i < ca . length ; i ++ ) { SYFkRoYNDs += ca [ i ] - '0' ; } System . out . println ( SYFkRoYNDs ) ; } } } import java . util . * ; public class DdToUWntEc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DdToUWntEc = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int end = l + DdToUWntEc - 1 ; int sum ; if ( l >= 0 ) { sum = ( l + 1 + end ) * ( DdToUWntEc - 1 ) / 2 ; } else if ( end > 0 ) { sum = ( l + end ) * DdToUWntEc / 2 ; } else { sum = ( l + end - 1 ) * ( DdToUWntEc - 1 ) / 2 ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class SoQbWuvUsf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SoQbWuvUsf = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; StringBuilder answer = new StringBuilder ( ) ; for ( int i = 0 ; i < SoQbWuvUsf ; 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 pdScGOmNMP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pdScGOmNMP = sc . nextInt ( ) ; String ans = " APPROVED " ; int tmp ; for ( int i = 0 ; i < pdScGOmNMP ; 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 zOUxZvLzGZ { Scanner sc = new Scanner ( System . in ) ; void doIt ( ) { sC ( ) ; } void sC ( ) { String s = sc . next ( ) ; int zOUxZvLzGZ = 0 , one = 0 ; char [ ] c = s . toCharArray ( ) ; for ( int i = 0 ; i < c . length ; i ++ ) { if ( c [ i ] == '0' ) zOUxZvLzGZ ++ ; else one ++ ; } if ( one > zOUxZvLzGZ ) { System . out . println ( zOUxZvLzGZ * 2 ) ; } else System . out . println ( one * 2 ) ; } public static void main ( String [ ] args ) { new Main ( ) . doIt ( ) ; } } import java . util . * ; public class VYRFcUiamp { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int VYRFcUiamp = stdIn . nextInt ( ) ; int [ ] flag = new int [ 101 ] ; Arrays . fill ( flag , 0 ) ; for ( int i = 0 ; i < VYRFcUiamp ; 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 bHyUCEcdIP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter ou = new PrintWriter ( System . out ) ; int bHyUCEcdIP = Integer . parseInt ( sc . next ( ) ) ; int h = Integer . parseInt ( sc . next ( ) ) ; boolean ebishu = false ; if ( bHyUCEcdIP == 2 * Integer . parseInt ( sc . next ( ) ) && h == 2 * Integer . parseInt ( sc . next ( ) ) ) ebishu = true ; ou . print ( bHyUCEcdIP * ( long ) h / 2.0 + " " ) ; if ( ebishu ) ou . print ( 1 + " \n " ) ; else ou . print ( 0 + " \n " ) ; ou . flush ( ) ; } } import java . util . * ; public class KdThGGbdTE { 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 KdThGGbdTE = 0 ; KdThGGbdTE < x + 1 ; KdThGGbdTE ++ ) { Integer sum = 2 * KdThGGbdTE + 4 * ( x - KdThGGbdTE ) ; if ( sum == y ) ans = " Yes " ; } System . out . println ( ans ) ; } } import java . util . * ; public class YBmNjbjRmJ { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int YBmNjbjRmJ = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; String postal = sc . next ( ) ; String [ ] decomp = new String [ 3 ] ; decomp [ 0 ] = postal . substring ( 0 , YBmNjbjRmJ ) ; decomp [ 1 ] = postal . substring ( YBmNjbjRmJ , YBmNjbjRmJ + 1 ) ; decomp [ 2 ] = postal . substring ( YBmNjbjRmJ + 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 WHBcfzRDGo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WHBcfzRDGo , n ; WHBcfzRDGo = sc . nextInt ( ) ; n = sc . nextInt ( ) ; int [ ] ans ; ans = new int [ WHBcfzRDGo + 1 ] ; for ( int i = 0 ; i <= WHBcfzRDGo ; 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 <= WHBcfzRDGo ; i ++ ) { System . out . println ( ans [ i ] ) ; } } } import java . util . Scanner ; public class OkIouwydes { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OkIouwydes = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; boolean flag = false ; A : for ( int x = 0 ; x <= Math . min ( Y / 10000 , OkIouwydes ) ; x ++ ) { for ( int y = 0 ; y <= Math . min ( ( Y - 10000 * x ) / 5000 , OkIouwydes - x ) ; y ++ ) { int k = Y - 10000 * x - 5000 * y ; if ( k % 1000 == 0 ) { int z = k / 1000 ; if ( z == ( OkIouwydes - 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 aMgjcjQSem { 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 aMgjcjQSem { public static PrintWriter out ; public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int aMgjcjQSem = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; if ( w >= aMgjcjQSem ) { out . println ( " unsafe " ) ; } else { out . println ( " safe " ) ; } out . close ( ) ; } } import java . util . Scanner ; public class JYjgxvQREW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JYjgxvQREW = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] matrix = new int [ JYjgxvQREW ] [ m ] ; int [ ] vector = new int [ m ] ; for ( int i = 0 ; i < JYjgxvQREW ; 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 < JYjgxvQREW ; 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 icxGksNqkp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int icxGksNqkp ; double ave , d ; while ( ( icxGksNqkp = scan . nextInt ( ) ) != 0 ) { int [ ] point = new int [ icxGksNqkp ] ; ave = 0 ; for ( int i = 0 ; i < icxGksNqkp ; i ++ ) { point [ i ] = scan . nextInt ( ) ; ave += point [ i ] ; } ave /= ( double ) icxGksNqkp ; d = 0 ; for ( int i = 0 ; i < icxGksNqkp ; i ++ ) { d += ( Math . pow ( ( ave - point [ i ] ) , 2 ) ) ; } d /= ( double ) icxGksNqkp ; d = Math . sqrt ( d ) ; System . out . printf ( " %.8f \n " , d ) ; } scan . close ( ) ; } } import java . util . Scanner ; public class gHFriLWWYj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gHFriLWWYj = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int [ ] [ ] nm = new int [ gHFriLWWYj ] [ m ] ; int [ ] [ ] ml = new int [ m ] [ l ] ; for ( int i = 0 ; i < gHFriLWWYj ; 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 < gHFriLWWYj ; 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 aBDOIyAgpM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aBDOIyAgpM = sc . nextInt ( ) ; int s = aBDOIyAgpM % 60 ; int M = aBDOIyAgpM / 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 BIUMJCiTah { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BIUMJCiTah = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ BIUMJCiTah ] ; for ( int i = 0 ; i < BIUMJCiTah ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; int sum = 0 ; for ( int i = 0 ; i < k && i < BIUMJCiTah ; i ++ ) { sum += arr [ i ] ; } System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class duLfaFecUl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] task = new int [ 3 ] ; int duLfaFecUl = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { task [ i ] = sc . nextInt ( ) ; } Arrays . sort ( task ) ; for ( int i = 0 ; i < 2 ; i ++ ) { duLfaFecUl += Math . abs ( task [ i ] - task [ i + 1 ] ) ; } System . out . println ( duLfaFecUl ) ; } } import java . io . * ; class LYTlDtAkAJ { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = reader . readLine ( ) ; int LYTlDtAkAJ = Integer . parseInt ( line ) ; int answer = ( int ) Math . pow ( LYTlDtAkAJ , 3 ) ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class EkfuXruAYM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EkfuXruAYM = sc . nextInt ( ) ; int kind = sc . nextInt ( ) ; int [ ] di = new int [ kind ] ; int [ ] count = new int [ EkfuXruAYM ] ; for ( int i = 0 ; i < EkfuXruAYM ; 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 < EkfuXruAYM ; i ++ ) { if ( count [ i ] == 0 ) { trickCount ++ ; } } System . out . println ( trickCount ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class stIsdZnzqO { 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 stIsdZnzqO = charArray . length - 1 ; stIsdZnzqO >= 0 ; stIsdZnzqO -- ) { System . out . print ( charArray [ stIsdZnzqO ] ) ; } System . out . println ( " " ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . Scanner ; public class GRklDSuZaH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GRklDSuZaH = sc . nextInt ( ) ; for ( int i = 1 ; i <= GRklDSuZaH ; 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 OOCJsNISrM { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int OOCJsNISrM = sc . nextInt ( ) ; int [ ] [ ] array = new int [ 2 ] [ OOCJsNISrM ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < OOCJsNISrM ; j ++ ) { array [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] ans = new int [ 2 ] [ OOCJsNISrM ] ; ans [ 0 ] [ 0 ] = array [ 0 ] [ 0 ] ; for ( int i = 0 ; i < OOCJsNISrM - 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 < OOCJsNISrM ; i ++ ) { ans [ 1 ] [ i ] = Math . max ( ans [ 0 ] [ i ] , ans [ 1 ] [ i - 1 ] ) + array [ 1 ] [ i ] ; } System . out . println ( ans [ 1 ] [ OOCJsNISrM - 1 ] ) ; } } import java . util . Scanner ; public class UOyhmnVyGH { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long UOyhmnVyGH = scanner . nextLong ( ) ; long answer = UOyhmnVyGH - 1 ; answer = getAnswer ( UOyhmnVyGH , answer ) ; System . out . println ( answer ) ; } private static long getAnswer ( long UOyhmnVyGH , long answer ) { int newStart = ( int ) Math . sqrt ( UOyhmnVyGH ) ; for ( long i = newStart ; i > 1 ; i -- ) { if ( UOyhmnVyGH % i == 0 ) { long divisible = UOyhmnVyGH / i ; long possibleAnswer = ( i - 1 ) + ( divisible - 1 ) ; return possibleAnswer ; } } return answer ; } } import java . util . * ; public class IPVMKWPHWK { public static void main ( String [ ] args ) { int IPVMKWPHWK ; Scanner sc = new Scanner ( System . in ) ; String num = sc . next ( ) ; num = num . replaceAll ( " 0 " , " " ) ; IPVMKWPHWK = num . IPVMKWPHWK ( ) ; System . out . println ( IPVMKWPHWK ) ; } } import java . util . Scanner ; public class zwtKXslcYS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zwtKXslcYS = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int res ; if ( zwtKXslcYS <= 5 ) { res = 0 ; } else if ( zwtKXslcYS <= 12 ) { res = b / 2 ; } else { res = b ; } System . out . println ( res ) ; } } import java . util . * ; public class TeViWaNzEY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TeViWaNzEY = sc . nextInt ( ) , D = sc . nextInt ( ) , c = 0 ; for ( int i = 0 ; i < TeViWaNzEY ; 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 DMXCHNXfBU { public static void main ( String [ ] args ) { try ( BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int DMXCHNXfBU = 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 ) { DMXCHNXfBU += 3 ; } else if ( cmp == 0 ) { DMXCHNXfBU ++ ; hanako ++ ; } else { hanako += 3 ; } } System . out . println ( DMXCHNXfBU + " " + hanako ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class JUQzWESnLn { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; int JUQzWESnLn = ob . nextInt ( ) ; boolean C = true ; String R = " " ; while ( C ) { JUQzWESnLn %= 10 ; C = false ; } if ( ( JUQzWESnLn == 2 ) || ( JUQzWESnLn == 4 ) || ( JUQzWESnLn == 5 ) || ( JUQzWESnLn == 7 ) || ( JUQzWESnLn == 9 ) ) { R += " hon " ; } else if ( ( JUQzWESnLn == 0 ) || ( JUQzWESnLn == 1 ) || ( JUQzWESnLn == 6 ) || ( JUQzWESnLn == 8 ) ) { R += " pon " ; } else if ( JUQzWESnLn == 3 ) { R += " bon " ; } System . out . println ( R ) ; } } import java . util . * ; public class vqauGGGLYm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vqauGGGLYm = sc . nextInt ( ) ; int yen = sc . nextInt ( ) ; int s = yen / 1000 - vqauGGGLYm ; for ( int i = 0 ; i <= Math . min ( s / 9 , vqauGGGLYm ) ; i ++ ) { for ( int j = 0 ; j <= Math . min ( vqauGGGLYm - i , s / 4 ) ; j ++ ) { if ( i * 9 + j * 4 == s ) { System . out . println ( i + " " + j + " " + ( vqauGGGLYm - 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 WCTtMTAnCw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int WCTtMTAnCw = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = Math . max ( WCTtMTAnCw , b ) ; int d = Math . min ( WCTtMTAnCw , b ) ; int out = 0 ; out += c ; out += Math . max ( c - 1 , d ) ; System . out . println ( out ) ; scan . close ( ) ; } } import java . util . Scanner ; public class UOPrcFAuIn { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int UOPrcFAuIn = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int result = 0 ; switch ( UOPrcFAuIn ) { 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 WQXdnYjVPr { public static void main ( String [ ] args ) { Solve s = new Solve ( ) ; s . solve ( ) ; } } class WQXdnYjVPr { public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; double WQXdnYjVPr = sc . nextInt ( ) ; double K = sc . nextInt ( ) ; double n = 0d ; double res = 0d ; String message ; for ( double i = 1 ; i <= WQXdnYjVPr ; i ++ ) { for ( int j = 0 ; j < 100000 ; j ++ ) { if ( i * Math . pow ( 2 , j ) >= K ) { n = j ; j = 100000 ; } } res += 1 / ( WQXdnYjVPr * 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 UcRGNvGKJQ { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line = br . readLine ( ) ; int UcRGNvGKJQ = Integer . parseInt ( line ) ; int [ ] a = new int [ UcRGNvGKJQ ] ; int k = 0 ; int count = 1 ; boolean fin = false ; for ( int i = 0 ; i < UcRGNvGKJQ ; i ++ ) { a [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } for ( int i = 0 ; i < UcRGNvGKJQ ; 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 gatWXRRPzz { 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 gatWXRRPzz { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String gatWXRRPzz = in . next ( ) ; if ( gatWXRRPzz . compareTo ( " Sunny " ) == 0 ) { out . println ( " Cloudy " ) ; } else if ( gatWXRRPzz . compareTo ( " Cloudy " ) == 0 ) { out . println ( " Rainy " ) ; } else { out . println ( " Sunny " ) ; } } } static class gatWXRRPzz { 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 EqrKIFEbgq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long EqrKIFEbgq = sc . nextLong ( ) ; long hh = sc . nextLong ( ) ; long xx = sc . nextLong ( ) ; long yy = sc . nextLong ( ) ; System . out . print ( EqrKIFEbgq * hh / 2.0 ) ; System . out . print ( " " + ( xx * 2 == EqrKIFEbgq && yy * 2 == hh ? 1 : 0 ) ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class OcSOwGHiXP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; char [ ] t = sc . next ( ) . toCharArray ( ) ; int OcSOwGHiXP = 0 ; int len = s . length ; for ( int i = 0 ; i < len ; i ++ ) { if ( s [ i ] != t [ i ] ) OcSOwGHiXP ++ ; } System . out . println ( OcSOwGHiXP ) ; } } import java . util . Scanner ; public class JwQgVwdQUT { 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 JwQgVwdQUT = 0 ; JwQgVwdQUT < 26 ; JwQgVwdQUT ++ ) { if ( C . equals ( slist [ JwQgVwdQUT ] ) ) { C = slist [ JwQgVwdQUT + 1 ] ; System . out . println ( C ) ; break ; } } } } import java . util . * ; class qfUHTwuVYu { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int qfUHTwuVYu = stdIn . nextInt ( ) ; int x = stdIn . nextInt ( ) ; int count = 1 ; int sum = 0 ; while ( qfUHTwuVYu -- > 0 ) { sum += stdIn . nextInt ( ) ; if ( x < sum ) break ; count ++ ; } System . out . println ( count ) ; } } import java . util . Scanner ; public class dbfbfFiXJS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double dbfbfFiXJS = sc . nextDouble ( ) ; System . out . println ( ( int ) Math . ceil ( dbfbfFiXJS / 2 ) ) ; } } import java . util . Scanner ; public class rjrFYMSwEB { private static int rjrFYMSwEB , x ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; rjrFYMSwEB = stdIn . nextInt ( ) ; for ( int i = 1 ; i <= rjrFYMSwEB ; 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 RvfFJeTfbe { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String nb = buf . readLine ( ) ; int RvfFJeTfbe = Integer . parseInt ( nb ) ; System . out . println ( ( int ) Math . pow ( RvfFJeTfbe , 3 ) ) ; } } import java . lang . reflect . Array ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class PANipDnIid { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; List < String [ ] > list = new ArrayList < > ( ) ; int PANipDnIid = 0 ; int N = 0 ; int M = 0 ; while ( scan . hasNext ( ) ) { if ( PANipDnIid == 0 ) { N = scan . nextInt ( ) ; M = scan . nextInt ( ) ; PANipDnIid ++ ; continue ; } String str = scan . nextLine ( ) ; String [ ] sp = str . split ( " " ) ; list . add ( sp ) ; PANipDnIid ++ ; if ( PANipDnIid > 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 NAyToKEMwF { static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; long NAyToKEMwF = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; sc . close ( ) ; long res1 = Math . max ( 0 , NAyToKEMwF - k ) ; long res2 = Math . max ( 0 , Math . min ( NAyToKEMwF + b - k , b ) ) ; System . out . println ( res1 + " " + res2 ) ; } public static void main ( String [ ] args ) { solve ( ) ; } } import java . util . Scanner ; public class lHOonpFkBY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; String [ ] s = sc . next ( ) . split ( " " ) ; for ( int lHOonpFkBY = 0 ; lHOonpFkBY < s . length ; lHOonpFkBY ++ ) { sb . append ( s [ lHOonpFkBY ] . equals ( " 1 " ) ? " 9 " : " 1 " ) ; } System . out . println ( sb ) ; } } import java . util . Scanner ; public class REZekEMTca { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int REZekEMTca = sc . nextInt ( ) , b = sc . nextInt ( ) ; StringBuilder a_str = new StringBuilder ( ) ; StringBuilder b_str = new StringBuilder ( ) ; for ( int i = 0 ; i < REZekEMTca ; i ++ ) { a_str . append ( b ) ; } for ( int i = 0 ; i < b ; i ++ ) { b_str . append ( REZekEMTca ) ; } System . out . println ( a_str . toString ( ) . compareTo ( b_str . toString ( ) ) < 0 ? a_str . toString ( ) : b_str . toString ( ) ) ; } } import java . util . * ; public class ALrdlMBEll { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ALrdlMBEll = sc . nextInt ( ) ; long total = 0 ; for ( long i = 0 ; i <= ALrdlMBEll ; i ++ ) { if ( i % 3 != 0 && i % 5 != 0 ) { total += i ; } } System . out . println ( total ) ; } } import java . util . * ; import java . util . Collections ; public class uSQwTlpdpO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uSQwTlpdpO = sc . nextInt ( ) ; String S = sc . next ( ) ; int cnt = 0 ; for ( int i = 0 ; i < uSQwTlpdpO - 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 TWzDFsgmYQ { public static void main ( String [ ] args ) { int TWzDFsgmYQ ; int b ; try ( Scanner scanner = new Scanner ( System . in ) ) { TWzDFsgmYQ = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; } if ( ( TWzDFsgmYQ & b & 1 ) == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class MwwkojpSac { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MwwkojpSac = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] monsters = new int [ MwwkojpSac ] ; for ( int i = 0 ; i < MwwkojpSac ; i ++ ) { monsters [ i ] = sc . nextInt ( ) ; } Arrays . sort ( monsters ) ; long hp = 0 ; if ( k >= MwwkojpSac ) { System . out . println ( hp ) ; } else { for ( int j = 0 ; j < MwwkojpSac - k ; j ++ ) { hp += monsters [ j ] ; } System . out . println ( hp ) ; } } } import java . util . Scanner ; public class FoENdhwTmO { public static void main ( String [ ] args ) { Scanner c = new Scanner ( System . in ) ; long FoENdhwTmO = c . nextInt ( ) ; System . out . println ( ( FoENdhwTmO + ( FoENdhwTmO * FoENdhwTmO ) + ( FoENdhwTmO * FoENdhwTmO * FoENdhwTmO ) ) ) ; } } import java . util . * ; public class xHlIBdGfzF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xHlIBdGfzF = Integer . parseInt ( sc . next ( ) ) ; int d = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < xHlIBdGfzF ; 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 xOfcWJpoNn { public static void main ( String [ ] args ) throws Exception { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; int xOfcWJpoNn = 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' ) { xOfcWJpoNn ++ ; if ( max <= xOfcWJpoNn ) { max = xOfcWJpoNn ; } } else { xOfcWJpoNn = 0 ; } } System . out . println ( max ) ; } } import java . util . Scanner ; public class LIXIvZsqoC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] array = sc . nextLine ( ) . split ( " " ) ; int LIXIvZsqoC = 0 ; for ( String s : array ) { if ( Integer . parseInt ( s ) == 1 ) { LIXIvZsqoC ++ ; } } System . out . println ( LIXIvZsqoC ) ; } } import java . util . Scanner ; public class PCGbPyPXru { public static void main ( String [ ] args ) { String PCGbPyPXru ; Scanner n = new Scanner ( System . in ) ; PCGbPyPXru = n . next ( ) ; if ( PCGbPyPXru . equals ( " Sunny " ) ) System . out . print ( " Cloudy " ) ; else if ( PCGbPyPXru . equals ( " Cloudy " ) ) System . out . print ( " Rainy " ) ; else if ( PCGbPyPXru . equals ( " Rainy " ) ) System . out . print ( " Sunny " ) ; } } import java . util . Scanner ; public class TimOfKLXwX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TimOfKLXwX = 0 , b = 0 , c = 0 ; int [ ] n = new int [ 10 ] ; for ( int i = 0 ; i < 10 ; i ++ ) { n [ i ] = sc . nextInt ( ) ; if ( n [ i ] > TimOfKLXwX ) { c = b ; b = TimOfKLXwX ; TimOfKLXwX = n [ i ] ; } else if ( n [ i ] > b ) { c = b ; b = n [ i ] ; } else if ( n [ i ] > c ) { c = n [ i ] ; } } System . out . println ( TimOfKLXwX ) ; System . out . println ( b ) ; System . out . println ( c ) ; } } import java . io . * ; class JgPAGMIxIl { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; char JgPAGMIxIl ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { JgPAGMIxIl = str . charAt ( i ) ; if ( Character . isUpperCase ( JgPAGMIxIl ) ) JgPAGMIxIl = Character . toLowerCase ( JgPAGMIxIl ) ; else if ( Character . isLowerCase ( JgPAGMIxIl ) ) JgPAGMIxIl = Character . toUpperCase ( JgPAGMIxIl ) ; System . out . print ( JgPAGMIxIl ) ; } System . out . println ( ) ; } catch ( IOException e ) { System . out . println ( " Exception : " + e ) ; } } } import java . util . * ; class RiMcibGFFP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RiMcibGFFP = sc . nextInt ( ) ; int waza = sc . nextInt ( ) ; long ret = 0 ; int [ ] hoge = new int [ RiMcibGFFP ] ; if ( RiMcibGFFP <= waza ) { System . out . println ( 0 ) ; return ; } for ( int i = 0 ; i < RiMcibGFFP ; i ++ ) { hoge [ i ] = sc . nextInt ( ) ; } Arrays . sort ( hoge ) ; for ( int i = 0 ; i < RiMcibGFFP - waza ; i ++ ) { ret += hoge [ i ] ; } System . out . print ( ret ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class lGmpWixKRT { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int lGmpWixKRT = sc . nextInt ( ) ; int maxPotision = 0 ; int maxValue = 0 ; int secondValue = 0 ; boolean maxDup = false ; for ( int i = 0 ; i < lGmpWixKRT ; 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 < lGmpWixKRT ; i ++ ) { System . out . println ( maxValue ) ; } } else { for ( int i = 0 ; i < lGmpWixKRT ; i ++ ) { if ( i == maxPotision ) { System . out . println ( secondValue ) ; } else { System . out . println ( maxValue ) ; } } } } } import java . util . * ; public class cFrZgPBAXD { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String cFrZgPBAXD = scan . nextLine ( ) ; String strings = cFrZgPBAXD + cFrZgPBAXD ; 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 WEXPvVFtcu { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int WEXPvVFtcu = sc . nextInt ( ) ; int H = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; boolean flg = false ; BigDecimal S = BigDecimal . valueOf ( WEXPvVFtcu ) ; S = S . multiply ( BigDecimal . valueOf ( H ) ) ; S = S . divide ( BigDecimal . valueOf ( 2 ) , 10 , RoundingMode . HALF_UP ) ; if ( 2 * x == WEXPvVFtcu && 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 KbtySbtuHp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; loop : while ( true ) { long KbtySbtuHp = scanner . nextInt ( ) ; String op = scanner . next ( ) ; long b = scanner . nextInt ( ) ; switch ( op ) { case " + " : System . out . println ( KbtySbtuHp + b ) ; break ; case " - " : System . out . println ( KbtySbtuHp - b ) ; break ; case " * " : System . out . println ( KbtySbtuHp * b ) ; break ; case " / " : System . out . println ( KbtySbtuHp / 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 lkNICgxqAo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lkNICgxqAo = sc . nextInt ( ) ; boolean [ ] isZorome = new boolean [ lkNICgxqAo ] ; for ( int i = 0 ; i < lkNICgxqAo ; 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 < lkNICgxqAo - 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 GIfIRUHxzP { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int GIfIRUHxzP = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int M = 2 * D + 1 ; System . out . println ( ( GIfIRUHxzP + 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 pRcFtnaVFz { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int pRcFtnaVFz = Integer . parseInt ( str [ 0 ] ) ; int l = Integer . parseInt ( str [ 1 ] ) ; String [ ] s = new String [ pRcFtnaVFz ] ; for ( int i = 0 ; i < pRcFtnaVFz ; i ++ ) { s [ i ] = in . readLine ( ) ; } Arrays . sort ( s ) ; for ( int i = 0 ; i < pRcFtnaVFz ; i ++ ) { System . out . print ( s [ i ] ) ; } System . out . println ( ) ; } } import java . util . * ; import java . io . * ; public class FzpghVYDZq { 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 FzpghVYDZq = Integer . parseInt ( br . readLine ( ) ) ; long ans = 0 ; for ( int i = 1 ; i <= FzpghVYDZq ; 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 oEdWIUBrYv { 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 oEdWIUBrYv = 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 wwDCWjuyxz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double wwDCWjuyxz = sc . nextDouble ( ) ; double ans = wwDCWjuyxz / 3 ; System . out . printf ( " %.12f \n " , ans * ans * ans ) ; } } import java . util . Scanner ; public class vFldkJWCcW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long vFldkJWCcW = sc . nextLong ( ) , a = sc . nextLong ( ) , b = sc . nextLong ( ) ; long sum = a * ( vFldkJWCcW / ( a + b ) ) ; sum += a < vFldkJWCcW % ( a + b ) ? a : vFldkJWCcW % ( a + b ) ; System . out . println ( sum ) ; } } import java . util . Scanner ; public class PrJUXapxms { public static void main ( String [ ] args ) { Scanner inputscan = new Scanner ( System . in ) ; int PrJUXapxms = 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 <= PrJUXapxms && Vertical1 >= 0 && Vertical2 <= H ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . math . * ; public class FORvzdaaLV { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String FORvzdaaLV = sc . next ( ) ; String b = sc . next ( ) ; BigDecimal a1 = new BigDecimal ( FORvzdaaLV ) ; BigDecimal b1 = new BigDecimal ( b ) ; BigDecimal res = a1 . multiply ( b1 ) ; System . out . println ( res . setScale ( 0 , RoundingMode . DOWN ) ) ; } } import java . io . * ; class LyWdsiQOTv { } class LyWdsiQOTv { public static void main ( String [ ] args ) throws IOException { Program obj = new Program ( ) ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] ip ; int LyWdsiQOTv , M , C ; int [ ] A , B ; ip = in . readLine ( ) . split ( " " ) ; LyWdsiQOTv = 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 ( -- LyWdsiQOTv >= 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 QwhzBQPHrG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; boolean [ ] [ ] cardHasFlag = new boolean [ 4 ] [ 13 ] ; int QwhzBQPHrG = sc . nextInt ( ) ; for ( int i = 0 ; i < QwhzBQPHrG ; 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 ewlvVCErHK { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ewlvVCErHK = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int sum = 0 ; if ( d <= ewlvVCErHK ) { System . out . println ( d ) ; return ; } sum = ewlvVCErHK ; d -= ewlvVCErHK ; if ( d <= b ) { System . out . println ( sum ) ; return ; } d -= b ; sum -= d ; System . out . println ( sum ) ; } } import java . util . * ; public class nsreIcQVAk { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int nsreIcQVAk = s . nextInt ( ) ; long [ ] monsters = new long [ nsreIcQVAk + 1 ] ; long [ ] strength = new long [ nsreIcQVAk ] ; long count = 0 ; for ( int i = 0 ; i < nsreIcQVAk + 1 ; i ++ ) { monsters [ i ] = s . nextInt ( ) ; } for ( int i = 0 ; i < nsreIcQVAk ; i ++ ) { strength [ i ] = s . nextInt ( ) ; } for ( int i = 0 ; i < nsreIcQVAk ; 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 xkgKseGcPc { public static void main ( final String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { String s = scanner . nextLine ( ) ; int xkgKseGcPc = 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 ) ) { xkgKseGcPc ++ ; } } if ( xkgKseGcPc == 2 ) { xkgKseGcPc = 0 ; } else { System . out . println ( " No " ) ; flag = false ; break ; } } if ( flag ) { System . out . println ( " Yes " ) ; } } } } import java . util . * ; class JBxlykkFYO { 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 JBxlykkFYO = sc . nextInt ( ) ; int [ ] triangle = new int [ 3 ] ; for ( int cnt = 0 ; cnt < JBxlykkFYO ; 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 uwoURpjsdK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long uwoURpjsdK = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long answer = uwoURpjsdK * B / calcGcd ( uwoURpjsdK , 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 tVWIGJWIVa { public static void main ( String [ ] args ) { int tVWIGJWIVa ; 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 aKglosNMPc { static long aKglosNMPc = ( 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 aKglosNMPc { 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 rDXTSvOQrp { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int rDXTSvOQrp = in . nextInt ( ) , b = in . nextInt ( ) , c = in . nextInt ( ) , n = in . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i <= rDXTSvOQrp ; 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 gMQhTeDZcy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; for ( int gMQhTeDZcy = 1 ; gMQhTeDZcy <= 10000 ; gMQhTeDZcy ++ ) { 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 FFiPWemJdm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FFiPWemJdm = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean [ ] clash = new boolean [ FFiPWemJdm + 1 ] ; Arrays . fill ( clash , true ) ; for ( int i = 0 ; i < m ; i ++ ) clash [ sc . nextInt ( ) ] = false ; int [ ] dp = new int [ FFiPWemJdm + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 0 ; i < FFiPWemJdm ; i ++ ) { for ( int j = i + 1 ; j <= Math . min ( i + 2 , FFiPWemJdm ) ; j ++ ) { if ( clash [ j ] ) { dp [ j ] += dp [ i ] ; dp [ j ] %= 1000000007 ; } } } System . out . println ( dp [ FFiPWemJdm ] ) ; sc . close ( ) ; } } import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class KXSaLXZrjr { 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 KXSaLXZrjr { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String str = in . next ( ) ; int KXSaLXZrjr = 0 ; for ( char c : str . toCharArray ( ) ) { if ( c == '1' ) { KXSaLXZrjr ++ ; } } out . print ( KXSaLXZrjr ) ; } } } import java . util . Scanner ; public class DzPnayohKD { public static int getGcd ( int a , int b ) { if ( a == b ) return b ; int DzPnayohKD = Math . max ( a , b ) ; int smaller = Math . min ( a , b ) ; int modded = DzPnayohKD % smaller ; if ( modded == 0 ) return smaller ; return getGcd ( smaller , DzPnayohKD % 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 akcaFXRQAF { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; int akcaFXRQAF = s . nextInt ( ) ; int [ ] a = new int [ akcaFXRQAF ] ; for ( int i = 0 ; i < akcaFXRQAF ; i ++ ) a [ i ] = s . nextInt ( ) ; int count = 0 ; boolean flag = false ; int j = 1 ; for ( int i = 0 ; i < akcaFXRQAF ; 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 ZBUBRMMnmw { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ZBUBRMMnmw = sc . nextInt ( ) ; int [ ] s = new int [ ZBUBRMMnmw ] ; for ( int i = 0 ; i < ZBUBRMMnmw ; 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 = ZBUBRMMnmw - 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 sDKKGEVlgS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String someString = sc . next ( ) ; char sDKKGEVlgS = 'R' ; int rCount = 0 ; for ( int i = 0 ; i < someString . length ( ) ; i ++ ) { if ( rCount == 0 && someString . charAt ( i ) == sDKKGEVlgS ) { rCount = 1 ; } if ( someString . charAt ( i ) == sDKKGEVlgS ) { if ( i > 0 && someString . charAt ( i - 1 ) == sDKKGEVlgS ) { rCount ++ ; } } } System . out . println ( rCount ) ; } } import java . util . * ; public class MrrqzbCPfy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MrrqzbCPfy = sc . nextInt ( ) ; int [ ] L = new int [ MrrqzbCPfy ] ; for ( int i = 0 ; i < MrrqzbCPfy ; i ++ ) { L [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( L ) ; int sum = 0 ; for ( int i = MrrqzbCPfy - 2 ; 0 <= i ; i -- ) { sum += L [ i ] ; } if ( L [ MrrqzbCPfy - 1 ] < sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class NdwEHZZCIb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NdwEHZZCIb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( ! ( e - NdwEHZZCIb > k ) ) { System . out . print ( " Yay! " ) ; } else { System . out . print ( " :( " ) ; } } } import java . util . Scanner ; public class GblfkKJgbk { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int GblfkKJgbk = in . nextInt ( ) ; int n = in . nextInt ( ) ; int [ ] a = new int [ 200009 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; } a [ n ] = GblfkKJgbk + a [ 0 ] ; int ans = 1000000009 ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . min ( ans , GblfkKJgbk - ( a [ i + 1 ] - a [ i ] ) ) ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class ctfvIrXFSY { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int ctfvIrXFSY = Integer . parseInt ( s . next ( ) ) ; int b = Integer . parseInt ( s . next ( ) ) ; System . out . printf ( " %d %d %.5f " , ctfvIrXFSY / b , ctfvIrXFSY % b , ( double ) ctfvIrXFSY / ( double ) b ) ; } } import java . io . BufferedInputStream ; import java . io . BufferedOutputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class DvbJUThTXC { 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 DvbJUThTXC = s . charAt ( 0 ) ; dp [ 0 ] [ 0 ] = ( DvbJUThTXC == '1' ? 1 : 0 ) ; dp [ 1 ] [ 0 ] = ( DvbJUThTXC == '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 WzYOaNsmVm { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] s = br . readLine ( ) . split ( " " ) ; long WzYOaNsmVm = 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 > WzYOaNsmVm && flag == true ) { K -= WzYOaNsmVm ; sum += WzYOaNsmVm ; } else if ( K <= WzYOaNsmVm && 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 LeRkpueLIU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LeRkpueLIU = sc . nextInt ( ) ; int [ ] p = new int [ LeRkpueLIU ] ; for ( int i = 0 ; i < LeRkpueLIU ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int c = 0 ; for ( int i = 0 ; i < LeRkpueLIU ; 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 aFwUTzSeDc { 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 aFwUTzSeDc = Integer . parseInt ( str [ 0 ] ) ; int W = Integer . parseInt ( str [ 1 ] ) ; if ( aFwUTzSeDc == 0 && W == 0 ) { break ; } for ( int i = 0 ; i < aFwUTzSeDc ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { if ( i == 0 || j == 0 || i == aFwUTzSeDc - 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 YxxkXnaipf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int YxxkXnaipf = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( YxxkXnaipf > 0 && YxxkXnaipf <= 9 && b > 0 && b <= 9 ) System . out . println ( YxxkXnaipf * b ) ; else System . out . println ( " -1 " ) ; } } import java . util . Scanner ; public class TdicGmYCOw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TdicGmYCOw = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; System . out . println ( solve ( TdicGmYCOw , Q , R ) ) ; sc . close ( ) ; } static int solve ( int TdicGmYCOw , int Q , int R ) { return TdicGmYCOw + Q + R - Math . max ( Math . max ( TdicGmYCOw , Q ) , R ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class xFLxYFzDoW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > A = new ArrayList < Integer > ( ) ; for ( int xFLxYFzDoW = 0 ; xFLxYFzDoW < 3 ; xFLxYFzDoW ++ ) { 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 vzprdUPYnG { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int vzprdUPYnG = sc . nextInt ( ) ; ArrayList < Integer > a = new ArrayList < Integer > ( vzprdUPYnG ) ; for ( int i = 0 ; i < vzprdUPYnG ; 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 < vzprdUPYnG ; 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 ASEDJAxLDZ { static long ASEDJAxLDZ = 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 SrfmcxnauU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] t = { " eraser " , " erase " , " dreamer " , " dream " } ; for ( int SrfmcxnauU = 0 ; SrfmcxnauU < 4 ; SrfmcxnauU ++ ) s = s . replace ( t [ SrfmcxnauU ] , " " ) ; System . out . println ( s . equals ( " " ) ? " YES " : " NO " ) ; } } import java . util . Scanner ; class bELjfbhege { private final int bELjfbhege ; Solver ( Scanner in ) { int N = in . nextInt ( ) ; bELjfbhege = in . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( in . nextInt ( ) >= bELjfbhege ) count ++ ; } System . out . println ( count ) ; } void solve ( ) { } } class bELjfbhege { 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 rdneMcLAXD { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int rdneMcLAXD = 100000 ; int n = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { rdneMcLAXD *= 1.05 ; if ( ( rdneMcLAXD - ( ( rdneMcLAXD / 1000 ) * 1000 ) ) != 0 ) { rdneMcLAXD = ( rdneMcLAXD / 1000 ) * 1000 + 1000 ; } else { rdneMcLAXD = ( rdneMcLAXD / 1000 ) * 1000 ; } } System . out . println ( rdneMcLAXD ) ; } } import java . util . Scanner ; class CwukzZmLJr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] chars = new int [ 256 ] ; for ( int CwukzZmLJr = 0 ; CwukzZmLJr < 256 ; CwukzZmLJr ++ ) chars [ CwukzZmLJr ] = 0 ; while ( scan . hasNextLine ( ) ) { String line = scan . nextLine ( ) ; for ( int CwukzZmLJr = 0 ; CwukzZmLJr < line . length ( ) ; CwukzZmLJr ++ ) { char ch = Character . toLowerCase ( line . charAt ( CwukzZmLJr ) ) ; 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 BSqYbeGJGv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BSqYbeGJGv = Integer . parseInt ( sc . next ( ) ) ; int X = Integer . parseInt ( sc . next ( ) ) ; int [ ] M = new int [ BSqYbeGJGv ] ; for ( int i = 0 ; i < BSqYbeGJGv ; i ++ ) { M [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; Arrays . sort ( M ) ; int sum = 0 ; int cnt = BSqYbeGJGv ; for ( int i = 0 ; i < BSqYbeGJGv ; 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 KZAhTuwAcR { static Scanner sc = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { while ( sc . hasNext ( ) ) { long KZAhTuwAcR = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; long x = KZAhTuwAcR ; long y = b ; long max = y ; while ( x % y != 0 ) { max = x % y ; x = y ; y = max ; } long min = KZAhTuwAcR * b / max ; System . out . println ( max + " " + min ) ; } } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class hXHjVhqGdx { 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 hXHjVhqGdx = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; os . println ( hXHjVhqGdx * B ) ; } } import java . util . * ; public class fokTZoSfxy { 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 fokTZoSfxy = 7 - week . indexOf ( dow ) ; System . out . println ( fokTZoSfxy ) ; } } import java . util . Scanner ; public class QSOJZvhGWi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QSOJZvhGWi = scan . nextInt ( ) ; System . out . println ( QSOJZvhGWi / 500 * 1000 + QSOJZvhGWi % 500 / 5 * 5 ) ; } } import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class fzpRkenkvc { 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 fzpRkenkvc = 0 ; for ( int i = 0 ; i < s . length ( ) / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( s . length ( ) - i - 1 ) ) { fzpRkenkvc ++ ; } } p ( fzpRkenkvc ) ; } } import java . util . * ; class VJqiwXneev { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VJqiwXneev = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; Integer [ ] h = new Integer [ VJqiwXneev ] ; int c = 0 ; for ( int i = 0 ; i < VJqiwXneev ; 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 lNmGxywTAI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lNmGxywTAI = sc . nextInt ( ) ; int [ ] a = new int [ lNmGxywTAI ] ; for ( int i = 0 ; i < lNmGxywTAI ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; int alice = 0 ; int bob = 0 ; int check = 0 ; for ( int i = lNmGxywTAI - 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 jAWyxlVvNq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int jAWyxlVvNq = sc . nextInt ( ) ; int [ ] [ ] dp = new int [ 201 ] [ 201 ] ; long res = 0 ; for ( int i = 1 ; i <= jAWyxlVvNq ; i ++ ) { for ( int j = 1 ; j <= jAWyxlVvNq ; 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 <= jAWyxlVvNq ; 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 VuLMsKZPOz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int VuLMsKZPOz = Integer . parseInt ( S . substring ( 5 , 7 ) ) ; if ( VuLMsKZPOz < 5 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class awlsmlPAaD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int awlsmlPAaD = sc . nextInt ( ) ; ArrayList < Integer > deckList = new ArrayList < > ( ) ; for ( int i = 1 ; i <= awlsmlPAaD ; 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 mMPjEpqzWS { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; scanner . close ( ) ; int mMPjEpqzWS = 0 , minus = 0 ; for ( int n = 0 ; n < S . length ( ) ; n ++ ) { String s = S . substring ( n , n + 1 ) ; if ( s . equals ( " + " ) ) { mMPjEpqzWS ++ ; } else if ( s . equals ( " - " ) ) { minus ++ ; } } int A = mMPjEpqzWS - minus ; System . out . println ( A ) ; } } import java . util . Scanner ; public class uKOHjFOzjU { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int uKOHjFOzjU = 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 ] + ( uKOHjFOzjU - 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 ( uKOHjFOzjU - max ) ; scan . close ( ) ; } } import java . util . Scanner ; class KkemkPKGLv { public static void main ( String [ ] args ) { int KkemkPKGLv = 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 ) { KkemkPKGLv ++ ; } yaku = 0 ; } System . out . println ( KkemkPKGLv ) ; } } import java . util . Scanner ; public class PimzsSgiYK { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; int PimzsSgiYK = S . PimzsSgiYK ( ) ; int count = 0 ; for ( int i = 0 ; i < PimzsSgiYK / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( PimzsSgiYK - 1 - i ) ) count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class QDDDgqwUba { public static void main ( String [ ] args ) { int QDDDgqwUba ; Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; for ( QDDDgqwUba = 0 ; QDDDgqwUba < n ; QDDDgqwUba ++ ) { a . add ( Integer . parseInt ( sc . next ( ) ) ) ; } sc . close ( ) ; Collections . sort ( a , Comparator . reverseOrder ( ) ) ; int ans = 0 ; for ( QDDDgqwUba = 0 ; QDDDgqwUba < n ; QDDDgqwUba ++ ) { if ( QDDDgqwUba % 2 == 0 ) ans += a . get ( QDDDgqwUba ) ; else ans -= a . get ( QDDDgqwUba ) ; } 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 OyxeUCGAdd { public static void main ( String [ ] args ) { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String OyxeUCGAdd = null ; try { OyxeUCGAdd = br . readLine ( ) ; br . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } SimpleDateFormat sdf = new SimpleDateFormat ( " yyyy/MM/dd " ) ; Date formatDate = null ; try { formatDate = sdf . parse ( OyxeUCGAdd ) ; } 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 CNPIIJAekP { public static void main ( String ... args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String a = sc . next ( ) ; String b = sc . next ( ) ; int CNPIIJAekP = Integer . parseInt ( a + b ) ; int tmp = ( int ) Math . sqrt ( CNPIIJAekP ) ; if ( Math . pow ( tmp , 2 ) == CNPIIJAekP ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class KjYFfGVwHE { 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 KjYFfGVwHE = 0 ; KjYFfGVwHE < s . length ( ) ; KjYFfGVwHE ++ ) { if ( map . containsKey ( s . charAt ( KjYFfGVwHE ) ) ) { map . put ( s . charAt ( KjYFfGVwHE ) , map . get ( s . charAt ( KjYFfGVwHE ) ) + 1 ) ; } else { map . put ( s . charAt ( KjYFfGVwHE ) , 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 dOSdxDdfya { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dOSdxDdfya = 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 + dOSdxDdfya ) % 26 ] ; } } } System . out . println ( R [ s ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class bbGQOjWcAL { 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 bbGQOjWcAL = Integer . parseInt ( ss [ 0 ] ) ; int b = Integer . parseInt ( ss [ 1 ] ) ; System . out . print ( bbGQOjWcAL * b ) ; System . out . print ( " " ) ; System . out . println ( 2 * bbGQOjWcAL + 2 * b ) ; } } import java . util . * ; class rUxcziFUtn { 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 rUxcziFUtn = 0 ; rUxcziFUtn < 3 ; rUxcziFUtn ++ ) { arr [ rUxcziFUtn ] = Integer . parseInt ( aaa [ rUxcziFUtn ] ) ; } Arrays . sort ( arr ) ; System . out . println ( arr [ 2 ] - arr [ 0 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class yKTVnRIgFb { public static void main ( String [ ] args ) throws IOException { final int yKTVnRIgFb = 10 ; int [ ] a = new int [ yKTVnRIgFb ] ; InputStreamReader is = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( is ) ; for ( int i = 0 ; i < yKTVnRIgFb ; i ++ ) { a [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } for ( int i = 0 ; i < yKTVnRIgFb ; i ++ ) { for ( int j = i + 1 ; j < yKTVnRIgFb ; 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 HszEufSBGK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long HszEufSBGK = Long . parseLong ( sc . next ( ) ) ; long yokin = 100 ; int counter = 0 ; while ( ! ( yokin >= HszEufSBGK ) ) { yokin *= 1.01 ; counter ++ ; } System . out . println ( counter ) ; } } import java . util . Scanner ; public class fREABMvOVc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fREABMvOVc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int divisor = 0 ; for ( int i = 0 ; i <= ( b - fREABMvOVc ) ; i ++ ) { if ( c % ( fREABMvOVc + i ) == 0 ) { divisor += 1 ; } } System . out . println ( divisor ) ; sc . close ( ) ; } } import java . util . * ; public class aRwYFErmYr { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int aRwYFErmYr = in . nextInt ( ) ; long [ ] mo = new long [ aRwYFErmYr + 1 ] ; for ( int i = 0 ; i < aRwYFErmYr + 1 ; i ++ ) { mo [ i ] = in . nextInt ( ) ; } long sum = 0 ; long yu = 0 ; for ( int i = 0 ; i < aRwYFErmYr ; 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 fwgVYnvgqm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String fwgVYnvgqm = sc . next ( ) ; System . out . println ( " ABC " . equals ( fwgVYnvgqm ) ? " ARC " : " ABC " ) ; } } import java . util . * ; public class DxRNlZxSjP { private static void prin ( String ans ) { System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DxRNlZxSjP = sc . nextInt ( ) ; int upp = DxRNlZxSjP / 100 ; int downn = DxRNlZxSjP % 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 BvvQHxXmEF { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String W = br . readLine ( ) . toLowerCase ( ) ; int BvvQHxXmEF = 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 ) ) BvvQHxXmEF ++ ; } } System . out . println ( BvvQHxXmEF ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class bIPoVsupET { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int bIPoVsupET = Integer . parseInt ( in . readLine ( ) ) ; if ( bIPoVsupET < 0 || Math . pow ( 10 , 4 ) < bIPoVsupET ) throw new RuntimeException ( " error:range " ) ; String [ ] nums = new String [ bIPoVsupET ] ; nums = in . readLine ( ) . split ( " " ) ; int min = Integer . parseInt ( nums [ 0 ] ) , max = Integer . parseInt ( nums [ 0 ] ) ; long sum = 0 ; for ( int i = 0 ; i < bIPoVsupET ; 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 SbgNAuaqNd { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int SbgNAuaqNd = input . nextInt ( ) ; int M = input . nextInt ( ) ; int cnt = 0 ; System . out . println ( SbgNAuaqNd * ( SbgNAuaqNd - 1 ) / 2 + M * ( M - 1 ) / 2 ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class ZEUZZNTyAh { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; final String ZEUZZNTyAh = sc . next ( ) ; sc . close ( ) ; String ans = null ; switch ( ZEUZZNTyAh ) { 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 zeFHWBTbwK { 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 zeFHWBTbwK { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int zeFHWBTbwK = Integer . parseInt ( in . next ( ) + in . next ( ) ) ; for ( int i = 1 ; i < 10000 ; i ++ ) { if ( zeFHWBTbwK == i * i ) { out . println ( " Yes " ) ; return ; } } out . println ( " No " ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class tVotlANeeb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > x = new ArrayList < > ( ) ; for ( int tVotlANeeb = 0 ; tVotlANeeb < 5 ; tVotlANeeb ++ ) { x . add ( sc . nextInt ( ) ) ; } for ( Integer tVotlANeeb : x ) { if ( tVotlANeeb == 0 ) { System . out . println ( x . indexOf ( tVotlANeeb ) + 1 ) ; } } sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class XkwoDMuhAI { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int XkwoDMuhAI = 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 ( XkwoDMuhAI - ans ) > Math . abs ( XkwoDMuhAI - i ) ) { ans = i ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class igzUsyXCDT { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int igzUsyXCDT = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int C = scan . nextInt ( ) ; boolean flag = false ; if ( igzUsyXCDT == B && B != C ) { flag = true ; } if ( B == C && C != igzUsyXCDT ) { flag = true ; } if ( igzUsyXCDT == C && B != igzUsyXCDT ) { flag = true ; } if ( flag ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . IOException ; import java . util . Scanner ; public class RhHecYmuSa { 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 RhHecYmuSa = Integer . parseInt ( data [ 0 ] ) ; final int x = Integer . parseInt ( data [ 1 ] ) ; if ( RhHecYmuSa == 0 && x == 0 ) break ; int count = 0 ; for ( int i = 1 ; i <= RhHecYmuSa - 2 ; i ++ ) { for ( int j = i + 1 ; j <= RhHecYmuSa - 1 ; j ++ ) { for ( int k = j + 1 ; k <= RhHecYmuSa ; k ++ ) { if ( ( i + j + k ) == x ) count ++ ; } } } System . out . println ( count ) ; } } } import java . util . * ; class csfsZslIPI { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String csfsZslIPI = scan . next ( ) ; System . out . println ( csfsZslIPI . matches ( " [A][a-z][a-z]*[C][a-z]*[a-z] " ) ? " AC " : " WA " ) ; } } import java . util . Scanner ; public class SDjEAkkUtq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SDjEAkkUtq = sc . nextInt ( ) ; int [ ] d1 = new int [ SDjEAkkUtq ] ; int [ ] d2 = new int [ SDjEAkkUtq ] ; for ( int i = 0 ; i <= SDjEAkkUtq - 1 ; i ++ ) { d1 [ i ] = sc . nextInt ( ) ; d2 [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i <= SDjEAkkUtq - 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 == SDjEAkkUtq - 3 ) { System . out . println ( " No " ) ; } } sc . close ( ) ; } } import java . util . * ; public class TowosBEMuG { 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 TowosBEMuG = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == 'o' ) TowosBEMuG += 100 ; } System . out . println ( 700 + TowosBEMuG ) ; } 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 pyWAZufyCg { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int pyWAZufyCg = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; int [ ] dp = new int [ pyWAZufyCg ] ; for ( int i = 1 ; i < pyWAZufyCg ; 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 aghthinHAo { public static void main ( String [ ] args ) { Scanner Input = new Scanner ( System . in ) ; String A = Input . next ( ) ; String B = Input . next ( ) ; int aghthinHAo = 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 ) ) { aghthinHAo ++ ; } } System . out . println ( aghthinHAo ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; public class TWOgkudFvB { public static boolean TWOgkudFvB = 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 GfjSTwKzrm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GfjSTwKzrm = sc . nextInt ( ) ; int A_2 = sc . nextInt ( ) ; int A_3 = sc . nextInt ( ) ; int [ ] S = new int [ ] { GfjSTwKzrm , A_2 , A_3 } ; Arrays . sort ( S ) ; System . out . println ( ( S [ 2 ] - S [ 1 ] ) + ( S [ 1 ] - S [ 0 ] ) ) ; } } import java . util . * ; public class beZqUTTiCy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int beZqUTTiCy = sc . nextInt ( ) ; int [ ] x = new int [ beZqUTTiCy ] ; int [ ] y = new int [ beZqUTTiCy ] ; int sum = 0 ; for ( int i = 0 ; i < beZqUTTiCy ; i ++ ) { x [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < beZqUTTiCy ; i ++ ) { y [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < beZqUTTiCy ; i ++ ) { if ( x [ i ] >= y [ i ] ) { sum += x [ i ] - y [ i ] ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class INKXuZLGHd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int INKXuZLGHd = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int Z = sc . nextInt ( ) ; System . out . printf ( " %d %d %d " , Z , INKXuZLGHd , Y ) ; } } import java . io . * ; class cTbsndcUTR { 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 cTbsndcUTR = 0 ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { digit [ i ] = Character . getNumericValue ( str1 . charAt ( i ) ) ; cTbsndcUTR += digit [ i ] ; } if ( cTbsndcUTR == 0 ) { break ; } else System . out . println ( cTbsndcUTR ) ; } } } import java . util . Scanner ; class UNNQqdkwUu { public static void main ( String [ ] args ) { Scanner S = new Scanner ( System . in ) ; while ( true ) { int UNNQqdkwUu = S . nextInt ( ) ; int y = S . nextInt ( ) ; if ( UNNQqdkwUu == 0 && y == 0 ) break ; if ( UNNQqdkwUu < y ) System . out . printf ( " %d %d \n " , UNNQqdkwUu , y ) ; else System . out . printf ( " %d %d \n " , y , UNNQqdkwUu ) ; } } } import java . util . * ; public class sheDdcOozO { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int sheDdcOozO = in . nextInt ( ) ; StringBuilder ans ; int cnt = 0 ; for ( int i = 1 ; i <= sheDdcOozO ; i ++ ) { ans = new StringBuilder ( " " + i ) ; if ( ans . length ( ) % 2 != 0 ) { cnt ++ ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class KXPfzYafZL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int KXPfzYafZL = scan . nextInt ( ) ; int Y = scan . nextInt ( ) ; for ( int x = 0 ; x <= KXPfzYafZL ; x ++ ) { for ( int y = 0 ; y <= KXPfzYafZL - x ; y ++ ) { int total = x * 10000 + y * 5000 + 1000 * ( KXPfzYafZL - x - y ) ; if ( total == Y ) { System . out . println ( x + " " + y + " " + ( KXPfzYafZL - x - y ) ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . util . Scanner ; public class yrpfEEmtOu { 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 yrpfEEmtOu = 0 ; for ( int i = 2 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == 'C' ) { yrpfEEmtOu ++ ; } 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 ( yrpfEEmtOu == 1 ) { System . out . println ( " AC " ) ; } else { System . out . println ( " WA " ) ; } } } } import java . util . * ; public class iSQWqtWrlp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iSQWqtWrlp , i , j , count = 0 ; iSQWqtWrlp = Integer . parseInt ( sc . next ( ) ) ; int [ ] height = new int [ iSQWqtWrlp ] ; for ( i = 0 ; i < iSQWqtWrlp ; 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 gOkSToNlbV { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long gOkSToNlbV = scanner . nextLong ( ) ; String result = new String ( ) ; while ( gOkSToNlbV > 0 ) { int nums = ( int ) ( 'a' + ( gOkSToNlbV - 1 ) % 26 ) ; char temporal = ( char ) nums ; result = temporal + result ; gOkSToNlbV = gOkSToNlbV / 26 ; if ( temporal == 'z' ) gOkSToNlbV -- ; } System . out . print ( result ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class GqQPKQVhmG { public static boolean isPalindrome ( int n ) { String s = " " + n ; String a = " " ; for ( int GqQPKQVhmG = s . length ( ) - 1 ; GqQPKQVhmG >= 0 ; GqQPKQVhmG -- ) { a += s . charAt ( GqQPKQVhmG ) ; } 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 GqQPKQVhmG = a ; GqQPKQVhmG <= b ; GqQPKQVhmG ++ ) { if ( isPalindrome ( GqQPKQVhmG ) ) count ++ ; } System . out . println ( count ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class sLrGATHEyc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < String > list = new ArrayList < String > ( ) ; while ( true ) { String sLrGATHEyc = sc . nextLine ( ) ; if ( sLrGATHEyc . equals ( " 0 0 " ) ) { break ; } list . add ( sLrGATHEyc ) ; } for ( String sLrGATHEyc : list ) { String [ ] string = sLrGATHEyc . 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 zfmlLmcVak { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int zfmlLmcVak = sc . nextInt ( ) ; String input = sc . next ( ) ; if ( zfmlLmcVak % 2 == 1 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < zfmlLmcVak / 2 ; i ++ ) { if ( input . charAt ( i ) != input . charAt ( zfmlLmcVak / 2 + i ) ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class GUUuIFSwkK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String GUUuIFSwkK = sc . next ( ) ; char [ ] ss = GUUuIFSwkK . toCharArray ( ) ; if ( ss [ 0 ] + 0 >= 65 && ss [ 0 ] + 0 <= 90 ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . * ; public class AZlUTYEnEU { public static void main ( String [ ] args ) { int AZlUTYEnEU = 0 ; int count7 = 0 ; Scanner sc = new Scanner ( System . in ) ; String [ ] line = sc . nextLine ( ) . split ( " " ) ; for ( String n : line ) { if ( n . equals ( " 5 " ) ) { AZlUTYEnEU ++ ; } if ( n . equals ( " 7 " ) ) { count7 ++ ; } } if ( AZlUTYEnEU == 2 && count7 == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; class cEkrDtvCOH { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int cEkrDtvCOH = scn . nextInt ( ) ; String a = scn . next ( ) ; String b = scn . next ( ) ; String result = " " ; String [ ] c = new String [ cEkrDtvCOH ] ; String [ ] d = new String [ cEkrDtvCOH ] ; for ( int i = 0 ; i < cEkrDtvCOH ; 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 salsxfHfRy { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int salsxfHfRy = scn . nextInt ( ) ; int k = scn . nextInt ( ) ; int [ ] h = new int [ salsxfHfRy ] ; for ( int i = 0 ; i < salsxfHfRy ; i ++ ) { h [ i ] = scn . nextInt ( ) ; } Arrays . sort ( h ) ; long att = 0 ; for ( int i = 0 ; i < salsxfHfRy - k ; i ++ ) { att = att + h [ i ] ; } System . out . println ( att ) ; } } import java . util . * ; public class FCBJpEWpBL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FCBJpEWpBL = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int x = 0 ; if ( FCBJpEWpBL <= b ) { x = x + b ; if ( FCBJpEWpBL <= b - 1 ) { x = x + b - 1 ; } else { x = x + FCBJpEWpBL ; } } else { x = x + FCBJpEWpBL ; if ( b <= FCBJpEWpBL - 1 ) { x = x + FCBJpEWpBL - 1 ; } else { x = x + b ; } } System . out . println ( x ) ; } } import java . util . Scanner ; public class xSojMCTtXW { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xSojMCTtXW = scan . nextInt ( ) ; int h = xSojMCTtXW / 3600 ; int d = ( xSojMCTtXW % 3600 ) / 60 ; int s = ( xSojMCTtXW % 3600 ) % 60 ; System . out . println ( h + " : " + d + " : " + s ) ; scan . close ( ) ; } } import java . util . Scanner ; import java . util . ArrayList ; public class iIQyxeIbsP { public static void main ( String [ ] args ) { String [ ] lines = getStdin ( ) ; String [ ] inputs = lines [ 0 ] . split ( " " ) ; int iIQyxeIbsP = Integer . parseInt ( inputs [ 0 ] ) ; int y = Integer . parseInt ( inputs [ 1 ] ) ; System . out . println ( iIQyxeIbsP * 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 PSzDGmzPCt { 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 PSzDGmzPCt = sc . nextInt ( ) ; double d = 0.0 ; for ( int i = 0 ; i < PSzDGmzPCt ; 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 SSsrxpuAWa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Queue < Integer > queue = new ArrayDeque < > ( ) ; int SSsrxpuAWa = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; String [ ] name = new String [ SSsrxpuAWa ] ; int [ ] time = new int [ SSsrxpuAWa ] ; for ( int i = 0 ; i < SSsrxpuAWa ; 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 vPbnzLHknx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vPbnzLHknx = sc . nextInt ( ) ; int i = 1 ; int x = i ; int start = 0 ; while ( i <= vPbnzLHknx ) { 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 aENnxxlziK { static String a ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int aENnxxlziK = stdIn . nextInt ( ) ; int [ ] a = new int [ aENnxxlziK ] ; for ( int i = 0 ; i < aENnxxlziK ; i ++ ) { a [ i ] = stdIn . nextInt ( ) ; } show ( a , aENnxxlziK ) ; insertionSort ( a , aENnxxlziK ) ; } static void show ( int [ ] a , int aENnxxlziK ) { System . out . print ( a [ 0 ] ) ; for ( int i = 1 ; i < aENnxxlziK ; i ++ ) { System . out . print ( " " + a [ i ] ) ; } System . out . println ( ) ; } static void insertionSort ( int [ ] a , int aENnxxlziK ) { for ( int i = 1 ; i < aENnxxlziK ; 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 , aENnxxlziK ) ; } } } import java . util . Scanner ; public class nfdKgFiBsP { 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 nfdKgFiBsP = 0 ; nfdKgFiBsP < ch . length ; nfdKgFiBsP ++ ) { if ( Character . isAlphabetic ( ch [ nfdKgFiBsP ] ) ) { int x = ch [ nfdKgFiBsP ] - 'a' ; count [ x ] ++ ; } } } for ( int nfdKgFiBsP = 0 ; nfdKgFiBsP < count . length ; nfdKgFiBsP ++ ) { char x = ( char ) ( 'a' + nfdKgFiBsP ) ; System . out . print ( x + " : " ) ; System . out . println ( count [ nfdKgFiBsP ] ) ; } } } import java . util . * ; public class iHdrDtJmvn { private static final int iHdrDtJmvn = 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 wetuhMMBpF { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int wetuhMMBpF = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( wetuhMMBpF * b % 2 == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } scan . close ( ) ; } } import java . util . * ; public class PSokaKPeiL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PSokaKPeiL = sc . nextInt ( ) ; int [ ] h = new int [ PSokaKPeiL ] ; for ( int i = 0 ; i < PSokaKPeiL ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } if ( PSokaKPeiL == 2 ) { System . out . println ( Math . abs ( h [ 0 ] - h [ 1 ] ) ) ; return ; } int [ ] cost = new int [ PSokaKPeiL ] ; cost [ 0 ] = 0 ; cost [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 2 ; i < PSokaKPeiL ; 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 [ PSokaKPeiL - 1 ] ) ; } } import java . util . * ; public class JkVcSZisOq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double JkVcSZisOq = 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 ) == JkVcSZisOq && Math . floor ( i * rB ) == B ) { System . out . println ( i ) ; return ; } } System . out . println ( - 1 ) ; } } import java . util . Scanner ; class uVusYTOwVc { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int uVusYTOwVc = scan . nextInt ( ) ; int [ ] a = new int [ uVusYTOwVc + 1 ] ; int [ ] b = new int [ uVusYTOwVc ] ; for ( int i = 0 ; i < uVusYTOwVc + 1 ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < uVusYTOwVc ; i ++ ) { b [ i ] = scan . nextInt ( ) ; } long ans = 0 ; for ( int j = 0 ; j < uVusYTOwVc ; 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 gCHMPnTtoJ { 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 gCHMPnTtoJ = 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 ] ) { gCHMPnTtoJ ++ ; } } } } System . out . println ( gCHMPnTtoJ ) ; } } } import java . util . Scanner ; public class KKtBcmbiMC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KKtBcmbiMC = sc . nextInt ( ) ; for ( ; KKtBcmbiMC > 1 ; KKtBcmbiMC -- ) { for ( int i = 2 ; i < KKtBcmbiMC ; i ++ ) { int n = i * i ; if ( n > KKtBcmbiMC ) break ; while ( n <= KKtBcmbiMC ) { if ( n == KKtBcmbiMC ) { System . out . println ( KKtBcmbiMC ) ; return ; } n *= i ; } } } System . out . println ( KKtBcmbiMC ) ; } } import java . util . Scanner ; public class JdgUUduyWt { public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int JdgUUduyWt , b , c , hozon ; JdgUUduyWt = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; if ( JdgUUduyWt > b ) { hozon = JdgUUduyWt ; JdgUUduyWt = b ; b = hozon ; } if ( b > c ) { hozon = b ; b = c ; c = hozon ; } if ( JdgUUduyWt > b ) { hozon = JdgUUduyWt ; JdgUUduyWt = b ; b = hozon ; } System . out . println ( JdgUUduyWt + " " + 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 XEwvjpvMgI { public static void main ( String [ ] args ) { int XEwvjpvMgI , j ; Scanner sc = new Scanner ( in ) ; int n = parseInt ( sc . next ( ) ) ; String [ ] s = new String [ n ] ; for ( XEwvjpvMgI = 0 ; XEwvjpvMgI < n ; XEwvjpvMgI ++ ) { s [ XEwvjpvMgI ] = sc . next ( ) ; } sc . close ( ) ; String [ ] s2 ; for ( XEwvjpvMgI = 0 ; XEwvjpvMgI < n ; XEwvjpvMgI ++ ) { s2 = s [ XEwvjpvMgI ] . split ( " " ) ; Arrays . sort ( s2 ) ; s [ XEwvjpvMgI ] = String . join ( " " , s2 ) ; } HashMap < String , Integer > c = new HashMap < > ( ) ; for ( XEwvjpvMgI = 0 ; XEwvjpvMgI < n ; XEwvjpvMgI ++ ) { if ( c . containsKey ( s [ XEwvjpvMgI ] ) ) { c . put ( s [ XEwvjpvMgI ] , c . get ( s [ XEwvjpvMgI ] ) + 1 ) ; } else { c . put ( s [ XEwvjpvMgI ] , 1 ) ; } } long ans = 0 ; for ( Integer ii : c . values ( ) ) { ans += ( long ) ii * ( ii - 1 ) / 2 ; } out . println ( ans ) ; } } import java . util . * ; public class TuGMBWCZtl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long TuGMBWCZtl = Long . parseLong ( sc . next ( ) ) ; int sqrt = ( int ) Math . sqrt ( TuGMBWCZtl ) ; for ( int i = sqrt ; i >= 1 ; i -- ) { if ( TuGMBWCZtl % i == 0 ) { System . out . println ( i + TuGMBWCZtl / i - 2 ) ; break ; } } } } import java . util . * ; public class wYQAKcdTAP { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String wYQAKcdTAP = sc . next ( ) ; String ff = wYQAKcdTAP . substring ( 2 , 4 ) ; String ee = wYQAKcdTAP . 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 nClXrOrDZr { public static long [ ] num = new long [ 1023 ] ; public static int nClXrOrDZr = 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 wNlBzyHkpH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wNlBzyHkpH = sc . nextInt ( ) ; int [ ] d = new int [ wNlBzyHkpH ] ; long sum = 0 ; d [ 0 ] = sc . nextInt ( ) ; for ( int i = 1 ; i < wNlBzyHkpH ; 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 gwNFhGWfkE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gwNFhGWfkE = 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 dqYuCMdSXP { public static void main ( String [ ] args ) { long dqYuCMdSXP = 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 ] ) % dqYuCMdSXP ; } System . out . println ( S [ n ] ) ; } } import java . io . * ; import java . util . * ; class StVMWTpmCq { public static void main ( String [ ] args ) throws IOException { int StVMWTpmCq , 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 ) ) ; } StVMWTpmCq = 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 ) <= StVMWTpmCq && 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 eJmkloCoRl { 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 eJmkloCoRl = Integer . parseInt ( st . nextToken ( ) ) ; int ac = 0 , wa = 0 , tle = 0 , re = 0 ; for ( int i = 0 ; i < eJmkloCoRl ; 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 SDiAKxFAcM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SDiAKxFAcM = sc . nextInt ( ) ; int [ ] A = new int [ SDiAKxFAcM ] ; for ( int i = 0 ; i < SDiAKxFAcM ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int sortCount = 0 ; for ( int i = 0 ; i < SDiAKxFAcM ; i ++ ) { int flag = 0 ; int minj = i ; for ( int j = i ; j < SDiAKxFAcM ; 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 OruZztqAEg { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; long OruZztqAEg = stdIn . nextInt ( ) ; long b = stdIn . nextInt ( ) ; long c = stdIn . nextInt ( ) ; long d = stdIn . nextInt ( ) ; System . out . println ( Math . max ( OruZztqAEg * c , Math . max ( OruZztqAEg * d , Math . max ( b * c , b * d ) ) ) ) ; } } import java . util . Scanner ; public class etdxensggT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long etdxensggT = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; if ( K <= etdxensggT ) { etdxensggT = etdxensggT - K ; K = 0 ; } else { K = K - etdxensggT ; etdxensggT = 0 ; } if ( K <= B ) { B = B - K ; K = 0 ; } else { K = K - B ; B = 0 ; } System . out . println ( etdxensggT + " " + B ) ; } } import java . util . Scanner ; public class CdPOsumBCc { 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 CdPOsumBCc = 0 ; CdPOsumBCc < S . length ( ) ; CdPOsumBCc ++ ) { Sarr [ CdPOsumBCc ] = S . substring ( CdPOsumBCc ) + S . substring ( 0 , CdPOsumBCc ) ; } boolean result = false ; for ( int CdPOsumBCc = 0 ; CdPOsumBCc < S . length ( ) ; CdPOsumBCc ++ ) { if ( Sarr [ CdPOsumBCc ] . equals ( T ) ) { result = true ; break ; } } System . out . println ( result ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class ndllvoFJKp { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int ndllvoFJKp = sc . nextInt ( ) ; String S = sc . next ( ) ; char [ ] cs = S . toCharArray ( ) ; int count = 0 ; for ( int i = 0 ; i < ndllvoFJKp - 2 ; i ++ ) { if ( cs [ i ] == 'A' && cs [ i + 1 ] == 'B' && cs [ i + 2 ] == 'C' ) { count ++ ; } } System . out . println ( count ) ; } } } import java . util . * ; public class pXnZosHCeC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pXnZosHCeC = Integer . parseInt ( sc . next ( ) ) ; int [ ] ary = new int [ pXnZosHCeC ] ; 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 QQqlEHcQjE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QQqlEHcQjE = sc . nextInt ( ) ; int [ ] hairetu = new int [ QQqlEHcQjE ] ; 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 xDTZtMvdbH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xDTZtMvdbH = 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 ; xDTZtMvdbH ++ ; } System . out . println ( xDTZtMvdbH ) ; } } import java . util . Scanner ; public class vLCQRMEYXQ { void run ( ) { Scanner scan = new Scanner ( System . in ) ; double vLCQRMEYXQ = scan . nextDouble ( ) ; System . out . printf ( " %f %f \n " , vLCQRMEYXQ * vLCQRMEYXQ * Math . PI , 2 * Math . PI * vLCQRMEYXQ ) ; } 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 YvZbnQdzOU { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int YvZbnQdzOU = 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 <= YvZbnQdzOU ; 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 LctJKlkJLG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . nextLine ( ) ; String alp = " abcdefghijklmnopqrstuvwxyz " ; int LctJKlkJLG = alp . indexOf ( C ) ; System . out . println ( alp . charAt ( LctJKlkJLG + 1 ) ) ; } } import java . util . * ; public class dOjrnhtsup { public static void main ( String [ ] args ) { Scanner obj = new Scanner ( System . in ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; for ( int dOjrnhtsup = 0 ; dOjrnhtsup < 3 ; dOjrnhtsup ++ ) { a . add ( obj . nextInt ( ) ) ; } Collections . sort ( a ) ; int sum = a . get ( 0 ) + a . get ( 1 ) ; System . out . println ( sum ) ; } } import java . util . * ; class OhAZsParVO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long OhAZsParVO = sc . nextLong ( ) - 1 ; List < Integer > list = new ArrayList < > ( ) ; while ( OhAZsParVO > 25 ) { list . add ( ( int ) ( OhAZsParVO % 26 ) ) ; OhAZsParVO = OhAZsParVO / 26 - 1 ; } list . add ( ( int ) OhAZsParVO ) ; 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 rftkBpsKwo { public static void main ( String [ ] argv ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String t = scan . next ( ) ; int rftkBpsKwo = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; String u = scan . next ( ) ; if ( u . equals ( s ) ) rftkBpsKwo -- ; if ( u . equals ( t ) ) b -- ; System . out . println ( rftkBpsKwo + " " + b ) ; scan . close ( ) ; } } import java . util . * ; class VbFWAaYGWr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ns = sc . next ( ) ; String [ ] s = ns . split ( " " ) ; int VbFWAaYGWr = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( Integer . parseInt ( s [ i ] ) == 1 ) { VbFWAaYGWr ++ ; } } System . out . println ( VbFWAaYGWr ) ; } } import java . util . Scanner ; public class wipfjlMtjs { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int wipfjlMtjs = 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 < wipfjlMtjs ; 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 JRaUKeKNLs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int JRaUKeKNLs = scan . nextInt ( ) ; int ans = 0 ; int b = 1 ; ArrayList < Integer > list = new ArrayList ( ) ; while ( JRaUKeKNLs > 0 ) { list . add ( JRaUKeKNLs % 10 ) ; JRaUKeKNLs /= 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 VaklTDuJru { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String st = s . nextLine ( ) ; int VaklTDuJru = 0 ; for ( int i = 0 ; i < st . length ( ) ; i ++ ) { if ( st . charAt ( i ) == 'R' ) VaklTDuJru += 1 ; else if ( VaklTDuJru != 0 ) break ; } System . out . println ( VaklTDuJru ) ; } } import java . util . * ; public class ltQMPIuHZr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ltQMPIuHZr = 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 ( ltQMPIuHZr - set . size ( ) ) ; } } import java . util . * ; public class plJVpQGTNR { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } private void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; int plJVpQGTNR = scanner . nextInt ( ) ; int T = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; double nearOndo = 0 ; int nearIndex = 26 ; for ( int index = 0 ; index < plJVpQGTNR ; 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 WGTedMluCg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WGTedMluCg = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int pos = WGTedMluCg ; WGTedMluCg *= - 1 ; WGTedMluCg += 1 ; while ( WGTedMluCg < pos ) { System . out . print ( x + WGTedMluCg + " " ) ; WGTedMluCg ++ ; } } } import java . util . Scanner ; class UukoNRQqZE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String UukoNRQqZE = sc . next ( ) ; if ( UukoNRQqZE . matches ( " (dream|dreamer|erase|eraser)+? " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class rjyfDiIFvk { public static int rjyfDiIFvk ; public static int y ; public static int z ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; rjyfDiIFvk = sc . nextInt ( ) ; y = sc . nextInt ( ) ; if ( rjyfDiIFvk > y ) { solve ( rjyfDiIFvk , y ) ; } else { solve ( y , rjyfDiIFvk ) ; } 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 mvHhkizhTQ { static Scanner sc = new Scanner ( System . in ) ; static Scanner sc2 = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int mvHhkizhTQ = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] c = new int [ mvHhkizhTQ ] ; int [ ] t = new int [ mvHhkizhTQ ] ; int min = 10000 ; for ( int i = 0 ; i < mvHhkizhTQ ; i ++ ) { c [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < mvHhkizhTQ ; 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 SAUpcMMDIr { public static void main ( String ... args ) { final Scanner sc = new Scanner ( System . in ) ; final int SAUpcMMDIr = sc . nextInt ( ) ; final int b = sc . nextInt ( ) ; System . out . printf ( " %d %d \n " , SAUpcMMDIr * b , ( SAUpcMMDIr + b ) * 2 ) ; } } public class SAUpcMMDIr { public static void main ( String ... args ) { Rectangle . main ( ) ; } } import java . util . * ; import java . io . * ; public class fDoCngWKzy { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int fDoCngWKzy = Integer . parseInt ( br . readLine ( ) ) ; String [ ] Bstr = br . readLine ( ) . split ( " " ) ; int [ ] B = new int [ fDoCngWKzy - 1 ] ; for ( int i = 0 ; i < fDoCngWKzy - 1 ; i ++ ) { B [ i ] = Integer . parseInt ( Bstr [ i ] ) ; } int [ ] A = new int [ fDoCngWKzy ] ; int sum = 0 ; for ( int i = 0 ; i < fDoCngWKzy - 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 == fDoCngWKzy - 2 ) sum += A [ fDoCngWKzy - 1 ] ; } System . out . println ( sum ) ; } } import java . util . Scanner ; public class OsqnhavBrK { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int OsqnhavBrK = S . length ( ) ; int lastIndex = S . length ( ) ; char [ ] sArray = S . toCharArray ( ) ; for ( int i = 0 ; i < sArray . length ; i ++ ) { if ( sArray [ i ] == 'A' ) { OsqnhavBrK = i ; break ; } } for ( int i = 0 ; i < sArray . length ; i ++ ) { if ( sArray [ i ] == 'Z' ) lastIndex = i ; } System . out . println ( S . substring ( OsqnhavBrK , lastIndex + 1 ) . length ( ) ) ; sc . close ( ) ; } } import java . util . Scanner ; class pyCeHvRwoX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pyCeHvRwoX = sc . nextInt ( ) , sum = 0 ; double ave , tmpsum = 0 ; while ( pyCeHvRwoX != 0 ) { int [ ] s = new int [ pyCeHvRwoX ] ; for ( int i = 0 ; i < pyCeHvRwoX ; i ++ ) { s [ i ] = sc . nextInt ( ) ; sum += s [ i ] ; } ave = ( double ) sum / pyCeHvRwoX ; for ( int i = 0 ; i < pyCeHvRwoX ; i ++ ) tmpsum += ( s [ i ] - ave ) * ( s [ i ] - ave ) ; ave = tmpsum / pyCeHvRwoX ; System . out . println ( Math . sqrt ( ave ) ) ; sum = 0 ; tmpsum = 0 ; pyCeHvRwoX = sc . nextInt ( ) ; } } } import java . util . Scanner ; public class AatoXHfqws { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 5 ] ; boolean AatoXHfqws = 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 ) AatoXHfqws = true ; else { AatoXHfqws = false ; break out ; } } } if ( AatoXHfqws == true ) System . out . print ( " Yay! " ) ; else System . out . print ( " :( " ) ; } } import java . util . * ; public class HPQCWXirQI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HPQCWXirQI = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; double [ ] h = new double [ HPQCWXirQI ] ; for ( int i = 0 ; i < HPQCWXirQI ; i ++ ) { int b = sc . nextInt ( ) ; h [ i ] = t - b * 0.006 ; } double min = 1000000000 ; int ans = - 1 ; for ( int i = 0 ; i < HPQCWXirQI ; 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 wCbvjfEFZo { static class wCbvjfEFZo { 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 wCbvjfEFZo = 0 ; wCbvjfEFZo < w . length ( ) ; wCbvjfEFZo ++ ) { int k = w . charAt ( wCbvjfEFZo ) - 'a' ; arr [ k ] = arr [ k ] + 1 ; } for ( int wCbvjfEFZo = 0 ; wCbvjfEFZo < 26 ; wCbvjfEFZo ++ ) { if ( arr [ wCbvjfEFZo ] % 2 != 0 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; public class bEoiYWsQLR { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int bEoiYWsQLR = sc . nextInt ( ) ; int t , x , y , dis ; String ans = " Yes " ; for ( int i = 0 ; i < bEoiYWsQLR ; 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 NTpxLdMeCy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NTpxLdMeCy = 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 eIkOfqMvEO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eIkOfqMvEO = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; double [ ] Temp = new double [ eIkOfqMvEO ] ; double min = ( double ) Integer . MAX_VALUE ; int minNum = - 1 ; for ( int i = 0 ; i < eIkOfqMvEO ; 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 EVQznMMPDu { public static void main ( String [ ] hides ) { Scanner s = new Scanner ( System . in ) ; String EVQznMMPDu = s . next ( ) ; switch ( EVQznMMPDu ) { 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 OMutVWOYId { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; sc . close ( ) ; char [ ] c = s . toCharArray ( ) ; int OMutVWOYId = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) if ( c [ i ] == '1' ) OMutVWOYId = OMutVWOYId + 1 ; System . out . println ( OMutVWOYId ) ; } } import java . util . * ; public class ijUvPuWUiu { Scanner sc = new Scanner ( System . in ) ; final int ijUvPuWUiu = 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 ] ) % ijUvPuWUiu ; } if ( i + 2 < n ) { dp [ i + 2 ] = ( dp [ i + 2 ] + dp [ i ] ) % ijUvPuWUiu ; } } } System . out . println ( dp [ n - 1 ] ) ; } public static void main ( String [ ] args ) { new Main ( ) . doIt ( ) ; } } import java . util . * ; import java . lang . * ; public class ybevNIMNeS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ybevNIMNeS = sc . nextLine ( ) ; if ( ybevNIMNeS . charAt ( 1 ) == 'R' ) System . out . println ( " ABC " ) ; else System . out . println ( " ARC " ) ; } } import java . util . * ; public class KZXbMzPZfO { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; long KZXbMzPZfO = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long divc = b / c - ( KZXbMzPZfO - 1 ) / c ; long divd = b / d - ( KZXbMzPZfO - 1 ) / d ; long lcmcd = lcm ( c , d ) ; long divcd = b / lcmcd - ( KZXbMzPZfO - 1 ) / lcmcd ; System . out . println ( ( b - KZXbMzPZfO + 1 ) - divc - divd + divcd ) ; } private static long gcd ( long KZXbMzPZfO , long b ) { while ( b > 0 ) { long temp = b ; b = KZXbMzPZfO % b ; KZXbMzPZfO = temp ; } return KZXbMzPZfO ; } private static long lcm ( long KZXbMzPZfO , long b ) { return KZXbMzPZfO * ( b / gcd ( KZXbMzPZfO , b ) ) ; } } import java . util . Scanner ; public class DfVnhulvoQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DfVnhulvoQ = sc . nextInt ( ) ; int ans = 0 ; sc . close ( ) ; for ( int i = 1 ; i <= DfVnhulvoQ ; i += 2 ) { if ( numYaku8 ( i ) ) ans += 1 ; } System . out . println ( ans ) ; } private static boolean numYaku8 ( int DfVnhulvoQ ) { int yaku = 0 ; for ( int i = 1 ; i <= DfVnhulvoQ ; i ++ ) { if ( DfVnhulvoQ % i == 0 ) yaku += 1 ; } if ( yaku == 8 ) return true ; return false ; } } import java . util . * ; class lPeCSTkhcD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lPeCSTkhcD = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sho = 0 ; int amrS = 0 ; int ans = 0 ; for ( int i = 1 ; i < lPeCSTkhcD + 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 AiNIVbmxPl { 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 AiNIVbmxPl ; int val = strArraySub . length ; for ( int i = 1 ; i <= val ; i ++ ) { AiNIVbmxPl = val - i ; System . out . print ( strArraySub [ AiNIVbmxPl ] ) ; } System . out . println ( " " ) ; } } import java . util . * ; public class AIMOmWMvtL { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; int AIMOmWMvtL = 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 < AIMOmWMvtL ) ? " No " : " Yes " ) ; ob . close ( ) ; } } import java . util . * ; public class jvXgvCsJCv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jvXgvCsJCv = Integer . parseInt ( sc . nextLine ( ) ) ; StringTokenizer dates = new StringTokenizer ( sc . nextLine ( ) ) ; StringTokenizer dates2 = new StringTokenizer ( sc . nextLine ( ) ) ; int mayor = 0 ; for ( int i = 0 ; i < jvXgvCsJCv ; 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 LzXDeiEaVd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LzXDeiEaVd = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; long i = LzXDeiEaVd * x + b * y ; long ii = c * 2 * Math . max ( x , y ) ; long iii = 0 ; if ( x > y ) { iii = c * 2 * y + LzXDeiEaVd * ( 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 ENBxOUAGjA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int ENBxOUAGjA = sc . nextInt ( ) ; int [ ] a = new int [ ENBxOUAGjA ] ; for ( int i = 0 ; i < ENBxOUAGjA ; 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 < ENBxOUAGjA ; j ++ ) { System . out . println ( a [ j ] ) ; } } } } import java . util . * ; public class qkNxibJKrO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qkNxibJKrO = sc . nextInt ( ) ; char [ ] [ ] s = new char [ qkNxibJKrO ] [ 10 ] ; HashMap < String , Long > h = new HashMap < > ( ) ; long ans = 0 ; for ( int i = 0 ; i < qkNxibJKrO ; 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 CwrhUvBIHo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long CwrhUvBIHo = scan . nextInt ( ) ; scan . close ( ) ; System . out . println ( CwrhUvBIHo / 2 + CwrhUvBIHo % 2 ) ; } } import java . util . Scanner ; public class SyltOhmIEO { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int SyltOhmIEO , b , c ; Scanner sc = new Scanner ( System . in ) ; String [ ] input = sc . nextLine ( ) . split ( " " ) ; SyltOhmIEO = Integer . parseInt ( input [ 0 ] ) ; b = Integer . parseInt ( input [ 1 ] ) ; c = Integer . parseInt ( input [ 2 ] ) ; int cnt = 0 ; for ( int i = SyltOhmIEO ; i <= b ; i ++ ) { if ( c % i == 0 ) cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . * ; public class nHaIcNKUBe { 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 nHaIcNKUBe = scn . nextInt ( ) ; nHaIcNKUBe > 0 ; nHaIcNKUBe -- ) { 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 LhEBVGUQlV { public static void main ( String [ ] args ) { Scanner Sc = new Scanner ( System . in ) ; String LhEBVGUQlV = Sc . next ( ) ; if ( LhEBVGUQlV . contains ( " 7 " ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class joTzbLobsV { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long joTzbLobsV = scan . nextLong ( ) ; long value2 = ( long ) ( scan . nextDouble ( ) * 100 + 0.001 ) ; long sum = joTzbLobsV * value2 / 100 ; scan . close ( ) ; System . out . println ( sum ) ; } } import java . util . * ; public class mAXbvOpwjo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] str = sc . next ( ) . toCharArray ( ) ; int mAXbvOpwjo = 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' ) { mAXbvOpwjo ++ ; } } System . out . println ( mAXbvOpwjo == 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 ZwwIeBKZRn { 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 ZwwIeBKZRn { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int ZwwIeBKZRn = in . nextInt ( ) ; int b = in . nextInt ( ) ; if ( ZwwIeBKZRn == b ) out . println ( 0 ) ; else if ( ( ZwwIeBKZRn + b ) % 2 == 1 ) out . println ( " IMPOSSIBLE " ) ; else out . println ( ( ZwwIeBKZRn + b ) / 2 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class wnXdstKyyF { 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 wnXdstKyyF = 0 ; wnXdstKyyF < 10 ; wnXdstKyyF ++ ) { input [ wnXdstKyyF ] = Integer . parseInt ( br . readLine ( ) ) ; checked [ wnXdstKyyF ] = false ; } for ( int wnXdstKyyF = 0 ; wnXdstKyyF < 3 ; wnXdstKyyF ++ ) { 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 IhWMRhSbGI { 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 IhWMRhSbGI = 0 ; for ( int i = 0 ; i < line_S . length ; i ++ ) { if ( line_S [ i ] . compareTo ( line_T [ i ] ) != 0 ) { IhWMRhSbGI ++ ; } } System . out . println ( IhWMRhSbGI ) ; } } import java . util . * ; import java . io . * ; import java . lang . * ; public class JwTwYZCdYq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JwTwYZCdYq = sc . nextInt ( ) ; ArrayList < Integer > arr = new ArrayList < > ( ) ; int ans = 0 ; for ( int i = 0 ; i < JwTwYZCdYq ; i ++ ) { int a = sc . nextInt ( ) ; arr . add ( a ) ; } for ( int i = 1 ; i < ( JwTwYZCdYq - 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 dGZvBXpPQa { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int dGZvBXpPQa = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { for ( int j = i ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( i ) == t . charAt ( j ) ) dGZvBXpPQa ++ ; break ; } } System . out . print ( dGZvBXpPQa ) ; } } import java . util . Scanner ; public class AlvwgBINDc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long AlvwgBINDc = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long lcm = c * d / gcd ( c , d ) ; long u = b - AlvwgBINDc + 1 ; long cs = b / c - ( AlvwgBINDc - 1 ) / c ; long ds = b / d - ( AlvwgBINDc - 1 ) / d ; long lcms = b / lcm - ( AlvwgBINDc - 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 lHRqsslWqA { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String lHRqsslWqA = stdIn . next ( ) ; if ( lHRqsslWqA . equals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } else { System . out . println ( " ABC " ) ; } stdIn . close ( ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class gtFnCgJwXp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int gtFnCgJwXp = scanner . nextInt ( ) ; int next = 1 ; int [ ] a = new int [ gtFnCgJwXp ] ; HashSet < Integer > hSet = new HashSet < > ( ) ; for ( int i = 0 ; i < gtFnCgJwXp ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < gtFnCgJwXp ; 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 DiIICftbGb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DiIICftbGb = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) , d = sc . nextInt ( ) , e = sc . nextInt ( ) , k = sc . nextInt ( ) ; String res = " Yay! " ; if ( e - DiIICftbGb > k ) { res = " :( " ; } System . out . println ( res ) ; } } import java . util . Scanner ; public class sWgOKQZyKk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int sWgOKQZyKk = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int plus = sWgOKQZyKk + b ; int minus = sWgOKQZyKk - b ; int multiplied = sWgOKQZyKk * 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 cNWOpdqwkR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int cNWOpdqwkR = 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 ( cNWOpdqwkR > tmp ) { cNWOpdqwkR = tmp ; } } System . out . println ( cNWOpdqwkR ) ; } } } import java . util . * ; class uMkOwEtZZJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uMkOwEtZZJ = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] L = new int [ uMkOwEtZZJ ] ; int [ ] D = new int [ uMkOwEtZZJ + 1 ] ; D [ 0 ] = 0 ; for ( int i = 0 ; i < uMkOwEtZZJ ; i ++ ) { L [ i ] = sc . nextInt ( ) ; } int ans = 1 ; for ( int i = 1 ; i <= uMkOwEtZZJ ; i ++ ) { D [ i ] = D [ i - 1 ] + L [ i - 1 ] ; if ( D [ i ] <= X ) { ans += 1 ; } } System . out . println ( ans ) ; } } import java . util . * ; public class kXeTfpIXjW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long kXeTfpIXjW = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long C = sc . nextLong ( ) ; long D = sc . nextLong ( ) ; System . out . println ( count ( B , C , D ) - count ( kXeTfpIXjW - 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 SlyNOtAoxa { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int SlyNOtAoxa = 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 EhlBriLYTr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EhlBriLYTr = scan . nextInt ( ) ; while ( EhlBriLYTr > 0 ) { int sum = 0 ; int [ ] s = new int [ EhlBriLYTr ] ; for ( int i = 0 ; i < EhlBriLYTr ; i ++ ) { s [ i ] = scan . nextInt ( ) ; sum += s [ i ] ; } double ave = ( double ) sum / EhlBriLYTr ; double HF = 0 ; for ( int i = 0 ; i < EhlBriLYTr ; i ++ ) { HF += ( ave - s [ i ] ) * ( ave - s [ i ] ) ; } HF /= ( double ) EhlBriLYTr ; HF = Math . pow ( HF , 0.5 ) ; System . out . println ( HF ) ; EhlBriLYTr = scan . nextInt ( ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class deCATqlMCP { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int deCATqlMCP = scn . nextInt ( ) ; int b = scn . nextInt ( ) ; int c = scn . nextInt ( ) ; int [ ] arr = { deCATqlMCP , 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 NickDgtygY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NickDgtygY = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; double v = t + 0.5 ; int p = 0 ; p = ( int ) v / NickDgtygY ; int r = 0 ; r = ( int ) p * b ; System . out . println ( r ) ; } } import java . util . * ; public class TjJPjQoPRD { Scanner sc ; int TjJPjQoPRD ; int [ ] v ; public Main ( ) { sc = new Scanner ( System . in ) ; } private void calc ( ) { TjJPjQoPRD = sc . nextInt ( ) ; v = new int [ TjJPjQoPRD ] ; for ( int i = 0 ; i < TjJPjQoPRD ; i ++ ) v [ i ] = sc . nextInt ( ) ; Arrays . sort ( v ) ; double ans = ( double ) v [ 0 ] ; for ( int i = 1 ; i < TjJPjQoPRD ; 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 KAhnFnFTNP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KAhnFnFTNP = sc . nextInt ( ) ; if ( KAhnFnFTNP == 1 ) { System . out . println ( 0 ) ; } else { int Ans = 0 ; int Temp = 0 ; int [ ] H = new int [ KAhnFnFTNP ] ; for ( int i = 0 ; i < KAhnFnFTNP ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < KAhnFnFTNP - 1 ; i ++ ) { if ( H [ i ] >= H [ i + 1 ] ) { Temp += 1 ; } if ( ( H [ i ] < H [ i + 1 ] ) | ( i == KAhnFnFTNP - 2 ) ) { if ( Ans < Temp ) { Ans = Temp ; } Temp = 0 ; } } System . out . println ( Ans ) ; } sc . close ( ) ; } } import java . io . * ; class pGSugZYjGt { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String taro , hanako , str ; int pGSugZYjGt = 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 ) pGSugZYjGt += 3 ; else { pGSugZYjGt ++ ; sh ++ ; } } System . out . println ( pGSugZYjGt + " " + sh ) ; } } import java . util . Scanner ; public class PDmqnVPuMp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PDmqnVPuMp = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int product = PDmqnVPuMp * l ; int around = 2 * ( PDmqnVPuMp + l ) ; System . out . println ( product + " " + around ) ; } } import java . util . Scanner ; public class TCfRdoXOBr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TCfRdoXOBr = 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 lLuSnAHPDs { public static void main ( String [ ] args ) { int lLuSnAHPDs ; int [ ] A1i ; int [ ] A2i ; Set < Integer > searched = new HashSet < > ( ) ; Queue < Integer > queue = new LinkedList < > ( ) ; try ( Scanner sc = new Scanner ( System . in ) ) { lLuSnAHPDs = sc . nextInt ( ) ; A1i = new int [ lLuSnAHPDs ] ; A2i = new int [ lLuSnAHPDs ] ; for ( int i = 0 ; i < lLuSnAHPDs ; i ++ ) { A1i [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < lLuSnAHPDs ; i ++ ) { A2i [ i ] = sc . nextInt ( ) ; } } int [ ] Sum1 = new int [ lLuSnAHPDs ] ; int sum1 = 0 ; for ( int i = 0 ; i < lLuSnAHPDs ; i ++ ) { sum1 += A1i [ i ] ; Sum1 [ i ] = sum1 ; } int [ ] Sum2 = new int [ lLuSnAHPDs ] ; int sum2 = 0 ; for ( int i = lLuSnAHPDs - 1 ; i >= 0 ; i -- ) { sum2 += A2i [ i ] ; Sum2 [ i ] = sum2 ; } int result = 0 ; for ( int i = 0 ; i < lLuSnAHPDs ; i ++ ) { if ( result < Sum1 [ i ] + Sum2 [ i ] ) { result = Sum1 [ i ] + Sum2 [ i ] ; } } System . out . println ( result ) ; } } import java . util . * ; public class ayCKugXbJL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ayCKugXbJL = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; if ( ayCKugXbJL <= C && B <= C ) { System . out . println ( " 0 " ) ; } else if ( ayCKugXbJL <= C && B <= D ) { System . out . println ( B - C ) ; } else if ( ayCKugXbJL <= C && B > D ) { System . out . println ( D - C ) ; } else if ( ayCKugXbJL > C && D <= ayCKugXbJL ) { System . out . println ( " 0 " ) ; } else if ( ayCKugXbJL > C && B >= D ) { System . out . println ( D - ayCKugXbJL ) ; } else { System . out . println ( B - ayCKugXbJL ) ; } } } import java . util . Scanner ; public class XWwkSmEoPn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; char [ ] s = scanner . next ( ) . toCharArray ( ) ; for ( int XWwkSmEoPn = 1 ; XWwkSmEoPn < 3 ; XWwkSmEoPn ++ ) { if ( s [ XWwkSmEoPn ] != s [ XWwkSmEoPn - 1 ] ) { System . out . println ( " Yes " ) ; return ; } } System . out . println ( " No " ) ; } } import java . util . Scanner ; public class BQpweDmYWY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BQpweDmYWY = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int sum = l * BQpweDmYWY ; int [ ] aji = new int [ BQpweDmYWY ] ; for ( int i = 0 ; i < BQpweDmYWY ; i ++ ) { sum += i ; aji [ i ] = l + i ; } int min = Integer . MAX_VALUE / 2 ; int aji2 = 0 ; for ( int i = 0 ; i < BQpweDmYWY ; 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 IkzhNwfiIg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String alpha = " abcdefghijklmnopqrstuvwxyz " ; String target = sc . next ( ) ; for ( int IkzhNwfiIg = 0 ; IkzhNwfiIg <= 24 ; IkzhNwfiIg ++ ) { if ( String . valueOf ( alpha . charAt ( IkzhNwfiIg ) ) . equals ( target ) ) { System . out . println ( alpha . charAt ( IkzhNwfiIg + 1 ) ) ; } } } } import java . util . * ; public class Bxxsjybqkk { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int Bxxsjybqkk = s . nextInt ( ) , x = s . nextInt ( ) , t = s . nextInt ( ) ; int count = 0 ; count = Bxxsjybqkk / x * t ; if ( Bxxsjybqkk % x > 0 ) count += t ; System . out . println ( count ) ; } } import java . util . Scanner ; public class PWiXvzaizo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int PWiXvzaizo = scan . nextInt ( ) ; int taro = 0 ; int hanako = 0 ; for ( int i = 0 ; i < PWiXvzaizo ; 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 eDOXbyYsUD { 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 eDOXbyYsUD = Integer . parseInt ( line [ 0 ] ) ; int W = Integer . parseInt ( line [ 1 ] ) ; if ( eDOXbyYsUD != 0 && W != 0 ) { String yoko = Wwrite ( W ) ; Hwrite ( eDOXbyYsUD , 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 eDOXbyYsUD , String yoko ) { for ( int i = 0 ; i < eDOXbyYsUD ; i ++ ) { System . out . println ( yoko ) ; } } } import java . util . * ; public class VFskWpibMr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int VFskWpibMr = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( VFskWpibMr + VFskWpibMr * VFskWpibMr + VFskWpibMr * VFskWpibMr * VFskWpibMr ) ; } } import java . util . * ; public class ZgQMhOxrzB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZgQMhOxrzB = sc . nextInt ( ) ; int [ ] res = new int [ ZgQMhOxrzB ] ; 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 RoohnlWIDc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String RoohnlWIDc = sc . next ( ) ; String [ ] ar = RoohnlWIDc . split ( " " ) ; for ( String s : ar ) { if ( s . equals ( " 1 " ) ) { System . out . print ( 9 ) ; } else { System . out . print ( 1 ) ; } } } } import java . util . Scanner ; public class bnitSxOdbZ { static void putArray ( int [ ] array ) { System . out . print ( array [ 0 ] ) ; for ( int bnitSxOdbZ = 1 ; bnitSxOdbZ < array . length ; bnitSxOdbZ ++ ) { System . out . print ( " " + array [ bnitSxOdbZ ] ) ; } 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 bnitSxOdbZ = 0 ; bnitSxOdbZ < array . length ; bnitSxOdbZ ++ ) { array [ bnitSxOdbZ ] = sc . nextInt ( ) ; } putArray ( array ) ; for ( int bnitSxOdbZ = 1 ; bnitSxOdbZ < array . length ; bnitSxOdbZ ++ ) { int v = array [ bnitSxOdbZ ] ; int j = bnitSxOdbZ - 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 ibJViuwHsG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ibJViuwHsG = scan . nextInt ( ) ; int i = 0 ; int taro_count = 0 ; int hana_count = 0 ; for ( i = 0 ; i < ibJViuwHsG ; 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 GBMAVHpfWP { public static int [ ] ans ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GBMAVHpfWP = sc . nextInt ( ) ; int [ ] list = new int [ GBMAVHpfWP ] ; for ( int i = 0 ; i < GBMAVHpfWP ; i ++ ) { list [ i ] = sc . nextInt ( ) ; } int count = 0 ; boolean flag = true ; while ( flag ) { for ( int i = 0 ; i < GBMAVHpfWP ; i ++ ) { if ( list [ i ] % 2 == 1 ) { flag = false ; } list [ i ] = list [ i ] / 2 ; if ( i == GBMAVHpfWP - 1 && flag ) { count ++ ; } } } System . out . println ( count ) ; } } import java . math . BigInteger ; import java . util . * ; public class lLkAtEKmdV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; long lLkAtEKmdV = sc . nextLong ( ) ; BigInteger K = BigInteger . valueOf ( lLkAtEKmdV ) ; 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 vfpdOsGedX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vfpdOsGedX = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long x = 1 ; long n = 0 ; while ( true ) { n = vfpdOsGedX * x ; if ( n % b == 0 ) { break ; } x ++ ; } System . out . println ( n ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class kMLGZzfbZN { 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 kMLGZzfbZN = Integer . parseInt ( arr [ 0 ] ) ; int x = Integer . parseInt ( arr [ 1 ] ) ; if ( kMLGZzfbZN == 0 && x == 0 ) break ; int cnt = 0 ; for ( int i = 1 ; i <= kMLGZzfbZN ; i ++ ) { for ( int j = i + 1 ; j <= kMLGZzfbZN ; j ++ ) { for ( int k = j + 1 ; k <= kMLGZzfbZN ; 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 TLzWUEHJxz { 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 TLzWUEHJxz = 0 ; TLzWUEHJxz < intarray . length ; TLzWUEHJxz ++ ) { intarray [ TLzWUEHJxz ] = Integer . parseInt ( strarray [ TLzWUEHJxz ] ) ; } return intarray ; } static Integer [ ] inputvalInteger ( ) throws Exception { String [ ] strarray = br . readLine ( ) . trim ( ) . split ( " " ) ; Integer [ ] intarray = new Integer [ strarray . length ] ; for ( int TLzWUEHJxz = 0 ; TLzWUEHJxz < intarray . length ; TLzWUEHJxz ++ ) { intarray [ TLzWUEHJxz ] = Integer . parseInt ( strarray [ TLzWUEHJxz ] ) ; } return intarray ; } public static void main ( String [ ] args ) throws Exception { int n = Integer . parseInt ( br . readLine ( ) . trim ( ) ) ; HashSet < Integer > st = new HashSet < > ( ) ; for ( int TLzWUEHJxz = 0 ; TLzWUEHJxz < n ; TLzWUEHJxz ++ ) { int d = Integer . parseInt ( br . readLine ( ) . trim ( ) ) ; st . add ( d ) ; } System . out . println ( st . size ( ) ) ; } } import java . util . Scanner ; public class MSmEwbFWja { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String MSmEwbFWja = scanner . next ( ) ; switch ( MSmEwbFWja ) { 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 AYaKgEsVAP { 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 AYaKgEsVAP = input . length ; AYaKgEsVAP > 0 ; AYaKgEsVAP -- ) { System . out . print ( input [ AYaKgEsVAP - 1 ] ) ; } System . out . println ( ) ; } } } public class vijXnsnWIG { public static void main ( String [ ] args ) { java . util . Scanner cin = new java . util . Scanner ( System . in ) ; int vijXnsnWIG ; for ( vijXnsnWIG = cin . nextInt ( ) ; vijXnsnWIG != 0 ; -- vijXnsnWIG ) { 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 FJsWYhlUOa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int FJsWYhlUOa = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; if ( FJsWYhlUOa == - 1 && f == - 1 && r == - 1 ) { break ; } if ( FJsWYhlUOa == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } else { int S = FJsWYhlUOa + 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 aEkMpPbAGE { 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 aEkMpPbAGE = Integer . parseInt ( scan . next ( ) ) ; for ( int i = 0 ; i < aEkMpPbAGE ; 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 iKLxzfEMTI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iKLxzfEMTI = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String q = " Odd " ; if ( iKLxzfEMTI % 2 == 0 || b % 2 == 0 ) { q = " Even " ; } System . out . println ( q ) ; } } import java . util . Scanner ; public class nKpHdyCCSk { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int nKpHdyCCSk = scn . nextInt ( ) ; int ans = 0 ; int num = 0 ; while ( nKpHdyCCSk / ( 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 += nKpHdyCCSk - Math . pow ( 10 , num - 1 ) + 1 ; } System . out . println ( ans ) ; } } import java . util . * ; public class BXKntOhTmv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BXKntOhTmv = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; int sum = L * BXKntOhTmv + ( BXKntOhTmv * ( BXKntOhTmv - 1 ) ) / 2 ; if ( L > 0 ) sum -= L ; else if ( L + BXKntOhTmv - 1 < 0 ) sum -= L + BXKntOhTmv - 1 ; System . out . println ( sum ) ; sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class VxkDqvzwos { 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 VxkDqvzwos = sc . nextInt ( ) ; sc . close ( ) ; Arrays . parallelSort ( a ) ; for ( int i = 0 ; i < VxkDqvzwos ; 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 FlejNqkWXj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FlejNqkWXj = sc . nextInt ( ) ; List < String > list = new ArrayList < String > ( ) ; for ( int i = 0 ; FlejNqkWXj > 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 pmIZcIBVoW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] a = new int [ 3 ] [ 3 ] ; for ( int pmIZcIBVoW = 0 ; pmIZcIBVoW < 3 ; pmIZcIBVoW ++ ) for ( int j = 0 ; j < 3 ; j ++ ) a [ pmIZcIBVoW ] [ 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 bUIgAOdVyY { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int bUIgAOdVyY = scan . nextInt ( ) ; int cnt = 0 ; boolean a = bUIgAOdVyY > 99 ; if ( a ) { cnt ++ ; bUIgAOdVyY = bUIgAOdVyY - 100 ; } boolean b = bUIgAOdVyY > 9 ; if ( b ) { bUIgAOdVyY = bUIgAOdVyY - 10 ; cnt ++ ; } boolean c = bUIgAOdVyY == 1 ; if ( c ) { cnt ++ ; } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class FYpsQdkXsJ { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int [ ] list = new int [ 9 ] ; int FYpsQdkXsJ = scanner . nextInt ( ) ; for ( int i = 0 ; i < FYpsQdkXsJ ; 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 FJMKMNSJjn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FJMKMNSJjn = sc . nextInt ( ) ; int max = 1 ; String w = " " ; Map < String , Integer > map = new HashMap < > ( ) ; List < String > strArr = new ArrayList < > ( ) ; for ( int i = 0 ; i < FJMKMNSJjn ; 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 zXFlNKlxUx { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int zXFlNKlxUx = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int A = 0 ; for ( int i = 0 ; i < N ; i ++ ) { A += sc . nextInt ( ) ; } System . out . println ( zXFlNKlxUx > A ? " No " : " Yes " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class OOQwkhXvvq { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . OOQwkhXvvq ) ) ) { int OOQwkhXvvq = Integer . parseInt ( br . readLine ( ) ) ; System . out . println ( OOQwkhXvvq * 2 * Math . PI ) ; } } } import java . util . * ; public class QlMJImicjC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int QlMJImicjC = s . length ( ) ; int tlen = t . length ( ) ; int min = 10000 ; for ( int i = 0 ; i < QlMJImicjC - 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 cwQvDubClD { public static void main ( String ... args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int cwQvDubClD = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ cwQvDubClD ] ; for ( int i = 0 ; i < cwQvDubClD ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int [ ] dp = new int [ cwQvDubClD ] ; for ( int i = 0 ; i < cwQvDubClD ; 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 [ cwQvDubClD - 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 QtYONJLUVa { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QtYONJLUVa = scan . nextInt ( ) ; int q = scan . nextInt ( ) ; int r = scan . nextInt ( ) ; int [ ] a = { QtYONJLUVa , q , r } ; Arrays . sort ( a ) ; System . out . println ( a [ 0 ] + a [ 1 ] ) ; } } import java . util . * ; public class yaFZrnKDfU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yaFZrnKDfU = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int [ ] [ ] X = new int [ yaFZrnKDfU ] [ D ] ; for ( int i = 0 ; i < yaFZrnKDfU ; 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 < yaFZrnKDfU ; i ++ ) { for ( int j = i ; j < yaFZrnKDfU ; 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 flHlorJpae { public static void main ( String [ ] args ) throws java . lang . Exception { PrintWriter out = new PrintWriter ( System . out ) ; FastScanner fs = new FastScanner ( ) ; long flHlorJpae = fs . nextLong ( ) ; double b = fs . nextDouble ( ) ; BigDecimal bg1 = BigDecimal . valueOf ( flHlorJpae ) ; BigDecimal bg2 = BigDecimal . valueOf ( b ) ; out . println ( bg1 . multiply ( bg2 ) . setScale ( 0 , RoundingMode . DOWN ) ) ; out . close ( ) ; } static class flHlorJpae { 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 [ ] flHlorJpae = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) flHlorJpae [ i ] = nextInt ( ) ; return flHlorJpae ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } } import java . util . Scanner ; public class ZbceoaghrI { public static void main ( String [ ] args ) { Scanner kb = new Scanner ( System . in ) ; int ZbceoaghrI = kb . nextInt ( ) ; int [ ] [ ] a = new int [ ZbceoaghrI ] [ 3 ] ; int x , y , z ; for ( int i = 0 ; i < ZbceoaghrI ; i ++ ) { a [ i ] [ 0 ] = kb . nextInt ( ) ; a [ i ] [ 1 ] = kb . nextInt ( ) ; a [ i ] [ 2 ] = kb . nextInt ( ) ; } for ( int i = 0 ; i < ZbceoaghrI ; 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 SyfqxlMNtF { public static void main ( String [ ] args ) { run ( ) ; } static void run ( ) { Scanner sc = new Scanner ( System . in ) ; int SyfqxlMNtF = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int ans = isDivisor ( SyfqxlMNtF , b , c ) ; System . out . println ( ans ) ; } static int isDivisor ( int SyfqxlMNtF , int b , int c ) { int ans = 0 ; for ( int i = SyfqxlMNtF ; i <= b ; i ++ ) { if ( c % i == 0 ) { ans ++ ; } } return ans ; } } import java . util . HashMap ; import java . util . Scanner ; public class pBsAuOhoRX { public static void main ( String [ ] args ) { HashMap < String , String > map = new HashMap < String , String > ( ) ; Scanner sc = new Scanner ( System . in ) ; int pBsAuOhoRX = sc . nextInt ( ) ; String str = sc . nextLine ( ) ; for ( int i = 0 ; i < pBsAuOhoRX ; i ++ ) { map . put ( sc . nextLine ( ) , " " ) ; } sc . close ( ) ; System . out . println ( map . size ( ) ) ; } } import java . util . * ; public class oVOalnLNWJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oVOalnLNWJ = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] [ ] mat = new int [ oVOalnLNWJ ] [ M ] ; for ( int i = 0 ; i < oVOalnLNWJ ; 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 , oVOalnLNWJ , M ) ) { answer = answer + 1 ; } } System . out . println ( answer ) ; } public static boolean isAllLike ( int [ ] [ ] mat , int x , int oVOalnLNWJ , int M ) { boolean isLike = false ; for ( int i = 0 ; i < oVOalnLNWJ ; 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 gUEvZbtXPG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gUEvZbtXPG = 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 <= gUEvZbtXPG ; 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 sfEJMZJFhg { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String token = sc . next ( ) ; String [ ] strArray = token . split ( " " ) ; int sfEJMZJFhg = 0 ; if ( strArray [ 0 ] . equals ( " 1 " ) ) { sfEJMZJFhg ++ ; } if ( strArray [ 1 ] . equals ( " 1 " ) ) { sfEJMZJFhg += 1 ; } if ( strArray [ 2 ] . equals ( " 1 " ) ) { sfEJMZJFhg += 1 ; } System . out . println ( sfEJMZJFhg ) ; sc . close ( ) ; } } import java . util . * ; public class GmxLDpJtej { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GmxLDpJtej = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int min = 10001 ; for ( int i = 0 ; i < GmxLDpJtej ; 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 VpmNsbwRso { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VpmNsbwRso = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] mArray = new int [ m + 1 ] ; for ( int i = 0 ; i < VpmNsbwRso ; 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 ] == VpmNsbwRso ) result ++ ; } System . out . println ( result ) ; sc . close ( ) ; } } import java . io . * ; import java . util . * ; public class pMxHieTzHR { public static void main ( String [ ] args ) throws Exception { Scanner cin = new Scanner ( System . in ) ; int pMxHieTzHR = cin . nextInt ( ) , b = cin . nextInt ( ) ; System . out . println ( GCD ( pMxHieTzHR , b ) ) ; } public static int GCD ( int pMxHieTzHR , int b ) { if ( b == 0 ) return pMxHieTzHR ; return GCD ( b , pMxHieTzHR % b ) ; } } import java . util . Scanner ; import java . util . Stack ; public class eiSiQSoFQF { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String [ ] A = scan . nextLine ( ) . split ( " " ) ; Stack < Integer > num = new Stack < Integer > ( ) ; int eiSiQSoFQF = 0 ; int b = 0 ; for ( int i = 0 ; i < A . length ; i ++ ) { if ( A [ i ] . equals ( " + " ) ) { eiSiQSoFQF = num . pop ( ) ; b = num . pop ( ) ; num . add ( b + eiSiQSoFQF ) ; continue ; } if ( A [ i ] . equals ( " - " ) ) { eiSiQSoFQF = num . pop ( ) ; b = num . pop ( ) ; num . add ( b - eiSiQSoFQF ) ; continue ; } if ( A [ i ] . equals ( " * " ) ) { eiSiQSoFQF = num . pop ( ) ; b = num . pop ( ) ; num . add ( b * eiSiQSoFQF ) ; continue ; } if ( A [ i ] . equals ( " / " ) ) { eiSiQSoFQF = num . pop ( ) ; b = num . pop ( ) ; num . add ( b / eiSiQSoFQF ) ; 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 gPCdWCGZkp { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long gPCdWCGZkp , b = 0 ; long n = Long . parseLong ( br . readLine ( ) ) ; int digits , mindigits = 11 ; for ( gPCdWCGZkp = 1 ; gPCdWCGZkp <= Math . sqrt ( n ) ; gPCdWCGZkp ++ ) { if ( n % gPCdWCGZkp == 0 ) { b = n / gPCdWCGZkp ; digits = String . valueOf ( Math . max ( gPCdWCGZkp , b ) ) . length ( ) ; if ( digits < mindigits ) mindigits = digits ; } } System . out . println ( mindigits ) ; } } import java . util . * ; import java . lang . Double ; public class cSPVHmsLSJ { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; String cSPVHmsLSJ = reader . nextLine ( ) ; if ( cSPVHmsLSJ . equals ( " ABC " ) ) { System . out . println ( " ARC " ) ; } else { System . out . println ( " ABC " ) ; } } } import java . util . Scanner ; public class nHJIcBbgcM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String nHJIcBbgcM = sc . nextLine ( ) ; StringBuffer sb = new StringBuffer ( nHJIcBbgcM ) ; String rv = sb . reverse ( ) . toString ( ) ; System . out . println ( rv ) ; } } import java . util . Scanner ; public class aMJbgWzINf { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int aMJbgWzINf = stdIn . nextInt ( ) ; int [ ] a = new int [ aMJbgWzINf + 1 ] ; for ( int i = 1 ; i <= aMJbgWzINf ; 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 <= aMJbgWzINf ; i ++ ) System . out . println ( a [ i ] ) ; } } import java . util . Scanner ; public class DFRgVftJth { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DFRgVftJth = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int A = 10000 ; int B = 5000 ; int C = 1000 ; for ( int ai = 0 ; ai <= DFRgVftJth ; ai ++ ) { for ( int bi = 0 ; bi <= DFRgVftJth - ai ; bi ++ ) { int ci = DFRgVftJth - 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 BYNPCNERqm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BYNPCNERqm = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( y % 2 == 1 ) { System . out . println ( " No " ) ; return ; } if ( y >= 2 * BYNPCNERqm && y <= 4 * BYNPCNERqm ) { System . out . println ( " Yes " ) ; return ; } System . out . println ( " No " ) ; } } import java . util . * ; public class ULpRYMAQsg { static int ULpRYMAQsg = ( 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 lWWNfFvyKd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; while ( true ) { String [ ] str = scan . nextLine ( ) . split ( " " ) ; int lWWNfFvyKd = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 2 ] ) ; if ( " ? " . equals ( str [ 1 ] ) ) break ; if ( " + " . equals ( str [ 1 ] ) ) { System . out . println ( lWWNfFvyKd + b ) ; } else if ( " - " . equals ( str [ 1 ] ) ) { System . out . println ( lWWNfFvyKd - b ) ; } else if ( " * " . equals ( str [ 1 ] ) ) { System . out . println ( lWWNfFvyKd * b ) ; } else if ( " / " . equals ( str [ 1 ] ) ) { System . out . println ( lWWNfFvyKd / b ) ; } } } } import java . util . Scanner ; public class asZoAErWZm { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String N = in . next ( ) ; int asZoAErWZm = 0 ; for ( int i = 1 ; i <= Integer . parseInt ( N ) ; i ++ ) if ( String . valueOf ( i ) . length ( ) % 2 == 1 ) asZoAErWZm ++ ; System . out . println ( asZoAErWZm ) ; } } import java . util . * ; public class FjJBTTEtOQ { 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 FjJBTTEtOQ = 0 ; FjJBTTEtOQ < 26 ; FjJBTTEtOQ ++ ) { alpha [ FjJBTTEtOQ ] = str . charAt ( FjJBTTEtOQ ) ; } int [ ] count = new int [ 26 ] ; for ( int FjJBTTEtOQ = 0 ; FjJBTTEtOQ < w . length ( ) ; FjJBTTEtOQ ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) { if ( w . charAt ( FjJBTTEtOQ ) == alpha [ j ] ) count [ j ] ++ ; } } for ( int FjJBTTEtOQ = 0 ; FjJBTTEtOQ < 26 ; FjJBTTEtOQ ++ ) { if ( count [ FjJBTTEtOQ ] % 2 != 0 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( " Yes " ) ; } } import java . util . Scanner ; class EaBbhGaLpx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EaBbhGaLpx = sc . nextInt ( ) ; int [ ] t = new int [ EaBbhGaLpx + 1 ] ; t [ 0 ] = 0 ; int [ ] x = new int [ EaBbhGaLpx + 1 ] ; x [ 0 ] = 0 ; int [ ] y = new int [ EaBbhGaLpx + 1 ] ; x [ 0 ] = 0 ; for ( int i = 1 ; i <= EaBbhGaLpx ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < EaBbhGaLpx ; 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 OucNRjEgha { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int OucNRjEgha = Integer . parseInt ( br . readLine ( ) ) ; Map < String , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < OucNRjEgha ; 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 RBuqgphxoA { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int RBuqgphxoA = s . nextInt ( ) ; int m = s . nextInt ( ) ; int x = s . nextInt ( ) ; char [ ] road = new char [ RBuqgphxoA ] ; 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 < RBuqgphxoA ; 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 < RBuqgphxoA ; q ++ ) { if ( road [ q ] == 'c' ) { ++ countC ; } } } System . out . println ( countC ) ; } } import java . util . * ; public class SgpLghgnhS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String [ ] split = s . split ( " " ) ; int SgpLghgnhS ; int count = 0 , ans = 0 ; for ( SgpLghgnhS = 0 ; SgpLghgnhS < s . length ( ) ; SgpLghgnhS ++ ) { if ( split [ SgpLghgnhS ] . equals ( " A " ) || split [ SgpLghgnhS ] . equals ( " C " ) || split [ SgpLghgnhS ] . equals ( " G " ) || split [ SgpLghgnhS ] . 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 rgixIySqGW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; int rgixIySqGW = Integer . parseInt ( s . replaceAll ( " " , " " ) ) ; int sqrt = ( int ) Math . sqrt ( rgixIySqGW ) ; System . out . println ( ( sqrt * sqrt == rgixIySqGW ) ? " Yes " : " No " ) ; } } import java . util . * ; public class XKzXNAohjl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Random rand = new Random ( ) ; int XKzXNAohjl = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += sc . nextInt ( ) ; } if ( XKzXNAohjl <= sum ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class bwhIhcaLkp { static int bwhIhcaLkp = 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 , bwhIhcaLkp ) - 1 ) ; } public static void test ( long hp ) { hp = hp / 2 ; if ( hp == 0 ) return ; bwhIhcaLkp ++ ; test ( hp ) ; } } import java . io . * ; public class nIRXVoBoAJ { 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 nIRXVoBoAJ = Integer . parseInt ( arr [ 0 ] ) ; int w = Integer . parseInt ( arr [ 1 ] ) ; if ( nIRXVoBoAJ == 0 && w == 0 ) { break ; } for ( int i = 0 ; i < nIRXVoBoAJ ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( i == 0 || i == nIRXVoBoAJ - 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 xNsqSkHoiP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xNsqSkHoiP = sc . nextInt ( ) ; int len = String . valueOf ( xNsqSkHoiP ) . 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 += xNsqSkHoiP - ( int ) Math . pow ( 10 , len - 1 ) + 1 ; } System . out . println ( res ) ; } } import java . util . * ; public class KETUokiKfa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KETUokiKfa = sc . nextInt ( ) ; String S = sc . next ( ) ; char Si = S . charAt ( 0 ) ; int count = 1 ; for ( int i = 1 ; i < KETUokiKfa ; i ++ ) { if ( S . charAt ( i ) == Si ) ; else { count ++ ; Si = S . charAt ( i ) ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class LOoXTeMKaA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LOoXTeMKaA = sc . nextInt ( ) ; int [ ] a = new int [ LOoXTeMKaA ] ; float sum = 0 ; for ( int y = 0 ; y < LOoXTeMKaA ; y ++ ) { a [ y ] = sc . nextInt ( ) ; sum += a [ y ] ; } int p = Math . round ( sum / LOoXTeMKaA ) ; int res = 0 ; for ( int i = 0 ; i < LOoXTeMKaA ; i ++ ) { res += ( a [ i ] - p ) * ( a [ i ] - p ) ; } System . out . println ( res ) ; sc . close ( ) ; } } import java . util . Scanner ; class dzDZnyvcRu { private static int gcd ( int a , int b ) { while ( b != 0 ) { int dzDZnyvcRu = a % b ; a = b ; b = dzDZnyvcRu ; } 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 CustVLBjtx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] tmp = sc . nextLine ( ) . split ( " " ) ; int CustVLBjtx = Integer . valueOf ( tmp [ 0 ] ) ; int b = Integer . valueOf ( tmp [ 1 ] ) ; int sum = judge ( CustVLBjtx , b ) ; if ( CustVLBjtx < b ) { b -- ; } else { CustVLBjtx -- ; } sum += judge ( CustVLBjtx , b ) ; System . out . println ( sum ) ; } public static int judge ( int CustVLBjtx , int b ) { int res = 0 ; if ( CustVLBjtx < b ) { res = b ; } else { res = CustVLBjtx ; } return res ; } } import java . util . Scanner ; public class dpcYNhETPZ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dpcYNhETPZ = scan . nextInt ( ) ; int A = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int cnt = 0 ; for ( int i = A ; i <= B ; i ++ ) { if ( i % dpcYNhETPZ == 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 SuurRFlbSv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int SuurRFlbSv = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int resultCount = 0 ; for ( int i = 0 ; i < SuurRFlbSv ; i ++ ) { final int num = sc . nextInt ( ) ; if ( num % 2 == 0 ) { list . add ( num ) ; } else { break ; } } if ( list . size ( ) != SuurRFlbSv ) { System . out . print ( resultCount ) ; return ; } boolean continueFlag = true ; while ( continueFlag ) { int count = 0 ; for ( int j = 0 ; j < SuurRFlbSv ; j ++ ) { int num = list . get ( j ) ; if ( num % 2 == 0 ) { list . set ( j , num / 2 ) ; count ++ ; } else { continueFlag = false ; break ; } } if ( count == SuurRFlbSv ) { resultCount ++ ; } } System . out . print ( resultCount ) ; sc . close ( ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class OvxmmBXDdq { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int OvxmmBXDdq = scanner . nextInt ( ) ; int count = 0 ; boolean flg = true ; List < Integer > numList = new ArrayList < > ( ) ; scanner . nextLine ( ) ; for ( int i = 0 ; i < OvxmmBXDdq ; 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 YopBFsCMiS { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] array = br . readLine ( ) . split ( " " ) ; int YopBFsCMiS = Integer . parseInt ( array [ 0 ] ) ; int y = Integer . parseInt ( array [ 1 ] ) ; int z = y % 4 ; if ( ( z == 0 || z % 2 == 0 ) && 4 * YopBFsCMiS >= y && 2 * YopBFsCMiS <= 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 UQzIypsAnS { public static void main ( String [ ] args ) throws NumberFormatException , IOException { try ( Scanner sc = new Scanner ( System . in ) ) { int UQzIypsAnS = 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 ZpKyjuakkf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; try { final int ZpKyjuakkf = 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 + ZpKyjuakkf ; 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 WCdIQKegci { public static void main ( String [ ] args ) { Scanner sc = new java . util . Scanner ( System . in ) ; int WCdIQKegci = 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 ) { WCdIQKegci += max ; } else { bob += max ; } iCards . remove ( iCards . indexOf ( max ) ) ; } System . out . println ( WCdIQKegci - bob ) ; } } import java . util . * ; public class VRlAsldrpL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . next ( ) ; char VRlAsldrpL = C . charAt ( 0 ) ; System . out . println ( ++ VRlAsldrpL ) ; } } import java . util . Scanner ; public class qNALVzmxms { public static int Int ( int a ) { int qNALVzmxms = 0 ; if ( a == 9 ) { qNALVzmxms = 1 ; } else { qNALVzmxms = 9 ; } return qNALVzmxms ; } 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 mzfGBEDRXd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long mzfGBEDRXd = scanner . nextLong ( ) ; long R = scanner . nextLong ( ) ; if ( R - mzfGBEDRXd >= 2018L ) { System . out . println ( 0 ) ; return ; } long m1 = mzfGBEDRXd % 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 MoaXKxpsEm { public static void main ( String [ ] args ) { int MoaXKxpsEm = 0 ; int K = 0 ; String S ; Scanner sc = new Scanner ( System . in ) ; MoaXKxpsEm = 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 COIeuoKloL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int COIeuoKloL = 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 < COIeuoKloL ; 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 gVHiSOkgfn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gVHiSOkgfn = sc . nextInt ( ) ; int [ ] arr = new int [ gVHiSOkgfn ] ; for ( int i = 0 ; i < gVHiSOkgfn ; i ++ ) { arr [ sc . nextInt ( ) - 1 ] = i + 1 ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < gVHiSOkgfn ; 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 nFSsYIPuZz { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int nFSsYIPuZz = input . nextInt ( ) ; String S = input . next ( ) ; if ( S . length ( ) <= nFSsYIPuZz ) System . out . println ( S ) ; else System . out . println ( S . substring ( 0 , nFSsYIPuZz ) + " ... " ) ; } } public class YazKlvGaSD { public void run ( java . util . Scanner sc ) { int [ ] a ; int YazKlvGaSD , j ; a = new int [ sc . nextInt ( ) ] ; for ( YazKlvGaSD = 0 ; YazKlvGaSD < a . length ; ++ YazKlvGaSD ) a [ YazKlvGaSD ] = sc . nextInt ( ) ; for ( YazKlvGaSD = 0 ; YazKlvGaSD < a . length ; ++ YazKlvGaSD ) { final int t = a [ YazKlvGaSD ] ; for ( j = YazKlvGaSD - 1 ; j >= 0 ; -- j ) { if ( t < a [ j ] ) { a [ j + 1 ] = a [ j ] ; a [ j ] = t ; } } printArray ( a ) ; } } private void printArray ( int [ ] a ) { int YazKlvGaSD ; for ( YazKlvGaSD = 0 ; YazKlvGaSD < a . length ; ++ YazKlvGaSD ) { System . out . print ( a [ YazKlvGaSD ] ) ; if ( YazKlvGaSD + 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 GpYmYHbZnJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int GpYmYHbZnJ = 0 , H , A ; H = scan . nextInt ( ) ; A = scan . nextInt ( ) ; while ( H > 0 ) { H = H - A ; GpYmYHbZnJ ++ ; } System . out . println ( GpYmYHbZnJ ) ; } } import java . util . * ; class xVWAHUuRif { int max ( int xVWAHUuRif , int b ) { if ( xVWAHUuRif < b ) return b ; else return xVWAHUuRif ; } int min ( int xVWAHUuRif , int b ) { if ( xVWAHUuRif > b ) return b ; else return xVWAHUuRif ; } Main ( ) { Scanner sc = new Scanner ( System . in ) ; int xVWAHUuRif , c , d ; xVWAHUuRif = sc . nextInt ( ) ; d = - 1000000000 ; c = sc . nextInt ( ) ; for ( int i = 0 ; i < xVWAHUuRif - 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 BwPJvhMGjG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double BwPJvhMGjG = 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 ( BwPJvhMGjG * BwPJvhMGjG + b * b - 2 * BwPJvhMGjG * b * Math . cos ( Math . toRadians ( kaku ) ) ) ; System . out . println ( result ) ; } } import java . io . * ; import java . util . * ; class dYeggfLwbj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dYeggfLwbj = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; while ( dYeggfLwbj != 0 || W != 0 ) { for ( int i = 0 ; i < dYeggfLwbj ; i ++ ) { for ( int j = 0 ; j < W ; j ++ ) { System . out . printf ( " # " ) ; } System . out . printf ( " \n " ) ; } System . out . printf ( " \n " ) ; dYeggfLwbj = sc . nextInt ( ) ; W = sc . nextInt ( ) ; } } } import java . math . BigInteger ; import java . util . Scanner ; public class ORqgmAhGIQ { public static void main ( String [ ] args ) { Long K ; Scanner sc = new Scanner ( System . in ) ; K = sc . nextLong ( ) ; Long bank = 100L ; int ORqgmAhGIQ = 0 ; while ( bank < K ) { bank = ( long ) ( bank * 1.01 ) ; ORqgmAhGIQ ++ ; } System . out . println ( ORqgmAhGIQ ) ; } } import java . util . * ; public class igJGjeYnys { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int igJGjeYnys = sc . nextInt ( ) ; if ( igJGjeYnys / 10 == 0 ) { System . out . println ( igJGjeYnys % 10 ) ; } else if ( igJGjeYnys / 100 == 0 ) { System . out . println ( 9 ) ; } else if ( igJGjeYnys / 1000 == 0 ) { System . out . println ( igJGjeYnys % 1000 - 99 + 9 ) ; } else if ( igJGjeYnys / 10000 == 0 ) { System . out . println ( 909 ) ; } else if ( igJGjeYnys / 100000 == 0 ) { System . out . println ( igJGjeYnys % 100000 - 9999 + 900 + 9 ) ; } else { System . out . println ( 90909 ) ; } } } import java . util . * ; public class hNeCODjYoT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hNeCODjYoT = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; if ( c - ( hNeCODjYoT - b ) >= 0 ) { System . out . println ( c - ( hNeCODjYoT - b ) ) ; } else { System . out . println ( 0 ) ; } } } import java . util . Scanner ; public class pELtukilhs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pELtukilhs = sc . nextInt ( ) ; int [ ] A ; A = new int [ pELtukilhs ] ; int count = 0 ; for ( int i = 0 ; i < pELtukilhs ; ++ i ) { A [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < pELtukilhs - 1 ; ++ i ) { for ( int j = 0 ; j < pELtukilhs - 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 , pELtukilhs ) ; System . out . println ( count ) ; } public static void print ( int [ ] A , int pELtukilhs ) { for ( int i = 0 ; i < pELtukilhs ; ++ i ) { System . out . print ( A [ i ] ) ; if ( i < pELtukilhs - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } import java . util . * ; public class QOgGvPJeKw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QOgGvPJeKw = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= QOgGvPJeKw ; 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 aXvFPYQnlk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aXvFPYQnlk = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; for ( int i = 1 ; i <= K ; i ++ ) { if ( K - aXvFPYQnlk == 0 ) { System . out . println ( aXvFPYQnlk * 1 ) ; return ; } if ( K - aXvFPYQnlk < 0 ) { System . out . println ( K * 1 ) ; return ; } if ( ( K - aXvFPYQnlk ) - B <= 0 ) { System . out . println ( aXvFPYQnlk * 1 + B * 0 ) ; return ; } if ( ( K - aXvFPYQnlk ) - B > 0 ) { System . out . println ( aXvFPYQnlk * 1 + B * 0 + ( ( ( K - aXvFPYQnlk ) - 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 IsfIXyzudh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; for ( int IsfIXyzudh = 0 ; IsfIXyzudh < 10 ; IsfIXyzudh ++ ) { 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 hdmvdlfDKL { 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 hdmvdlfDKL = 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 ( hdmvdlfDKL % ans == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class sWMWFDJqeh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sWMWFDJqeh = sc . nextInt ( ) ; int cnt = 0 ; if ( sWMWFDJqeh % 2 == 0 ) { cnt = sWMWFDJqeh / 2 ; System . out . println ( cnt ) ; } else { cnt = ( int ) ( sWMWFDJqeh / 2 ) + 1 ; System . out . println ( cnt ) ; } } } import java . util . Scanner ; public class qKCdjRbKFO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String qKCdjRbKFO = sc . next ( ) ; String str = sc . next ( ) ; sc . close ( ) ; qKCdjRbKFO += qKCdjRbKFO ; if ( qKCdjRbKFO . contains ( str ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class nqjjNJkAel { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int nqjjNJkAel = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int [ ] H = new int [ nqjjNJkAel ] ; for ( int i = 0 ; i < nqjjNJkAel ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } double min = Double . MAX_VALUE ; int minPotision = 0 ; for ( int i = 0 ; i < nqjjNJkAel ; 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 NTvffqvewS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NTvffqvewS = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sc . nextLine ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < NTvffqvewS ; 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 < NTvffqvewS ; 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 ( NTvffqvewS - 1 ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class jroecHKCPu { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int jroecHKCPu = stdIn . nextInt ( ) ; int n1 = jroecHKCPu / 100 ; jroecHKCPu = jroecHKCPu - n1 * 100 ; int n2 = jroecHKCPu / 10 ; jroecHKCPu = jroecHKCPu - n2 * 10 ; if ( jroecHKCPu == 2 || jroecHKCPu == 4 || jroecHKCPu == 5 || jroecHKCPu == 7 || jroecHKCPu == 9 ) { System . out . println ( " hon " ) ; } else if ( jroecHKCPu == 0 || jroecHKCPu == 1 || jroecHKCPu == 6 || jroecHKCPu == 8 ) { System . out . println ( " pon " ) ; } else { System . out . println ( " bon " ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class tjnzxMVuFc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tjnzxMVuFc = sc . nextInt ( ) ; ArrayList < String > list = new ArrayList < > ( ) ; String newWord ; for ( int i = 0 ; i < tjnzxMVuFc ; 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 oPJnEYmBzP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String str = sc . next ( ) ; if ( str . equals ( " - " ) ) break ; int oPJnEYmBzP = sc . nextInt ( ) ; int [ ] array = new int [ oPJnEYmBzP ] ; String result = str ; for ( int i = 0 ; i < oPJnEYmBzP ; i ++ ) { int shuffleNum = sc . nextInt ( ) ; result = result . substring ( shuffleNum ) + result . substring ( 0 , shuffleNum ) ; } System . out . println ( result ) ; } } } import java . util . * ; public class epyrotuXsn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int epyrotuXsn = 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 ( epyrotuXsn - j ) ) ; } int a = epyrotuXsn - min ; if ( Arrays . asList ( p ) . contains ( a ) ) { System . out . println ( epyrotuXsn + min ) ; } else { System . out . println ( a ) ; } } } import java . util . * ; public class WpQXHFHbGG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int WpQXHFHbGG = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int day = 0 ; for ( int i = 0 ; i < M ; i ++ ) { day += scan . nextInt ( ) ; } if ( day > WpQXHFHbGG ) { System . out . println ( - 1 ) ; } else { System . out . println ( WpQXHFHbGG - day ) ; } } } import java . util . Scanner ; public class AGYtbvMYYd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AGYtbvMYYd = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= AGYtbvMYYd ; i ++ ) { for ( int j = 1 ; j <= AGYtbvMYYd ; j ++ ) { for ( int k = 1 ; k <= AGYtbvMYYd ; 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 uXsYgxNHrT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uXsYgxNHrT = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= uXsYgxNHrT ; 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 ygjWewsLOS { public static void main ( String [ ] args ) { BufferedReader inMsg = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String ygjWewsLOS = " " ; try { while ( ( ygjWewsLOS = inMsg . readLine ( ) ) != null ) { String [ ] ab = ygjWewsLOS . 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 MnrXRHxHBA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] s = S . toCharArray ( ) ; int MnrXRHxHBA = 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' ) ) { MnrXRHxHBA += 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 ) { MnrXRHxHBA += count0 * 2 ; } else { MnrXRHxHBA += count1 * 2 ; } System . out . println ( MnrXRHxHBA ) ; } } import java . util . Scanner ; public class AUNRfLfqqF { static float roundUp ( float value ) { float AUNRfLfqqF = value % 1000 ; if ( AUNRfLfqqF > 0 ) { value = value + ( 1000 - AUNRfLfqqF ) ; } 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 HaJxWngfZX { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int HaJxWngfZX = in . nextInt ( ) ; int i = 10 , res = 0 , sign = 1 ; while ( HaJxWngfZX >= i ) { res += ( i - 1 ) * sign ; sign *= - 1 ; i *= 10 ; } if ( res <= 0 ) res += HaJxWngfZX ; System . out . println ( res ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class DrcFQJQSTf { public static void main ( String [ ] args ) throws Exception { BufferedReader stdIn = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s ; int DrcFQJQSTf = 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 ( ++ DrcFQJQSTf , in1 , in2 ) ; } System . exit ( 0 ) ; } private static void doMain ( int DrcFQJQSTf , int in1 , int in2 ) { if ( in1 < in2 ) System . out . println ( in1 + " " + in2 ) ; else System . out . println ( in2 + " " + in1 ) ; } } import java . util . * ; class ScvYfxEFiK { static int ScvYfxEFiK = 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 nrwricAEep { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int nrwricAEep = sc . nextInt ( ) ; int [ ] a = new int [ 100 ] ; for ( int i = 0 ; i < nrwricAEep ; i ++ ) a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; int Alice = 0 ; int Bob = 0 ; for ( int i = 99 ; i > 99 - nrwricAEep ; i -- ) if ( i % 2 == 1 ) Alice += a [ i ] ; else Bob += a [ i ] ; System . out . println ( Alice - Bob ) ; } } import java . util . * ; public class SlTrkSiXTZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SlTrkSiXTZ = sc . nextInt ( ) ; int ans = 0 ; for ( int i = SlTrkSiXTZ ; 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 pEMdfxpOcZ { class pEMdfxpOcZ { int pEMdfxpOcZ , 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 AzGJBjeYOQ { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long AzGJBjeYOQ = 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 ( AzGJBjeYOQ ) + 10 ; l ++ ) { if ( AzGJBjeYOQ % l == 0 ) { O = l ; T = AzGJBjeYOQ / 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 WBDmByaWnY { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int WBDmByaWnY = Integer . parseInt ( scanner . next ( ) ) ; int Y = Integer . parseInt ( scanner . next ( ) ) ; scanner . close ( ) ; for ( int x = 0 ; x <= WBDmByaWnY ; x ++ ) { for ( int y = 0 ; y <= WBDmByaWnY ; y ++ ) { int z = WBDmByaWnY - 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 oZLNjmdvgV { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int oZLNjmdvgV = scan . nextInt ( ) ; int strlenge = scan . nextInt ( ) ; String [ ] output = new String [ oZLNjmdvgV ] ; for ( int i = 0 ; i < oZLNjmdvgV ; i ++ ) { output [ i ] = scan . next ( ) ; } Arrays . sort ( output ) ; for ( int i = 0 ; i < oZLNjmdvgV ; i ++ ) { System . out . print ( output [ i ] ) ; } scan . close ( ) ; } } import java . util . * ; public class MbdZZqJKYP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MbdZZqJKYP = sc . nextInt ( ) ; String n = String . valueOf ( MbdZZqJKYP ) ; char [ ] a = n . toCharArray ( ) ; char b = a [ 0 ] ; char [ ] c = { b , b , b } ; int ans = Integer . parseInt ( String . valueOf ( c ) ) ; if ( ans >= MbdZZqJKYP ) { System . out . println ( ans ) ; } else { ans += 111 ; System . out . println ( ans ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class xlsMSxSNTo { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xlsMSxSNTo = scan . nextInt ( ) ; String S = scan . next ( ) ; int S_length = S . length ( ) ; if ( xlsMSxSNTo < S_length ) { for ( int i = 0 ; i < xlsMSxSNTo ; i ++ ) { System . out . print ( S . charAt ( i ) ) ; } System . out . print ( " ... " ) ; } else { System . out . print ( S ) ; } } } import java . util . * ; public class tIkPQWtUtE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tIkPQWtUtE = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int x = tIkPQWtUtE * 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 cpYAXNwaRC { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int cpYAXNwaRC = scanner . nextInt ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) { if ( cpYAXNwaRC <= 111 * i ) { System . out . println ( 111 * i ) ; break ; } } } } import java . util . * ; public class IdbxzSeffG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IdbxzSeffG = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= IdbxzSeffG ; 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 gHSLjzykBf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gHSLjzykBf = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ gHSLjzykBf ] ; 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 XSIpBRwrzi { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int XSIpBRwrzi = Integer . parseInt ( br . readLine ( ) ) ; int count = 0 ; for ( int i = 0 ; i < XSIpBRwrzi ; 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 mKVAOrKfdu { 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 mKVAOrKfdu = scan . nextInt ( ) ; for ( int i = 0 ; i < mKVAOrKfdu ; 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 NNRUZrceoO { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int NNRUZrceoO = scan . nextInt ( ) ; int [ ] P = new int [ NNRUZrceoO ] ; int countI = 1 ; for ( int i = 0 ; i < NNRUZrceoO ; i ++ ) { int b = scan . nextInt ( ) ; P [ i ] = b ; } int j = 1 ; int Min = P [ 0 ] ; while ( j < NNRUZrceoO ) { if ( P [ j ] < Min ) { Min = P [ j ] ; countI ++ ; } j ++ ; } System . out . println ( countI ) ; } } import java . util . * ; import java . io . * ; public class wfghhtbAqi { public static void main ( String [ ] args ) throws Exception { int wfghhtbAqi = 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 txhGzngwmq { public static void main ( String [ ] args ) { int txhGzngwmq ; try ( Scanner sc = new Scanner ( System . in ) ) { txhGzngwmq = sc . nextInt ( ) ; } int maxKeta = ( int ) Math . floor ( Math . log10 ( ( double ) txhGzngwmq ) + 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 += txhGzngwmq - ( int ) ( Math . pow ( 10 , maxKeta - 1 ) ) + 1 ; } System . out . println ( answer ) ; } } import java . util . Scanner ; public class pnkQWNxAgB { static Scanner sc = new Scanner ( System . in ) ; static int pnkQWNxAgB = 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 < pnkQWNxAgB ; 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 = pnkQWNxAgB ; 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 FXswwaRsED { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FXswwaRsED = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int i = 1 ; int sum = 0 ; while ( FXswwaRsED * i <= t ) { sum += b ; i += 1 ; } System . out . println ( sum ) ; } } import java . util . * ; public class mKJSTFArBO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int mKJSTFArBO = 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 ) ) ) { mKJSTFArBO = Math . max ( mKJSTFArBO , i - leftIdx ) ; leftIdx = i + 1 ; } } mKJSTFArBO = Math . max ( mKJSTFArBO , s . length ( ) - leftIdx ) ; System . out . println ( mKJSTFArBO ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class WiPlwnciNr { static BufferedReader reader ; public static void main ( String [ ] args ) { reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strings = readLine ( ) ; int WiPlwnciNr = Integer . parseInt ( strings [ 0 ] ) ; int A = Integer . parseInt ( strings [ 1 ] ) ; print ( ( WiPlwnciNr + 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 sAQhbDMFNp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int sAQhbDMFNp = scan . nextInt ( ) ; int num2 = scan . nextInt ( ) ; int num3 = scan . nextInt ( ) ; int count = 0 ; if ( sAQhbDMFNp != num2 ) { count ++ ; } if ( num2 != num3 ) { count ++ ; } if ( sAQhbDMFNp != num3 ) { count ++ ; } if ( count == 1 || count == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . lang . * ; public class syHtfokiKK { public static void solve ( long syHtfokiKK , long b , long c , long d ) { while ( syHtfokiKK > 0 && c > 0 ) { c -= b ; if ( c <= 0 ) { System . out . println ( " Yes " ) ; return ; } syHtfokiKK -= d ; } if ( c == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void gora ( ) { Scanner scn = new Scanner ( System . in ) ; long syHtfokiKK = scn . nextLong ( ) ; long b = scn . nextLong ( ) ; long c = scn . nextLong ( ) ; long d = scn . nextLong ( ) ; solve ( syHtfokiKK , b , c , d ) ; } public static void main ( String [ ] args ) { gora ( ) ; } } import java . util . Scanner ; public class BrVpwlfayN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BrVpwlfayN = 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 < BrVpwlfayN ; i ++ ) { System . out . print ( Schar [ i ] ) ; System . out . print ( Tchar [ i ] ) ; } return ; } } import java . util . * ; class lkrMsKCsbH { public static void main ( String [ ] args ) { int lkrMsKCsbH = 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' ) { lkrMsKCsbH += 1 ; } } } System . out . println ( lkrMsKCsbH ) ; } } import java . util . Scanner ; class OAZQDLwfZY { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int OAZQDLwfZY = scan . nextInt ( ) ; int kimatu = scan . nextInt ( ) ; int saisiken = scan . nextInt ( ) ; while ( OAZQDLwfZY != - 1 || kimatu != - 1 || saisiken != - 1 ) { int y ; y = OAZQDLwfZY + kimatu ; if ( OAZQDLwfZY == - 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 " ) ; } OAZQDLwfZY = scan . nextInt ( ) ; kimatu = scan . nextInt ( ) ; saisiken = scan . nextInt ( ) ; } } } import java . util . Scanner ; public class blADWaIMTh { 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 blADWaIMTh = true ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { blADWaIMTh = true ; for ( int j = 0 ; j < n - i ; j ++ ) { if ( a [ j ] != b [ j + i ] ) { blADWaIMTh = false ; break ; } } for ( int j = n - i ; j < n ; j ++ ) { if ( a [ j ] != b [ j - n + i ] ) { blADWaIMTh = false ; break ; } } if ( blADWaIMTh ) break ; } System . out . println ( blADWaIMTh ? " Yes " : " No " ) ; } } import java . util . ArrayList ; import static java . util . Collections . reverse ; import java . util . List ; import java . util . Scanner ; public class InaTzoAyAp { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int InaTzoAyAp = scanner . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < InaTzoAyAp ; 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 FHlKRJuuml { public static void main ( String [ ] args ) throws IOException { int FHlKRJuuml , b , f , r , v ; String [ ] list ; int [ ] [ ] [ ] building ; StringBuilder builder = new StringBuilder ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; FHlKRJuuml = Integer . parseInt ( br . readLine ( ) ) ; building = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int i = 0 ; i < FHlKRJuuml ; 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 nipplBsjcQ { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nipplBsjcQ = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; int count1 = 0 ; int count2 = 0 ; int count3 = 0 ; int count4 = 0 ; for ( int i = 0 ; i < nipplBsjcQ ; i ++ ) { list . add ( sc . next ( ) ) ; } for ( int i = 0 ; i < nipplBsjcQ ; 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 msOrAcubcW { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; int msOrAcubcW = scan . nextInt ( ) ; int x = 1 ; int y = 0 ; if ( msOrAcubcW >= 3 && msOrAcubcW <= 10000 ) { for ( int count = 0 ; count < msOrAcubcW ; 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 UTCvzopQUs { public static void main ( String [ ] args ) throws IOException { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; for ( ; ; ) { String [ ] str = br . readLine ( ) . split ( " " ) ; int UTCvzopQUs = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 2 ] ) ; if ( str [ 1 ] . equals ( " ? " ) ) break ; switch ( str [ 1 ] ) { case " + " : System . out . println ( UTCvzopQUs + b ) ; break ; case " - " : System . out . println ( UTCvzopQUs - b ) ; break ; case " * " : System . out . println ( UTCvzopQUs * b ) ; break ; case " / " : System . out . println ( UTCvzopQUs / b ) ; break ; default : break ; } } br . close ( ) ; } catch ( Exception e ) { System . exit ( - 1 ) ; } } } import java . util . * ; public class tvWmYyIERJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tvWmYyIERJ = 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 + tvWmYyIERJ ) % 26 ; ans [ i ] = ( char ) ( 'A' + c ) ; } System . out . println ( new String ( ans ) ) ; } } import java . util . Scanner ; public class XmlHtKudlB { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s , t ; int XmlHtKudlB ; s = scan . next ( ) ; t = scan . next ( ) ; XmlHtKudlB = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == t . charAt ( i ) ) XmlHtKudlB += 1 ; } System . out . println ( XmlHtKudlB ) ; } } import java . io . * ; import java . util . * ; class bFnWwByDao { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int bFnWwByDao = 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 < bFnWwByDao ; i ++ ) { sb . append ( str_1 [ i ] ) ; sb . append ( str_2 [ i ] ) ; } System . out . println ( sb ) ; } } } import java . util . * ; public class GzuQpZIQGo { static int GzuQpZIQGo = 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 XKIgRkjtrS { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader sb = new BufferedReader ( new InputStreamReader ( System . in ) ) ; Integer [ ] hList = new Integer [ 10 ] ; for ( int XKIgRkjtrS = 0 ; XKIgRkjtrS < 10 ; XKIgRkjtrS ++ ) { int h = Integer . parseInt ( sb . readLine ( ) ) ; hList [ XKIgRkjtrS ] = h ; } Arrays . sort ( hList , Collections . reverseOrder ( ) ) ; for ( int rank = 0 ; rank < 3 ; rank ++ ) { System . out . println ( hList [ rank ] ) ; } } } import java . util . Scanner ; public class pEmYxynoyt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pEmYxynoyt = sc . nextInt ( ) ; int ans = ( 10000 - pEmYxynoyt ) % 1000 ; System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; public class duMDzStMTo { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int duMDzStMTo = sc . nextInt ( ) ; System . out . println ( ( duMDzStMTo / 3600 ) + " : " + ( duMDzStMTo % 3600 / 60 ) + " : " + ( duMDzStMTo % 60 ) ) ; } } import java . util . * ; class fOhNsRjuBg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fOhNsRjuBg = 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 dkeplSFsCs { public static void main ( String [ ] args ) { int dkeplSFsCs ; int b ; Scanner sc = new Scanner ( System . in ) ; dkeplSFsCs = sc . nextInt ( ) ; b = sc . nextInt ( ) ; int area = dkeplSFsCs * b ; int syu = 2 * ( dkeplSFsCs + b ) ; System . out . println ( area + " " + syu ) ; } } import java . util . * ; public class HkgxFSscOL { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int HkgxFSscOL = scanner . nextInt ( ) ; int a = 0 ; int b = 0 ; for ( int i = 1 ; i <= HkgxFSscOL ; i += 2 ) { for ( int j = 1 ; j <= HkgxFSscOL ; 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 HheoCLPFYX { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int HheoCLPFYX = 1 , b = 1 ; while ( HheoCLPFYX != 0 && b != 0 ) { HheoCLPFYX = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; if ( HheoCLPFYX == 0 && b == 0 ) { break ; } for ( int i = 1 ; i <= HheoCLPFYX ; i ++ ) { for ( int j = 1 ; j <= b ; j ++ ) { if ( i == 1 && j != b ) { System . out . print ( " # " ) ; } else if ( i == HheoCLPFYX && 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 soyGgqnUYg { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int soyGgqnUYg = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; scanner . close ( ) ; String ans = null ; if ( soyGgqnUYg < b && b < c ) { ans = " Yes " ; } else { ans = " No " ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class tssbOLJIXK { public static void main ( String [ ] args ) { Main m = new Main ( ) ; m . answer ( ) ; } private Scanner scan = new Scanner ( System . in ) ; private int tssbOLJIXK ; private int b ; public Main ( ) { tssbOLJIXK = Integer . parseInt ( scan . next ( ) ) ; b = Integer . parseInt ( scan . next ( ) ) ; scan . close ( ) ; } public final void answer ( ) { String ans = tssbOLJIXK * b % 2 == 0 ? " Even " : " Odd " ; System . out . println ( ans ) ; } } import java . util . Scanner ; class YloyZEfRTB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YloyZEfRTB , Q , R ; int max = 0 ; YloyZEfRTB = sc . nextInt ( ) ; Q = sc . nextInt ( ) ; R = sc . nextInt ( ) ; if ( YloyZEfRTB >= Q ) { if ( YloyZEfRTB >= R ) { max = Q + R ; } else { max = YloyZEfRTB + Q ; } } else if ( Q >= R ) { if ( Q >= YloyZEfRTB ) { max = YloyZEfRTB + R ; } else { max = Q + R ; } } else if ( R >= YloyZEfRTB ) { if ( R >= Q ) { max = YloyZEfRTB + Q ; } else { max = YloyZEfRTB + R ; } } System . out . println ( max ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class AzNKMtZKFv { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; String AzNKMtZKFv = st . nextToken ( ) ; System . out . println ( AzNKMtZKFv . charAt ( 2 ) == AzNKMtZKFv . charAt ( 3 ) && AzNKMtZKFv . charAt ( 4 ) == AzNKMtZKFv . charAt ( 5 ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class uhWGiLuJBH { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . start ( ) ; } private void start ( ) { Scanner scanner = new Scanner ( System . in ) ; int uhWGiLuJBH = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = scanner . nextInt ( ) ; if ( uhWGiLuJBH < b && b < c ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class HlvYcDpHLj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; String [ ] s = S . split ( " / " ) ; int HlvYcDpHLj = 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 pOyZcsNeDg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pOyZcsNeDg = sc . nextInt ( ) ; String [ ] W = new String [ pOyZcsNeDg ] ; for ( int i = 0 ; i < pOyZcsNeDg ; i ++ ) { W [ i ] = sc . next ( ) ; } sc . close ( ) ; String result = " Yes " ; for ( int i = 0 ; i < pOyZcsNeDg ; i ++ ) { for ( int j = i + 1 ; j < pOyZcsNeDg ; j ++ ) { if ( W [ i ] . equals ( W [ j ] ) ) { result = " No " ; break ; } } if ( result == " No " ) { break ; } } String start = " " ; if ( result == " Yes " ) { for ( int i = 0 ; i < pOyZcsNeDg ; 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 eYwLxVlOtU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eYwLxVlOtU = sc . nextInt ( ) ; int variety = sc . nextInt ( ) ; int [ ] k = new int [ eYwLxVlOtU ] ; int [ ] preference = new int [ variety ] ; int ans = 0 ; for ( int i = 0 ; i < eYwLxVlOtU ; 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 ] == eYwLxVlOtU ) { ans ++ ; } } System . out . println ( ans ) ; sc . close ( ) ; } private static int gcd ( int m , int eYwLxVlOtU ) { if ( m < eYwLxVlOtU ) { return gcd ( eYwLxVlOtU , m ) ; } if ( eYwLxVlOtU == 0 ) { return m ; } return gcd ( eYwLxVlOtU , m % eYwLxVlOtU ) ; } } import java . util . Scanner ; public class jegUTVcoQD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String jegUTVcoQD = sc . next ( ) ; String ans ; if ( jegUTVcoQD . equals ( " Sunny " ) ) { ans = " Cloudy " ; } else if ( jegUTVcoQD . equals ( " Cloudy " ) ) { ans = " Rainy " ; } else { ans = " Sunny " ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class xiCcAQVhOA { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int xiCcAQVhOA = stdIn . nextInt ( ) ; int Y = stdIn . nextInt ( ) / 1000 ; int ans10 = - 1 ; int ans5 = - 1 ; int ans1 = - 1 ; for ( int i = 0 ; i <= xiCcAQVhOA ; i ++ ) { for ( int j = 0 ; j <= xiCcAQVhOA - i ; j ++ ) { if ( 10 * i + 5 * j + ( xiCcAQVhOA - i - j ) == Y ) { ans10 = i ; ans5 = j ; ans1 = xiCcAQVhOA - i - j ; break ; } } } System . out . println ( ans10 + " " + ans5 + " " + ans1 ) ; } } import java . util . * ; class TwJRdlrkQx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TwJRdlrkQx = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int sum = 1 ; for ( int i = 1 ; i <= TwJRdlrkQx ; i ++ ) { sum = sum * 100 ; } System . out . println ( sum * ( n + n / 100 ) ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class XNPHLcBAHB { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int XNPHLcBAHB = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; HashSet h = new HashSet ( ) ; h . add ( XNPHLcBAHB ) ; h . add ( b ) ; h . add ( c ) ; if ( h . size ( ) == 2 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . * ; public class mXBnRbZWmS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mXBnRbZWmS = sc . nextInt ( ) ; int yen = 1000 ; while ( yen < mXBnRbZWmS ) { yen = yen + 1000 ; } System . out . println ( yen - mXBnRbZWmS ) ; } } import java . util . Scanner ; public class rYUWROwQMA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rYUWROwQMA = sc . nextInt ( ) ; int sum = 100000 ; for ( int i = 0 ; i < rYUWROwQMA ; 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 FlUtdhXHfA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] strs = new String [ 100 ] ; int FlUtdhXHfA = 0 ; while ( true ) { String str = sc . next ( ) ; if ( str . equals ( " - " ) ) { for ( int j = 0 ; j < FlUtdhXHfA ; 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 [ FlUtdhXHfA ] = str ; FlUtdhXHfA ++ ; } } } import java . util . * ; public class wJCDyBZciY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String ans = " " ; for ( int wJCDyBZciY = 0 ; wJCDyBZciY < s . length ( ) ; wJCDyBZciY ++ ) { String temp = s . substring ( wJCDyBZciY , wJCDyBZciY + 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 ZvFQzWeswb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ZvFQzWeswb = sc . next ( ) ; String B = sc . next ( ) ; String C = sc . next ( ) ; System . out . println ( C + " " + ZvFQzWeswb + " " + B ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class FHNKPoNWZm { 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 FHNKPoNWZm = Integer . parseInt ( items [ 0 ] ) ; int b = Integer . parseInt ( items [ 1 ] ) ; int c = Integer . parseInt ( items [ 2 ] ) ; int counter = 0 ; for ( int i = FHNKPoNWZm ; i <= b ; i ++ ) { if ( c % i == 0 ) { counter ++ ; } } System . out . println ( counter ) ; } } import java . util . * ; public class YqrHPfMeFk { 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 YqrHPfMeFk = x . charAt ( 0 ) ; if ( YqrHPfMeFk == '+' || YqrHPfMeFk == '-' || YqrHPfMeFk == '*' ) { int second = stack . pop ( ) ; int first = stack . pop ( ) ; if ( YqrHPfMeFk == '+' ) { first += second ; } else if ( YqrHPfMeFk == '-' ) { 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 UCAZoVroOT { 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 UCAZoVroOT = Integer . parseInt ( repStr ) ; for ( int i = 0 ; i < UCAZoVroOT ; 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 dmvEULtflO { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int dmvEULtflO = stdIn . nextInt ( ) ; int k = stdIn . nextInt ( ) ; int [ ] h = new int [ dmvEULtflO ] ; for ( int i = 0 ; i < dmvEULtflO ; i ++ ) { h [ i ] = stdIn . nextInt ( ) ; } int [ ] dp = new int [ dmvEULtflO ] ; Arrays . fill ( dp , Integer . MAX_VALUE ) ; dp [ 0 ] = 0 ; dp [ 1 ] = Math . abs ( h [ 1 ] - h [ 0 ] ) ; for ( int i = 0 ; i < dmvEULtflO ; i ++ ) { for ( int j = i + 1 ; j <= i + k ; j ++ ) { if ( j >= dmvEULtflO ) { break ; } dp [ j ] = Math . min ( dp [ i ] + Math . abs ( h [ j ] - h [ i ] ) , dp [ j ] ) ; } } System . out . println ( dp [ dmvEULtflO - 1 ] ) ; } } import java . util . * ; public class XNFzomnhhF { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; String s = scn . next ( ) ; int XNFzomnhhF = 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 { XNFzomnhhF = Math . max ( nans , XNFzomnhhF ) ; nans = 0 ; i ++ ; } } XNFzomnhhF = Math . max ( nans , XNFzomnhhF ) ; System . out . println ( XNFzomnhhF ) ; } } import java . util . Scanner ; public class TuWvLVpLzL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TuWvLVpLzL = sc . nextInt ( ) ; int ans = 1 ; for ( int i = 2 ; i < TuWvLVpLzL ; i ++ ) { int j = i ; if ( TuWvLVpLzL >= Math . pow ( j , 2 ) ) { while ( j <= TuWvLVpLzL ) { j *= i ; } j /= i ; ans = Math . max ( ans , j ) ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class fUBSQDAvMU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fUBSQDAvMU = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int max = Math . max ( fUBSQDAvMU , c ) ; int min = Math . min ( b , d ) ; System . out . println ( Math . max ( 0 , min - max ) ) ; } } import java . util . Scanner ; public class RsWobgqzJZ { public static void main ( String [ ] args ) { int [ ] list ; int RsWobgqzJZ ; int primes = 0 ; Scanner keyboard = new Scanner ( System . in ) ; RsWobgqzJZ = keyboard . nextInt ( ) ; list = new int [ RsWobgqzJZ ] ; for ( int i = 0 ; i < RsWobgqzJZ ; i ++ ) { list [ i ] = keyboard . nextInt ( ) ; } for ( int i = 0 ; i < RsWobgqzJZ ; 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 atUuJkUOxU { public static void main ( String [ ] args ) { int atUuJkUOxU ; Scanner sc = new Scanner ( System . in ) ; atUuJkUOxU = sc . nextInt ( ) ; int c = 0 ; int [ ] b = new int [ atUuJkUOxU ] ; for ( int i = 0 ; i < atUuJkUOxU ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } Arrays . sort ( b ) ; for ( int j = 0 ; j < atUuJkUOxU - 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 LuLlyjQANT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LuLlyjQANT = sc . nextInt ( ) ; while ( true ) { if ( BigInteger . valueOf ( LuLlyjQANT ) . isProbablePrime ( 100 ) ) { System . out . println ( LuLlyjQANT ) ; return ; } LuLlyjQANT ++ ; } } } import java . util . Scanner ; public class tcOtLpxnbq { public static void main ( String [ ] args ) { int tcOtLpxnbq ; Scanner sc = new Scanner ( System . in ) ; tcOtLpxnbq = sc . nextInt ( ) ; System . out . println ( ( tcOtLpxnbq / 500 ) * 1000 + ( tcOtLpxnbq % 500 ) / 5 * 5 ) ; } } import java . util . Scanner ; class YSDXoLUbeW { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int YSDXoLUbeW = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int lower ; int bigger ; if ( YSDXoLUbeW > b ) { lower = b ; bigger = YSDXoLUbeW ; } else { lower = YSDXoLUbeW ; 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 FaXZvVzwYO { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int FaXZvVzwYO = scanner . nextInt ( ) ; Integer [ ] nums = new Integer [ FaXZvVzwYO ] ; for ( int i = 0 ; i < FaXZvVzwYO ; i ++ ) { nums [ i ] = scanner . nextInt ( ) ; } int diff = 0 ; boolean isEven = ( FaXZvVzwYO % 2 ) == 0 ; Arrays . sort ( nums , Collections . reverseOrder ( ) ) ; int pairLastIndex = isEven ? FaXZvVzwYO - 1 : FaXZvVzwYO - 2 ; for ( int i = 0 ; i < pairLastIndex ; i = i + 2 ) { diff += nums [ i ] - nums [ i + 1 ] ; } if ( ! isEven ) diff += nums [ FaXZvVzwYO - 1 ] ; System . out . println ( diff ) ; } } import java . util . Scanner ; public class UiXRyiZRhr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UiXRyiZRhr = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] A = new int [ UiXRyiZRhr ] ; int wa = 0 ; for ( int i = 0 ; i < UiXRyiZRhr ; i ++ ) { A [ i ] = sc . nextInt ( ) ; wa += A [ i ] ; } sc . close ( ) ; int ok = 0 ; for ( int i = UiXRyiZRhr - 1 ; i >= 0 ; i -- ) { ok += A [ i ] * ( 4 * M ) >= wa ? 1 : 0 ; } System . out . println ( ok >= M ? " Yes " : " No " ) ; } } import java . util . * ; public class slCADsEVJD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int slCADsEVJD = sc . nextInt ( ) ; int o = 0 ; int [ ] a = new int [ slCADsEVJD ] ; PriorityQueue < Integer > num = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < slCADsEVJD ; 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 < slCADsEVJD ; i ++ ) { int b = sc . nextInt ( ) ; o += b ; } for ( int i = 0 ; i < slCADsEVJD - 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 uMQiohRBAG { 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 uMQiohRBAG = Integer . parseInt ( a [ 0 ] ) ; int y = Integer . parseInt ( a [ 1 ] ) ; if ( uMQiohRBAG > y ) { sb . append ( y + " " + uMQiohRBAG + " \n " ) ; } else { sb . append ( uMQiohRBAG + " " + y + " \n " ) ; } } System . out . print ( sb ) ; } } import java . util . * ; public class puMWiWjSFa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int puMWiWjSFa = 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 HPBzHdCxWJ { 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 HPBzHdCxWJ = 0 ; HPBzHdCxWJ < weather . length ; ++ HPBzHdCxWJ ) { if ( tw . equals ( weather [ HPBzHdCxWJ ] ) ) { System . out . println ( weather [ ( HPBzHdCxWJ + 1 ) % 3 ] ) ; break ; } } } } import java . util . Scanner ; public class CwfiPldGmk { private void calc ( ) { Scanner scanner = new Scanner ( System . in ) ; int CwfiPldGmk = scanner . nextInt ( ) ; int y = scanner . nextInt ( ) ; int d = CwfiPldGmk / y ; int r = CwfiPldGmk % y ; double f = ( double ) CwfiPldGmk / ( 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 puYFIzLJVr { 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 lBMVWwmPYM { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long lBMVWwmPYM = scan . nextInt ( ) ; long y = scan . nextInt ( ) ; scan . close ( ) ; if ( lBMVWwmPYM < y ) { long tmp = y ; y = lBMVWwmPYM ; lBMVWwmPYM = tmp ; } long ans = ( lBMVWwmPYM * y ) / gcd ( lBMVWwmPYM , y ) ; System . out . println ( ans ) ; } static long gcd ( long lBMVWwmPYM , long y ) { if ( lBMVWwmPYM % y == 0 ) return y ; else return gcd ( y , lBMVWwmPYM % y ) ; } } import java . util . Scanner ; class AyiyilGhRN { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int AyiyilGhRN = scanner . nextInt ( ) ; int taroPoint = 0 ; int hanakoPoint = 0 ; scanner . nextLine ( ) ; for ( int i = 1 ; i <= AyiyilGhRN ; 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 PsDvBXXOUK { 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 PsDvBXXOUK = Integer . valueOf ( inputs [ 0 ] ) ; int width = Integer . valueOf ( inputs [ 1 ] ) ; StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < PsDvBXXOUK ; i ++ ) { if ( i == 0 || i == PsDvBXXOUK - 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 mVxCnesacV { static int mVxCnesacV = 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 hrKwmfxvwP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int hrKwmfxvwP = Integer . parseInt ( a + b ) ; boolean bl = false ; for ( int i = 1 ; i * i <= hrKwmfxvwP ; i ++ ) { if ( i * i == hrKwmfxvwP ) { bl = true ; break ; } } System . out . println ( bl == true ? " Yes " : " No " ) ; } } import java . util . * ; public class lIhglwjcwZ { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; ArrayList < Character > caca = new ArrayList < Character > ( ) ; String n = scn . next ( ) ; for ( int lIhglwjcwZ = 0 ; lIhglwjcwZ < n . length ( ) ; lIhglwjcwZ ++ ) { if ( n . charAt ( lIhglwjcwZ ) == '1' ) caca . add ( '1' ) ; else if ( n . charAt ( lIhglwjcwZ ) == '0' ) caca . add ( '0' ) ; else if ( n . charAt ( lIhglwjcwZ ) == 'B' ) { if ( ! caca . isEmpty ( ) ) caca . remove ( caca . size ( ) - 1 ) ; } } for ( int lIhglwjcwZ = 0 ; lIhglwjcwZ < caca . size ( ) ; lIhglwjcwZ ++ ) System . out . print ( caca . get ( lIhglwjcwZ ) ) ; 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 FLHTdhwaJW { public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int FLHTdhwaJW = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= FLHTdhwaJW ; 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 qwfgZhZAEf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qwfgZhZAEf = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; String ans ; if ( ( qwfgZhZAEf == b && b == c ) || ( qwfgZhZAEf != b && b != c && c != qwfgZhZAEf ) ) ans = " No " ; else ans = " Yes " ; System . out . println ( ans ) ; } } import java . util . Scanner ; class IwoOpGZNUQ { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int IwoOpGZNUQ = sc . nextInt ( ) ; long sum = 0 , left = 0 ; int [ ] A = new int [ IwoOpGZNUQ + 1 ] ; for ( int i = 0 ; i <= IwoOpGZNUQ ; i ++ ) { A [ i ] = sc . nextInt ( ) ; sum += A [ i ] ; } for ( int i = 0 ; i < IwoOpGZNUQ ; 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 <= IwoOpGZNUQ ; 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 NjeLReWMFO { 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 EoISgUzIny { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EoISgUzIny = sc . nextInt ( ) ; int [ ] h = new int [ EoISgUzIny ] ; int max = 0 ; int idx = 0 ; for ( int i = 0 ; i < EoISgUzIny ; i ++ ) { h [ i ] = sc . nextInt ( ) ; if ( h [ i ] > max ) { max = h [ i ] ; idx = i ; } } int max2 = 0 ; for ( int i = 0 ; i < EoISgUzIny ; i ++ ) { if ( i != idx ) { if ( h [ i ] > max2 ) { max2 = h [ i ] ; } } } for ( int i = 0 ; i < EoISgUzIny ; 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 jvMsByNgXL { 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 HRLOFXiQBE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HRLOFXiQBE = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] people = new int [ HRLOFXiQBE ] ; for ( int i = 0 ; i < HRLOFXiQBE ; 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 eCCMdkxtlK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eCCMdkxtlK = sc . nextInt ( ) ; int check = 1 ; for ( int i = 1 ; i < 10 ; i ++ ) { int f = eCCMdkxtlK % i ; if ( f == 0 ) { int a = eCCMdkxtlK / 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 taHMVgcYWc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int taHMVgcYWc = sc . nextInt ( ) ; int [ ] a = new int [ taHMVgcYWc + 1 ] ; for ( int i = 1 ; i <= taHMVgcYWc ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int cnt = 1 ; int point_now = 1 ; while ( cnt <= taHMVgcYWc ) { 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 pZypsunVqA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pZypsunVqA = sc . nextInt ( ) ; int ans = ( int ) pow ( pZypsunVqA , 3 ) ; System . out . println ( ans ) ; } } import java . util . * ; public class fWwcDOutaG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long fWwcDOutaG = Long . parseLong ( sc . next ( ) ) ; long k = Long . parseLong ( sc . next ( ) ) ; System . out . println ( Math . min ( fWwcDOutaG % k , k - ( fWwcDOutaG % k ) ) ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class RvLZRDkZym { 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 RvLZRDkZym = 0 ; RvLZRDkZym < w . length ( ) ; ++ RvLZRDkZym ) { if ( map . containsKey ( w . charAt ( RvLZRDkZym ) ) ) { Integer cap = map . get ( w . charAt ( RvLZRDkZym ) ) ; map . remove ( w . charAt ( RvLZRDkZym ) ) ; map . put ( w . charAt ( RvLZRDkZym ) , cap + 1 ) ; } else { map . put ( w . charAt ( RvLZRDkZym ) , 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 HEoSEFXdOh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HEoSEFXdOh = sc . nextInt ( ) ; int [ ] a = new int [ HEoSEFXdOh ] ; for ( int i = 0 ; i < HEoSEFXdOh ; 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 VJaPUdssSm { public static void main ( String [ ] args ) { try { Scanner sc = new Scanner ( System . in ) ; int VJaPUdssSm = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k ; if ( VJaPUdssSm == b ) { System . out . println ( " IMPOSSIBLE " ) ; } else if ( VJaPUdssSm < 0 ) { System . out . println ( " IMPOSSIBLE " ) ; } else if ( b > 1000000000 ) { System . out . println ( " IMPOSSIBLE " ) ; } else { k = ( b + VJaPUdssSm ) / 2 ; if ( ( k * 2 ) != ( VJaPUdssSm + 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 YnfhlwPpgP { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int YnfhlwPpgP = 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 >= YnfhlwPpgP ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class sNOrpMPdjC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sNOrpMPdjC = sc . nextInt ( ) ; int [ ] p = new int [ sNOrpMPdjC ] ; int flg = 0 ; String ans = " NO " ; for ( int i = 0 ; i < sNOrpMPdjC ; 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 hHBkhodAdf { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner sc = new Scanner ( System . in ) ; int hHBkhodAdf = sc . nextInt ( ) ; int [ ] p = new int [ hHBkhodAdf ] ; for ( int i = 0 ; i < hHBkhodAdf ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int min = 10000000 ; int count = 0 ; for ( int i = 0 ; i < hHBkhodAdf ; i ++ ) { if ( p [ i ] < min ) { count ++ ; min = p [ i ] ; } } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; class CAqhEtZeVs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CAqhEtZeVs = sc . nextInt ( ) ; int [ ] a = new int [ CAqhEtZeVs ] ; for ( int i = 0 ; i < CAqhEtZeVs ; i ++ ) a [ i ] = sc . nextInt ( ) ; int [ ] dp = new int [ CAqhEtZeVs + 1 ] ; for ( int i = 2 ; i <= CAqhEtZeVs ; 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 [ CAqhEtZeVs ] ) ; } } import java . util . Scanner ; import java . util . Arrays ; class sbNEByaBID { boolean [ ] primeTable ; public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; PrimeNum prime = new PrimeNum ( 100000010 ) ; prime . createTable ( ) ; int sbNEByaBID = cin . nextInt ( ) , ct = 0 ; for ( int i = 0 ; i < sbNEByaBID ; i ++ ) { int num = cin . nextInt ( ) ; if ( prime . judge ( num ) ) ct ++ ; } System . out . println ( ct ) ; } } class sbNEByaBID { private boolean [ ] primeTable ; private int maxNum ; PrimeNum ( int sbNEByaBID ) { primeTable = new boolean [ sbNEByaBID ] ; Arrays . fill ( primeTable , true ) ; this . maxNum = sbNEByaBID ; } 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 sbNEByaBID ) { return ( primeTable [ sbNEByaBID ] ) ; } protected int serch ( int sbNEByaBID ) { for ( int i = 2 ; i < maxNum ; i ++ ) { if ( primeTable [ i ] ) sbNEByaBID -- ; if ( sbNEByaBID == 0 ) return ( i ) ; } return ( - 1 ) ; } } import java . util . Scanner ; public class IyxEGlIwMC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IyxEGlIwMC = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int r = Integer . parseInt ( sc . next ( ) ) ; int result = Math . min ( Math . min ( IyxEGlIwMC + q , q + r ) , IyxEGlIwMC + r ) ; System . out . println ( result ) ; } } import java . util . Scanner ; public class tGvisUKxWD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tGvisUKxWD = sc . nextInt ( ) ; for ( int i = 9 ; i >= 0 ; i -- ) { if ( tGvisUKxWD > i * 111 ) { System . out . println ( ( i + 1 ) * 111 ) ; break ; } } } } import java . util . * ; import java . io . * ; public class UcgYVcZGzO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UcgYVcZGzO = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int ans = 0 ; int able = 2 * d + 1 ; for ( int i = 1 ; i < 20 ; i ++ ) { if ( i * able >= UcgYVcZGzO ) { ans = i ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; public class SHOtZAUDUF { public static void main ( String [ ] omkar ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; int SHOtZAUDUF = Integer . parseInt ( st . nextToken ( ) ) ; int res = SHOtZAUDUF / 500 ; res *= 1000 ; int lol = SHOtZAUDUF % 500 - SHOtZAUDUF % 5 ; System . out . println ( res + lol ) ; } } import java . util . * ; public class DSdfcmzKAk { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int DSdfcmzKAk = s . nextInt ( ) ; int m = s . nextInt ( ) ; int ans = 10000 ; for ( int i = 0 ; i < DSdfcmzKAk ; 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 LyWwULAkeU { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int LyWwULAkeU = sc . nextInt ( ) ; int ans = 0 ; if ( LyWwULAkeU >= 195 ) { ans = 5 ; } else if ( LyWwULAkeU >= 189 ) { ans = 4 ; } else if ( LyWwULAkeU >= 165 ) { ans = 3 ; } else if ( LyWwULAkeU >= 135 ) { ans = 2 ; } else if ( LyWwULAkeU >= 105 ) { ans = 1 ; } System . out . println ( ans ) ; } } import java . util . * ; public class jaqVAaUFtV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jaqVAaUFtV = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; int max = 1 ; for ( int i = 0 ; i < jaqVAaUFtV ; 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 gkhFQJWCjR { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; ArrayList < Integer > intArr = new ArrayList < Integer > ( ) ; for ( int gkhFQJWCjR = 0 ; gkhFQJWCjR < 3 ; gkhFQJWCjR ++ ) 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 bJsFGefHxu { 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 QnDTyjvAsi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String QnDTyjvAsi = sc . next ( ) ; if ( QnDTyjvAsi . equals ( " AAA " ) || QnDTyjvAsi . equals ( " BBB " ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; import java . io . * ; import java . math . * ; public class mlcrfvFazf { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int mlcrfvFazf = sc . nextInt ( ) ; int odd = sc . nextInt ( ) ; int ans = mlcrfvFazf * ( mlcrfvFazf - 1 ) / 2 + odd * ( odd - 1 ) / 2 ; System . out . println ( ans ) ; } } import java . util . * ; public class TfiLscDYMI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TfiLscDYMI = 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 CFCBGPXbgq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CFCBGPXbgq = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int abprice = CFCBGPXbgq * 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 = CFCBGPXbgq ; 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 NedDYKbfqO { 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 NedDYKbfqO = 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 == NedDYKbfqO && d == B ) { ans = i ; break ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class iDEmogxmSg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iDEmogxmSg = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int cnt = 0 ; for ( int i = iDEmogxmSg ; 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 dVpjBRgVGe { 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 dVpjBRgVGe = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { x [ i ] = sc . nextInt ( ) ; if ( x [ i ] == 0 ) { dVpjBRgVGe = i + 1 ; } } return dVpjBRgVGe ; } public void show ( int dVpjBRgVGe ) { System . out . println ( dVpjBRgVGe ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class LYnBmQhRXm { 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 LYnBmQhRXm = ( char ) ( aa . charAt ( 0 ) + 1 ) ; String vv = LYnBmQhRXm + " " ; p ( vv ) ; } } import java . util . Scanner ; public class KgsZgiYaPn { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; double KgsZgiYaPn = in . nextDouble ( ) ; double d = in . nextDouble ( ) ; int ans = 0 ; while ( KgsZgiYaPn -- > 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 CMeRQsPSSI { final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int CMeRQsPSSI = sc . nextInt ( ) ; if ( CMeRQsPSSI % 2 == 1 ) { System . out . println ( " No " ) ; return ; } String s = sc . next ( ) ; int l = ( int ) ( CMeRQsPSSI / 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 IMdWnRUvdL { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int IMdWnRUvdL = Integer . parseInt ( br . readLine ( ) ) ; int [ ] seqS = new int [ IMdWnRUvdL ] ; String [ ] line = br . readLine ( ) . split ( " " ) ; for ( int i = 0 ; i < IMdWnRUvdL ; 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 eeDEQrEgnB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eeDEQrEgnB = 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 ( eeDEQrEgnB > 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 ) { eeDEQrEgnB = eeDEQrEgnB - A_attack ; T_turn = 1 ; A_turn = 0 ; } } if ( eeDEQrEgnB > 0 ) { System . out . println ( " Yes " ) ; } else if ( eeDEQrEgnB <= 0 ) { System . out . println ( " No " ) ; } } } import java . util . * ; public class MjEsLHWdJZ { static int gcd ( int a , int b ) { return b > 0 ? gcd ( b , a % b ) : a ; } static long MjEsLHWdJZ = 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 bxsHlBnkUI { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long bxsHlBnkUI = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long x = scan . nextLong ( ) ; long y = scan . nextLong ( ) ; long c = bxsHlBnkUI * x ; long d = bxsHlBnkUI * 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 QvPaWkwgid { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String s1 = sc . next ( ) ; int QvPaWkwgid = 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 <= QvPaWkwgid && QvPaWkwgid <= 20000 ) { if ( 0 <= b && b <= 20000 ) { if ( op == '+' ) { System . out . println ( QvPaWkwgid + b ) ; } else if ( op == '-' ) { System . out . println ( QvPaWkwgid - b ) ; } else if ( op == '*' ) { System . out . println ( QvPaWkwgid * b ) ; } else if ( op == '/' ) { System . out . println ( QvPaWkwgid / b ) ; } } } } } } import java . util . * ; public class LWnAHmNbJy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LWnAHmNbJy = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int plus = LWnAHmNbJy + b ; int minus = LWnAHmNbJy - b ; int mult = LWnAHmNbJy * 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 CiWGcazdla { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int CiWGcazdla = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean [ ] ac = new boolean [ CiWGcazdla + 1 ] ; long [ ] wa = new long [ CiWGcazdla + 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 <= CiWGcazdla ; 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 FDFOqbmIBN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FDFOqbmIBN = sc . nextInt ( ) ; int [ ] d = new int [ FDFOqbmIBN ] ; for ( int i = 0 ; i < FDFOqbmIBN ; i ++ ) { String line = sc . next ( ) ; d [ i ] = Integer . parseInt ( line ) ; } int K = 0 ; int count = 0 ; int countLeft = 0 ; int countRight = FDFOqbmIBN ; Arrays . sort ( d ) ; for ( int i = 0 ; i < FDFOqbmIBN ; 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 qerAHDPxPu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qerAHDPxPu = 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 = qerAHDPxPu - ans ; if ( ans < 0 ) ans = - 1 ; sc . close ( ) ; System . out . println ( ans ) ; } } import java . util . * ; import java . math . * ; import java . io . * ; public class PJGjFjeOzc { public static void main ( String [ ] args ) throws Exception { int PJGjFjeOzc = 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 ZxKftEEZUC { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . nextLine ( ) ; String result = " " ; for ( int ZxKftEEZUC = 0 ; ZxKftEEZUC < str . length ( ) ; ZxKftEEZUC ++ ) { String s = str . substring ( ZxKftEEZUC , ZxKftEEZUC + 1 ) ; if ( s . equals ( s . toLowerCase ( ) ) ) { result += s . toUpperCase ( ) ; } else { result += s . toLowerCase ( ) ; } } System . out . println ( result ) ; } } import java . util . * ; public class XsNHAmnAOI { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int XsNHAmnAOI ; XsNHAmnAOI = in . nextInt ( ) ; SortedMap < String , Integer > poll = new TreeMap < String , Integer > ( ) ; int maxvote = 0 ; for ( long i = 0 ; i < XsNHAmnAOI ; 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 yKtDBHMrNz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yKtDBHMrNz = sc . nextInt ( ) ; int [ ] A = new int [ yKtDBHMrNz ] ; for ( int i = 0 ; i < yKtDBHMrNz ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } boolean ok = true ; for ( int i = 0 ; i < yKtDBHMrNz ; 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 eJsoFULudk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int eJsoFULudk = scanner . nextInt ( ) ; long sum = 0 ; for ( long i = 1 ; i < eJsoFULudk + 1 ; i ++ ) { if ( ! ( i % 3 == 0 || i % 5 == 0 ) ) { sum = sum + i ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; public class QeywWceOGi { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int QeywWceOGi = scanner . nextInt ( ) , y = scanner . nextInt ( ) ; System . out . println ( ( ( QeywWceOGi * 2 <= y ) && ( QeywWceOGi * 4 >= y ) && ( 0 == ( y & 1 ) ) ) ? " Yes " : " No " ) ; } } } import java . util . * ; import java . util . Collections ; public class pmKBSnAKxE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; for ( int pmKBSnAKxE = 0 ; pmKBSnAKxE <= 2 ; pmKBSnAKxE ++ ) { list . add ( sc . nextInt ( ) ) ; } int K = sc . nextInt ( ) ; Collections . sort ( list , Collections . reverseOrder ( ) ) ; for ( int pmKBSnAKxE = 0 ; pmKBSnAKxE < K ; pmKBSnAKxE ++ ) { list . set ( 0 , list . get ( 0 ) * 2 ) ; } System . out . println ( list . get ( 0 ) + list . get ( 1 ) + list . get ( 2 ) ) ; } } import java . util . * ; public class GXkEqVNiMh { Scanner sc = new Scanner ( System . in ) ; final int GXkEqVNiMh = 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 ccRnAGXoal { static String a ; public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int ccRnAGXoal = stdIn . nextInt ( ) ; int count = 0 ; IN : for ( int i = 0 ; i < ccRnAGXoal ; 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 YVHJpMVTnA { static long YVHJpMVTnA = 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 zctqAyJKdz { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int zctqAyJKdz = stdIn . nextInt ( ) ; String S = stdIn . next ( ) ; String answer = " Yes " ; if ( zctqAyJKdz % 2 != 0 ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } for ( int i = 0 ; i < zctqAyJKdz / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( zctqAyJKdz / 2 + i ) ) { System . out . println ( " No " ) ; System . exit ( 0 ) ; } } System . out . println ( answer ) ; } } import java . util . Scanner ; public class IhdXIlzqLZ { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; String answer = " " ; final int IhdXIlzqLZ = scan . nextInt ( ) ; int len = scan . nextInt ( ) ; String [ ] words = new String [ IhdXIlzqLZ ] ; for ( int i = 0 ; i < IhdXIlzqLZ ; i ++ ) { words [ i ] = scan . next ( ) ; } for ( int i = 1 ; i < IhdXIlzqLZ ; 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 < IhdXIlzqLZ ; i ++ ) { answer = answer . concat ( words [ i ] ) ; } System . out . println ( answer ) ; } } import java . util . Scanner ; public class spIBkEtNAE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int spIBkEtNAE = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int x = 1 ; int result = 0 ; while ( x < B ) { x += ( spIBkEtNAE - 1 ) ; result ++ ; } System . out . println ( result ) ; } } import java . util . * ; public class APAQkdocSe { static final long APAQkdocSe = ( 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 ] %= APAQkdocSe ; } } } System . out . println ( dp [ n ] ) ; sc . close ( ) ; } } import java . util . * ; import java . lang . Math ; public class iMHDeZaNlR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iMHDeZaNlR = sc . nextInt ( ) ; int count = 0 ; int count2 = 0 ; if ( iMHDeZaNlR == 1 ) count -- ; if ( iMHDeZaNlR == 2 ) count -= 2 ; while ( count2 < 2 ) { count ++ ; if ( iMHDeZaNlR == 4 ) count2 ++ ; if ( iMHDeZaNlR % 2 == 0 ) iMHDeZaNlR /= 2 ; else iMHDeZaNlR = iMHDeZaNlR * 3 + 1 ; } System . out . println ( count ) ; } } import java . util . * ; public class BsgSAZwuHm { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int BsgSAZwuHm = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] price = new int [ BsgSAZwuHm ] ; for ( int i = 0 ; i < BsgSAZwuHm ; 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 TRFbiUrLvN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TRFbiUrLvN = sc . nextInt ( ) ; int ac = 0 , wa = 0 , tle = 0 , re = 0 ; while ( TRFbiUrLvN -- > 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 jbHUAwSNis { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jbHUAwSNis = Integer . parseInt ( sc . next ( ) ) ; int [ ] d = new int [ jbHUAwSNis ] ; for ( int i = 0 ; i < jbHUAwSNis ; i ++ ) { d [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( d ) ; System . out . println ( d [ jbHUAwSNis / 2 ] - d [ jbHUAwSNis / 2 - 1 ] ) ; } } import java . util . Scanner ; public class PfvjKjiPht { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PfvjKjiPht = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; int ans = 0 ; for ( int i = 0 ; i < PfvjKjiPht ; i ++ ) { int digit = sc . nextInt ( ) ; if ( min > digit ) { min = digit ; ans ++ ; } } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class WXdzznXNpf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WXdzznXNpf , j , t ; int cnt = 0 ; int check = 0 ; int mini , minikey ; int n = sc . nextInt ( ) ; int [ ] num ; num = new int [ n ] ; for ( WXdzznXNpf = 0 ; WXdzznXNpf < n ; WXdzznXNpf ++ ) { num [ WXdzznXNpf ] = sc . nextInt ( ) ; } for ( WXdzznXNpf = 0 ; WXdzznXNpf < n - 1 ; WXdzznXNpf ++ ) { mini = WXdzznXNpf ; minikey = num [ WXdzznXNpf ] ; for ( j = WXdzznXNpf + 1 ; j < n ; j ++ ) { if ( num [ j ] < minikey ) { mini = j ; minikey = num [ j ] ; check ++ ; } } t = num [ WXdzznXNpf ] ; num [ WXdzznXNpf ] = num [ mini ] ; num [ mini ] = t ; if ( check > 0 ) cnt ++ ; check = 0 ; } for ( WXdzznXNpf = 0 ; WXdzznXNpf < n - 1 ; WXdzznXNpf ++ ) { System . out . print ( num [ WXdzznXNpf ] + " " ) ; } System . out . println ( num [ n - 1 ] ) ; System . out . println ( cnt ) ; sc . close ( ) ; } } import java . util . * ; class aJkBkVziZe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aJkBkVziZe = 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 ; aJkBkVziZe = i ; } } } System . out . println ( aJkBkVziZe ) ; 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 qHxBqUwNSl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qHxBqUwNSl = 0 ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; while ( ( A - 1 ) * ( qHxBqUwNSl - 1 ) + A < B ) { qHxBqUwNSl ++ ; } System . out . println ( qHxBqUwNSl ) ; sc . close ( ) ; } } import java . util . * ; class XJGDpjaoai { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XJGDpjaoai = sc . nextInt ( ) ; int ans = 0 ; for ( int i = XJGDpjaoai ; 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 fpbfWsBLtU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fpbfWsBLtU = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; if ( fpbfWsBLtU <= b ) { if ( b <= c ) { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * c + fpbfWsBLtU + b ) ) ; } else { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * b + fpbfWsBLtU + c ) ) ; } } else { if ( fpbfWsBLtU <= c ) { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * c + fpbfWsBLtU + b ) ) ; } else { System . out . println ( ( int ) ( Math . pow ( 2 , k ) * fpbfWsBLtU + b + c ) ) ; } } } } import java . util . Scanner ; public class cUraEcrSCy { private static int countPower ( int n ) { int cUraEcrSCy = 0 ; while ( n % 2 == 0 ) { ++ cUraEcrSCy ; n /= 2 ; } return cUraEcrSCy ; } 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 AQyCdpVlcK { public static int AQyCdpVlcK ; 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 ) ; AQyCdpVlcK = scan . nextInt ( ) ; List = new int [ AQyCdpVlcK ] ; for ( int i = 0 ; i < AQyCdpVlcK ; i ++ ) { List [ i ] = scan . nextInt ( ) ; } SelectionSort ( ) ; if ( AQyCdpVlcK == 1 ) System . out . println ( List [ 0 ] ) ; else { for ( int i = 0 ; i < AQyCdpVlcK ; i ++ ) { if ( i == AQyCdpVlcK - 1 ) System . out . println ( List [ AQyCdpVlcK - 1 ] ) ; else System . out . print ( List [ i ] + " " ) ; } } System . out . println ( Count ) ; } public static void SelectionSort ( ) { for ( int i = 0 ; i < AQyCdpVlcK ; i ++ ) { min_j = i ; for ( int j = i ; j < AQyCdpVlcK ; 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 jBwgIrLtat { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jBwgIrLtat = 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 MSSryYSErD { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner in = new Scanner ( System . in ) ; int MSSryYSErD = in . nextInt ( ) ; int m = in . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) sum += in . nextInt ( ) ; int re = MSSryYSErD - sum ; if ( re < 0 ) { System . out . println ( - 1 ) ; } else { System . out . println ( re ) ; } } } import java . util . Scanner ; public class ACdnbMTSLm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ACdnbMTSLm = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] a = sc . nextLine ( ) . split ( " " ) ; int [ ] array = new int [ ACdnbMTSLm ] ; for ( int i = 0 ; i < ACdnbMTSLm ; i ++ ) { array [ i ] = Integer . parseInt ( a [ i ] ) ; } int changeCount = 0 ; int minj ; for ( int i = 0 ; i < ACdnbMTSLm ; i ++ ) { minj = i ; for ( int j = i ; j < ACdnbMTSLm ; 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 EQqsfoUNFz { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int EQqsfoUNFz = scanner . nextInt ( ) ; int [ ] a = new int [ 10000 ] ; int max = - 1000000 ; int min = 1000000 ; long sum = 0 ; for ( int i = 0 ; i < EQqsfoUNFz ; 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 yPlXsGgsyv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yPlXsGgsyv = sc . nextInt ( ) ; int [ ] h = new int [ yPlXsGgsyv + 2 ] ; int maxh = 0 ; int zero1 = 0 ; int zero2 = yPlXsGgsyv ; int ret = 0 ; for ( int i = 1 ; i < yPlXsGgsyv + 1 ; i ++ ) { h [ i ] = sc . nextInt ( ) ; maxh = Math . max ( maxh , h [ i ] ) ; } h [ 0 ] = 0 ; h [ yPlXsGgsyv + 1 ] = 0 ; for ( int i = 1 ; i <= maxh ; i ++ ) { zero1 = 0 ; zero2 = yPlXsGgsyv ; for ( int j = 0 ; j < yPlXsGgsyv + 2 ; j ++ ) { if ( h [ j ] == 0 ) { zero2 = j ; if ( zero2 - zero1 > 1 ) { ret ++ ; } zero1 = zero2 ; } } for ( int k = 0 ; k < yPlXsGgsyv + 2 ; k ++ ) { if ( h [ k ] > 0 ) { h [ k ] -- ; } } } System . out . println ( ret ) ; } } import java . util . * ; public class ryxoqwUOjg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ryxoqwUOjg = sc . nextInt ( ) ; int attack1 = sc . nextInt ( ) ; int hp2 = sc . nextInt ( ) ; int attack2 = sc . nextInt ( ) ; while ( ryxoqwUOjg > 0 && hp2 > 0 ) { hp2 -= attack1 ; if ( hp2 <= 0 ) { System . out . println ( " Yes " ) ; continue ; } ryxoqwUOjg -= attack2 ; if ( ryxoqwUOjg <= 0 ) { System . out . println ( " No " ) ; continue ; } } } } import java . util . * ; public class ZISlJZPthG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZISlJZPthG = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int [ ] p = new int [ ZISlJZPthG ] ; for ( int i = 0 ; i < q ; i ++ ) p [ sc . nextInt ( ) - 1 ] ++ ; for ( int i = 0 ; i < ZISlJZPthG ; 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 rouwDvpJLC { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int rouwDvpJLC = 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 [ rouwDvpJLC ] ; for ( int i = 0 ; i < q ; i ++ ) { a [ i ] = Integer . parseInt ( in . readLine ( ) ) ; count [ a [ i ] - 1 ] ++ ; } for ( int i = 0 ; i < rouwDvpJLC ; i ++ ) { if ( k - ( q - count [ i ] ) <= 0 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } } import java . util . * ; public class QnbcKUrpbh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int QnbcKUrpbh = sc . nextInt ( ) ; int [ ] d = new int [ QnbcKUrpbh ] ; for ( int i = 0 ; i < QnbcKUrpbh ; i ++ ) { d [ i ] = sc . nextInt ( ) ; } Arrays . sort ( d ) ; int count = 0 ; for ( int i = 1 ; i < QnbcKUrpbh ; i ++ ) { if ( d [ i ] == d [ i - 1 ] ) count ++ ; } System . out . println ( QnbcKUrpbh - count ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . math . BigDecimal ; import java . util . Scanner ; public class RjuOEPEidD { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; long RjuOEPEidD = sc . nextInt ( ) ; long H = sc . nextInt ( ) ; long x = sc . nextInt ( ) ; long y = sc . nextInt ( ) ; sc . close ( ) ; String a = BigDecimal . valueOf ( ( ( double ) RjuOEPEidD * H ) / 2.0 ) . toPlainString ( ) ; out . print ( a ) ; out . print ( " " ) ; if ( RjuOEPEidD == 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 DdZMRdJBhZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DdZMRdJBhZ = 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 ( ( DdZMRdJBhZ * DdZMRdJBhZ ) + ( b * b ) - ( 2 * DdZMRdJBhZ * b * cosA ) ) ; System . out . println ( answer ) ; } } import java . util . Scanner ; public class JqZBTxVBDO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JqZBTxVBDO = sc . nextInt ( ) ; for ( ; ; JqZBTxVBDO ++ ) { if ( isPrime ( JqZBTxVBDO ) ) break ; } System . out . println ( JqZBTxVBDO ) ; } public static boolean isPrime ( int JqZBTxVBDO ) { if ( ( JqZBTxVBDO % 2 == 0 && JqZBTxVBDO != 2 || JqZBTxVBDO == 1 ) ) return false ; for ( int i = 3 ; i <= Math . sqrt ( JqZBTxVBDO ) ; i += 2 ) { if ( JqZBTxVBDO % i == 0 ) return false ; } return true ; } } import java . util . * ; public class zzwyeimIqF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zzwyeimIqF = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; if ( Y % 2 == 1 ) { System . out . println ( " No " ) ; } else { int y = Y / 2 ; if ( y - zzwyeimIqF < 0 ) { System . out . println ( " No " ) ; } else if ( y - 2 * zzwyeimIqF > 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } } import java . util . Scanner ; class POhyxzdXZU { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int POhyxzdXZU , b , c ; POhyxzdXZU = scn . nextInt ( ) ; b = scn . nextInt ( ) ; c = scn . nextInt ( ) ; System . out . printf ( ( POhyxzdXZU + b + c ) <= 21 ? " win " : " bust " ) ; } } import java . util . * ; class iqehbcbEMB { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String iqehbcbEMB = in . nextLine ( ) ; if ( iqehbcbEMB . equals ( " ABC " ) ) System . out . println ( " ARC " ) ; else if ( iqehbcbEMB . equals ( " ARC " ) ) System . out . println ( " ABC " ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class mVlcdzvqSR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mVlcdzvqSR = sc . nextInt ( ) ; Integer [ ] a = new Integer [ mVlcdzvqSR ] ; Integer [ ] tmpA = new Integer [ mVlcdzvqSR ] ; for ( int i = 0 ; i < mVlcdzvqSR ; 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 < mVlcdzvqSR ; i ++ ) { if ( a [ i ] == first ) { System . out . println ( second ) ; } else { System . out . println ( first ) ; } } sc . close ( ) ; } } import java . util . Scanner ; class xpwONWxqZg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String s1 = sc . next ( ) ; int xpwONWxqZg = Integer . parseInt ( s1 ) ; String s2 = sc . next ( ) ; int W = Integer . parseInt ( s2 ) ; if ( xpwONWxqZg <= 300 && W <= 300 ) { if ( xpwONWxqZg == 0 && W == 0 ) { break ; } for ( int i = 1 ; i <= xpwONWxqZg ; i ++ ) { if ( i == 1 || i == xpwONWxqZg ) { 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 SuEjQRXYVz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int SuEjQRXYVz = s . length ; int res = 0 ; for ( int i = 0 ; i < ( SuEjQRXYVz - 1 - i ) ; i ++ ) { if ( s [ i ] != s [ SuEjQRXYVz - 1 - i ] ) { res ++ ; } } System . out . println ( res ) ; } } import java . util . * ; public class krtfFDIkAe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int krtfFDIkAe = 0 ; int W = 0 ; while ( true ) { krtfFDIkAe = sc . nextInt ( ) ; W = sc . nextInt ( ) ; if ( krtfFDIkAe != 0 && W != 0 ) { for ( int i = 0 ; i < krtfFDIkAe ; 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 XEVEqnhSEd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { String cards = sc . next ( ) ; if ( cards . equals ( " - " ) ) { break ; } int XEVEqnhSEd = sc . nextInt ( ) ; for ( int i = 0 ; i < XEVEqnhSEd ; 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 cullzsUrZh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int cullzsUrZh = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int counter = 0 ; for ( int i = cullzsUrZh ; 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 dhFIacilzb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int dhFIacilzb = scanner . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; long total = 0 ; for ( int i = 0 ; i < dhFIacilzb ; 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 iVnVIxGKXJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iVnVIxGKXJ = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] array = { 1 , 1 , 1 } ; array [ iVnVIxGKXJ - 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 RApnugDakw { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int RApnugDakw = in . nextInt ( ) ; if ( RApnugDakw == 0 ) break ; int [ ] numbers = new int [ RApnugDakw ] ; for ( int i = 0 ; i < RApnugDakw ; i ++ ) numbers [ i ] = in . nextInt ( ) ; long double_sum = 0 ; for ( int i = 0 ; i < RApnugDakw ; i ++ ) double_sum += numbers [ i ] ; double_sum = double_sum * double_sum ; long sum_double = 0 ; for ( int i = 0 ; i < RApnugDakw ; i ++ ) sum_double += ( numbers [ i ] * numbers [ i ] ) ; double sd = Math . sqrt ( ( sum_double - double_sum / ( double ) RApnugDakw ) / ( double ) RApnugDakw ) ; System . out . printf ( " %5.8f " , sd ) ; System . out . println ( ) ; } } } import java . util . Scanner ; public class nEFFsRHwaQ { public static void main ( String [ ] args ) { int nEFFsRHwaQ = 0 ; Scanner scan = new Scanner ( System . in ) ; ; while ( true ) { nEFFsRHwaQ ++ ; int a = scan . nextInt ( ) ; if ( a == 0 ) { break ; } System . out . println ( " Case " + nEFFsRHwaQ + " : " + a ) ; } scan . close ( ) ; } } import javax . swing . * ; import java . io . * ; import java . util . * ; import java . math . * ; import static java . util . Comparator . * ; public class DDglFHVvmf { public static void main ( String [ ] args ) throws IOException { FastReader s = new FastReader ( ) ; int DDglFHVvmf = s . nextInt ( ) ; int b = s . nextInt ( ) ; int numOfSock = 1 ; int count = 0 ; while ( numOfSock < b ) { numOfSock -= 1 ; numOfSock += DDglFHVvmf ; count ++ ; } System . out . println ( count ) ; } } class DDglFHVvmf { 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 AjJcBwMMAP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AjJcBwMMAP = sc . nextInt ( ) ; boolean flg = true ; int i = 1 ; while ( flg ) { int cg = 1000 * i - AjJcBwMMAP ; if ( cg >= 0 ) { flg = false ; System . out . println ( cg ) ; } i ++ ; } } } import java . util . Scanner ; import java . util . Arrays ; public class aanTJjoKat { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int aanTJjoKat = scan . nextInt ( ) ; long [ ] a = new long [ aanTJjoKat ] ; for ( int i = 0 ; i < aanTJjoKat ; i ++ ) { a [ i ] = scan . nextLong ( ) ; if ( a [ i ] == 0 ) { System . out . println ( 0 ) ; return ; } } Arrays . sort ( a ) ; long ans = 1 ; for ( int i = aanTJjoKat - 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 TKyqMcbkcN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TKyqMcbkcN = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int left = 0 ; int right = TKyqMcbkcN ; 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 xizgMRZMnt { static int xizgMRZMnt = 0 ; public static void main ( String [ ] args ) { int anser = 100000000 ; Scanner scan = new Scanner ( System . in ) ; xizgMRZMnt = scan . nextInt ( ) ; ArrayList < Integer > address = new ArrayList < > ( ) ; for ( int i = 0 ; i < xizgMRZMnt ; i ++ ) { address . add ( scan . nextInt ( ) ) ; } Collections . sort ( address ) ; for ( int i = address . get ( 0 ) ; i <= address . get ( xizgMRZMnt - 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 < xizgMRZMnt ; i ++ ) { sum = sum + ( j - array . get ( i ) ) * ( j - array . get ( i ) ) ; } return sum ; } } import java . util . Scanner ; public class uwoLJRjyDM { public static void main ( String [ ] args ) { int uwoLJRjyDM = 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 ) { uwoLJRjyDM ++ ; if ( uwoLJRjyDM == 3 ) { hako = 1 ; } } else { uwoLJRjyDM = 0 ; } } if ( hako == 1 ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . * ; import java . util . stream . * ; class shijngXRuR { 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 shijngXRuR = sc . nextInt ( ) ; for ( int i = 0 ; i < shijngXRuR ; 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 FWYrTEJDUh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int FWYrTEJDUh = scan . nextInt ( ) ; int last = FWYrTEJDUh % 100 ; int first = ( FWYrTEJDUh - 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 DXnSKZtnUO { public static void main ( String [ ] args ) { try { InputStreamReader isr = new InputStreamReader ( System . in ) ; BufferedReader br = new BufferedReader ( isr ) ; String a = br . readLine ( ) ; int DXnSKZtnUO = 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 ( DXnSKZtnUO >= a . length ( ) ) { System . out . println ( " A " ) ; break ; } now = a . substring ( DXnSKZtnUO , DXnSKZtnUO + 1 ) ; DXnSKZtnUO ++ ; } 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 iyyIGZqXpu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final long iyyIGZqXpu = 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 ) - ( ( iyyIGZqXpu - 1 ) - ( iyyIGZqXpu - 1 ) / C - ( iyyIGZqXpu - 1 ) / D + ( iyyIGZqXpu - 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 QfCGpqGmxo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QfCGpqGmxo = sc . nextInt ( ) ; int ans = 0 ; while ( QfCGpqGmxo >= 5 ) { if ( QfCGpqGmxo >= 500 ) { QfCGpqGmxo -= 500 ; ans += 1000 ; } else { QfCGpqGmxo -= 5 ; ans += 5 ; } } System . out . println ( ans ) ; } } import java . util . * ; public class joWeCPqPZU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int joWeCPqPZU = 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 < joWeCPqPZU ; 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 KupcLRjjyT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; try { String w = sc . nextLine ( ) ; int KupcLRjjyT = w . length ( ) ; Map < String , Integer > map = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < KupcLRjjyT ; 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 DoGgoyRKgn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; sc . useDelimiter ( " \\ s " ) ; int DoGgoyRKgn = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int d = DoGgoyRKgn / b ; int r = DoGgoyRKgn % b ; double A = DoGgoyRKgn ; 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 TagOUnDxFu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TagOUnDxFu = sc . nextInt ( ) ; Integer [ ] a = new Integer [ TagOUnDxFu ] ; for ( int i = 0 ; i < TagOUnDxFu ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( a , Collections . reverseOrder ( ) ) ; int A = a [ 0 ] , B = 0 ; for ( int i = 1 ; i < TagOUnDxFu ; i ++ ) { if ( i % 2 == 0 ) { A += a [ i ] ; } else { B += a [ i ] ; } } System . out . println ( A - B ) ; } } import java . util . Scanner ; public class JdJfADlvbO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JdJfADlvbO = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; sc . close ( ) ; if ( JdJfADlvbO * b >= JdJfADlvbO + b && JdJfADlvbO * b >= JdJfADlvbO - b ) { System . out . println ( JdJfADlvbO * b ) ; } else if ( JdJfADlvbO + b >= JdJfADlvbO - b && JdJfADlvbO + b >= JdJfADlvbO * b ) { System . out . println ( JdJfADlvbO + b ) ; } else { System . out . println ( JdJfADlvbO - b ) ; } } } import java . util . Scanner ; public class bfYKxTXXcM { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; scan . close ( ) ; boolean bfYKxTXXcM = true ; if ( S . charAt ( 2 ) != S . charAt ( 3 ) ) bfYKxTXXcM = false ; else if ( S . charAt ( 4 ) != S . charAt ( 5 ) ) bfYKxTXXcM = false ; if ( bfYKxTXXcM ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class nYmaCMxHQY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long nYmaCMxHQY = sc . nextLong ( ) ; long sum = 0 ; for ( int a = 1 ; a <= nYmaCMxHQY ; ++ a ) { for ( int b = 1 ; b <= nYmaCMxHQY ; ++ b ) { long g1 = findGcd ( a , b ) ; for ( int c = 1 ; c <= nYmaCMxHQY ; ++ 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 rLqMjLVxaF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rLqMjLVxaF = sc . nextInt ( ) ; int [ ] [ ] A = new int [ 2 ] [ rLqMjLVxaF ] ; for ( int i = 0 ; i < rLqMjLVxaF ; i ++ ) { A [ 0 ] [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < rLqMjLVxaF ; i ++ ) { A [ 1 ] [ i ] = sc . nextInt ( ) ; } int ans ; int tempofans = 0 ; int num = 0 ; for ( int k = 0 ; k < rLqMjLVxaF ; k ++ ) { num = 0 ; for ( int j = 0 ; j < rLqMjLVxaF ; 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 oOnNJJCKJU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int oOnNJJCKJU = sc . nextInt ( ) ; int xx = 0 ; int yy = 0 ; int time = 0 ; for ( int i = 0 ; i < oOnNJJCKJU ; 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 oJevmFbtDI { 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 oJevmFbtDI = sc . nextInt ( ) ; int color2_n = sc . nextInt ( ) ; final String target = sc . next ( ) ; if ( target . equals ( color1 ) ) { oJevmFbtDI -- ; } else if ( target . equals ( color2 ) ) { color2_n -- ; } System . out . println ( oJevmFbtDI + " " + color2_n ) ; sc . close ( ) ; } } import java . util . Scanner ; public class XJVHIiGQkw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XJVHIiGQkw = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; sc . close ( ) ; int C = 1 ; int D = 0 ; while ( B > C ) { C += XJVHIiGQkw - 1 ; D ++ ; } System . out . println ( D ) ; } } import java . util . Scanner ; public class zVWQteuMPF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zVWQteuMPF = sc . nextInt ( ) ; int [ ] l = new int [ zVWQteuMPF ] ; for ( int i = 0 ; i < zVWQteuMPF ; i ++ ) { l [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; int max = 0 ; int sum = 0 ; for ( int i = 0 ; i < zVWQteuMPF ; 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 wnlazrMrBu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wnlazrMrBu = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int tap = 1 ; int atap = 0 ; while ( tap < b ) { tap -- ; tap += wnlazrMrBu ; 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 wkzwtetsrR { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int wkzwtetsrR = Integer . parseInt ( str [ 0 ] ) ; int y = Integer . parseInt ( str [ 1 ] ) ; System . out . println ( wkzwtetsrR * y + " " + ( 2 * wkzwtetsrR + 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 UXOesUgVQR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UXOesUgVQR = 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 ) UXOesUgVQR ++ ; } System . out . print ( UXOesUgVQR ) ; System . out . println ( ) ; } } import java . util . Scanner ; public class JefUUNpWEl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; int JefUUNpWEl = 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 ( JefUUNpWEl == tmp ) { result = " Yes " ; } } } System . out . println ( result ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class XGFMsKZwHw { public static void main ( String [ ] args ) throws Exception { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { int XGFMsKZwHw = Integer . parseInt ( reader . readLine ( ) ) ; String [ ] array = reader . readLine ( ) . split ( " " ) ; int [ ] H = new int [ XGFMsKZwHw ] ; for ( int i = 0 ; i < XGFMsKZwHw ; i ++ ) { H [ i ] = Integer . parseInt ( array [ i ] ) ; } boolean ret = true ; for ( int i = XGFMsKZwHw - 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 rBCGSsfIEm { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int rBCGSsfIEm = 1 ; while ( true ) { String str = input . nextLine ( ) ; if ( ! str . equals ( " 0 " ) ) { System . out . println ( " Case " + rBCGSsfIEm + " : " + str ) ; rBCGSsfIEm = rBCGSsfIEm + 1 ; } else { break ; } } } } import java . util . Scanner ; public class KGXidKSkLw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KGXidKSkLw = Integer . parseInt ( sc . next ( ) ) ; int [ ] p = new int [ KGXidKSkLw ] ; int idx ; for ( idx = 0 ; idx < KGXidKSkLw ; idx ++ ) { p [ idx ] = Integer . parseInt ( sc . next ( ) ) ; } int cnt = 0 ; for ( idx = 1 ; idx < KGXidKSkLw - 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 hkqTRcDGgi { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int hkqTRcDGgi = in . nextInt ( ) ; int [ ] [ ] A = new int [ 2 ] [ hkqTRcDGgi ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < hkqTRcDGgi ; j ++ ) { A [ i ] [ j ] = in . nextInt ( ) ; } } int ans = 0 ; for ( int i = 0 ; i < hkqTRcDGgi ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j <= i ; j ++ ) { sum += A [ 0 ] [ j ] ; } for ( int j = i ; j < hkqTRcDGgi ; j ++ ) { sum += A [ 1 ] [ j ] ; } ans = Math . max ( ans , sum ) ; } System . out . println ( ans ) ; in . close ( ) ; } } import java . util . * ; public class ELgaIWDisc { public static Scanner in = new Scanner ( System . in ) ; public static int ELgaIWDisc = 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 == ELgaIWDisc - 1 ) { return 0 ; } else { if ( dp [ idx ] == - 1 ) { long c1 = solve ( idx + 1 ) + Math . abs ( h [ idx ] - h [ idx + 1 ] ) ; long c2 = oo ; if ( ELgaIWDisc - 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 ; } ELgaIWDisc = in . nextInt ( ) ; for ( int i = 0 ; i < ELgaIWDisc ; i ++ ) { h [ i ] = in . nextInt ( ) ; } System . out . println ( solve ( 0 ) ) ; } } import java . util . * ; public class HdFmTShJZr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int HdFmTShJZr = sc . nextInt ( ) ; String [ ] S = new String [ HdFmTShJZr ] ; for ( int i = 0 ; i < HdFmTShJZr ; ++ i ) { S [ i ] = sc . next ( ) ; } int [ ] C = new int [ 4 ] ; for ( int i = 0 ; i < HdFmTShJZr ; ++ 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 NhtaAxXNdM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NhtaAxXNdM = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; sc . close ( ) ; int a = T / NhtaAxXNdM ; System . out . println ( a * B ) ; } } import java . util . * ; public class DCvYYnpWRz { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; int DCvYYnpWRz = scn . nextInt ( ) ; int b = scn . nextInt ( ) ; int ans = DCvYYnpWRz * b ; int ans2 = 0 ; for ( int i = 0 ; i < b ; i ++ ) { ans2 += DCvYYnpWRz ; } System . out . println ( ans2 ) ; } } import java . util . Scanner ; class SizakPVMoX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String SizakPVMoX = sc . next ( ) ; System . out . println ( SizakPVMoX . replaceAll ( " \\ - " , " " ) . length ( ) - ( 4 - SizakPVMoX . replaceAll ( " \\ - " , " " ) . length ( ) ) ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class hkLxmGIHxh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hkLxmGIHxh = sc . nextInt ( ) ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; int [ ] A = new int [ hkLxmGIHxh ] ; for ( int i = 0 ; i < hkLxmGIHxh ; i ++ ) { int a = sc . nextInt ( ) ; map . put ( i , a ) ; A [ i ] = a ; } sc . close ( ) ; Arrays . sort ( A ) ; for ( int i = 0 ; i < hkLxmGIHxh ; i ++ ) { int except = map . get ( i ) ; System . out . println ( A [ hkLxmGIHxh - 1 ] == except ? A [ hkLxmGIHxh - 2 ] : A [ hkLxmGIHxh - 1 ] ) ; } } } import java . util . * ; import java . io . * ; public class DRHIOJhspb { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int DRHIOJhspb = in . nextInt ( ) ; System . out . println ( Math . min ( DRHIOJhspb * in . nextInt ( ) , in . nextInt ( ) ) ) ; } } import java . util . Scanner ; public class hRwCwUElCs { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int hRwCwUElCs = scanner . nextInt ( ) ; int ans = 0 ; if ( hRwCwUElCs == 0 ) { ans = 1 ; } System . out . println ( ans ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } } import java . util . * ; public class dfFZmCbBLo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dfFZmCbBLo = sc . nextInt ( ) ; int [ ] nums = new int [ dfFZmCbBLo ] ; for ( int i = 0 ; i < dfFZmCbBLo ; 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 FVPahsAAlz { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int FVPahsAAlz = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( FVPahsAAlz * B ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class ZBbTHCWTgR { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . ZBbTHCWTgR ) ) ) { String ZBbTHCWTgR = br . readLine ( ) ; System . out . println ( ZBbTHCWTgR . equals ( " Sunny " ) ? " Cloudy " : ZBbTHCWTgR . equals ( " Cloudy " ) ? " Rainy " : " Sunny " ) ; } } } import java . util . * ; class xdwLZbYoWP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xdwLZbYoWP = 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 ( xdwLZbYoWP , c ) , 0 ) ) ; } } import java . util . Scanner ; public class qyNDJQthnV { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int qyNDJQthnV = 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 ) { qyNDJQthnV ++ ; } else { if ( maxCount < qyNDJQthnV ) { maxCount = qyNDJQthnV ; } qyNDJQthnV = 0 ; } actual = siguiente ; } if ( maxCount < qyNDJQthnV ) { maxCount = qyNDJQthnV ; } System . out . println ( maxCount ) ; } } import java . util . Scanner ; import java . lang . Math ; public class uYSpVEuMex { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int uYSpVEuMex = sc . nextInt ( ) ; int [ ] [ ] grid = new int [ 2 ] [ uYSpVEuMex ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < uYSpVEuMex ; j ++ ) { grid [ i ] [ j ] = sc . nextInt ( ) ; } } int [ ] [ ] ans = new int [ 2 ] [ uYSpVEuMex ] ; ans [ 0 ] [ 0 ] = grid [ 0 ] [ 0 ] ; ans [ 1 ] [ 0 ] = grid [ 1 ] [ 0 ] + ans [ 0 ] [ 0 ] ; for ( int j = 1 ; j < uYSpVEuMex ; j ++ ) { ans [ 0 ] [ j ] = grid [ 0 ] [ j ] + ans [ 0 ] [ j - 1 ] ; } for ( int j = 1 ; j < uYSpVEuMex ; j ++ ) { ans [ 1 ] [ j ] = grid [ 1 ] [ j ] + Math . max ( ans [ 1 ] [ j - 1 ] , ans [ 0 ] [ j ] ) ; } System . out . println ( ans [ 1 ] [ uYSpVEuMex - 1 ] ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; public class ZuWEimsEDw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZuWEimsEDw = sc . nextInt ( ) ; double t = sc . nextDouble ( ) ; double a = sc . nextDouble ( ) ; double [ ] h = new double [ ZuWEimsEDw ] ; double [ ] dist = new double [ ZuWEimsEDw ] ; int answer = 0 ; double tmp = 10000000 ; for ( int i = 0 ; i < ZuWEimsEDw ; i ++ ) { h [ i ] = sc . nextDouble ( ) ; } for ( int i = 0 ; i < ZuWEimsEDw ; i ++ ) { dist [ i ] = Math . abs ( a - ( t - h [ i ] * 0.006 ) ) ; } for ( int i = 0 ; i < ZuWEimsEDw ; i ++ ) { if ( tmp > dist [ i ] ) { answer = i ; tmp = dist [ i ] ; } } System . out . println ( answer + 1 ) ; } } import java . util . * ; public class pJSgHvzBEO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pJSgHvzBEO = sc . nextInt ( ) ; int x = 0 ; while ( true ) { if ( pJSgHvzBEO <= 1000 ) { x = 1000 - pJSgHvzBEO ; break ; } else { pJSgHvzBEO = pJSgHvzBEO - 1000 ; } } System . out . println ( x ) ; } } import java . util . * ; public class PWlJWKIcbb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String PWlJWKIcbb = sc . next ( ) ; String [ ] str2 = PWlJWKIcbb . 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 pNQXtTYWRz { public static void main ( String [ ] args ) { try { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String a = reader . readLine ( ) ; String [ ] b = a . split ( " " ) ; int pNQXtTYWRz = Integer . parseInt ( b [ 0 ] ) ; int d = Integer . parseInt ( b [ 1 ] ) ; String [ ] e = new String [ d ] ; int [ ] [ ] f = new int [ pNQXtTYWRz ] [ d ] ; for ( int g = 0 ; g < pNQXtTYWRz ; 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 < pNQXtTYWRz ; 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 CjmycNqDQG { 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 CjmycNqDQG = Integer . parseInt ( line [ 0 ] ) ; int y = Integer . parseInt ( line [ 1 ] ) ; if ( CjmycNqDQG == 0 && y == 0 ) { break ; } else { sb . append ( Integer . toString ( CjmycNqDQG < y ? CjmycNqDQG : y ) ) . append ( " " ) . append ( Integer . toString ( CjmycNqDQG < y ? y : CjmycNqDQG ) ) . append ( " \n " ) ; } } System . out . print ( sb ) ; } } import java . util . Scanner ; public class mSjbVUNzkA { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mSjbVUNzkA = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; if ( k <= mSjbVUNzkA + b ) { if ( k >= mSjbVUNzkA ) { System . out . println ( mSjbVUNzkA ) ; } else { System . out . println ( k ) ; } } else { System . out . println ( mSjbVUNzkA - ( k - mSjbVUNzkA - b ) ) ; } sc . close ( ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class WFjOFdUKca { public static void main ( String [ ] args ) { Scanner inData = new Scanner ( System . in ) ; int WFjOFdUKca = inData . nextInt ( ) ; int K = inData . nextInt ( ) ; int [ ] P = new int [ WFjOFdUKca ] ; for ( int i = 0 ; i < WFjOFdUKca ; 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 CnJxcWpKdz { public static void main ( String [ ] args ) { try { int CnJxcWpKdz ; int paper ; Scanner scan = new Scanner ( System . in ) ; String N = scan . next ( ) ; CnJxcWpKdz = Integer . parseInt ( N ) ; if ( CnJxcWpKdz % 2 == 0 ) { paper = CnJxcWpKdz / 2 ; } else { paper = CnJxcWpKdz / 2 + 1 ; } System . out . println ( paper ) ; } catch ( Exception e ) { System . out . println ( " error " ) ; } } } import java . util . Scanner ; public class SErNXVkANI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( ( System . in ) ) ; int SErNXVkANI = sc . nextInt ( ) ; int [ ] a = new int [ SErNXVkANI ] ; int ans = 0 , o = 0 , e = 0 ; for ( int i = 0 ; i < SErNXVkANI ; i ++ ) { int x = sc . nextInt ( ) ; if ( x % 2 == 0 ) { a [ e ] = x ; e ++ ; } else { o ++ ; } } if ( o != SErNXVkANI ) { 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 zfIMdhlIpS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long zfIMdhlIpS = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long t = sc . nextLong ( ) ; if ( zfIMdhlIpS <= x ) { System . out . println ( t ) ; return ; } long ans = 0 ; ans += ( zfIMdhlIpS / x ) * t ; zfIMdhlIpS %= x ; if ( zfIMdhlIpS > 0 ) { ans += t ; } sc . close ( ) ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class jpadmMKDqd { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String a = scan . next ( ) ; char jpadmMKDqd = a . charAt ( 0 ) ; char c = a . charAt ( 1 ) ; char d = a . charAt ( 2 ) ; char f = 'R' ; if ( jpadmMKDqd == c && c == d && d == f ) { System . out . println ( " 3 " ) ; } else if ( ( jpadmMKDqd == c && c == f ) || ( c == d && d == f ) ) { System . out . println ( " 2 " ) ; } else if ( ! ( jpadmMKDqd == f || c == f || d == f ) ) { System . out . println ( " 0 " ) ; } else { System . out . println ( " 1 " ) ; } } } class SArEGOVTsa { public static void main ( String [ ] args ) { java . util . Scanner sc = new java . util . Scanner ( System . in ) ; final int SArEGOVTsa = sc . nextInt ( ) ; final int L = sc . nextInt ( ) ; int output = 0 ; if ( - 1 <= L - 1 ) { output -= L ; } else if ( L - 1 <= - SArEGOVTsa ) { output -= L + SArEGOVTsa - 1 ; } output += SArEGOVTsa * ( L - 1 ) + SArEGOVTsa * ( SArEGOVTsa + 1 ) / 2 ; System . out . println ( output ) ; } } import java . util . * ; public class ispgmLvRVB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ispgmLvRVB = 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 ; ispgmLvRVB ++ ; } } System . out . println ( ispgmLvRVB ) ; } } import java . util . Scanner ; public class ocEGUQBJbv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] ary = sc . next ( ) . toCharArray ( ) ; int ocEGUQBJbv = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( ary [ i ] == '+' ) { ocEGUQBJbv ++ ; } else { ocEGUQBJbv -- ; } } sc . close ( ) ; System . out . println ( ocEGUQBJbv ) ; } } import java . util . Scanner ; public class HdUoZoNUFT { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; String W = scn . nextLine ( ) ; int HdUoZoNUFT = 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 ) ) { HdUoZoNUFT ++ ; } } System . out . println ( HdUoZoNUFT ) ; } } import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class KbcsXThDpm { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int KbcsXThDpm = scanner . nextInt ( ) ; Map < String , Long > counts = new HashMap < > ( ) ; for ( int i = 0 ; i < KbcsXThDpm ; ++ 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 SIhpZEGJIS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SIhpZEGJIS = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int q = Integer . parseInt ( sc . next ( ) ) ; int [ ] point = new int [ SIhpZEGJIS ] ; Arrays . fill ( point , k - q ) ; for ( int i = 0 ; i < q ; i ++ ) { point [ Integer . parseInt ( sc . next ( ) ) - 1 ] ++ ; } for ( int i = 0 ; i < SIhpZEGJIS ; i ++ ) { if ( point [ i ] >= 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class olOKgrtNlp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int olOKgrtNlp = scan . nextInt ( ) ; System . out . println ( ( double ) ( olOKgrtNlp - olOKgrtNlp / 2 ) / ( double ) ( olOKgrtNlp ) ) ; } } import java . util . Scanner ; public class taOxhasmRu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line1 = sc . nextLine ( ) ; int taOxhasmRu = Integer . parseInt ( line1 ) ; String line2 = sc . nextLine ( ) ; String [ ] kari = line2 . split ( " " ) ; int [ ] A = new int [ taOxhasmRu ] ; for ( int i = 0 ; i < taOxhasmRu ; i ++ ) { A [ i ] = Integer . parseInt ( kari [ i ] ) ; } System . out . println ( line2 ) ; int v = 0 ; int j = 0 ; for ( int i = 1 ; i < taOxhasmRu ; 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 < taOxhasmRu - 1 ; k ++ ) { System . out . print ( A [ k ] ) ; System . out . print ( " " ) ; } System . out . println ( A [ taOxhasmRu - 1 ] ) ; } } } import java . util . * ; import java . lang . * ; import java . io . * ; public class PhHFGcuGou { 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 PhHFGcuGou = in . nextLong ( ) ; long b = in . nextLong ( ) ; long max = Math . max ( PhHFGcuGou , b ) ; for ( long i = 0 ; i < max ; i ++ ) { if ( Math . abs ( PhHFGcuGou - i ) == Math . abs ( b - i ) ) { out . println ( i ) ; out . close ( ) ; return ; } } out . println ( " IMPOSSIBLE " ) ; out . close ( ) ; } static class PhHFGcuGou { 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 cCTsOvmJBq { 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 cCTsOvmJBq , b ; for ( int i = 0 ; i < line . length ; i ++ ) { switch ( line [ i ] ) { case " + " : cCTsOvmJBq = stack . pollLast ( ) ; b = stack . pollLast ( ) ; stack . offer ( b + cCTsOvmJBq ) ; break ; case " - " : cCTsOvmJBq = stack . pollLast ( ) ; b = stack . pollLast ( ) ; stack . offer ( b - cCTsOvmJBq ) ; break ; case " * " : cCTsOvmJBq = stack . pollLast ( ) ; b = stack . pollLast ( ) ; stack . offer ( b * cCTsOvmJBq ) ; break ; default : stack . offer ( Integer . parseInt ( line [ i ] ) ) ; break ; } } System . out . println ( stack . poll ( ) ) ; } } import java . util . Scanner ; public class tJtwmHoLgh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tJtwmHoLgh = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; while ( 0 < c && 0 < tJtwmHoLgh ) { c -= b ; if ( c <= 0 ) { break ; } tJtwmHoLgh -= d ; } if ( 0 < tJtwmHoLgh ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class fpuiUdfHEs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fpuiUdfHEs = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int s = ( fpuiUdfHEs >= B ) ? fpuiUdfHEs : B ; int f = ( fpuiUdfHEs >= B ) ? B : fpuiUdfHEs ; 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 ZjUpDUkBDV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZjUpDUkBDV = sc . nextInt ( ) ; Map < String , Integer > map = new HashMap < > ( ) ; while ( ZjUpDUkBDV > 0 ) { String a = sc . next ( ) ; if ( map . containsKey ( a ) ) { map . put ( a , map . get ( a ) + 1 ) ; } else { map . put ( a , 1 ) ; } ZjUpDUkBDV -- ; } 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 hKBQqqJzFF { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int hKBQqqJzFF = scan . nextInt ( ) ; long total = 0 ; for ( int a = 1 ; a < hKBQqqJzFF + 1 ; a ++ ) { for ( int b = 1 ; b < hKBQqqJzFF + 1 ; b ++ ) { for ( int c = 1 ; c < hKBQqqJzFF + 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 WXTKxEPzQt { 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 WXTKxEPzQt = 0 ; int maxCount = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( acgt . contains ( sArray [ i ] ) ) { WXTKxEPzQt ++ ; if ( WXTKxEPzQt > maxCount ) { maxCount = WXTKxEPzQt ; } } else { WXTKxEPzQt = 0 ; } } System . out . println ( maxCount ) ; } } import java . util . Scanner ; class SsQwKWzlxu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . next ( ) ; int SsQwKWzlxu = Integer . parseInt ( s1 ) ; String s2 = sc . next ( ) ; int b = Integer . parseInt ( s2 ) ; double p = Math . pow ( 10 , 9 ) ; if ( 1 <= SsQwKWzlxu && SsQwKWzlxu <= p ) { if ( 1 <= b && b <= p ) { int d = SsQwKWzlxu / b ; int r = SsQwKWzlxu % b ; double f = ( double ) SsQwKWzlxu / ( double ) b ; System . out . println ( d + " " + r + " " + String . format ( " %1$3f " , f ) ) ; } } } } import java . util . * ; class GskIRDMYlL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GskIRDMYlL = sc . nextInt ( ) ; long [ ] A = new long [ GskIRDMYlL + 2 ] ; long [ ] B = new long [ GskIRDMYlL + 1 ] ; long cnt = 0 ; long wk = 0 ; long wk2 = 0 ; for ( int i = 0 ; i < GskIRDMYlL + 1 ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < GskIRDMYlL ; i ++ ) { B [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < GskIRDMYlL ; 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 DSRWqYxOVi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int DSRWqYxOVi = str . DSRWqYxOVi ( ) ; for ( int i = 0 ; i < DSRWqYxOVi ; 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 caYwWWtjpg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int caYwWWtjpg = sc . nextInt ( ) ; HashSet < Integer > set = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < caYwWWtjpg ; i ++ ) { int number = sc . nextInt ( ) ; set . add ( number ) ; } System . out . println ( set . size ( ) ) ; } } import java . util . Scanner ; class deJgfhIuzS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String deJgfhIuzS = sc . nextLine ( ) ; deJgfhIuzS = deJgfhIuzS . replaceAll ( " eraser " , " " ) ; deJgfhIuzS = deJgfhIuzS . replaceAll ( " erase " , " " ) ; deJgfhIuzS = deJgfhIuzS . replaceAll ( " dreamer " , " " ) ; deJgfhIuzS = deJgfhIuzS . replaceAll ( " dream " , " " ) ; if ( deJgfhIuzS . equals ( " " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . io . IOException ; import java . util . Arrays ; import java . util . Scanner ; public class JYcniTHFlO { public static void main ( String [ ] args ) throws IOException { try ( Scanner s = new Scanner ( System . in ) ) { int JYcniTHFlO = 3 ; int [ ] array = new int [ JYcniTHFlO ] ; for ( int i = 0 ; i < JYcniTHFlO ; 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 jpGuEhGYjJ { public static void main ( String [ ] args ) { HashMap < Integer , Integer > h = new HashMap < > ( ) ; int jpGuEhGYjJ = 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 ) { jpGuEhGYjJ ++ ; } } System . out . println ( jpGuEhGYjJ ) ; } } import java . util . Scanner ; import java . util . InputMismatchException ; class vutHxoyXJn { public static void main ( String [ ] args ) { int vutHxoyXJn = 0 , y = 0 ; int [ ] [ ] z ; Scanner scanner = new Scanner ( System . in ) ; vutHxoyXJn = 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 RLUCqqeEYB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RLUCqqeEYB = sc . nextInt ( ) ; System . out . println ( RLUCqqeEYB * 2 * 3.14 ) ; } } import java . util . * ; public class LmnYibVHbe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LmnYibVHbe = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] [ ] vectorA = new int [ LmnYibVHbe ] [ m ] ; int [ ] vectorB = new int [ m ] ; int [ ] vectorC = new int [ LmnYibVHbe ] ; for ( int i = 0 ; i < LmnYibVHbe ; 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 < LmnYibVHbe ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { vectorC [ i ] += vectorA [ i ] [ j ] * vectorB [ j ] ; } } for ( int i = 0 ; i < LmnYibVHbe ; 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 BnjgyTmDwB { 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 BnjgyTmDwB = Integer . parseInt ( s ) ; s = in . readLine ( ) ; String [ ] as = s . split ( " " ) ; int [ ] a = new int [ BnjgyTmDwB ] ; for ( int i = 0 ; i < BnjgyTmDwB ; i ++ ) { a [ i ] = Integer . parseInt ( as [ i ] ) ; } output ( a ) ; insertionSort ( a , BnjgyTmDwB ) ; } private static void insertionSort ( int [ ] a , int BnjgyTmDwB ) { for ( int i = 1 ; i < BnjgyTmDwB ; 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 ZEmvuyHPVj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZEmvuyHPVj , second ; ZEmvuyHPVj = sc . nextInt ( ) ; second = sc . nextInt ( ) ; if ( ZEmvuyHPVj > 0 && ZEmvuyHPVj < 10 && second > 0 && second < 10 ) System . out . println ( ZEmvuyHPVj * second ) ; else System . out . println ( " -1 " ) ; } } import java . util . * ; import java . io . * ; class BhsxePokWo { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; long BhsxePokWo = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long K = sc . nextLong ( ) ; long nA = Math . max ( 0 , BhsxePokWo - K ) ; long nB = Math . max ( 0 , B - Math . max ( K - BhsxePokWo , 0 ) ) ; System . out . println ( nA + " " + nB ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } } import java . util . * ; public class dAxBAZYLZf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dAxBAZYLZf = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; String [ ] S = sc . next ( ) . split ( " - " ) ; if ( S . length == 2 ) { if ( S [ 0 ] . length ( ) == dAxBAZYLZf && 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 ZcGJxUxIBx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ZcGJxUxIBx ; while ( ( ZcGJxUxIBx = scan . nextInt ( ) ) != 0 ) { int [ ] s = new int [ ZcGJxUxIBx ] ; double m = 0 ; for ( int i = 0 ; i < ZcGJxUxIBx ; i ++ ) { s [ i ] = scan . nextInt ( ) ; m += s [ i ] ; } m /= ZcGJxUxIBx ; double sum = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { sum += ( s [ i ] - m ) * ( s [ i ] - m ) ; } System . out . println ( Math . sqrt ( sum / ZcGJxUxIBx ) ) ; } } } import java . util . Scanner ; public class bzMaoVRCRc { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int bzMaoVRCRc = in . nextInt ( ) ; int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int sum2 = 0 ; for ( int i = 1 ; i <= bzMaoVRCRc ; 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 NEqwoXfGqh { 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 INFNkVUPNn { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int INFNkVUPNn = 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 ( ) ) ) { INFNkVUPNn ++ ; } } } System . out . println ( INFNkVUPNn ) ; } } import java . util . Scanner ; public class wkyAzMEwwN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wkyAzMEwwN = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] ACs = new int [ wkyAzMEwwN + 1 ] ; int [ ] WAs = new int [ wkyAzMEwwN + 1 ] ; for ( int i = 0 ; i < wkyAzMEwwN + 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 <= wkyAzMEwwN ; 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 CwunmebGCg { public static void main ( String [ ] args ) { int CwunmebGCg , 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 ++ ) { CwunmebGCg = n ; l = 0 ; m = n / 2 ; while ( true ) { if ( s [ m ] == t [ j ] ) { count ++ ; break ; } if ( m == l ) { break ; } if ( s [ m ] > t [ j ] ) { CwunmebGCg = m ; m = ( CwunmebGCg + l ) / 2 ; } if ( s [ m ] < t [ j ] ) { l = m + 1 ; m = ( CwunmebGCg + l ) / 2 ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class RRBvnxQTnr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long RRBvnxQTnr = Long . parseLong ( sc . next ( ) ) ; long b = Long . parseLong ( sc . next ( ) ) ; long k = Long . parseLong ( sc . next ( ) ) ; long resultA = RRBvnxQTnr - 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 oCpZaxSjtg { private static int [ ] heights ; private static int oCpZaxSjtg , ans = Integer . MAX_VALUE , k ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; oCpZaxSjtg = sc . nextInt ( ) ; k = sc . nextInt ( ) ; heights = new int [ oCpZaxSjtg + 3 ] ; dp = new int [ oCpZaxSjtg + 3 ] ; for ( int i = 1 ; i <= oCpZaxSjtg ; 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 == oCpZaxSjtg ) return 0 ; if ( dp [ ind ] != - 1 ) { return dp [ ind ] ; } int min = Integer . MAX_VALUE ; for ( int i = ind + 1 ; i <= Math . min ( oCpZaxSjtg , 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 AhBwrqhxqn { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { String AhBwrqhxqn = " No " ; String inStr = br . readLine ( ) ; String target = br . readLine ( ) ; String ring = inStr + inStr ; if ( inStr . length ( ) >= target . length ( ) ) { if ( ring . indexOf ( target ) != - 1 ) AhBwrqhxqn = " Yes " ; } System . out . println ( AhBwrqhxqn ) ; } } } import java . io . * ; class IrydZuUiGS { public static void main ( String [ ] args ) throws IOException { BufferedReader buf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int IrydZuUiGS = Integer . parseInt ( buf . readLine ( ) ) ; String [ ] str ; int tarou = 0 ; int hanako = 0 ; for ( int i = 0 ; i < IrydZuUiGS ; 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 dQAfJQMgJt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] T = new int [ 5 ] ; int [ ] D = new int [ 5 ] ; for ( int dQAfJQMgJt = 0 ; dQAfJQMgJt < 5 ; dQAfJQMgJt ++ ) { T [ dQAfJQMgJt ] = sc . nextInt ( ) ; } int sum = 0 ; for ( int dQAfJQMgJt = 0 ; dQAfJQMgJt < 5 ; dQAfJQMgJt ++ ) { if ( T [ dQAfJQMgJt ] % 10 == 0 ) { D [ dQAfJQMgJt ] = T [ dQAfJQMgJt ] ; } else { D [ dQAfJQMgJt ] = ( T [ dQAfJQMgJt ] / 10 ) * 10 + 10 ; } } int max = 0 ; for ( int dQAfJQMgJt = 0 ; dQAfJQMgJt < 5 ; dQAfJQMgJt ++ ) { if ( ( D [ dQAfJQMgJt ] - T [ dQAfJQMgJt ] ) > max ) { max = D [ dQAfJQMgJt ] - T [ dQAfJQMgJt ] ; } sum = sum + D [ dQAfJQMgJt ] ; } System . out . println ( sum - max ) ; } } import java . util . Scanner ; public class hsWDKadTFg { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int hsWDKadTFg = s . nextInt ( ) ; int [ ] a = new int [ hsWDKadTFg ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = 0 ; } for ( int i = 0 ; i < hsWDKadTFg - 1 ; i ++ ) { a [ s . nextInt ( ) - 1 ] ++ ; } for ( int i : a ) { System . out . println ( i ) ; } } } import java . util . * ; public class kZJeJMMevK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int kZJeJMMevK = 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 ++ ; } kZJeJMMevK = Math . kZJeJMMevK ( kZJeJMMevK , sum ) ; } System . out . println ( kZJeJMMevK ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; class btYymaSiUF { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int btYymaSiUF = scanner . nextInt ( ) ; List < Integer > numList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < btYymaSiUF ; i ++ ) { numList . add ( scanner . nextInt ( ) ) ; } scanner . close ( ) ; int flag = 1 ; int c = 0 ; while ( flag == 1 ) { flag = 0 ; for ( int j = btYymaSiUF - 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 < btYymaSiUF ; i ++ ) { System . out . print ( numList . get ( i ) ) ; if ( i < btYymaSiUF - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; System . out . println ( c ) ; } } import java . util . Scanner ; public class jlsauniOBO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jlsauniOBO = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ jlsauniOBO ] ; int [ ] b = new int [ jlsauniOBO ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ sc . nextInt ( ) - 1 ] ++ ; b [ sc . nextInt ( ) - 1 ] ++ ; } sc . close ( ) ; for ( int i = 0 ; i < jlsauniOBO ; i ++ ) { System . out . println ( a [ i ] + b [ i ] ) ; } } } import java . util . Scanner ; public class wBHanpGrMs { 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 wBHanpGrMs = 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 ] ) { wBHanpGrMs = false ; break ; } wBHanpGrMs = true ; } if ( wBHanpGrMs == true ) { msg = " Yes " ; break ; } } System . out . println ( msg ) ; } } import java . math . BigDecimal ; import java . util . Scanner ; public class PMjSkIjBhN { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; long PMjSkIjBhN = stdIn . nextLong ( ) ; double b = stdIn . nextDouble ( ) ; BigDecimal bd1 = BigDecimal . valueOf ( PMjSkIjBhN ) ; BigDecimal bd2 = BigDecimal . valueOf ( b ) ; BigDecimal ans = bd1 . multiply ( bd2 ) . setScale ( 0 , BigDecimal . ROUND_DOWN ) ; System . out . println ( ans ) ; } } import java . util . * ; class NBgwuPveal { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NBgwuPveal = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . printf ( " %d " , c ) ; System . out . printf ( " %d " , NBgwuPveal ) ; System . out . print ( b ) ; } } import java . util . LinkedList ; import java . util . Scanner ; public class kkojOaqkQZ { 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 kkojOaqkQZ ; int op2 ; for ( String item : items ) { switch ( item ) { case " + " : op2 = stack . pop ( ) ; kkojOaqkQZ = stack . pop ( ) ; stack . push ( kkojOaqkQZ + op2 ) ; break ; case " - " : op2 = stack . pop ( ) ; kkojOaqkQZ = stack . pop ( ) ; stack . push ( kkojOaqkQZ - op2 ) ; break ; case " * " : op2 = stack . pop ( ) ; kkojOaqkQZ = stack . pop ( ) ; stack . push ( kkojOaqkQZ * op2 ) ; break ; default : stack . push ( Integer . parseInt ( item ) ) ; } } System . out . println ( stack . pop ( ) ) ; } } class kkojOaqkQZ { 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 aztDSZbsKu { public static void main ( String [ ] args ) { boolean aztDSZbsKu = 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 tSlnBwPJzZ { static class tSlnBwPJzZ { public void find ( int perimeter , int [ ] arr ) { arr [ arr . length - 1 ] = perimeter ; int tSlnBwPJzZ = Integer . MAX_VALUE ; int antiClock = ( arr [ 0 ] + perimeter ) % perimeter ; tSlnBwPJzZ = Math . min ( tSlnBwPJzZ , perimeter - ( perimeter - arr [ arr . length - 2 ] ) - antiClock ) ; tSlnBwPJzZ = Math . min ( tSlnBwPJzZ , perimeter - ( arr [ 1 ] - arr [ 0 ] ) ) ; for ( int i = 1 ; i < arr . length - 1 ; i ++ ) { tSlnBwPJzZ = Math . min ( tSlnBwPJzZ , perimeter - ( arr [ i + 1 ] - arr [ i ] ) ) ; tSlnBwPJzZ = Math . min ( tSlnBwPJzZ , perimeter - ( arr [ i ] - arr [ i - 1 ] ) ) ; } System . out . println ( tSlnBwPJzZ ) ; } } 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 qfBNlnKtzl { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int qfBNlnKtzl = sc . nextInt ( ) ; int L = sc . nextInt ( ) ; String [ ] A = new String [ qfBNlnKtzl ] ; for ( int i = 0 ; i < qfBNlnKtzl ; 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 TrDMWnSeEn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] [ ] rooms = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int TrDMWnSeEn = 0 ; TrDMWnSeEn < 4 ; TrDMWnSeEn ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { rooms [ TrDMWnSeEn ] [ j ] [ k ] = 0 ; } } } int n = sc . nextInt ( ) ; for ( int TrDMWnSeEn = 0 ; TrDMWnSeEn < n ; TrDMWnSeEn ++ ) { 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 TrDMWnSeEn = 0 ; TrDMWnSeEn < 4 ; TrDMWnSeEn ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { System . out . print ( " " + rooms [ TrDMWnSeEn ] [ j ] [ k ] ) ; } System . out . println ( " " ) ; } if ( TrDMWnSeEn < 3 ) { System . out . println ( " #################### " ) ; } } sc . close ( ) ; } } import java . util . Scanner ; class OKhIPNxSHV { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int OKhIPNxSHV = Integer . parseInt ( scan . next ( ) ) ; int a = Integer . parseInt ( scan . next ( ) ) ; int b = Integer . parseInt ( scan . next ( ) ) ; int sum = 0 ; for ( int i = 1 ; i < OKhIPNxSHV + 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 KflfDiOjWl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KflfDiOjWl = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int num = KflfDiOjWl / a ; int amari = KflfDiOjWl % a ; System . out . println ( amari == 0 ? num : num + 1 ) ; } } import java . util . Scanner ; public class TRDtwKHBkR { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { String TRDtwKHBkR = scanner . nextLine ( ) ; System . out . println ( " 2018/01/ " + TRDtwKHBkR . split ( " / " ) [ 2 ] ) ; } } } import java . util . * ; public class REwjujqHhM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int REwjujqHhM = sc . nextInt ( ) ; int ans = 0 ; int count = 0 ; if ( REwjujqHhM < 105 ) { System . out . println ( 0 ) ; return ; } for ( int i = 105 ; i <= REwjujqHhM ; 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 uVIiANcaXK { public static void main ( String ... args ) { Scanner in = new Scanner ( System . in ) ; int uVIiANcaXK = in . nextInt ( ) ; int k = in . nextInt ( ) ; int q = in . nextInt ( ) ; int [ ] poinst = new int [ uVIiANcaXK ] ; 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 sCVoAhsIBT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sCVoAhsIBT = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) sCVoAhsIBT += sc . nextInt ( ) ; System . out . println ( sCVoAhsIBT < 22 ? " win " : " bust " ) ; } } import java . util . * ; public class sqpbeStyva { public static void main ( String [ ] args ) { solve_148_A ( ) ; return ; } private static void solve_148_A ( ) { Scanner sc = new Scanner ( System . in ) ; int sqpbeStyva = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C ; C = ( 6 - sqpbeStyva - B ) ; System . out . println ( C ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class qqfjSRsnVv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qqfjSRsnVv = sc . nextInt ( ) ; HashSet < Long > hs = new HashSet < > ( ) ; for ( int i = 0 ; i < qqfjSRsnVv ; i ++ ) { hs . add ( sc . nextLong ( ) ) ; } String ans = hs . size ( ) == qqfjSRsnVv ? " 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 yGwMXmCiPc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yGwMXmCiPc = Integer . parseInt ( sc . next ( ) ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int sumA = A * yGwMXmCiPc ; System . out . println ( ( sumA >= B ? B : sumA ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class mQsCCSFGKX { static boolean binary_search ( int x , int [ ] data ) { int mQsCCSFGKX = 0 , right = data . length ; while ( true ) { int mid = ( mQsCCSFGKX + right ) / 2 ; if ( mQsCCSFGKX > right ) return false ; if ( data [ mid ] == x ) { return true ; } else if ( data [ mid ] < x ) { mQsCCSFGKX = 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 RRmXJiaJHf { public static void main ( String [ ] args ) throws Exception { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int RRmXJiaJHf = in . nextInt ( ) ; int W = in . nextInt ( ) ; System . out . println ( W >= RRmXJiaJHf ? " unsafe " : " safe " ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class ZnjdTGyMRX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZnjdTGyMRX = 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 ( ZnjdTGyMRX ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . io . * ; class qiFTQcIkAf { public static void main ( String [ ] args ) { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String qiFTQcIkAf = br . readLine ( ) ; String p = br . readLine ( ) ; qiFTQcIkAf = qiFTQcIkAf + qiFTQcIkAf ; if ( qiFTQcIkAf . equals ( " " ) || p . equals ( " " ) ) System . exit ( 0 ) ; if ( qiFTQcIkAf . indexOf ( p ) != - 1 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } catch ( Exception e ) { System . err . println ( e ) ; } } } import java . util . * ; class XeHTLsetSc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XeHTLsetSc = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; for ( int i = 0 ; i <= XeHTLsetSc ; i ++ ) { int x = i * 10000 ; if ( x > Y ) break ; for ( int j = 0 ; j <= XeHTLsetSc - i ; j ++ ) { int y = j * 5000 ; if ( ( x + y ) > Y ) break ; if ( ( Y - x - y ) / 1000 == ( XeHTLsetSc - i - j ) ) { System . out . println ( i + " " + j + " " + ( Y - x - y ) / 1000 ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . util . Scanner ; public class oTTtWoLjDP { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; int oTTtWoLjDP = Integer . parseInt ( std . next ( ) ) ; int [ ] line = new int [ oTTtWoLjDP ] ; int temp = 0 ; int exchange = 0 ; for ( int i = 0 ; i < oTTtWoLjDP ; i ++ ) { line [ i ] = Integer . parseInt ( std . next ( ) ) ; } boolean flag = true ; while ( flag ) { flag = false ; for ( int j = ( oTTtWoLjDP - 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 < oTTtWoLjDP ; i ++ ) { outsd += " " + line [ i ] ; } System . out . println ( outsd ) ; System . out . println ( exchange ) ; } } import java . util . Scanner ; public class iyWuPLiWnU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iyWuPLiWnU = 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 , iyWuPLiWnU ) ; System . out . println ( front + lower + back ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class lInLLVHlGJ { 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 lInLLVHlGJ = 0 ; lInLLVHlGJ < aa . length ; lInLLVHlGJ ++ ) { a [ lInLLVHlGJ ] = Long . parseLong ( aa [ lInLLVHlGJ ] ) ; } 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 uEKFAHEPUB { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int uEKFAHEPUB = 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 <= uEKFAHEPUB ; 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 HzFcyTdvvg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int HzFcyTdvvg = sc . nextInt ( ) ; if ( HzFcyTdvvg == 0 ) { break ; } double [ ] s = new double [ HzFcyTdvvg ] ; double sum = 0 ; for ( int i = 0 ; i < HzFcyTdvvg ; i ++ ) { s [ i ] = sc . nextDouble ( ) ; sum += s [ i ] ; } double average = sum / HzFcyTdvvg ; double res = 0 ; for ( int i = 0 ; i < HzFcyTdvvg ; i ++ ) { res += Math . pow ( s [ i ] - average , 2 ) / HzFcyTdvvg ; } System . out . println ( Math . sqrt ( res ) ) ; } } } import java . util . Scanner ; public class PBIbiQDyRA { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int PBIbiQDyRA = 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 ; } } PBIbiQDyRA = Math . PBIbiQDyRA ( PBIbiQDyRA , cnt ) ; } System . out . println ( PBIbiQDyRA ) ; } } import java . util . * ; public class KGdTZGirrf { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int KGdTZGirrf = stdIn . nextInt ( ) ; int [ ] s = new int [ KGdTZGirrf ] ; s [ 2 ] = KGdTZGirrf % 10 ; KGdTZGirrf /= 10 ; s [ 1 ] = KGdTZGirrf % 10 ; KGdTZGirrf /= 10 ; s [ 0 ] = KGdTZGirrf % 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 yIdsAtuIbs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long yIdsAtuIbs = sc . nextLong ( ) ; long n = ( int ) ( Math . log ( yIdsAtuIbs ) / Math . log ( 2 ) ) + 1 ; long ans = ( long ) Math . pow ( 2 , n ) - 1 ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class MezTWRQQpZ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int MezTWRQQpZ = scan . nextInt ( ) ; int ans = MezTWRQQpZ + MezTWRQQpZ * MezTWRQQpZ + MezTWRQQpZ * MezTWRQQpZ * MezTWRQQpZ ; 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 EaqZXCRmqL { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; Integer [ ] mountains = new Integer [ 10 ] ; for ( int EaqZXCRmqL = 0 ; EaqZXCRmqL < 10 ; EaqZXCRmqL ++ ) { mountains [ EaqZXCRmqL ] = sc . nextInt ( ) ; } Arrays . sort ( mountains , Collections . reverseOrder ( ) ) ; StringBuilder sb = new StringBuilder ( " " ) ; for ( int EaqZXCRmqL = 0 ; EaqZXCRmqL < 3 ; EaqZXCRmqL ++ ) { sb . append ( mountains [ EaqZXCRmqL ] ) ; sb . append ( '\n' ) ; } System . out . print ( sb ) ; } } import java . util . * ; public class OgCskBrHtF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OgCskBrHtF = sc . nextInt ( ) ; int [ ] array = new int [ OgCskBrHtF ] ; int sum = 0 ; for ( int i = 0 ; i < OgCskBrHtF ; i ++ ) { array [ i ] = sc . nextInt ( ) ; sum += array [ i ] ; } int sum2 = 0 ; int dif = 0 ; int min = 10000 ; for ( int i = 0 ; i < OgCskBrHtF ; 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 JFNfBqGWgL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JFNfBqGWgL = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int result = 0 ; int lower ; int upper ; lower = Math . max ( JFNfBqGWgL , c ) ; upper = Math . min ( b , d ) ; if ( upper >= lower ) { result = upper - lower ; } System . out . println ( result ) ; } } import java . util . Scanner ; public class HtCUAJGoiu { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int HtCUAJGoiu = sc . nextInt ( ) ; sc . close ( ) ; for ( int i = HtCUAJGoiu ; 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 pyuIkMVdVI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long pyuIkMVdVI = sc . nextLong ( ) ; long ans = 100 ; for ( long i = 1 ; i * i <= pyuIkMVdVI ; i ++ ) { if ( pyuIkMVdVI % i == 0 ) { ans = Math . min ( ans , getDigits ( pyuIkMVdVI / 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 WFLmcoPYgH { public static void main ( String [ ] args ) throws IOException { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ) { final String s = reader . readLine ( ) ; int WFLmcoPYgH = Integer . parseInt ( s ) ; boolean flg = false ; for ( int i = 0 ; i <= WFLmcoPYgH ; i ++ ) { for ( int j = 0 ; j <= WFLmcoPYgH ; j ++ ) { if ( WFLmcoPYgH == 4 * i + 7 * j ) { flg = true ; break ; } } } System . out . println ( flg ? " Yes " : " No " ) ; } } } import java . util . Scanner ; import java . util . Scanner ; public class ehJBWcwaqS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; boolean ehJBWcwaqS = false ; for ( int i = 0 ; i < s . length ( ) ; i = i + 2 ) { if ( ! ( s . charAt ( i ) == 'R' || s . charAt ( i ) == 'U' || s . charAt ( i ) == 'D' ) ) { ehJBWcwaqS = 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' ) ) { ehJBWcwaqS = true ; break ; } } if ( ehJBWcwaqS ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class ndYcAZaIRG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ndYcAZaIRG = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = ndYcAZaIRG * b ; int d = ndYcAZaIRG + b ; int e = ndYcAZaIRG - 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 rGrfyhVFeL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rGrfyhVFeL = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int x = rGrfyhVFeL - 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 tQyKQVLXKf { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int tQyKQVLXKf = in . nextInt ( ) ; System . out . println ( 2 * 3.14 * tQyKQVLXKf ) ; } } import java . util . Scanner ; public class bmxEzvzxbT { static Scanner scan ; public static boolean judgePN ( int a ) { if ( a == 1 ) return false ; int bmxEzvzxbT = a ; for ( int i = 2 ; i < a ; i ++ ) { bmxEzvzxbT = a / i ; if ( a % i == 0 ) return false ; if ( i > bmxEzvzxbT ) 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 BeiRWILxIx { public static void main ( final String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; boolean BeiRWILxIx = true ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { char tap = S . charAt ( i ) ; if ( i % 2 == 1 ) { if ( tap == 'R' ) BeiRWILxIx = false ; } else { if ( tap == 'L' ) BeiRWILxIx = false ; } } System . out . println ( BeiRWILxIx ? " Yes " : " No " ) ; } } import java . util . * ; import static java . util . Map . Entry . comparingByValue ; import static java . util . stream . Collectors . toMap ; public class ISNHMbRkgd { public static void main ( String [ ] args ) { Scanner Input = new Scanner ( System . in ) ; int ISNHMbRkgd = Input . nextInt ( ) ; HashMap < String , Integer > HM = new HashMap ( ) ; for ( int I = 0 ; I < ISNHMbRkgd ; I ++ ) { String S = Input . next ( ) ; if ( ! HM . containsKey ( S ) ) { HM . put ( S , 0 ) ; } } System . out . println ( HM . size ( ) ) ; } } import java . util . Scanner ; public class PImjcDRszH { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int PImjcDRszH = s . nextInt ( ) ; int b = s . nextInt ( ) ; int from = b - ( PImjcDRszH - 1 ) ; int to = b + ( PImjcDRszH - 1 ) ; for ( int i = from ; i <= to ; i ++ ) { System . out . print ( i + " " ) ; } } } import java . util . * ; public class OAjaucVOML { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; int OAjaucVOML = ob . nextInt ( ) ; int k = ob . nextInt ( ) ; int [ ] a = new int [ OAjaucVOML ] ; for ( int i = 0 ; i < OAjaucVOML ; i ++ ) { a [ i ] = ob . nextInt ( ) ; } int min = 0 ; int [ ] arr = new int [ OAjaucVOML ] ; 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 [ OAjaucVOML - 1 ] ) ; ob . close ( ) ; } } import java . util . * ; public class VkmOxPFzre { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VkmOxPFzre = Integer . parseInt ( sc . nextLine ( ) ) ; int max = 1 ; for ( int i = 2 ; i <= Math . sqrt ( VkmOxPFzre ) ; i ++ ) { int n = i ; for ( int j = 2 ; n * i <= VkmOxPFzre ; j ++ ) { n *= i ; } max = max < n ? n : max ; } System . out . println ( max ) ; } } import java . util . Scanner ; public class iYcXFrZHXw { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int iYcXFrZHXw = 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 , iYcXFrZHXw + 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 * iYcXFrZHXw , 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 WPKYGTNcXi { 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 WPKYGTNcXi { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String [ ] S = in . next ( ) . split ( " " ) ; String [ ] T = in . next ( ) . split ( " " ) ; int WPKYGTNcXi = 0 ; for ( int i = 0 ; i < S . length ; i ++ ) { if ( S [ i ] . compareTo ( T [ i ] ) == 0 ) { WPKYGTNcXi ++ ; } } out . println ( WPKYGTNcXi ) ; } } } import java . util . * ; public class xwvuNDsSkL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xwvuNDsSkL = sc . nextInt ( ) ; String ans = " Yes " ; int nowT = 0 ; int nowX = 0 ; int nowY = 0 ; for ( int i = 0 ; i < xwvuNDsSkL ; 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 JMGBIgJssf { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int JMGBIgJssf = scan . nextInt ( ) ; int N = scan . nextInt ( ) ; int [ ] box = new int [ N ] ; int con = 0 ; int min = JMGBIgJssf + 100 ; int judge = 0 ; int nbox ; for ( int i = 0 ; i < N ; i ++ ) { box [ i ] = scan . nextInt ( ) ; if ( JMGBIgJssf == box [ i ] ) { con = 1 ; } } if ( con == 0 ) { System . out . print ( JMGBIgJssf ) ; } else { for ( int i = 1 ; i <= 200 - JMGBIgJssf ; i ++ ) { int a = JMGBIgJssf - i ; int b = JMGBIgJssf + 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 JomnyWeZsO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JomnyWeZsO = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; String s = sc . next ( ) ; int [ ] pos = new int [ JomnyWeZsO ] ; for ( int i = 0 ; i < JomnyWeZsO - 1 ; i ++ ) { if ( s . charAt ( i ) == 'A' && s . charAt ( i + 1 ) == 'C' ) { pos [ i ] = 1 ; } } int [ ] num = new int [ JomnyWeZsO ] ; num [ 0 ] = pos [ 0 ] ; for ( int i = 1 ; i < JomnyWeZsO - 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 pyvMtMkwtz { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; String w = sc . next ( ) ; for ( int pyvMtMkwtz = 0 ; pyvMtMkwtz < w . length ( ) ; pyvMtMkwtz ++ ) { int sum = 0 ; for ( int j = 0 ; j < w . length ( ) ; j ++ ) { if ( w . charAt ( pyvMtMkwtz ) == 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 WvFoMXQKfJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WvFoMXQKfJ = sc . nextInt ( ) ; LinkedList < Integer > inputs = new LinkedList < > ( ) ; for ( int i = 0 ; i < WvFoMXQKfJ ; i ++ ) { inputs . add ( sc . nextInt ( ) ) ; } Collections . sort ( inputs ) ; double beforeParam = inputs . pop ( ) ; for ( int i = 0 ; i < WvFoMXQKfJ - 1 ; i ++ ) { beforeParam = ( beforeParam + inputs . pop ( ) ) / 2 ; } System . out . println ( beforeParam ) ; } } import java . util . * ; import java . lang . * ; import java . io . * ; public class OYCGryNeYJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int OYCGryNeYJ = scan . nextInt ( ) ; String str = scan . next ( ) ; if ( OYCGryNeYJ >= str . length ( ) ) { System . out . println ( str ) ; } else { System . out . println ( str . substring ( 0 , OYCGryNeYJ ) + " ... " ) ; } } } import java . util . * ; public class iGkZPEmrTk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iGkZPEmrTk = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; if ( S . length ( ) > iGkZPEmrTk ) S = S . substring ( 0 , iGkZPEmrTk ) + " ... " ; System . out . println ( S ) ; } } import java . util . * ; public class LCRAnuPmPS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LCRAnuPmPS = sc . nextInt ( ) ; int [ ] h = new int [ LCRAnuPmPS ] ; int landCt = 0 ; int answer = 0 ; for ( int i = 0 ; i < LCRAnuPmPS ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int start = h [ 0 ] ; for ( int i = 0 ; i < 101 ; i ++ ) { landCt = 0 ; for ( int j = 0 ; j < LCRAnuPmPS - 1 ; j ++ ) { if ( ( h [ j ] == 0 && h [ j + 1 ] > 0 ) || ( j == 0 && h [ 0 ] > 0 ) ) { landCt = landCt + 1 ; } } answer = answer + landCt ; oneMinus ( h ) ; } if ( LCRAnuPmPS != 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 hiRxfZdNzG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String in = sc . nextLine ( ) ; int hiRxfZdNzG = 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 = hiRxfZdNzG ; 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 " , hiRxfZdNzG , ( ( 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 lXhXUSzCOA { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int lXhXUSzCOA = 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 = lXhXUSzCOA ; 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 KtfAeWBpKK { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String search = scanner . nextLine ( ) ; boolean KtfAeWBpKK = true ; int count = 0 ; String end = " END_OF_TEXT " ; while ( KtfAeWBpKK ) { String word = scanner . next ( ) ; int result = word . lastIndexOf ( end ) ; if ( result != - 1 ) { KtfAeWBpKK = false ; } else { word = word . toLowerCase ( ) ; } if ( word . equals ( search ) ) { count ++ ; } } System . out . println ( count ) ; scanner . close ( ) ; } } import java . util . Scanner ; public class EiQljllYEF { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; String T = scan . next ( ) ; for ( int EiQljllYEF = 0 ; EiQljllYEF < S . length ( ) ; EiQljllYEF ++ ) { if ( S . charAt ( EiQljllYEF ) != T . charAt ( EiQljllYEF ) ) { System . out . println ( " No " ) ; break ; } else if ( ( EiQljllYEF == 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 uPzPlFEZMg { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; while ( true ) { int uPzPlFEZMg = cin . nextInt ( ) , x = cin . nextInt ( ) ; int res = 0 ; if ( uPzPlFEZMg == 0 && x == 0 ) break ; for ( int i = 1 ; i <= uPzPlFEZMg - 2 ; i ++ ) { for ( int j = i + 1 ; j <= uPzPlFEZMg - 1 ; j ++ ) { for ( int k = j + 1 ; k <= uPzPlFEZMg ; k ++ ) { if ( i + j + k == x ) res ++ ; } } } System . out . println ( res ) ; } } } import java . util . Scanner ; public class PsuaZsUyUi { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int PsuaZsUyUi = s . nextInt ( ) ; long res = PsuaZsUyUi ; res += PsuaZsUyUi * PsuaZsUyUi + PsuaZsUyUi * PsuaZsUyUi * PsuaZsUyUi ; System . out . println ( res ) ; } } import java . util . Scanner ; public class cbkOwbwPKz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cbkOwbwPKz = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int target = 0 ; int kekka = 10000 ; while ( target < 10000 ) { if ( ( int ) Math . floor ( ( double ) target * 0.08 ) == cbkOwbwPKz && ( 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 bvvZeWKnUF { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String num = scan . nextLine ( ) ; int bvvZeWKnUF = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { char c = num . charAt ( i ) ; if ( c == '1' ) { bvvZeWKnUF ++ ; } } System . out . println ( bvvZeWKnUF ) ; } } import java . util . Scanner ; public class pcckRqPkXB { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int pcckRqPkXB = scan . nextInt ( ) ; String s = scan . next ( ) ; String t = scan . next ( ) ; String ans = " " ; for ( int i = 0 ; i < pcckRqPkXB ; 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 uZNNCOmVbr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uZNNCOmVbr = Integer . parseInt ( sc . next ( ) ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int result = n ; if ( uZNNCOmVbr == 0 && n == 100 ) { result ++ ; } else if ( 0 < uZNNCOmVbr ) { for ( int i = 0 ; i < uZNNCOmVbr ; i ++ ) { result *= 100 ; } if ( n == 100 ) { int add = 1 ; for ( int i = 0 ; i < uZNNCOmVbr ; i ++ ) { add *= 100 ; } result += add ; } } System . out . println ( result ) ; sc . close ( ) ; } } import java . util . Scanner ; public class ahLftRMpcL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String day = sc . next ( ) ; int ahLftRMpcL = 0 ; switch ( day ) { case " SUN " : ahLftRMpcL = 7 ; break ; case " MON " : ahLftRMpcL = 6 ; break ; case " TUE " : ahLftRMpcL = 5 ; break ; case " WED " : ahLftRMpcL = 4 ; break ; case " THU " : ahLftRMpcL = 3 ; break ; case " FRI " : ahLftRMpcL = 2 ; break ; case " SAT " : ahLftRMpcL = 1 ; break ; } System . out . println ( ahLftRMpcL ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class BMAJKwEVHR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BMAJKwEVHR = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; List < Integer > list = new ArrayList < > ( ) ; int ans = BMAJKwEVHR ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . nextInt ( ) ) ; } for ( int dif = 0 ; dif <= n ; dif ++ ) { if ( ! list . contains ( BMAJKwEVHR - dif ) ) { ans = BMAJKwEVHR - dif ; break ; } if ( ! list . contains ( BMAJKwEVHR + dif ) ) { ans = BMAJKwEVHR + dif ; break ; } } if ( n > 100 ) { System . out . println ( " error " ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class nkIzJZrwQx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] antennaArr = new int [ 5 ] ; for ( int nkIzJZrwQx = 0 ; nkIzJZrwQx < antennaArr . length ; nkIzJZrwQx ++ ) { antennaArr [ nkIzJZrwQx ] = sc . nextInt ( ) ; } int border = sc . nextInt ( ) ; boolean canConnect = true ; for ( int nkIzJZrwQx = 0 ; nkIzJZrwQx < antennaArr . length ; nkIzJZrwQx ++ ) { for ( int j = 0 ; j < antennaArr . length ; j ++ ) { if ( nkIzJZrwQx >= j ) { continue ; } if ( antennaArr [ j ] - antennaArr [ nkIzJZrwQx ] > border ) { canConnect = false ; } } } if ( canConnect ) { System . out . println ( " Yay! " ) ; } else { System . out . println ( " :( " ) ; } } } import java . io . * ; import java . util . Scanner ; public class NvEJvfMLpl { public static boolean range ( int NvEJvfMLpl , int b , int c ) { if ( NvEJvfMLpl >= b ) return false ; if ( b >= c ) return false ; return true ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NvEJvfMLpl = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( range ( NvEJvfMLpl , b , c ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . io . * ; class pGbzfWSvPd { static PrintStream out = System . out ; static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int pGbzfWSvPd = in . nextInt ( ) ; int a = in . nextInt ( ) ; long min = a , max = a , sum = a ; for ( int i = 1 ; i < pGbzfWSvPd ; 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 cbxvUBbHxw { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int cbxvUBbHxw = 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 oIUSqFyDNK { public static void main ( String [ ] args ) { int oIUSqFyDNK = 1 ; int p = 2 ; double max = 0 ; double result ; Scanner scanner = new Scanner ( System . in ) ; int x = scanner . nextInt ( ) ; while ( oIUSqFyDNK < 1000 ) { while ( p < 1000 ) { result = Math . pow ( oIUSqFyDNK , p ) ; if ( result > x ) break ; if ( result >= max ) max = result ; p ++ ; } p = 2 ; oIUSqFyDNK ++ ; } System . out . println ( ( int ) max ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class ssIqXiBJlp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ssIqXiBJlp = 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 ( ssIqXiBJlp - i ) < abs ) { abs = Math . abs ( ssIqXiBJlp - i ) ; ans = i ; } } } if ( n == 0 || ! ( list . contains ( ssIqXiBJlp ) ) ) { System . out . println ( ssIqXiBJlp ) ; } else { System . out . println ( ans ) ; } } } import java . util . Scanner ; public class AathUEfTbi { 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 KKLAhUVMOE { 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 KKLAhUVMOE = 0 ; KKLAhUVMOE < Integer . parseInt ( b ) ; KKLAhUVMOE ++ ) { A += a ; } for ( int KKLAhUVMOE = 0 ; KKLAhUVMOE < Integer . parseInt ( a ) ; KKLAhUVMOE ++ ) { B += b ; } System . out . print ( ( A . compareTo ( B ) ) < 0 ? A : B ) ; } } import java . util . Scanner ; public class svimjlEavt { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long svimjlEavt = in . nextLong ( ) ; long tk = 0 ; long pchso = svimjlEavt / 500 ; tk = pchso * 1000 ; int baki = ( int ) ( svimjlEavt % 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 rjiLsSotCS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rjiLsSotCS = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; List < Integer > k = new ArrayList < > ( ) ; List < List < Integer > > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < rjiLsSotCS ; 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 < rjiLsSotCS ; i ++ ) { correct . retainAll ( a . get ( i ) ) ; } System . out . println ( correct . size ( ) ) ; } } import java . util . Scanner ; public class bPxptYSzFb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int bPxptYSzFb = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int H = scanner . nextInt ( ) ; int M = scanner . nextInt ( ) ; double degree = calculateAngle ( H , M ) ; double side = Math . sqrt ( bPxptYSzFb * bPxptYSzFb + B * B - 2 * bPxptYSzFb * 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 TGomxmyqlS { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int TGomxmyqlS = scan . nextInt ( ) ; double debt = 100000 ; for ( int i = 0 ; i < TGomxmyqlS ; 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 LozczsKuOT { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; String input = scan . next ( ) ; char [ ] inputArray = input . toCharArray ( ) ; int LozczsKuOT = 0 ; for ( int i = 0 ; i < inputArray . length ; i ++ ) { if ( inputArray [ i ] == '1' ) { LozczsKuOT ++ ; } } System . out . println ( LozczsKuOT ) ; } 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 LozczsKuOT = 1 ; if ( josu == 0 ) return 1 ; if ( primeNumMod_0 == 0 ) { while ( josu > 0 ) { if ( josu % 2 == 0 ) { kisu *= kisu ; josu = josu / 2 ; } else { LozczsKuOT *= kisu ; josu -- ; } } return LozczsKuOT ; } else { kisu = myMod ( kisu , primeNumMod_0 ) ; while ( josu > 0 ) { if ( josu % 2 == 0 ) { kisu *= myMod ( kisu , primeNumMod_0 ) ; josu = josu / 2 ; } else { LozczsKuOT *= myMod ( kisu , primeNumMod_0 ) ; josu -- ; } } return myMod ( LozczsKuOT , primeNumMod_0 ) ; } } } import java . util . Scanner ; public class eofzAGFRQR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eofzAGFRQR = sc . nextInt ( ) , b = sc . nextInt ( ) ; int c = sc . nextInt ( ) , x = sc . nextInt ( ) ; sc . close ( ) ; int tmpa = eofzAGFRQR , 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 <= eofzAGFRQR && tmp >= 0 ) ++ ans ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class bjqLDRZmUs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bjqLDRZmUs = sc . nextInt ( ) ; int last = sc . nextInt ( ) ; int res = last ; for ( int i = 0 ; i < bjqLDRZmUs - 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 RrDpsKOnUa { 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 RrDpsKOnUa = Integer . parseInt ( input1 [ 0 ] ) ; int k = Integer . parseInt ( input1 [ 1 ] ) ; String [ ] input2 = br . readLine ( ) . split ( " " ) ; int [ ] numbers = new int [ RrDpsKOnUa ] ; int ans = 0 ; for ( int i = 0 ; i < RrDpsKOnUa ; i ++ ) { numbers [ i ] = Integer . parseInt ( input2 [ i ] ) ; if ( numbers [ i ] >= k ) { ans ++ ; } } out . println ( ans ) ; out . close ( ) ; } } import java . util . Scanner ; public class xyXZlCQFgm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int xyXZlCQFgm = scan . nextInt ( ) ; int [ ] h = new int [ xyXZlCQFgm ] ; int i ; for ( i = 0 ; i < xyXZlCQFgm ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } for ( i = xyXZlCQFgm - 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 OARMuYQgiO { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int OARMuYQgiO = sc . nextInt ( ) ; int [ ] A = new int [ OARMuYQgiO ] ; int i ; int count = 0 ; for ( i = 0 ; i < OARMuYQgiO ; 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 gOLVVkEhFj { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int gOLVVkEhFj = stdIn . nextShort ( ) ; int n1 = 1 ; int n2 ; do { n2 = 100 * n1 + 10 * n1 + n1 ; if ( gOLVVkEhFj <= n2 ) { System . out . println ( n2 ) ; return ; } n1 = n1 + 1 ; } while ( n1 <= 9 ) ; } } import java . util . Scanner ; public class yoDgVZHxCC { public static void main ( String [ ] args ) { int yoDgVZHxCC , a , b , digitsSum = 0 , totalSum = 0 ; Scanner sc = new Scanner ( System . in ) ; yoDgVZHxCC = sc . nextInt ( ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; for ( int i = 1 ; i <= yoDgVZHxCC ; 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 LpDGpmrYeF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int LpDGpmrYeF = sc . nextInt ( ) ; final int W = sc . nextInt ( ) ; sc . close ( ) ; if ( LpDGpmrYeF > W ) { System . out . println ( " safe " ) ; } else { System . out . println ( " unsafe " ) ; } } } import java . util . * ; import java . io . * ; class zjzhkMpFgH { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int zjzhkMpFgH = Integer . parseInt ( br . readLine ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; int count = 0 ; int a = 1 , b ; if ( zjzhkMpFgH >= 3 && zjzhkMpFgH <= 10000 ) { for ( ; count < zjzhkMpFgH ; 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 SYTHsEuksT { public static void main ( String [ ] args ) { Main mainObj = new Main ( ) ; mainObj . solve ( ) ; } public void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int SYTHsEuksT = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] heightStrArr = sc . nextLine ( ) . split ( " " ) ; sc . close ( ) ; int [ ] heightArr = new int [ SYTHsEuksT ] ; for ( int i = 0 ; i < SYTHsEuksT ; i ++ ) { heightArr [ i ] = Integer . parseInt ( heightStrArr [ i ] ) ; } if ( heightArr [ 0 ] > 0 ) { heightArr [ 0 ] = heightArr [ 0 ] - 1 ; } for ( int i = 1 ; i < SYTHsEuksT ; 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 sWLuZdGtYr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sWLuZdGtYr = Integer . parseInt ( sc . next ( ) ) ; int m = Integer . parseInt ( sc . next ( ) ) ; int [ ] love = new int [ m ] ; int k , a ; for ( int i = 0 ; i < sWLuZdGtYr ; 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 ] == sWLuZdGtYr ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; class EAcZDnkIQg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EAcZDnkIQg = sc . nextInt ( ) ; int [ ] cnt = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { cnt [ i ] = 0 ; } String [ ] s = new String [ EAcZDnkIQg ] ; for ( int i = 0 ; i < EAcZDnkIQg ; 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 JGtVHYEkuP { void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int JGtVHYEkuP = sc . nextInt ( ) ; int [ ] p = new int [ JGtVHYEkuP ] ; for ( int i = 0 ; i < JGtVHYEkuP ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } if ( isOK ( p ) ) { System . out . println ( " YES " ) ; return ; } for ( int i = 0 ; i <= JGtVHYEkuP - 2 ; i ++ ) { for ( int j = i + 1 ; j <= JGtVHYEkuP - 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 DsAaMerBQY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] dance = sc . next ( ) . toCharArray ( ) ; boolean DsAaMerBQY = true ; for ( int i = 0 ; i < dance . length ; i ++ ) { if ( i % 2 == 0 ) { if ( dance [ i ] == 'L' ) { DsAaMerBQY = false ; break ; } } else { if ( dance [ i ] == 'R' ) { DsAaMerBQY = false ; break ; } } } if ( DsAaMerBQY ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class OscNpkbIpc { public Main ( ) { } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OscNpkbIpc ; int h ; int index ; int index2 ; int result = 1 ; Map < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; OscNpkbIpc = sc . nextInt ( ) ; for ( index = 0 ; index < OscNpkbIpc ; index ++ ) { h = sc . nextInt ( ) ; map . put ( index , h ) ; } sc . close ( ) ; loop1 : for ( index = 1 ; index < OscNpkbIpc ; 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 QZGqtxMuBA { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String x = sc . next ( ) ; double QZGqtxMuBA = Double . valueOf ( x ) ; int ans = 0 ; double tot = 100 ; while ( tot < QZGqtxMuBA ) { tot = Math . floor ( tot * 1.01 ) ; ans ++ ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class SmXyZBasca { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String SmXyZBasca = sc . nextLine ( ) ; sc . close ( ) ; System . out . println ( SmXyZBasca . lastIndexOf ( " Z " ) - SmXyZBasca . indexOf ( " A " ) + 1 ) ; } } import java . util . Scanner ; public class pnkSIlwuQK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pnkSIlwuQK = Integer . parseInt ( sc . next ( ) ) ; int [ ] H = new int [ pnkSIlwuQK ] ; for ( int i = 0 ; i < pnkSIlwuQK ; i ++ ) { H [ i ] = Integer . parseInt ( sc . next ( ) ) ; } int prev = ( H [ 0 ] > 1 ) ? H [ 0 ] - 1 : H [ 0 ] ; for ( int i = 1 ; i < pnkSIlwuQK - 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 MhNoxoPPXH { 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 MhNoxoPPXH = Integer . parseInt ( arr [ 0 ] ) ; int b = Integer . parseInt ( arr [ 1 ] ) ; System . out . println ( MhNoxoPPXH < b ? repeat ( arr [ 0 ] , b ) : repeat ( arr [ 1 ] , MhNoxoPPXH ) ) ; } } import java . util . * ; public class xXDKXjpctP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xXDKXjpctP = sc . nextInt ( ) ; char [ ] nChar = String . valueOf ( xXDKXjpctP ) . toCharArray ( ) ; int sn = 0 ; for ( int i = 0 ; i < nChar . length ; i ++ ) { sn += Integer . parseInt ( String . valueOf ( nChar [ i ] ) ) ; } if ( xXDKXjpctP % sn == 0 ) { System . out . println ( " Yes " ) ; return ; } System . out . println ( " No " ) ; } } import java . util . * ; class BnzoZBkjKd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BnzoZBkjKd = 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 ; BnzoZBkjKd -= D ; if ( BnzoZBkjKd <= 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 CgsUjkUbKM { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; String CgsUjkUbKM = s . next ( ) ; switch ( CgsUjkUbKM ) { 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 sTVeISBDsE { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; long sTVeISBDsE = scn . nextInt ( ) ; long num2 = scn . nextInt ( ) ; System . out . println ( CommonMultipleNum . cmn ( sTVeISBDsE , num2 ) ) ; } } class sTVeISBDsE { static long cmn ( long sTVeISBDsE , long num2 ) { long tmp ; long num3 = sTVeISBDsE ; num3 *= num2 ; while ( ( tmp = sTVeISBDsE % num2 ) != 0 ) { sTVeISBDsE = num2 ; num2 = tmp ; } return ( long ) ( num3 / num2 ) ; } } import java . util . * ; class HXFyOejZhz { public static void main ( String [ ] args ) { Scanner inp = new Scanner ( System . in ) ; do_ ( inp ) ; inp . close ( ) ; } public static void do_ ( Scanner inp ) { int HXFyOejZhz = inp . nextInt ( ) ; int b = inp . nextInt ( ) ; int c = inp . nextInt ( ) ; System . out . println ( c + " " + HXFyOejZhz + " " + b ) ; } } import java . util . * ; public class eteuRXgqhH { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String [ ] x = s . nextLine ( ) . split ( " " ) ; int eteuRXgqhH = 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 ) eteuRXgqhH / d ; if ( eteuRXgqhH % 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 vfXjeXHzOe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vfXjeXHzOe = sc . nextInt ( ) ; if ( vfXjeXHzOe % 10 == 3 || vfXjeXHzOe % 100 == 3 ) { System . out . println ( " bon " ) ; } else if ( vfXjeXHzOe % 10 == 0 || vfXjeXHzOe % 10 == 1 | vfXjeXHzOe % 10 == 6 || vfXjeXHzOe % 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 pBlMKFPqhJ { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int pBlMKFPqhJ = in . nextInt ( ) ; int n = in . nextInt ( ) ; if ( n == 100 ) n = 101 ; for ( int i = 0 ; i < pBlMKFPqhJ ; i ++ ) n *= 100 ; System . out . println ( n ) ; in . close ( ) ; } } import java . util . Scanner ; public class CMttlPwCZr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int CMttlPwCZr = scanner . nextInt ( ) ; int result = CMttlPwCZr + ( int ) Math . pow ( CMttlPwCZr , 2 ) + ( int ) Math . pow ( CMttlPwCZr , 3 ) ; System . out . println ( result ) ; } } import java . util . * ; public class nchoqVWDjQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nchoqVWDjQ = 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 ( ( nchoqVWDjQ - sum ) <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class lzXWUFhReX { static int [ ] stack = new int [ 1000 ] ; static int lzXWUFhReX = 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 ( ) { lzXWUFhReX -- ; return stack [ lzXWUFhReX + 1 ] ; } public static void push ( int i ) { lzXWUFhReX ++ ; stack [ lzXWUFhReX ] = i ; } } import java . util . Scanner ; public class naofzfmaAd { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . next ( ) ; String t = scanner . next ( ) ; int naofzfmaAd = t . length ( ) ; String T = t . substring ( 0 , naofzfmaAd - 1 ) ; if ( s . equals ( T ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } scanner . close ( ) ; } } import java . util . * ; public class SRfLsLYUqi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SRfLsLYUqi = sc . nextInt ( ) ; int [ ] a = new int [ SRfLsLYUqi + 1 ] ; for ( int i = 0 ; i < SRfLsLYUqi + 1 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } long sum = 0 ; for ( int i = 0 ; i < SRfLsLYUqi ; 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 uJXkGmLtGt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] x = new int [ 5 ] ; int uJXkGmLtGt = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { x [ i ] = sc . nextInt ( ) ; if ( x [ i ] != i + 1 ) uJXkGmLtGt = i + 1 ; } System . out . println ( uJXkGmLtGt ) ; } } import java . util . * ; public class MEueUZhlYi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MEueUZhlYi = 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 ) MEueUZhlYi / 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 oJbguzySNa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int oJbguzySNa = s . length ( ) ; for ( int i = 0 ; i < oJbguzySNa ; i ++ ) { System . out . print ( " x " ) ; } System . out . println ( " " ) ; } } import java . util . * ; public class ZNPhZwJBbS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZNPhZwJBbS = sc . nextInt ( ) ; int n = ZNPhZwJBbS ; 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 ( ZNPhZwJBbS % s == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class NVAcYFLvxE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long NVAcYFLvxE = sc . nextLong ( ) ; NVAcYFLvxE -- ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long total = b - NVAcYFLvxE ; long divD = b / d - NVAcYFLvxE / d ; long divC = b / c - NVAcYFLvxE / c ; long lcm = getLcm ( c , d ) ; long divL = b / lcm - NVAcYFLvxE / 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 orLFSBOlDd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int orLFSBOlDd = Integer . parseInt ( sc . next ( ) ) ; TreeMap < String , Integer > S = new TreeMap < String , Integer > ( ) ; String tmp ; int max = 1 ; int count ; for ( int i = 0 ; i < orLFSBOlDd ; 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 CqKDLnHvSH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CqKDLnHvSH = sc . nextInt ( ) ; long Y = sc . nextLong ( ) ; sc . close ( ) ; int A = 0 ; int B = 0 ; int C = 0 ; for ( int i = 0 ; i <= CqKDLnHvSH ; i ++ ) { A = i * 10000 ; for ( int j = 0 ; j <= CqKDLnHvSH ; j ++ ) { B = j * 5000 ; C = ( CqKDLnHvSH - i - j ) * 1000 ; if ( A + B + C == Y && C >= 0 ) { System . out . println ( i + " " + j + " " + ( CqKDLnHvSH - i - j ) ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . util . Scanner ; public class funqRgOzYT { 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 funqRgOzYT = 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 cRzOTkRCXn { public static void main ( String [ ] args ) { Scanner yomi = new Scanner ( System . in ) ; String cRzOTkRCXn = yomi . next ( ) ; if ( cRzOTkRCXn . equals ( " SUN " ) ) { System . out . println ( 7 ) ; } else if ( cRzOTkRCXn . equalsIgnoreCase ( " MON " ) ) { System . out . println ( 6 ) ; } else if ( cRzOTkRCXn . equalsIgnoreCase ( " TUE " ) ) { System . out . println ( 5 ) ; } else if ( cRzOTkRCXn . equalsIgnoreCase ( " WED " ) ) { System . out . println ( 4 ) ; } else if ( cRzOTkRCXn . equalsIgnoreCase ( " THU " ) ) { System . out . println ( 3 ) ; } else if ( cRzOTkRCXn . equalsIgnoreCase ( " FRI " ) ) { System . out . println ( 2 ) ; } else if ( cRzOTkRCXn . equalsIgnoreCase ( " SAT " ) ) { System . out . println ( 1 ) ; } } } import java . util . * ; public class JpUsWzfXco { public static void main ( String [ ] args ) throws NumberFormatException { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) . trim ( ) ; String [ ] segments = S . split ( " " ) ; int JpUsWzfXco = Integer . parseInt ( segments [ 0 ] ) ; int K = Integer . parseInt ( segments [ 1 ] ) ; double result = 0 ; double np = ( double ) 1.0 / JpUsWzfXco ; for ( int i = 1 ; i <= JpUsWzfXco ; 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 nOGXZxXxJb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nOGXZxXxJb = sc . nextInt ( ) ; String S = sc . next ( ) ; String S1 = S . substring ( nOGXZxXxJb / 2 ) ; String S2 = S . substring ( 0 , nOGXZxXxJb / 2 ) ; String S3 = S1 + S2 ; sc . close ( ) ; if ( nOGXZxXxJb % 2 == 1 ) { System . out . println ( " No " ) ; } else { if ( S . equals ( S3 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . * ; class LhVxabldTz { Scanner sc = new Scanner ( System . in ) ; void main ( ) { int LhVxabldTz = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] [ ] x = new int [ LhVxabldTz + 1 ] [ c + 1 ] ; for ( int i = 0 ; i < LhVxabldTz ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { x [ i ] [ j ] = sc . nextInt ( ) ; x [ i ] [ c ] += x [ i ] [ j ] ; } } for ( int i = 0 ; i < LhVxabldTz ; i ++ ) for ( int j = 0 ; j < c + 1 ; j ++ ) x [ LhVxabldTz ] [ j ] += x [ i ] [ j ] ; for ( int i = 0 ; i < LhVxabldTz + 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 oEHdzsMFlx { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int oEHdzsMFlx = in . nextInt ( ) ; int b = in . nextInt ( ) ; int min = b ; int max = b ; long sum = b ; for ( int i = 0 ; i < oEHdzsMFlx - 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 KTBxImxYRH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long KTBxImxYRH = sc . nextLong ( ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long C = KTBxImxYRH / ( A + B ) ; long D = KTBxImxYRH % ( 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 DgfUaRhiKF { 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 DgfUaRhiKF = Long . parseLong ( Ws [ 0 ] ) ; long B = Long . parseLong ( Ws [ 1 ] ) ; long K = DgfUaRhiKF + 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 XxJwPJxPVZ { public static void main ( String [ ] args ) throws IOException { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] Aandb = ( input . readLine ( ) ) . split ( " \\ s " ) ; int XxJwPJxPVZ = Integer . parseInt ( Aandb [ 0 ] ) ; int m = Integer . parseInt ( Aandb [ 1 ] ) ; int [ ] [ ] A = new int [ XxJwPJxPVZ ] [ m ] ; String [ ] z = null ; for ( int i = 0 ; i < XxJwPJxPVZ ; 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 < XxJwPJxPVZ ; 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 qkJlmuITbR { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qkJlmuITbR = scan . nextInt ( ) ; for ( int i = qkJlmuITbR ; 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 JuANljBVct { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int JuANljBVct = 0 ; String [ ] line ; line = new String [ 10000 ] ; try { while ( JuANljBVct < 10000 ) { line [ JuANljBVct ] = reader . readLine ( ) ; if ( line [ JuANljBVct ] . equals ( " 0 " ) ) break ; JuANljBVct ++ ; } JuANljBVct = 0 ; while ( JuANljBVct < 10000 ) { if ( line [ JuANljBVct ] . equals ( " 0 " ) ) break ; System . out . println ( " Case " + ( JuANljBVct + 1 ) + " : " + line [ JuANljBVct ] ) ; JuANljBVct ++ ; } } catch ( IOException e ) { System . out . println ( e ) ; } catch ( NumberFormatException e ) { System . out . println ( e ) ; } } } import java . util . * ; public class vTCzykdSbB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vTCzykdSbB = Integer . parseInt ( sc . nextLine ( ) ) ; String [ ] S = sc . nextLine ( ) . split ( " " ) ; int count = 0 ; int now = 0 ; for ( int i = 0 ; i < vTCzykdSbB ; 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 YcWgGrkuvu { 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 YcWgGrkuvu = 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 -- ) { YcWgGrkuvu -= A [ i ] ; if ( YcWgGrkuvu <= 0 ) break ; } if ( YcWgGrkuvu <= 0 ) os . println ( " Yes " ) ; else os . println ( " No " ) ; } } import java . util . * ; class AmrntzFKYw { public static void main ( String [ ] str ) { Scanner s = new Scanner ( System . in ) ; String s1 = s . next ( ) ; String s2 = s . next ( ) ; int AmrntzFKYw = s2 . length ( ) ; int i = 0 ; String res = s2 . substring ( i , AmrntzFKYw - 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 pzVTRZGWIL { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int pzVTRZGWIL = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int t = scan . nextInt ( ) ; int time = 0 ; while ( pzVTRZGWIL > 0 ) { pzVTRZGWIL -= x ; time += t ; } System . out . println ( time ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class qxyjDrCnpu { public static void main ( String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; int qxyjDrCnpu = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] problems = new int [ qxyjDrCnpu ] ; int [ ] was = new int [ qxyjDrCnpu ] ; 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 < qxyjDrCnpu ; i ++ ) { if ( problems [ i ] == 1 ) { wa += was [ i ] ; } } System . out . println ( Arrays . stream ( problems ) . sum ( ) + " " + wa ) ; } } import java . util . Scanner ; class tNKtgMUBHX { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int tNKtgMUBHX = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int a1 = tNKtgMUBHX * b ; int a2 = 2 * ( tNKtgMUBHX + b ) ; System . out . printf ( " %d %d \n " , a1 , a2 ) ; } } import java . util . Scanner ; public class pbiMHCjfEv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pbiMHCjfEv = sc . nextInt ( ) ; long res = 0 ; for ( int i = 1 ; i <= pbiMHCjfEv ; i ++ ) if ( String . valueOf ( i ) . length ( ) % 2 == 1 ) res ++ ; System . out . println ( res ) ; } } import java . util . * ; public class YXdQGDWRXE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YXdQGDWRXE = sc . nextInt ( ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; int count = 1 ; int ans = 0 ; for ( int i = 0 ; i < YXdQGDWRXE ; i ++ ) { int tmp = sc . nextInt ( ) ; if ( tmp == count ) { ans ++ ; count ++ ; } list . add ( tmp ) ; } if ( ans == 0 ) { System . out . println ( " -1 " ) ; } else { System . out . println ( YXdQGDWRXE - ans ) ; } } } import java . util . * ; public class eJyeWSawJT { 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 YkkMlbPAvZ { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int YkkMlbPAvZ = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; int c = stdIn . nextInt ( ) ; int x = stdIn . nextInt ( ) ; int y = stdIn . nextInt ( ) ; if ( c - 0.5 * YkkMlbPAvZ - 0.5 * b > 0 ) { System . out . println ( YkkMlbPAvZ * 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 ( YkkMlbPAvZ * ( x - y ) + 2 * c * y <= 2 * c * x ) { System . out . println ( YkkMlbPAvZ * ( x - y ) + 2 * c * y ) ; } else { System . out . println ( 2 * c * x ) ; } } } } } import java . util . * ; class jJAkFvTzcc { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jJAkFvTzcc = scan . nextInt ( ) ; String [ ] S = new String [ jJAkFvTzcc + 1 ] ; int [ ] C = { 0 , 0 , 0 , 0 } ; for ( int i = 0 ; i < jJAkFvTzcc + 1 ; i ++ ) { S [ i ] = scan . nextLine ( ) ; } for ( int i = 0 ; i < jJAkFvTzcc + 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 MVmwjmEPCA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MVmwjmEPCA = sc . nextInt ( ) ; int [ ] h = new int [ MVmwjmEPCA ] ; for ( int i = 0 ; i < MVmwjmEPCA ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int ans = 0 ; while ( true ) { boolean flg = true ; int count = 0 ; for ( int i = 0 ; i < MVmwjmEPCA ; 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 == MVmwjmEPCA ) { System . out . println ( ans ) ; return ; } } } } } import java . util . Scanner ; public class dEPZrqWNgR { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; boolean dEPZrqWNgR = 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 IWBNixEYuA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IWBNixEYuA = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; String ans = " No " ; if ( IWBNixEYuA == B && B != C ) ans = " Yes " ; if ( IWBNixEYuA == C && IWBNixEYuA != B ) ans = " Yes " ; if ( B == C && IWBNixEYuA != B ) ans = " Yes " ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class HbydyjaLAC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HbydyjaLAC = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] array = new int [ HbydyjaLAC ] ; int swap1 , swap2 ; byte garbage ; for ( int i = 0 ; i < HbydyjaLAC ; 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 < HbydyjaLAC ; i ++ ) { System . out . println ( array [ i ] ) ; } } } import java . util . Scanner ; public class vYVMGmkrEt { public static void vYVMGmkrEt ( String str ) { boolean vYVMGmkrEt = false ; if ( vYVMGmkrEt == 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 RaqEvUyKjO { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int RaqEvUyKjO = 0 ; int b = 0 ; int c = 0 ; int n = scanner . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { RaqEvUyKjO = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; c = scanner . nextInt ( ) ; if ( c * c == RaqEvUyKjO * RaqEvUyKjO + b * b || b * b == RaqEvUyKjO * RaqEvUyKjO + c * c || RaqEvUyKjO * RaqEvUyKjO == 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 HGvGeaaLXz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int HGvGeaaLXz = in . nextInt ( ) ; int [ ] value = new int [ HGvGeaaLXz ] ; for ( int i = 0 ; i < HGvGeaaLXz ; i ++ ) { value [ i ] = in . nextInt ( ) ; } int [ ] cost = new int [ HGvGeaaLXz ] ; for ( int j = 0 ; j < HGvGeaaLXz ; j ++ ) { cost [ j ] = in . nextInt ( ) ; } int result = solve ( HGvGeaaLXz , value , cost ) ; System . out . println ( result ) ; in . close ( ) ; } public static int solve ( int HGvGeaaLXz , int [ ] value , int [ ] cost ) { int result = 0 ; for ( int i = 0 ; i < HGvGeaaLXz ; i ++ ) { if ( ( value [ i ] - cost [ i ] ) > 0 ) { result += value [ i ] - cost [ i ] ; } } return result ; } } import java . util . * ; import java . util . stream . * ; public class zeDUcChDJx { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int zeDUcChDJx = in . nextInt ( ) ; int L = in . nextInt ( ) ; int min = Integer . MAX_VALUE ; int sum = 0 ; for ( int i = 0 ; i < zeDUcChDJx ; 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 VFpIRGQGtO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VFpIRGQGtO = sc . nextInt ( ) ; int cnt = 0 ; Set < Integer > set = new TreeSet < > ( ) ; for ( int i = 1 ; i <= VFpIRGQGtO ; 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 yfUQZmbkLl { 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 yfUQZmbkLl = sc . nextInt ( ) ; for ( int i = 0 ; i < yfUQZmbkLl ; 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 LBmPkFRnjD { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int LBmPkFRnjD = sc . nextInt ( ) ; int [ ] num = new int [ 1000000 ] ; int ans = 0 ; num [ 0 ] = LBmPkFRnjD ; for ( int i = 1 ; i < 1000000 ; i ++ ) { if ( LBmPkFRnjD % 2 == 0 ) { num [ i ] = LBmPkFRnjD / 2 ; LBmPkFRnjD = LBmPkFRnjD / 2 ; } else if ( LBmPkFRnjD % 2 == 1 ) { num [ i ] = 3 * LBmPkFRnjD + 1 ; LBmPkFRnjD = 3 * LBmPkFRnjD + 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 wMLEJXICkQ { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = reader . readLine ( ) . split ( " " ) ; int wMLEJXICkQ , Y ; wMLEJXICkQ = Integer . parseInt ( arr [ 0 ] ) ; Y = Integer . parseInt ( arr [ 1 ] ) ; int C , T ; C = 2 * wMLEJXICkQ - Y / 2 ; T = - wMLEJXICkQ + Y / 2 ; System . out . println ( 0 <= C && 0 <= T && 2 * C + 4 * T == Y && C + T == wMLEJXICkQ ? " Yes " : " No " ) ; return ; } } import java . util . * ; public class TGxLqFlOqo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TGxLqFlOqo = sc . nextInt ( ) ; int [ ] P = new int [ TGxLqFlOqo ] ; P [ 0 ] = sc . nextInt ( ) ; int error = 0 ; boolean asc = true ; boolean once = true ; for ( int i = 1 ; i < TGxLqFlOqo ; 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 mkMeaUGdhH { 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 mkMeaUGdhH = 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 ) ) { mkMeaUGdhH ++ ; } } } System . out . println ( mkMeaUGdhH ) ; } } import java . util . Scanner ; public class dOAzPPTXPl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] m = new int [ 200 ] ; int dOAzPPTXPl = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int min = Integer . MAX_VALUE ; int sum = 0 ; for ( int i = 0 ; i < dOAzPPTXPl ; i ++ ) m [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < dOAzPPTXPl ; i ++ ) X -= m [ i ] ; for ( int i = 0 ; i < dOAzPPTXPl ; i ++ ) if ( m [ i ] < min ) min = m [ i ] ; sum = dOAzPPTXPl + ( X / min ) ; System . out . println ( sum ) ; } } import java . util . Scanner ; import java . lang . Math ; public class EBCoaWQjUM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EBCoaWQjUM = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( solve ( EBCoaWQjUM ) ) ; } public static int solve ( int EBCoaWQjUM ) { int ans = 0 ; for ( int i = 1 ; i <= EBCoaWQjUM ; 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 CIqQvAlCOp { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int CIqQvAlCOp = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d ; d = 0 ; while ( CIqQvAlCOp <= b ) { if ( c % CIqQvAlCOp == 0 ) { d = d + 1 ; } CIqQvAlCOp = CIqQvAlCOp + 1 ; } System . out . println ( d ) ; } } import java . util . Scanner ; import java . util . Stack ; class elKoefvibA { public static void main ( String [ ] args ) { new Main ( ) . compute ( ) ; } void compute ( ) { Scanner sc = new Scanner ( System . in ) ; int elKoefvibA = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] nanbon = new int [ elKoefvibA ] ; for ( int i = 0 ; i < M ; i ++ ) { nanbon [ sc . nextInt ( ) - 1 ] ++ ; nanbon [ sc . nextInt ( ) - 1 ] ++ ; } for ( int i = 0 ; i < elKoefvibA ; i ++ ) { System . out . println ( nanbon [ i ] ) ; } } } import java . util . LinkedList ; import java . util . Queue ; import java . util . Scanner ; public class KCfrrEYAcY { public static void main ( String [ ] args ) { int KCfrrEYAcY ; 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 ) ; KCfrrEYAcY = Integer . parseInt ( input . next ( ) ) ; quantum = Integer . parseInt ( input . next ( ) ) ; for ( int i = 0 ; i < KCfrrEYAcY ; 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 HBsTmMrDwl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int HBsTmMrDwl = 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 iERLDLFIVM { public static void main ( String [ ] args ) { solve ( ) ; } private static void solve ( ) { Scanner input = new Scanner ( System . in ) ; int iERLDLFIVM = input . nextInt ( ) ; int [ ] nums = new int [ iERLDLFIVM ] ; int first = 0 ; int second = 0 ; for ( int i = 0 ; i < iERLDLFIVM ; 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 < iERLDLFIVM ; i ++ ) { if ( nums [ i ] == first ) { System . out . println ( second ) ; } else { System . out . println ( first ) ; } } } } import java . util . * ; public class JuBvzWjCdy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JuBvzWjCdy = sc . nextInt ( ) ; int [ ] a = new int [ JuBvzWjCdy ] ; int sumA = 0 ; int sumB = 0 ; for ( int i = 0 ; i < JuBvzWjCdy ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int i = JuBvzWjCdy - 1 ; i >= 0 ; i -= 2 ) { sumA += a [ i ] ; } for ( int i = JuBvzWjCdy - 2 ; i >= 0 ; i -= 2 ) { sumB += a [ i ] ; } System . out . println ( sumA - sumB ) ; } } import java . util . * ; public class caGfTTvAMj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int caGfTTvAMj = 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 < caGfTTvAMj ) ps [ i ] = Math . abs ( caGfTTvAMj - istack ) * 2 ; else ps [ i ] = Math . abs ( caGfTTvAMj - 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 ) caGfTTvAMj -= ans / 2 ; else caGfTTvAMj += ans / 2 ; System . out . println ( caGfTTvAMj ) ; } } import java . util . Scanner ; public class iwhodeidpv { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int iwhodeidpv = scan . nextInt ( ) ; int [ ] ar = new int [ iwhodeidpv ] ; int ans = 0 ; int pre = 0 ; int cur ; for ( int i = 0 ; i < iwhodeidpv ; 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 VmGJfzTOMO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VmGJfzTOMO = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int [ ] result = getMax ( VmGJfzTOMO , b , c ) ; VmGJfzTOMO = result [ 0 ] ; b = result [ 1 ] ; c = result [ 2 ] ; } System . out . println ( VmGJfzTOMO + b + c ) ; } private static int [ ] getMax ( int VmGJfzTOMO , int b , int c ) { int [ ] newInput = new int [ ] { VmGJfzTOMO , b , c } ; if ( VmGJfzTOMO <= b && c <= b ) { newInput [ 1 ] = 2 * b ; } else if ( b <= VmGJfzTOMO && c <= VmGJfzTOMO ) { newInput [ 0 ] = 2 * VmGJfzTOMO ; } else if ( VmGJfzTOMO <= c && b <= c ) { newInput [ 2 ] = 2 * c ; } return newInput ; } } import java . util . Scanner ; class bEvHuVDdTx { public static void main ( final String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int bEvHuVDdTx = scan . nextInt ( ) ; int H = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; int y = scan . nextInt ( ) ; double area = ( double ) bEvHuVDdTx * H / 2 ; int flag = 0 ; if ( x * 2 == bEvHuVDdTx && y * 2 == H ) { flag = 1 ; } System . out . println ( area + " " + flag ) ; } } import java . util . Scanner ; public class GyASDXrtbO { static int [ ] subTreeSize ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long GyASDXrtbO = sc . nextLong ( ) ; GyASDXrtbO -- ; int idx = 0 ; for ( ; idx < s . length ( ) && s . charAt ( idx ) == '1' ; idx ++ ) ; char ans = GyASDXrtbO < idx ? '1' : s . charAt ( idx ) ; System . out . println ( ans ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class KdHuFhtNiF { public static void main ( String [ ] args ) throws Exception { try { long KdHuFhtNiF = 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 ] ) ; KdHuFhtNiF = KdHuFhtNiF + x ; if ( x < min ) { min = x ; } if ( x > max ) { max = x ; } } System . out . println ( min + " " + max + " " + KdHuFhtNiF ) ; } catch ( Exception e ) { System . out . println ( " ???????????? " ) ; } } } import java . util . Scanner ; public class pkrkJedbMH { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int pkrkJedbMH = scan . nextInt ( ) * scan . nextInt ( ) ; scan . close ( ) ; System . out . println ( pkrkJedbMH ) ; } } import java . util . Scanner ; public class gIkSBGbqOl { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int gIkSBGbqOl = stdIn . nextInt ( ) ; int n = stdIn . nextInt ( ) ; int [ ] [ ] a = new int [ gIkSBGbqOl ] [ n ] ; int [ ] b = new int [ n ] ; int ans ; for ( int i = 0 ; i < gIkSBGbqOl ; 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 < gIkSBGbqOl ; 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 tAgsMuYqtU { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tAgsMuYqtU = 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 ) % tAgsMuYqtU == 0 ) { count += 1 ; } else { } } if ( count > 0 ) { System . out . println ( " OK " ) ; } if ( count == 0 ) { System . out . println ( " NG " ) ; } } } import java . util . Scanner ; public class OyzTKTiPby { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OyzTKTiPby = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; double d = OyzTKTiPby / 0.08 ; int x = ( int ) ( OyzTKTiPby / 0.08 ) ; if ( d != x ) x ++ ; System . err . println ( x ) ; int min = OyzTKTiPby ; int max = OyzTKTiPby ; int xmin = x ; int xmax = x ; int i = 0 ; while ( min == OyzTKTiPby ) { xmin -- ; min = ( int ) ( xmin * 0.08 ) ; } while ( max == OyzTKTiPby ) { 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 DenJeECGHa { 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 DenJeECGHa = Integer . valueOf ( arr01 [ 0 ] ) ; Boolean chkflg = true ; for ( int i = 0 ; i < DenJeECGHa - 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 LqUQVanFGO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LqUQVanFGO = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; long [ ] arr = new long [ LqUQVanFGO ] ; for ( int i = 0 ; i < LqUQVanFGO ; i ++ ) { arr [ i ] = sc . nextLong ( ) ; } Arrays . sort ( arr ) ; long total = 0 ; for ( int j = 0 ; j < LqUQVanFGO - K ; j ++ ) { total += arr [ j ] ; } System . out . println ( total ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class OBmChjSGmu { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; String t = in . next ( ) ; int OBmChjSGmu = 0 ; int min = 9999 ; for ( int i = 0 ; i <= s . length ( ) - t . length ( ) ; i ++ ) { OBmChjSGmu = 0 ; for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( s . charAt ( i + j ) == t . charAt ( j ) ) { } else { OBmChjSGmu ++ ; } } if ( min > OBmChjSGmu ) { min = OBmChjSGmu ; } } 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 qYQcPrdNXC { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] strArray = br . readLine ( ) . split ( " " ) ; int qYQcPrdNXC = Integer . parseInt ( strArray [ 0 ] ) ; int b = Integer . parseInt ( strArray [ 1 ] ) ; System . out . println ( getGCD ( qYQcPrdNXC , b ) ) ; } public static int getGCD ( int qYQcPrdNXC , int b ) { if ( qYQcPrdNXC == b ) return qYQcPrdNXC ; else if ( qYQcPrdNXC < b ) { return getGCD ( qYQcPrdNXC , b - qYQcPrdNXC ) ; } else return getGCD ( qYQcPrdNXC - b , qYQcPrdNXC ) ; } } import java . util . Scanner ; public class iuEBruMQrY { 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 iuEBruMQrY = 0 ; int b = 0 ; int c = 0 ; char currentChar = 'a' ; while ( true ) { if ( currentChar == 'a' ) { if ( iuEBruMQrY == s_a . length ( ) ) { System . out . println ( 'A' ) ; break ; } currentChar = s_a . charAt ( iuEBruMQrY ) ; iuEBruMQrY ++ ; } 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 cUizSaJahn { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int cUizSaJahn = scanner . nextInt ( ) , w = scanner . nextInt ( ) ; System . out . println ( ( cUizSaJahn > w ) ? " safe " : " unsafe " ) ; } } } import java . io . * ; import java . util . * ; public class sjLGbwqojH { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int sjLGbwqojH , B ; sjLGbwqojH = 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 == sjLGbwqojH && ( int ) ( i * tax10 + i ) - i == B ) { price = i ; break ; } } System . out . println ( price ) ; } } import java . util . * ; class rYwrHyyjFH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rYwrHyyjFH = sc . nextInt ( ) ; int [ ] t = new int [ rYwrHyyjFH + 1 ] , x = new int [ rYwrHyyjFH + 1 ] , y = new int [ rYwrHyyjFH + 1 ] ; boolean flag = true ; t [ 0 ] = 0 ; x [ 0 ] = 0 ; y [ 0 ] = 0 ; for ( int i = 1 ; i < rYwrHyyjFH + 1 ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < rYwrHyyjFH + 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 hCVxlTCjCm { static int hCVxlTCjCm = 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 vrNmKLrusE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vrNmKLrusE = sc . nextInt ( ) ; int a = 1000 ; int i = 2 ; while ( a < vrNmKLrusE ) { a = 1000 * i ; i ++ ; } System . out . println ( a - vrNmKLrusE ) ; } } import java . util . * ; public class SGyxCwLtRB { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int SGyxCwLtRB = scan . nextInt ( ) ; int k = scan . nextInt ( ) ; int q = scan . nextInt ( ) ; int [ ] g = new int [ SGyxCwLtRB ] ; for ( int i = 0 ; i < q ; i ++ ) { int t = scan . nextInt ( ) ; g [ t - 1 ] += 1 ; } for ( int j = 0 ; j < SGyxCwLtRB ; 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 eZCQQoOsXs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eZCQQoOsXs = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < eZCQQoOsXs ; 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 GquiLyDYqG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GquiLyDYqG = sc . nextInt ( ) ; int [ ] st = new int [ GquiLyDYqG ] ; for ( int i = 0 ; i < GquiLyDYqG ; i ++ ) { st [ i ] = sc . nextInt ( ) ; } Arrays . sort ( st ) ; int a = st [ 0 ] ; int b = st [ GquiLyDYqG - 1 ] ; System . out . println ( Math . abs ( a - b ) ) ; } } import java . util . * ; import java . lang . Math ; class aTAGjLkVJF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double aTAGjLkVJF = sc . nextInt ( ) ; double tmp = Math . ceil ( aTAGjLkVJF / 2 ) ; double ans = tmp / aTAGjLkVJF ; System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class uxZBwvcWYK { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int uxZBwvcWYK = 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 < uxZBwvcWYK ; 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 xjJkVjQhxT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xjJkVjQhxT = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 1 ; i <= xjJkVjQhxT ; 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 AiVKjrVXGP { 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 AiVKjrVXGP = 0 ; AiVKjrVXGP <= N ; AiVKjrVXGP ++ ) { for ( int m = 0 ; m <= N - AiVKjrVXGP ; m ++ ) { int n = N - AiVKjrVXGP - m ; if ( AiVKjrVXGP * 10000 + m * 5000 + n * 1000 == Y ) { System . out . println ( AiVKjrVXGP + " " + m + " " + n ) ; return ; } } } System . out . println ( " -1 -1 -1 " ) ; } } import java . io . * ; class mMgZuFLBeh { public static void main ( String [ ] args ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int mMgZuFLBeh = Integer . parseInt ( br . readLine ( ) ) ; int count = 0 ; for ( int i = 0 ; i < mMgZuFLBeh ; 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 pUVsrZmEGX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pUVsrZmEGX = 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 ( pUVsrZmEGX <= attack ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class vxzvholGGe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vxzvholGGe = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int len = ( vxzvholGGe < B ) ? vxzvholGGe : B ; List r = new ArrayList < Integer > ( ) ; for ( int i = 1 ; i <= len ; i ++ ) { if ( vxzvholGGe % i == 0 && B % i == 0 ) r . add ( i ) ; } System . out . println ( r . get ( r . size ( ) - K ) ) ; } } import java . util . Scanner ; public class asKzIljBTY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int asKzIljBTY = sc . nextInt ( ) ; long [ ] townmonster = new long [ asKzIljBTY + 1 ] ; for ( int i = 0 ; i < asKzIljBTY + 1 ; i ++ ) { townmonster [ i ] = sc . nextLong ( ) ; } long [ ] yusha = new long [ asKzIljBTY + 1 ] ; for ( int i = 0 ; i < asKzIljBTY ; i ++ ) { yusha [ i ] = sc . nextLong ( ) ; } yusha [ asKzIljBTY ] = 0 ; long count = 0 ; long yojou = 0 ; for ( int i = 0 ; i < asKzIljBTY + 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 vcmETbeciZ { 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 vcmETbeciZ = 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 " ) ) { vcmETbeciZ = 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 " ) ) { vcmETbeciZ = false ; } } if ( vcmETbeciZ ) { 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 ZvYQGLmpax { 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 ZvYQGLmpax = Integer . parseInt ( list . get ( 0 ) ) ; String s = list . get ( 1 ) ; br . close ( ) ; int count = 0 ; int size = ZvYQGLmpax ; 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 AOrFtONOWl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AOrFtONOWl = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int max = Math . max ( AOrFtONOWl , b ) ; max = Math . max ( max , c ) ; int sum = 0 ; if ( max == AOrFtONOWl ) { for ( int i = 0 ; i < n ; i ++ ) { AOrFtONOWl *= 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 = AOrFtONOWl + 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 AOrFtONOWl , int b ) { if ( b == 0 ) return AOrFtONOWl ; return gcd ( b , AOrFtONOWl % b ) ; } public static int lcm ( int AOrFtONOWl , int b ) { return AOrFtONOWl * b / gcd ( AOrFtONOWl , b ) ; } } import java . util . Scanner ; public class nnzHEtRTkP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nnzHEtRTkP = 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 < nnzHEtRTkP ; 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 ] == nnzHEtRTkP ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class vBysTQSYJy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final long vBysTQSYJy = 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 > vBysTQSYJy || y - r < 0 || y + r > H ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class AeMOyLEctT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AeMOyLEctT = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] lot = new int [ AeMOyLEctT ] ; String bar ; String [ ] s ; int a ; int b ; int save ; for ( int i = 0 ; i < AeMOyLEctT ; 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 < AeMOyLEctT ; i ++ ) { System . out . println ( " " + lot [ i ] ) ; } } } import java . util . Scanner ; class xYObRvibdV { public static void main ( String [ ] args ) { int xYObRvibdV ; int M ; int X ; int i ; int a = 0 ; int b = 0 ; int [ ] A = new int [ 99 ] ; Scanner sc = new Scanner ( System . in ) ; xYObRvibdV = 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 TZKEWAaUOA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TZKEWAaUOA = sc . nextInt ( ) ; int wk = 0 ; int ans = 0 ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 2 ; i <= TZKEWAaUOA ; 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 <= TZKEWAaUOA ; 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 GDbTnFagMz { public static void main ( String [ ] args ) throws Exception { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int GDbTnFagMz = Integer . parseInt ( stdReader . readLine ( ) ) ; String [ ] A = stdReader . readLine ( ) . split ( " " , 0 ) ; int j = 0 ; System . out . println ( String . join ( " " , A ) ) ; for ( int i = 1 ; i < GDbTnFagMz ; 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 yTqEDgpmAB { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String str = scan . next ( ) ; int yTqEDgpmAB = 0 ; int min2 = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( i % 2 == Character . getNumericValue ( str . charAt ( i ) ) ) { yTqEDgpmAB += 1 ; } else { min2 += 1 ; } } System . out . println ( Math . min ( yTqEDgpmAB , min2 ) ) ; } } import java . util . Scanner ; class aKQImSVlAz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aKQImSVlAz = sc . nextInt ( ) ; int numCol1Row2 = sc . nextInt ( ) ; int numCol2 = sc . nextInt ( ) ; int [ ] [ ] mat1 = new int [ aKQImSVlAz ] [ numCol1Row2 ] ; int [ ] [ ] mat2 = new int [ numCol1Row2 ] [ numCol2 ] ; long [ ] [ ] matOut = new long [ aKQImSVlAz ] [ numCol2 ] ; int i , j , k ; for ( i = 0 ; i < aKQImSVlAz ; 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 < aKQImSVlAz ; 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 ijXEasFSgM { 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 ijXEasFSgM = Integer . parseInt ( tmpArray [ 0 ] ) ; int b = Integer . parseInt ( tmpArray [ 1 ] ) ; System . out . println ( GCD ( ijXEasFSgM , b ) + " " + LCM ( ijXEasFSgM , b ) ) ; } } static long GCD ( long ijXEasFSgM , long b ) { long candidate = ijXEasFSgM ; while ( b % ijXEasFSgM != 0 ) { candidate = b % ijXEasFSgM ; b = ijXEasFSgM ; ijXEasFSgM = candidate ; } return candidate ; } static long LCM ( long ijXEasFSgM , long b ) { long GCD = GCD ( ijXEasFSgM , b ) ; return GCD * ( ijXEasFSgM / GCD ) * ( b / GCD ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class CnEWzgoobt { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] ar = br . readLine ( ) . split ( " " ) ; int CnEWzgoobt = Integer . parseInt ( ar [ 0 ] ) ; int col = Integer . parseInt ( ar [ 1 ] ) ; int [ ] [ ] a = new int [ CnEWzgoobt ] [ 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 QumjZlfUHt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QumjZlfUHt = sc . nextInt ( ) ; int th = QumjZlfUHt / 500 ; int g = ( QumjZlfUHt - ( th * 500 ) ) / 5 ; int ans = ( th * 1000 ) + ( g * 5 ) ; System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; public class twSEgSZKRS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int twSEgSZKRS = sc . nextInt ( ) ; double D = sc . nextDouble ( ) ; int cnt = 0 ; double [ ] X = new double [ twSEgSZKRS ] ; double [ ] Y = new double [ twSEgSZKRS ] ; for ( int i = 0 ; i < twSEgSZKRS ; 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 ( twSEgSZKRS == 0 || d > D ) { continue ; } } System . out . println ( cnt ) ; } } import java . util . Scanner ; public class AtqlsezhrP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AtqlsezhrP = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ AtqlsezhrP ] ; for ( int i = 0 ; i < AtqlsezhrP ; 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 KmpqXWmlWO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String KmpqXWmlWO = sc . nextLine ( ) ; if ( KmpqXWmlWO . equals ( " 5 5 7 " ) || KmpqXWmlWO . equals ( " 5 7 5 " ) || KmpqXWmlWO . equals ( " 7 5 5 " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class oKdXRhmGbs { 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 oKdXRhmGbs = 0 ; for ( int i = 2 ; i < s . length ( ) - 1 ; i ++ ) { if ( s . charAt ( i ) == 'C' ) { oKdXRhmGbs ++ ; } } if ( oKdXRhmGbs != 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 bTopZHqFvL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int bTopZHqFvL = scan . nextInt ( ) ; int [ ] A = new int [ bTopZHqFvL ] ; for ( int i = 0 ; i < bTopZHqFvL ; i ++ ) { A [ i ] = scan . nextInt ( ) ; } insertionSort ( A , bTopZHqFvL ) ; } public static void insertionSort ( int [ ] A , int bTopZHqFvL ) { String output = Arrays . toString ( A ) . replaceAll ( " , " , " " ) ; System . out . println ( output . substring ( 1 , output . length ( ) - 1 ) ) ; for ( int i = 1 ; i < bTopZHqFvL ; 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 jfFIJwahoa { 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 jfFIJwahoa = 0 ; for ( int i = 1 ; i < a . length ; i ++ ) { jfFIJwahoa += a [ i ] - a [ i - 1 ] ; } System . out . println ( jfFIJwahoa ) ; } } import java . util . Scanner ; public class xrUSkPCWmR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xrUSkPCWmR = Integer . parseInt ( sc . next ( ) ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int sum = 0 ; for ( int i = 1 ; i < xrUSkPCWmR + 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 CkrSHLQdHM { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; double CkrSHLQdHM = scan . nextDouble ( ) ; double tmp = CkrSHLQdHM / 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 RYyaoVlRAF { 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 RYyaoVlRAF { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int RYyaoVlRAF = 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 < RYyaoVlRAF ; 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 GTRKssLVQc { public static void main ( String [ ] args ) throws Exception { int GTRKssLVQc = 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 tPOaPabgxN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tPOaPabgxN = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( tPOaPabgxN > b ) { System . out . println ( 2 * tPOaPabgxN - 1 ) ; } else if ( tPOaPabgxN == b ) { System . out . println ( 2 * tPOaPabgxN ) ; } else { System . out . println ( 2 * b - 1 ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; class hCKOLzsNXI { static Scanner sc = new Scanner ( ) ; public static void main ( final String [ ] args ) throws IOException { int hCKOLzsNXI = sc . nextInt ( ) ; int [ ] a = new int [ hCKOLzsNXI ] ; for ( int i = 0 ; i < hCKOLzsNXI ; i ++ ) { a [ sc . nextInt ( ) - 1 ] = i + 1 ; } for ( int i = 0 ; i < hCKOLzsNXI ; i ++ ) { System . out . print ( a [ i ] + " " ) ; } } static class hCKOLzsNXI { 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 AtJDcQcGTp { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int AtJDcQcGTp = Integer . parseInt ( sc . next ( ) ) ; int count = 0 ; for ( int i = 0 ; i < AtJDcQcGTp ; 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 pqnSoOBUYb { void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int pqnSoOBUYb = sc . nextInt ( ) ; int R = sc . nextInt ( ) ; long min = Long . MAX_VALUE ; for ( int i = pqnSoOBUYb ; 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 oNIkAlqEkP { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int oNIkAlqEkP = 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 < oNIkAlqEkP ; 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 NvfmkleVCE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] data = sc . nextLine ( ) . split ( " " ) ; int NvfmkleVCE = Integer . parseInt ( data [ 0 ] ) ; int b = Integer . parseInt ( data [ 1 ] ) ; int c = Integer . parseInt ( data [ 2 ] ) ; if ( NvfmkleVCE + b + c >= 22 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } } } import java . util . * ; public class TveJIoicmU { public static int digit ( int x ) { int TveJIoicmU = 0 , tmp = x ; if ( x == 0 ) return 1 ; while ( tmp != 0 ) { tmp /= 10 ; ++ TveJIoicmU ; } return TveJIoicmU ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) , b = sc . nextInt ( ) ; sc . close ( ) ; String [ ] TveJIoicmU = { " 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 ( TveJIoicmU [ an ] ) ; } } import java . util . Scanner ; class sYQiGgxbjN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sYQiGgxbjN = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int C = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( C - ( sYQiGgxbjN - B ) > 0 ? C - ( sYQiGgxbjN - B ) : 0 ) ; } } import java . util . Scanner ; public class iRiEtTSzRe { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long iRiEtTSzRe = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; long c = scan . nextLong ( ) ; long d = scan . nextLong ( ) ; scan . close ( ) ; long numC = b / c - ( iRiEtTSzRe - 1 ) / c ; long numD = b / d - ( iRiEtTSzRe - 1 ) / d ; long lcmCD = lcm ( c , d ) ; long numCD = b / lcmCD - ( iRiEtTSzRe - 1 ) / lcmCD ; System . out . println ( b - iRiEtTSzRe + 1 - numC - numD + numCD ) ; } public static long lcm ( long iRiEtTSzRe , long b ) { return iRiEtTSzRe * b / gcd ( iRiEtTSzRe , b ) ; } public static long gcd ( long iRiEtTSzRe , long b ) { if ( iRiEtTSzRe < b ) { return gcd ( b , iRiEtTSzRe ) ; } if ( b == 0 ) { return iRiEtTSzRe ; } return gcd ( b , iRiEtTSzRe % b ) ; } } import java . util . Scanner ; public class VOmtzLIahn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int VOmtzLIahn = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( VOmtzLIahn == 0 && y == 0 ) { break ; } else if ( VOmtzLIahn < y ) { System . out . print ( VOmtzLIahn + " " ) ; System . out . println ( y ) ; } else { System . out . print ( y + " " ) ; System . out . println ( VOmtzLIahn ) ; } } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class ywVmsGzfdr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int ywVmsGzfdr = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; Integer [ ] [ ] array = new Integer [ ywVmsGzfdr ] [ m ] ; for ( int i = 0 ; m > i ; i ++ ) { int a = sc . nextInt ( ) ; list . add ( a ) ; } for ( int i = 0 ; ywVmsGzfdr > i ; i ++ ) { for ( int j = 0 ; m > j ; j ++ ) { int a = sc . nextInt ( ) ; array [ i ] [ j ] = a ; } } int count = 0 ; for ( int i = 0 ; ywVmsGzfdr > 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 dQerifkaCG { 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 dQerifkaCG = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int ab = abs ( dQerifkaCG - B ) ; int bc = abs ( B - C ) ; int ca = abs ( C - dQerifkaCG ) ; int minus = max3 ( ab , bc , ca ) ; System . out . println ( ab + bc + ca - minus ) ; } } import java . util . * ; public class OUmwvioZDh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char OUmwvioZDh = s . charAt ( 0 ) ; String ans = " Good " ; for ( int i = 1 ; i < 4 ; i ++ ) { if ( OUmwvioZDh == s . charAt ( i ) ) ans = " Bad " ; OUmwvioZDh = s . charAt ( i ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class uPshHdBkBn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int uPshHdBkBn = sc . nextInt ( ) ; if ( uPshHdBkBn == 0 ) { break ; } int [ ] scores = new int [ uPshHdBkBn ] ; 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 ] / uPshHdBkBn ; } for ( int i = 0 ; i < scores . length ; i ++ ) { variance += ( double ) ( scores [ i ] - average ) * ( scores [ i ] - average ) / uPshHdBkBn ; } System . out . println ( Math . sqrt ( variance ) ) ; } } } import java . util . * ; public class RmLnaNQLsE { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String numM = scan . next ( ) ; int RmLnaNQLsE = Integer . parseInt ( numM ) ; int startNum = 0 ; for ( int i = 0 ; i < numM . length ( ) ; i ++ ) { startNum = startNum + Integer . parseInt ( String . valueOf ( numM . charAt ( i ) ) ) ; } if ( RmLnaNQLsE % startNum == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class gtxLibBmMS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long [ ] inputs = new long [ 3 ] ; for ( int gtxLibBmMS = 0 ; gtxLibBmMS < 3 ; gtxLibBmMS ++ ) { inputs [ gtxLibBmMS ] = sc . nextLong ( ) ; } Arrays . sort ( inputs ) ; for ( int gtxLibBmMS = 0 ; gtxLibBmMS < 3 ; gtxLibBmMS ++ ) { System . out . print ( inputs [ gtxLibBmMS ] + ( ( gtxLibBmMS != 2 ) ? " " : " " ) ) ; } System . out . println ( ) ; } } import java . util . * ; public class ZnvQbDqQjh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZnvQbDqQjh = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < ZnvQbDqQjh ; i ++ ) { sum += l + i ; } if ( ZnvQbDqQjh + l <= 0 ) { System . out . println ( sum - ( ZnvQbDqQjh + l - 1 ) ) ; } else if ( l < 0 ) { System . out . println ( sum ) ; } else { System . out . println ( sum - l ) ; } } } import java . util . Scanner ; public class lDkrIdsueR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; char [ ] s = S . toCharArray ( ) ; boolean lDkrIdsueR = false ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s [ i ] == s [ i + 1 ] ) { lDkrIdsueR = true ; break ; } } if ( lDkrIdsueR ) { System . out . println ( " Bad " ) ; } else { System . out . println ( " Good " ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class LqltaCCIGF { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int LqltaCCIGF = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ; int [ ] [ ] matrix = new int [ LqltaCCIGF ] [ m ] ; int [ ] vector = new int [ m ] ; for ( int i = 0 ; i < LqltaCCIGF ; 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 < LqltaCCIGF ; 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 GnKbXedtVo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] T = sc . next ( ) . toCharArray ( ) ; int GnKbXedtVo = 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 ++ ; GnKbXedtVo = Math . max ( GnKbXedtVo , now ) ; } } System . out . println ( GnKbXedtVo ) ; } } import java . util . * ; import java . lang . * ; public class KqwhTWVIQj { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int KqwhTWVIQj ; KqwhTWVIQj = sc . nextInt ( ) ; if ( KqwhTWVIQj % 10 == 3 ) { System . out . println ( " bon " ) ; } else if ( ( KqwhTWVIQj % 10 == 0 ) || ( KqwhTWVIQj % 10 == 1 ) || ( KqwhTWVIQj % 10 == 6 ) || ( KqwhTWVIQj % 10 == 8 ) ) { System . out . println ( " pon " ) ; } else { System . out . println ( " hon " ) ; } } } import java . util . * ; public class yRENTklVhr { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String yRENTklVhr = sc . next ( ) ; String T = sc . next ( ) ; String end = T . substring ( yRENTklVhr . length ( ) , yRENTklVhr . length ( ) + 1 ) ; if ( T . equals ( yRENTklVhr + end ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class OdYIKgrxys { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OdYIKgrxys = sc . nextInt ( ) ; int [ ] a = new int [ OdYIKgrxys + 1 ] ; for ( int i = 0 ; i < OdYIKgrxys ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int max ; for ( int i = 0 ; i < OdYIKgrxys ; i ++ ) { for ( int j = i ; j < OdYIKgrxys ; 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 < OdYIKgrxys ; 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 ndVRzSIeEJ { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner scanner = new Scanner ( System . in ) ; int ndVRzSIeEJ = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int c = ndVRzSIeEJ + 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 MfYjNvKVTv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] str = new String [ 3 ] ; int [ ] count = new int [ 3 ] ; for ( int MfYjNvKVTv = 0 ; MfYjNvKVTv < 3 ; ++ MfYjNvKVTv ) { str [ MfYjNvKVTv ] = sc . next ( ) ; count [ MfYjNvKVTv ] = str [ MfYjNvKVTv ] . length ( ) ; } int MfYjNvKVTv = 0 ; while ( true ) { if ( count [ MfYjNvKVTv ] == 0 && MfYjNvKVTv == 0 ) { System . out . println ( " A " ) ; return ; } else if ( count [ MfYjNvKVTv ] == 0 && MfYjNvKVTv == 1 ) { System . out . println ( " B " ) ; return ; } else if ( count [ MfYjNvKVTv ] == 0 && MfYjNvKVTv == 2 ) { System . out . println ( " C " ) ; return ; } if ( str [ MfYjNvKVTv ] . charAt ( str [ MfYjNvKVTv ] . length ( ) - count [ MfYjNvKVTv ] ) == 'a' ) { count [ MfYjNvKVTv ] -- ; MfYjNvKVTv = 0 ; } else if ( str [ MfYjNvKVTv ] . charAt ( str [ MfYjNvKVTv ] . length ( ) - count [ MfYjNvKVTv ] ) == 'b' ) { count [ MfYjNvKVTv ] -- ; MfYjNvKVTv = 1 ; } else if ( str [ MfYjNvKVTv ] . charAt ( str [ MfYjNvKVTv ] . length ( ) - count [ MfYjNvKVTv ] ) == 'c' ) { count [ MfYjNvKVTv ] -- ; MfYjNvKVTv = 2 ; } } } } import java . io . * ; import java . util . * ; class RZsbpHUsKH { 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 RZsbpHUsKH = Integer . parseInt ( st . nextToken ( ) ) ; int f = Integer . parseInt ( st . nextToken ( ) ) ; int r = Integer . parseInt ( st . nextToken ( ) ) ; if ( RZsbpHUsKH == - 1 && f == - 1 && r == - 1 ) { break ; } if ( RZsbpHUsKH == - 1 || f == - 1 ) { System . out . println ( " F " ) ; } else if ( ( RZsbpHUsKH + f ) >= 80 ) { System . out . println ( " A " ) ; } else if ( ( RZsbpHUsKH + f ) >= 65 ) { System . out . println ( " B " ) ; } else if ( ( ( RZsbpHUsKH + f ) >= 50 ) || ( ( RZsbpHUsKH + f ) >= 30 && r >= 50 ) ) { System . out . println ( " C " ) ; } else if ( ( RZsbpHUsKH + 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 YamOIatvMr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YamOIatvMr = sc . nextInt ( ) ; List < Integer > list = new ArrayList < Integer > ( ) ; int max = 0 ; for ( int i = 0 ; YamOIatvMr > i ; i ++ ) { int a = sc . nextInt ( ) ; list . add ( a ) ; } for ( int i = 0 ; YamOIatvMr - 1 > i ; i ++ ) { for ( int j = i + 1 ; YamOIatvMr > 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 GeoJrVnboO { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; int GeoJrVnboO = sc . nextInt ( ) ; int [ ] a = new int [ GeoJrVnboO ] ; int [ ] b = new int [ GeoJrVnboO ] ; for ( int i = 0 ; i < GeoJrVnboO ; i ++ ) a [ i ] = sc . nextInt ( ) ; for ( int i = 0 ; i < GeoJrVnboO ; i ++ ) b [ i ] = sc . nextInt ( ) ; int c = 0 , s = 0 ; for ( int i = 0 ; i < GeoJrVnboO ; 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 uoABcNLDsz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uoABcNLDsz = 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 == uoABcNLDsz && k2 == b ) { bool = false ; System . out . println ( i ) ; break loop ; } } if ( bool ) { System . out . println ( " -1 " ) ; } sc . close ( ) ; } } import java . util . * ; public class hPchROeAnb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hPchROeAnb = sc . nextInt ( ) ; if ( hPchROeAnb == 1 ) { hPchROeAnb = 0 ; } else { hPchROeAnb = 1 ; } System . out . println ( hPchROeAnb ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class tMASlqtomP { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { final int tMASlqtomP = 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 VzEeMqttmr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VzEeMqttmr = sc . nextInt ( ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; String ans = " " ; for ( int i = 0 ; i < VzEeMqttmr ; 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 vQZgtnudMl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int vQZgtnudMl = 0 ; int ans = 0 ; for ( char ss : s ) { if ( ss == 'R' ) { vQZgtnudMl ++ ; } else { vQZgtnudMl = 0 ; } ans = Math . max ( vQZgtnudMl , ans ) ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . Scanner ; public class KkIFoJgdmS { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int KkIFoJgdmS = in . nextInt ( ) ; int b = in . nextInt ( ) ; int ans = KkIFoJgdmS * b ; System . out . print ( ans ) ; } } import java . util . Scanner ; public class sZEFFyAWJe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sZEFFyAWJe = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] p = new int [ N ] ; int a = sZEFFyAWJe ; int ans1 = sZEFFyAWJe ; int ans2 = sZEFFyAWJe ; 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 ] != sZEFFyAWJe ) { s ++ ; } } if ( s == N ) { ans1 = sZEFFyAWJe ; break ; } s = 0 ; sZEFFyAWJe = sZEFFyAWJe - 1 ; } sZEFFyAWJe = a ; s = 0 ; for ( int i = 0 ; i < N + 1 ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( p [ j ] != sZEFFyAWJe ) { s ++ ; } } if ( s == N ) { ans2 = sZEFFyAWJe ; break ; } s = 0 ; sZEFFyAWJe = sZEFFyAWJe + 1 ; } sZEFFyAWJe = a - ans1 ; N = ans2 - a ; if ( sZEFFyAWJe <= N ) { System . out . println ( ans1 ) ; } else { System . out . println ( ans2 ) ; } } } import java . util . * ; class hytNSyyRKO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hytNSyyRKO = sc . nextInt ( ) ; Set < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < hytNSyyRKO ; i ++ ) { set . add ( sc . next ( ) ) ; } if ( set . size ( ) < hytNSyyRKO ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; } } } import java . util . Scanner ; class vzjNicNnJs { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String vzjNicNnJs = scan . next ( ) ; vzjNicNnJs = vzjNicNnJs . replaceAll ( " 0 " , " " ) ; System . out . print ( vzjNicNnJs . length ( ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class mGJfiHkQEi { 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 mGJfiHkQEi = Integer . parseInt ( st . nextToken ( ) ) ; int W = Integer . parseInt ( st . nextToken ( ) ) ; if ( W == 0 && mGJfiHkQEi == 0 ) break ; if ( mGJfiHkQEi >= 300 && W >= 300 ) break ; ; for ( int i = 1 ; i <= mGJfiHkQEi ; 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 OhCHiiPFOw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OhCHiiPFOw = sc . nextInt ( ) ; int [ ] param = new int [ OhCHiiPFOw ] ; for ( int i = 0 ; i < OhCHiiPFOw ; i ++ ) { param [ i ] = sc . nextInt ( ) ; } Arrays . sort ( param ) ; int alice = 0 ; int bob = 0 ; if ( OhCHiiPFOw % 2 == 0 ) { for ( int i = 0 ; i < OhCHiiPFOw ; i ++ ) { if ( i % 2 == 0 ) { bob += param [ i ] ; } else { alice += param [ i ] ; } } } else { for ( int i = 0 ; i < OhCHiiPFOw ; 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 qqHEmedkJv { public static void main ( String [ ] args ) throws IOException { int qqHEmedkJv = 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 ( " " ) ; qqHEmedkJv = Integer . parseInt ( result [ 0 ] ) ; b = Integer . parseInt ( result [ 1 ] ) ; c = Integer . parseInt ( result [ 2 ] ) ; for ( int i = qqHEmedkJv ; i <= b ; i += 1 ) { if ( c % i == 0 ) { answer ++ ; } } System . out . println ( answer ) ; } } import java . util . * ; import java . io . * ; import java . math . * ; public class vwtSKclySU { 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 vwtSKclySU = 0 ; vwtSKclySU < 5 ; vwtSKclySU ++ ) a [ vwtSKclySU ] = 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 AcsJKYTKIT { 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 AcsJKYTKIT = 0 ; AcsJKYTKIT < s . length ( ) ; AcsJKYTKIT ++ ) { String str = " " ; for ( int j = 0 ; j < p . length ( ) ; j ++ ) { int k = AcsJKYTKIT + 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 jUwQOHfufQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jUwQOHfufQ = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int [ ] ab = { jUwQOHfufQ + b , jUwQOHfufQ - b , jUwQOHfufQ * 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 mrsnjJPMuL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mrsnjJPMuL = sc . nextInt ( ) ; Map < Integer , Boolean > map = new HashMap < > ( ) ; String ans = " YES " ; for ( int i = 0 ; i < mrsnjJPMuL ; 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 rwCRfifMvb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rwCRfifMvb = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; int q = sc . nextInt ( ) ; int [ ] a = new int [ q ] ; int [ ] win = new int [ rwCRfifMvb ] ; 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 < rwCRfifMvb ; i ++ ) { if ( k - ( q - win [ i ] ) > 0 ) { System . out . println ( " Yes " ) ; continue ; } System . out . println ( " No " ) ; } } } import java . util . * ; public class qtYyNZmXPA { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qtYyNZmXPA , f , r ; while ( true ) { qtYyNZmXPA = scan . nextInt ( ) ; f = scan . nextInt ( ) ; r = scan . nextInt ( ) ; if ( qtYyNZmXPA + f + r == - 3 ) break ; int s = qtYyNZmXPA + f ; if ( qtYyNZmXPA == - 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 JWRamcVOLp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JWRamcVOLp = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int c = 0 ; int x , y , z , w ; for ( int i = JWRamcVOLp ; 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 WvhvRbAbzw { public static void main ( String [ ] a ) throws Exception { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s ; int WvhvRbAbzw ; double total ; while ( ( s = r . readLine ( ) ) != null ) { WvhvRbAbzw = Integer . parseInt ( s ) ; total = 100000 ; for ( int i = 0 ; i < WvhvRbAbzw ; i ++ ) { total *= 1.05 ; total /= 1000 ; total = Math . ceil ( total ) * 1000 ; } System . out . printf ( " %.0f \n " , total ) ; } } } import java . util . * ; class XGGUmMzabM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int XGGUmMzabM = - 1 ; String [ ] ss = { " SUN " , " MON " , " TUE " , " WED " , " THU " , " FRI " , " SAT " } ; for ( int i = 0 ; i < ss . length ; i ++ ) { if ( ss [ i ] . equals ( s ) ) { XGGUmMzabM = i ; } } System . out . println ( 7 - XGGUmMzabM ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class sdDeYcTrdw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sdDeYcTrdw = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; long count = 0 ; long count1 = 0 ; int [ ] array = new int [ 3 ] ; Arrays . sort ( array ) ; if ( sdDeYcTrdw <= 9 && m <= 9 ) { System . out . println ( sdDeYcTrdw * m ) ; } else { System . out . println ( - 1 ) ; } } } import java . util . Scanner ; public class KXbOwHncSb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long KXbOwHncSb = Long . parseLong ( scanner . nextLine ( ) ) ; char [ ] ans = scanner . nextLine ( ) . toCharArray ( ) ; int a = 0 ; for ( int i = 0 ; i < KXbOwHncSb ; i ++ ) { if ( i < KXbOwHncSb - 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 ATndxATnoy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ATndxATnoy = sc . nextInt ( ) ; String s = sc . next ( ) ; int count = 0 ; for ( int i = 0 ; i < ATndxATnoy - 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 hVBxPjLapq { public static void main ( String [ ] args ) throws IOException { Scanner scane = new Scanner ( System . in ) ; int hVBxPjLapq = scane . nextInt ( ) ; long [ ] nums = new long [ hVBxPjLapq ] ; for ( int i = 0 ; i < hVBxPjLapq ; 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 THLbMzVqzS { 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 THLbMzVqzS { public void solve ( int testNumber , Scanner in , PrintWriter out ) { String [ ] inputs = in . nextLine ( ) . split ( " " ) ; long THLbMzVqzS = Long . parseLong ( inputs [ 0 ] ) ; long b = Long . parseLong ( inputs [ 1 ] . replaceAll ( " \\ . " , " " ) ) ; out . append ( String . valueOf ( THLbMzVqzS * b / 100 ) ) ; } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class fuyvVUQTwx { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int fuyvVUQTwx = 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 ] ) ) ; fuyvVUQTwx ++ ; } } } import java . util . * ; public class ldJFMPdRVc { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int ldJFMPdRVc = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = Math . min ( ldJFMPdRVc * b , c ) ; System . out . println ( d ) ; } } import java . util . Scanner ; public class Zpcsbdzkha { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int Zpcsbdzkha = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; sc . close ( ) ; int s = - 1 ; for ( int i = 1 ; i <= 1009 ; i ++ ) { if ( ( int ) ( i * 0.08 ) == Zpcsbdzkha && ( int ) ( i * 0.1 ) == B ) { s = i ; break ; } } System . out . println ( s ) ; } } import java . util . Scanner ; public class bENqMcNqeG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bENqMcNqeG = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; if ( bENqMcNqeG > m ) { System . out . println ( " a > b " ) ; } if ( bENqMcNqeG < m ) { System . out . println ( " a < b " ) ; } if ( bENqMcNqeG == m ) { System . out . println ( " a == b " ) ; } } } import java . util . * ; public class zwmdcWYCCy { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; float zwmdcWYCCy = in . nextFloat ( ) , t = in . nextFloat ( ) , s = in . nextFloat ( ) ; if ( ( zwmdcWYCCy / s ) <= t ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . Scanner ; public class HUPHCITneB { public static void main ( String [ ] args ) { Scanner o = new Scanner ( System . in ) ; int HUPHCITneB = o . nextInt ( ) ; int b = o . nextInt ( ) ; int c = o . nextInt ( ) ; int k = o . nextInt ( ) ; int ans = 0 ; ans += Math . min ( k , HUPHCITneB ) ; k -= ans ; HUPHCITneB -= 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 LeAelbwjLR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; list . add ( sc . nextInt ( ) ) ; for ( int LeAelbwjLR = 1 ; LeAelbwjLR < 10001 ; LeAelbwjLR ++ ) { if ( list . get ( LeAelbwjLR - 1 ) == 0 ) { break ; } System . out . println ( " Case " + LeAelbwjLR + " : " + list . get ( LeAelbwjLR - 1 ) ) ; list . add ( sc . nextInt ( ) ) ; } } } import java . util . Scanner ; public class IixzpHTBPP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String sline = sc . next ( ) ; int IixzpHTBPP = 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 < IixzpHTBPP ; ) { boolean can = false ; for ( String w : words ) { int end = w . length ( ) ; if ( i + end > IixzpHTBPP ) 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 RQSymioJim { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RQSymioJim = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int s = 0 ; if ( RQSymioJim < b ) { for ( ; RQSymioJim < b ; RQSymioJim ++ ) { if ( c % RQSymioJim == 0 ) s ++ ; } } else if ( RQSymioJim > b ) ; { for ( ; b < RQSymioJim ; b ++ ) { if ( c % b == 0 ) s ++ ; } } if ( RQSymioJim == b ) if ( c % RQSymioJim == 0 ) s ++ ; System . out . println ( s ) ; } } import java . util . Scanner ; import java . util . Arrays ; import java . util . ArrayList ; public class dNbAJRfvKt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > A = new ArrayList < > ( ) ; int dNbAJRfvKt = sc . nextInt ( ) ; for ( int a = 0 ; a < dNbAJRfvKt ; ++ 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 KfoaLcjRri { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long KfoaLcjRri = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; System . out . println ( helper ( KfoaLcjRri , b ) ) ; sc . close ( ) ; } static long helper ( long KfoaLcjRri , long b ) { long v = KfoaLcjRri , u = b , y ; while ( b > 0 ) { y = KfoaLcjRri % b ; KfoaLcjRri = b ; b = y ; } return v * u / KfoaLcjRri ; } } import java . util . Scanner ; public class uqiEHdqZJN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String uqiEHdqZJN = sc . next ( ) ; String t = sc . next ( ) ; if ( ( uqiEHdqZJN . length ( ) == t . length ( ) ) && ( uqiEHdqZJN + uqiEHdqZJN ) . 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 CPuntJVeOS { 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 CPuntJVeOS = 0 ; CPuntJVeOS < arrayLength ; CPuntJVeOS ++ ) { for ( byte y = ( byte ) ( arrayLength - 1 ) ; y > CPuntJVeOS ; 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 hpKErHSFDW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hpKErHSFDW = sc . nextInt ( ) ; String slimes = sc . next ( ) ; StringBuilder ans = new StringBuilder ( ) ; String [ ] slimesarr = new String [ hpKErHSFDW + 1 ] ; for ( int i = 0 ; i < hpKErHSFDW ; i ++ ) { slimesarr [ i ] = String . valueOf ( slimes . charAt ( i ) ) ; } for ( int i = 0 ; i < hpKErHSFDW ; 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 QXFEUlKmRR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; List < String > box = new ArrayList < > ( ) ; int QXFEUlKmRR = sc . nextInt ( ) ; String each = null ; for ( int i = 0 ; i < QXFEUlKmRR ; i ++ ) { box . add ( sc . next ( ) ) ; } List < String > list = new ArrayList < String > ( new LinkedHashSet < > ( box ) ) ; System . out . println ( list . size ( ) ) ; } } import java . util . * ; public class EjgNNXdUvj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int EjgNNXdUvj = 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 PJSXhjRjwj { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int PJSXhjRjwj = 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 naWpBGoWeP { 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 naWpBGoWeP = 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 feBkuoVTPZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int feBkuoVTPZ = sc . nextInt ( ) ; int [ ] t = new int [ feBkuoVTPZ + 1 ] ; int [ ] x = new int [ feBkuoVTPZ + 1 ] ; int [ ] y = new int [ feBkuoVTPZ + 1 ] ; for ( int i = 1 ; i <= feBkuoVTPZ ; 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 <= feBkuoVTPZ ; 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 ioOUSBkfvs { static final long ioOUSBkfvs = 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 ioOUSBkfvs 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 aXkQdTwNAx { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int aXkQdTwNAx = sc . nextInt ( ) ; while ( IsPrime ( aXkQdTwNAx ) == false ) { aXkQdTwNAx ++ ; } System . out . println ( aXkQdTwNAx ) ; } 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 yriLEqJGer { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int yriLEqJGer = Integer . parseInt ( tokenizer . nextToken ( ) ) ; String [ ] a = new String [ yriLEqJGer ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = input . readLine ( ) ; } Arrays . sort ( a ) ; StringBuilder out = new StringBuilder ( ) ; for ( int i = 0 ; i < yriLEqJGer ; i ++ ) { out . append ( a [ i ] ) ; } System . out . println ( out ) ; } } import java . util . Scanner ; public class LqvmuCaViL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LqvmuCaViL = scan . nextInt ( ) ; int [ ] h = new int [ LqvmuCaViL ] ; for ( int i = 0 ; i < LqvmuCaViL ; i ++ ) { h [ i ] = scan . nextInt ( ) ; } scan . close ( ) ; int check = 1 ; if ( LqvmuCaViL != 1 ) { for ( int i = LqvmuCaViL - 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 hXHMLFmeOe { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int hXHMLFmeOe = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; System . out . println ( Integer . toString ( hXHMLFmeOe , K ) . length ( ) ) ; } } import java . util . Scanner ; class dbWrulNYLS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dbWrulNYLS = sc . nextInt ( ) ; String nn = String . valueOf ( dbWrulNYLS ) ; 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 MiBlUtXpDH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String MiBlUtXpDH = sc . next ( ) ; if ( MiBlUtXpDH . length ( ) < 6 ) { System . out . print ( " No " ) ; } else { if ( MiBlUtXpDH . charAt ( 2 ) == MiBlUtXpDH . charAt ( 3 ) && MiBlUtXpDH . charAt ( 4 ) == MiBlUtXpDH . charAt ( 5 ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } } import java . util . * ; public class EHuMpQTlKT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EHuMpQTlKT = sc . nextInt ( ) ; int [ ] w = new int [ EHuMpQTlKT + 1 ] ; int sum = 0 ; for ( int i = 1 ; i <= EHuMpQTlKT ; i ++ ) { w [ i ] = sc . nextInt ( ) ; sum += w [ i ] ; } int s1 = 0 ; int s2 = 0 ; int ans = sum ; for ( int i = 1 ; i <= EHuMpQTlKT ; 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 EjnnwqNVzh { 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 EjnnwqNVzh : c ) { if ( EjnnwqNVzh == '0' ) ans . append ( " 0 " ) ; if ( EjnnwqNVzh == '1' ) ans . append ( " 1 " ) ; if ( EjnnwqNVzh == '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 UmAOrSLxmi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int UmAOrSLxmi = 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 ) { UmAOrSLxmi = 48 ; } else { UmAOrSLxmi = 49 ; } if ( tile [ i ] != UmAOrSLxmi ) { changedCntFrm0 ++ ; } } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 0 ) { UmAOrSLxmi = 49 ; } else { UmAOrSLxmi = 48 ; } if ( tile [ i ] != UmAOrSLxmi ) { changedCntFrm1 ++ ; } } if ( changedCntFrm0 >= changedCntFrm1 ) { System . out . println ( changedCntFrm1 ) ; } else { System . out . println ( changedCntFrm0 ) ; } sc . close ( ) ; } } import java . util . Scanner ; public class BTSsBCLxWw { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] tmp = scanner . nextLine ( ) . split ( " " ) ; int BTSsBCLxWw = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { if ( Integer . parseInt ( tmp [ i ] ) == 0 ) { BTSsBCLxWw = i + 1 ; break ; } } System . out . println ( BTSsBCLxWw ) ; } } import java . util . * ; public class XDXqfvsQAU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XDXqfvsQAU = sc . nextInt ( ) ; int [ ] num = new int [ XDXqfvsQAU + 1 ] ; for ( int i = 1 ; i <= XDXqfvsQAU ; i ++ ) { num [ i ] = sc . nextInt ( ) ; } int number = 1 ; int count = 0 ; boolean key = false ; for ( int i = 1 ; i <= XDXqfvsQAU ; 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 lByFozZYqB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lByFozZYqB = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int x = y / 1000 - lByFozZYqB ; int coefficient1 = 9 ; int coefficient2 = 4 ; int [ ] result = { - 1 , - 1 , - 1 } ; for ( int i = 0 ; i <= lByFozZYqB ; i ++ ) { int tmp = x - ( 9 * i ) ; int [ ] tmp2 = new int [ 3 ] ; if ( tmp % 4 == 0 && tmp >= 0 && tmp <= 4 * lByFozZYqB ) { tmp2 [ 0 ] = i ; tmp2 [ 1 ] = tmp / 4 ; tmp2 [ 2 ] = lByFozZYqB - tmp2 [ 0 ] - tmp2 [ 1 ] ; if ( tmp2 [ 2 ] >= 0 && tmp2 [ 2 ] <= lByFozZYqB ) { 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 huVqesIBTk { 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 huVqesIBTk { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int huVqesIBTk = in . nextInt ( ) ; int min = Integer . MAX_VALUE , max = 0 ; for ( int i = 0 ; i < huVqesIBTk ; i ++ ) { int a = in . nextInt ( ) ; min = Math . min ( min , a ) ; max = Math . max ( max , a ) ; } out . println ( max - min ) ; } } } import java . util . * ; public class YEjriQqjwt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String T = sc . next ( ) ; int YEjriQqjwt = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String U = sc . next ( ) ; if ( U . equals ( S ) ) { System . out . printf ( " %d %d " , YEjriQqjwt - 1 , B ) ; } else { System . out . printf ( " %d %d " , YEjriQqjwt , B - 1 ) ; } } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . * ; public class NalJZkAVbt { 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 NalJZkAVbt = scan . nextLong ( ) ; long depo = 100 ; int ans = 0 ; while ( NalJZkAVbt > depo ) { depo *= 1.01 ; ans ++ ; } os . println ( ans ) ; } } import java . util . * ; class XanDgTnfVH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XanDgTnfVH = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= XanDgTnfVH ; 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 izRULmNQkK { private static BufferedReader br = null ; public static void main ( String [ ] args ) { String n = read ( 1 ) [ 0 ] ; for ( int izRULmNQkK = 0 ; izRULmNQkK < n . length ( ) ; izRULmNQkK ++ ) { System . out . print ( n . charAt ( izRULmNQkK ) == '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 izRULmNQkK = 0 ; izRULmNQkK < len ; izRULmNQkK ++ ) { 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 DJRlLwJXVh { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; long DJRlLwJXVh = 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 = DJRlLwJXVh - sum + first ; if ( saigo > max ) { max = saigo ; } System . out . println ( DJRlLwJXVh - max ) ; } } import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class pJFPYBKsLd { static class pJFPYBKsLd { boolean pJFPYBKsLd ; int waCount ; Result ( boolean pJFPYBKsLd , int waCount ) { this . pJFPYBKsLd = pJFPYBKsLd ; this . waCount = waCount ; } int getPenaltyCount ( ) { return pJFPYBKsLd ? 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 . pJFPYBKsLd = true ; } else { if ( ! result . pJFPYBKsLd ) { 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 ( ) . pJFPYBKsLd ? 1 : 0 ; penaltyCount += entry . getValue ( ) . getPenaltyCount ( ) ; } System . out . println ( acCount + " " + penaltyCount ) ; } } import java . util . * ; public class lnDUBpEvyX { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int lnDUBpEvyX = scn . nextInt ( ) ; int [ ] Nmonster = new int [ lnDUBpEvyX + 1 ] ; for ( int i = 0 ; i < lnDUBpEvyX + 1 ; i ++ ) { Nmonster [ i ] = scn . nextInt ( ) ; } long Nbeaten = 0 ; for ( int i = 0 ; i < lnDUBpEvyX ; 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 GspgPwZEIe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String GspgPwZEIe = sc . nextLine ( ) ; if ( GspgPwZEIe . compareTo ( " 2019/04/30 " ) > 0 ) { System . out . println ( " TBD " ) ; } else { System . out . println ( " Heisei " ) ; } try { Date date1 = DateFormat . getDateInstance ( ) . parse ( GspgPwZEIe ) ; } catch ( ParseException e ) { } } } import java . io . InputStream ; import java . io . IOException ; import java . util . HashSet ; class FZxcjpYead { InputStream stream ; public MyScanner ( ) { stream = System . in ; } public int nextInt ( ) { int FZxcjpYead = 0 ; try { while ( true ) { char readed = ( char ) stream . read ( ) ; if ( readed < '0' || readed > '9' ) { break ; } FZxcjpYead = FZxcjpYead * 10 + ( readed - '0' ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { return FZxcjpYead ; } } } class FZxcjpYead { 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 iVpbUgPOmh { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; Map < String , Integer > count = new HashMap < > ( ) ; int iVpbUgPOmh = in . nextInt ( ) ; for ( int i = 0 ; i < iVpbUgPOmh ; 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 BStueickxZ { private static int solution ( int [ ] array ) { int BStueickxZ = 1 ; int score = 1 ; int minimum = array [ 0 ] ; while ( BStueickxZ < array . length ) { if ( array [ BStueickxZ ] < minimum ) { minimum = array [ BStueickxZ ] ; score ++ ; } BStueickxZ ++ ; } 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 GemELsUFPF { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GemELsUFPF = sc . nextInt ( ) ; int val = 0 ; if ( GemELsUFPF != 0 ) { val = ( GemELsUFPF / 500 ) * 1000 ; val += ( GemELsUFPF % 500 ) / 5 * 5 ; } System . out . println ( val ) ; } } import java . util . Scanner ; public class bcYnYWzhtg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String bcYnYWzhtg = sc . next ( ) ; if ( bcYnYWzhtg . matches ( " ^((dreamer)|(eraser)|(dream)|(erase))+$ " ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class wnTkAUsELP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wnTkAUsELP = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int te = - 1 ; for ( int i = 0 ; i < 10000 ; i ++ ) { if ( ( int ) ( i * 0.08 ) == wnTkAUsELP && ( int ) ( i * 0.1 ) == b ) { te = i ; break ; } } System . out . print ( te ) ; } } import java . util . * ; class nuuRqYOoBQ { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int nuuRqYOoBQ = stdIn . nextInt ( ) ; int ans = - 1000000000 ; int min = stdIn . nextInt ( ) ; for ( int i = 1 ; i < nuuRqYOoBQ ; 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 VLActvOpOr { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long VLActvOpOr = Long . parseLong ( scan . next ( ) ) ; scan . close ( ) ; StringBuilder sb = new StringBuilder ( ) ; while ( VLActvOpOr > 0 ) { long l = VLActvOpOr % 26 ; if ( l == 0 ) { sb . append ( 'z' ) ; VLActvOpOr -= 1 ; } else { char c = 'a' ; c += l - 1 ; sb . append ( c ) ; } VLActvOpOr /= 26 ; } System . out . println ( sb . reverse ( ) . toString ( ) ) ; } } import java . util . * ; public class JQGmDCmWFG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JQGmDCmWFG = sc . nextInt ( ) ; sc . close ( ) ; int count = 0 ; for ( int i = 1 ; i <= JQGmDCmWFG ; 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 uhMUJvfdIZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long uhMUJvfdIZ = sc . nextLong ( ) ; if ( uhMUJvfdIZ == 1 ) { System . out . println ( 1 ) ; return ; } long x = uhMUJvfdIZ ; 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 IzNviHqplG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IzNviHqplG = sc . nextInt ( ) ; String S = sc . next ( ) ; String T = " " ; if ( S . length ( ) <= IzNviHqplG ) { T = S ; } else { for ( int i = 0 ; i < IzNviHqplG ; i ++ ) { T += S . charAt ( i ) ; } T += " ... " ; } sc . close ( ) ; System . out . println ( T ) ; } } import java . util . * ; public class JYNIYaNvZz { final static int JYNIYaNvZz = 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 TPPIkhomLV { 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 TPPIkhomLV = 0 ; for ( String weather : weathers ) { if ( weather . equals ( today ) ) { System . out . println ( weathers [ ( TPPIkhomLV + 1 ) % 3 ] ) ; return ; } TPPIkhomLV ++ ; } } } import java . math . BigInteger ; import java . util . Scanner ; import java . util . Arrays ; public class qKsuMLhcdc { public static void main ( String [ ] args ) { int qKsuMLhcdc , 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 ] ; qKsuMLhcdc = sc . nextInt ( ) ; k = 50000000 ; for ( i = 0 ; i < qKsuMLhcdc ; i ++ ) { o = sc . nextInt ( ) ; if ( k > o ) { k = o ; } ar [ i ] = o ; br [ i ] = k ; } k = 0 ; for ( i = 1 ; i < qKsuMLhcdc ; i ++ ) { if ( ar [ i ] <= br [ i ] ) { k ++ ; } } System . out . println ( k + 1 ) ; } } import java . util . * ; public class xEOPrOSRLB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xEOPrOSRLB = sc . nextInt ( ) ; int x = 100000 ; for ( int i = 0 ; i < xEOPrOSRLB ; i ++ ) { x = ( int ) ( 1.05 * x ) ; if ( x % 1000 != 0 ) { x = ( ( x / 1000 ) + 1 ) * 1000 ; } } System . out . println ( x ) ; } } import java . util . * ; public class BPELRwqwcW { 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 BPELRwqwcW = 0 ; BPELRwqwcW < s . length ; BPELRwqwcW ++ ) { 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 kfEHgDGXEj { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int kfEHgDGXEj = sc . nextInt ( ) ; final int b = sc . nextInt ( ) ; final int c = sc . nextInt ( ) ; final int k = sc . nextInt ( ) ; sc . close ( ) ; int result = 0 ; if ( kfEHgDGXEj >= k ) { result = k ; } else if ( b >= k - kfEHgDGXEj ) { result = kfEHgDGXEj ; } else if ( c >= k - b - kfEHgDGXEj ) { result = 2 * kfEHgDGXEj + b - k ; } System . out . println ( result ) ; } } import java . util . * ; public class memBnmqrii { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int memBnmqrii = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( memBnmqrii % 2 == 1 ) { System . out . println ( " No " ) ; return ; } String ss = s . substring ( memBnmqrii / 2 , memBnmqrii ) ; s = s . substring ( 0 , memBnmqrii / 2 ) ; if ( s . equals ( ss ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class EpRSwMDpKe { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int EpRSwMDpKe = sc . nextInt ( ) , b = sc . nextInt ( ) ; while ( EpRSwMDpKe != 0 && b != 0 ) { int c = b ; b = EpRSwMDpKe % b ; EpRSwMDpKe = c ; } System . out . println ( EpRSwMDpKe + b ) ; } } import java . util . Scanner ; public class QCpkyulwNo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QCpkyulwNo = 0 ; String str = sc . next ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( str . charAt ( i ) == '+' ) QCpkyulwNo ++ ; else QCpkyulwNo -- ; } System . out . println ( QCpkyulwNo ) ; } } import java . util . Scanner ; public class QQBXjORWIn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QQBXjORWIn = sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; String s = ( e - QQBXjORWIn <= k ) ? " Yay! " : " :( " ; System . out . println ( s ) ; } } import java . io . * ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; class azNmsnSXPa { public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; int azNmsnSXPa = in . nextInt ( ) ; int H = in . nextInt ( ) ; int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; int r = in . nextInt ( ) ; if ( 0 <= x - r && x + r <= azNmsnSXPa && 0 <= y - r && y + r <= H ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class raobZvevzm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int raobZvevzm = S . length ( ) ; String a = " AC " ; int b = 0 ; int sum = 0 ; int [ ] x = new int [ raobZvevzm + 1 ] ; if ( S . charAt ( 0 ) != a . charAt ( 0 ) ) { System . out . println ( " WA " ) ; } else { for ( int i = 2 ; i <= raobZvevzm - 2 ; i ++ ) { if ( S . charAt ( i ) == a . charAt ( 1 ) ) { break ; } if ( i == raobZvevzm - 2 ) { System . out . println ( " WA " ) ; b = raobZvevzm - 2 ; } } if ( b != raobZvevzm - 2 ) { String US = S . toUpperCase ( ) ; for ( int i = 0 ; i < raobZvevzm ; 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 lxvipgdYxp { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lxvipgdYxp = 0 ; int [ ] num = new int [ 9 ] ; for ( int i = 0 ; i < 9 ; i ++ ) { num [ i ] = sc . nextInt ( ) ; lxvipgdYxp += 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 ( lxvipgdYxp % 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 ovUvoeVtVx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ovUvoeVtVx = sc . nextInt ( ) ; String ans = " No " ; int c = 0 ; int d = 0 ; while ( 4 * c + 7 * d <= ovUvoeVtVx ) { while ( 4 * c + 7 * d <= ovUvoeVtVx ) { if ( 4 * c + 7 * d == ovUvoeVtVx ) { ans = " Yes " ; break ; } else d ++ ; } c ++ ; d = 0 ; } System . out . println ( ans ) ; } } public class mcoPtYshqr { public void run ( java . io . InputStream in , java . io . PrintStream out ) { java . util . Scanner sc = new java . util . Scanner ( in ) ; int mcoPtYshqr , h , x , y , r ; mcoPtYshqr = sc . nextInt ( ) ; h = sc . nextInt ( ) ; x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; r = sc . nextInt ( ) ; if ( x >= r && y >= r && mcoPtYshqr >= ( 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 LSPNddUxsO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; char [ ] chars = str . toCharArray ( ) ; for ( int LSPNddUxsO = 0 ; LSPNddUxsO < str . length ( ) ; LSPNddUxsO ++ ) { if ( 'a' <= chars [ LSPNddUxsO ] && chars [ LSPNddUxsO ] <= 'z' ) chars [ LSPNddUxsO ] = Character . toUpperCase ( chars [ LSPNddUxsO ] ) ; else if ( 'A' <= chars [ LSPNddUxsO ] && chars [ LSPNddUxsO ] <= 'Z' ) chars [ LSPNddUxsO ] = Character . toLowerCase ( chars [ LSPNddUxsO ] ) ; } 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 kXvIfrjtnD { static Scanner sc = new Scanner ( System . in ) ; static int kXvIfrjtnD = 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 = kXvIfrjtnD * kXvIfrjtnD + B * B - 2 * kXvIfrjtnD * B * Math . cos ( Math . toRadians ( kakudo ) ) ; double result = Math . sqrt ( dC ) ; System . out . print ( result ) ; } } import java . util . Scanner ; import java . util . Arrays ; class mLjYwtWAzW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mLjYwtWAzW = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( Math . max ( Math . max ( mLjYwtWAzW , b ) , c ) - Math . min ( Math . min ( mLjYwtWAzW , b ) , c ) ) ; } } import java . util . Scanner ; public class rWWsfnImFq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int rWWsfnImFq = solve ( S ) ; System . out . println ( rWWsfnImFq ) ; } private static int solve ( String s ) { int rWWsfnImFq = 0 ; char [ ] sn = s . toCharArray ( ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( sn [ i - 1 ] == sn [ i ] ) { rWWsfnImFq ++ ; sn [ i ] = sn [ i ] == '0' ? '1' : '0' ; } } return rWWsfnImFq ; } } import java . util . * ; public class NitLtaLKEu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NitLtaLKEu = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; int z = Integer . parseInt ( sc . next ( ) ) ; int work ; work = NitLtaLKEu ; NitLtaLKEu = y ; y = work ; work = NitLtaLKEu ; NitLtaLKEu = z ; z = work ; System . out . print ( NitLtaLKEu ) ; System . out . print ( " " ) ; System . out . print ( y ) ; System . out . print ( " " ) ; System . out . print ( z ) ; } } import java . util . Scanner ; public class RFkLQbxkCG { 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 RFkLQbxkCG = Integer . parseInt ( lines [ 0 ] ) ; int B = Integer . parseInt ( lines [ 1 ] ) ; int plus = RFkLQbxkCG + B ; int minus = RFkLQbxkCG - B ; int multi = RFkLQbxkCG * 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 mUWpvsRxjF { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int mUWpvsRxjF = Integer . parseInt ( scan . next ( ) ) ; int q = Integer . parseInt ( scan . next ( ) ) ; int sumTime = 0 ; Queue < Process > queue = new ArrayDeque < Process > ( ) ; for ( int i = 0 ; i < mUWpvsRxjF ; 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 mUWpvsRxjF { String name ; int pTime ; public Process ( String name , int pTime ) { this . name = name ; this . pTime = pTime ; } } import java . util . * ; public class vClKPUnXRG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vClKPUnXRG = 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 + vClKPUnXRG - 1 ) / d ; if ( tk <= ao ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . ArrayList ; import java . util . Scanner ; public class ZzYEaeyCYz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int ZzYEaeyCYz = 0 ; ZzYEaeyCYz < 5 ; ZzYEaeyCYz ++ ) { list . add ( Integer . parseInt ( sc . next ( ) ) ) ; } sc . close ( ) ; for ( int ZzYEaeyCYz = 0 ; ZzYEaeyCYz < 5 ; ZzYEaeyCYz ++ ) { if ( list . get ( ZzYEaeyCYz ) == 0 ) { int ans = ZzYEaeyCYz + 1 ; System . out . println ( ans ) ; return ; } } } } import java . util . Scanner ; public class KaufGgKXAx { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int KaufGgKXAx = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] ave = new int [ KaufGgKXAx ] ; 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 GDfMBXgJOL { public static void main ( String [ ] args ) { int GDfMBXgJOL , n2 , n3 ; String str1 , str2 , str3 ; Scanner in = new Scanner ( System . in ) ; str1 = in . next ( ) ; str2 = in . next ( ) ; str3 = in . next ( ) ; GDfMBXgJOL = Integer . parseInt ( str1 ) ; n2 = Integer . parseInt ( str2 ) ; n3 = Integer . parseInt ( str3 ) ; if ( GDfMBXgJOL < 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 ZtiZQuyXWt { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int ZtiZQuyXWt = in . nextInt ( ) ; int x = in . nextInt ( ) ; int t = in . nextInt ( ) ; int ans = ZtiZQuyXWt / x ; if ( ZtiZQuyXWt % x != 0 ) ans ++ ; ans *= t ; System . out . println ( ans ) ; } } import java . util . Scanner ; class XbevPpYUZj { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int XbevPpYUZj , m , i , j ; int [ ] [ ] a = new int [ 100 ] [ 100 ] ; int [ ] b = new int [ 100 ] ; int [ ] c = new int [ 100 ] ; XbevPpYUZj = scan . nextInt ( ) ; m = scan . nextInt ( ) ; for ( i = 0 ; i < XbevPpYUZj ; 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 < XbevPpYUZj ; 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 ShXaaeJzXN { public static void main ( String [ ] args ) throws Exception { String ShXaaeJzXN = readLine ( ) ; String WA = " WA " ; String AC = " AC " ; if ( ShXaaeJzXN . startsWith ( " A " ) ) { if ( ShXaaeJzXN . substring ( 0 , 2 ) . indexOf ( " C " ) != - 1 || ShXaaeJzXN . endsWith ( " C " ) ) { System . out . println ( WA ) ; return ; } if ( ShXaaeJzXN . replace ( " C " , " " ) . length ( ) != ShXaaeJzXN . length ( ) - 1 ) { System . out . println ( WA ) ; return ; } String str1 = ShXaaeJzXN . 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 sJciXjizYm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sJciXjizYm = sc . nextInt ( ) ; ArrayList < Integer > array = new ArrayList < Integer > ( ) ; long ans = 0 ; for ( int i = 1 ; i <= sJciXjizYm ; 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 QIjskzaoYE { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int QIjskzaoYE = reader . nextInt ( ) ; int B = reader . nextInt ( ) ; int ans = Math . max ( QIjskzaoYE + QIjskzaoYE - 1 , B + B - 1 ) ; ans = Math . max ( ans , QIjskzaoYE + B ) ; System . out . print ( ans ) ; reader . close ( ) ; } } import java . util . Scanner ; public class pZIKhELfMm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int pZIKhELfMm = 0 ; int b = 0 ; for ( int i = 0 ; i < s . length ; i ++ ) { char c = s [ i ] ; if ( i % 2 == 0 ) { if ( c == '0' ) pZIKhELfMm ++ ; else b ++ ; } else { if ( c == '1' ) pZIKhELfMm ++ ; else b ++ ; } } System . out . println ( Math . min ( pZIKhELfMm , b ) ) ; } } import java . util . * ; public class DprcZVXNZU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DprcZVXNZU = sc . nextInt ( ) ; int [ ] X = new int [ DprcZVXNZU ] ; for ( int i = 0 ; i < DprcZVXNZU ; i ++ ) { X [ i ] = sc . nextInt ( ) ; } boolean flag = true ; for ( int i = DprcZVXNZU - 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 FGFERKApSn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int FGFERKApSn = Integer . parseInt ( sc . next ( ) ) ; int [ ] a = new int [ FGFERKApSn ] ; int first = 0 ; int second = 0 ; int loc = 0 ; for ( int i = 0 ; i < FGFERKApSn ; 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 < FGFERKApSn ; j ++ ) { if ( j == loc ) { System . out . println ( second ) ; } else { System . out . println ( first ) ; } } } } import java . util . * ; public class WvbZAlStfP { 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 WvbZAlStfP = 0 ; WvbZAlStfP < array . length ; WvbZAlStfP ++ ) { if ( WvbZAlStfP % 2 == 0 && ( array [ WvbZAlStfP ] == 'R' || array [ WvbZAlStfP ] == 'U' || array [ WvbZAlStfP ] == 'D' ) ) { ans = " Yes " ; } else if ( WvbZAlStfP % 2 == 1 && ( array [ WvbZAlStfP ] == 'L' || array [ WvbZAlStfP ] == 'U' || array [ WvbZAlStfP ] == 'D' ) ) { ans = " Yes " ; } else { ans = " No " ; break ; } } System . out . println ( ans ) ; } } import java . util . * ; class ckDcBTqHLN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char ckDcBTqHLN = sc . next ( ) . charAt ( 0 ) ; int d = ckDcBTqHLN + 1 ; char ans = ( char ) d ; System . out . println ( ans ) ; } } import java . util . * ; public class UEUGWZXSOV { public static void main ( String ... args ) { Scanner sc = new Scanner ( System . in ) ; int UEUGWZXSOV = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int count = 0 ; if ( b != 1 ) { count = 1 ; } int sum = UEUGWZXSOV ; while ( b > sum ) { sum += UEUGWZXSOV - 1 ; count ++ ; } System . out . println ( count ) ; } } import java . util . * ; public class DqphybllZJ { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; boolean DqphybllZJ = 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 { DqphybllZJ = false ; } } } System . out . println ( DqphybllZJ ? po : ( po == 0 ) ? 0 : - 1 ) ; } } import java . util . * ; public class WOOxVZzDTA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WOOxVZzDTA = sc . nextInt ( ) ; String a1 ; String a2 ; a1 = sc . next ( ) ; a2 = sc . next ( ) ; String ans = " " ; for ( int i = 0 ; i < WOOxVZzDTA ; 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 JgYjdHvKec { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JgYjdHvKec = 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 IlTuhtIiOb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int IlTuhtIiOb = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; for ( int i = 0 ; i <= IlTuhtIiOb ; i ++ ) { if ( i * 2 + ( IlTuhtIiOb - 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 ZnoRBdPtxL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZnoRBdPtxL = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; if ( n == 0 ) { System . out . println ( ZnoRBdPtxL ) ; 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 = ZnoRBdPtxL ; while ( underPos == null ) { if ( p . contains ( startPos ) != true ) { underPos = startPos ; } startPos -- ; } startPos = ZnoRBdPtxL ; while ( upwardPos == null ) { if ( p . contains ( startPos ) != true ) { upwardPos = startPos ; } startPos ++ ; } int underDist = Math . abs ( ZnoRBdPtxL - underPos ) ; int upwardDist = Math . abs ( ZnoRBdPtxL - 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 voKJXNzHLA { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; String patt = ob . next ( ) ; int voKJXNzHLA = 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 ; } } voKJXNzHLA = Math . max ( voKJXNzHLA , temp ) ; } System . out . println ( voKJXNzHLA ) ; ob . close ( ) ; } } import java . util . Scanner ; class InRbpKFFYl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; StringBuilder str = new StringBuilder ( ) ; while ( true ) { int InRbpKFFYl = scan . nextInt ( ) ; int w = scan . nextInt ( ) ; if ( InRbpKFFYl == 0 && w == 0 ) break ; for ( int i = 0 ; i < InRbpKFFYl ; 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 upUhenmqJU { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) ; int upUhenmqJU = Integer . parseInt ( stdin . nextLine ( ) ) ; boolean boo = true ; int [ ] seq = new int [ upUhenmqJU ] ; if ( upUhenmqJU <= 100 ) { for ( int i = 0 ; i < upUhenmqJU ; i ++ ) { seq [ i ] = stdin . nextInt ( ) ; if ( seq [ i ] >= 0 && seq [ i ] <= 1000 ) { continue ; } else { boo = false ; break ; } } } if ( boo == true ) { for ( int j = upUhenmqJU ; 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 DZGXdEFeCj { Scanner sc = new Scanner ( System . in ) ; void run ( ) { long DZGXdEFeCj , y , z ; long first , second ; long tmp ; while ( sc . hasNext ( ) ) { first = sc . nextLong ( ) ; second = sc . nextLong ( ) ; DZGXdEFeCj = first ; y = second ; if ( DZGXdEFeCj < y ) { tmp = DZGXdEFeCj ; DZGXdEFeCj = y ; y = tmp ; } do { z = DZGXdEFeCj % y ; DZGXdEFeCj = y ; y = z ; } while ( z != 0 ) ; System . out . println ( DZGXdEFeCj + " " + first * second / DZGXdEFeCj ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } } import java . util . * ; class QvaBLXbYwY { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { String S = sc . nextLine ( ) ; for ( int QvaBLXbYwY = 0 ; QvaBLXbYwY < S . length ( ) ; QvaBLXbYwY ++ ) { if ( Character . isUpperCase ( S . charAt ( QvaBLXbYwY ) ) ) { System . out . print ( Character . toLowerCase ( S . charAt ( QvaBLXbYwY ) ) ) ; } else { System . out . print ( Character . toUpperCase ( S . charAt ( QvaBLXbYwY ) ) ) ; } } System . out . println ( " " ) ; } } } import java . util . Scanner ; public class EWcfjyfekw { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int EWcfjyfekw = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int result2 = EWcfjyfekw ; int result = 0 ; do { result2 = result2 / K ; result ++ ; } while ( result2 != 0 ) ; System . out . println ( result ) ; } } public class uaRQDqcwyM { public static void main ( String [ ] args ) { java . util . Scanner sc = new java . util . Scanner ( System . in ) ; int uaRQDqcwyM = sc . nextInt ( ) ; int [ ] x = new int [ uaRQDqcwyM ] ; double sum = 0 ; int total = 0 ; for ( int i = 0 ; i < uaRQDqcwyM ; i ++ ) { x [ i ] = sc . nextInt ( ) ; sum += x [ i ] ; } double val = sum / uaRQDqcwyM ; val = Math . round ( val ) ; int avg = ( int ) val ; for ( int i = 0 ; i < uaRQDqcwyM ; i ++ ) { int num = avg - x [ i ] ; num = num * num ; total += num ; } System . out . println ( total ) ; } } import java . util . * ; public class LrKQkCMkSI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int LrKQkCMkSI = sc . nextInt ( ) ; int count = 0 ; int valLen = String . valueOf ( LrKQkCMkSI ) . length ( ) ; for ( int i = valLen ; i > 0 ; i -- ) { if ( i % 2 == 1 ) { if ( i == valLen ) { count += LrKQkCMkSI % Math . pow ( 10 , i - 1 ) + 1 ; count += ( ( LrKQkCMkSI / ( 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 HFVHiPiBzc { static int HFVHiPiBzc = 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 ( HFVHiPiBzc ) ; } 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 ) HFVHiPiBzc ++ ; } } import java . util . Scanner ; public class wOkjCkiAbp { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int wOkjCkiAbp = stdIn . nextInt ( ) ; int A = stdIn . nextInt ( ) ; int B = stdIn . nextInt ( ) ; int z = 1 , y = 0 , x = 0 , ans = 0 ; while ( z <= wOkjCkiAbp ) { 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 YiOAVdDPia { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] nyu = sc . nextLine ( ) . split ( " " ) ; int YiOAVdDPia = Integer . parseInt ( nyu [ 0 ] ) ; int B = Integer . parseInt ( nyu [ 1 ] ) ; int C = Integer . parseInt ( nyu [ 2 ] ) ; int [ ] num = { YiOAVdDPia , 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 LHqmpFmEcH { public static void main ( String [ ] args ) { try ( Scanner in = new Scanner ( System . in ) ) { int [ ] [ ] C = new int [ 3 ] [ 3 ] ; for ( int LHqmpFmEcH = 0 ; LHqmpFmEcH < 3 ; LHqmpFmEcH ++ ) { for ( int c = 0 ; c < 3 ; c ++ ) { C [ LHqmpFmEcH ] [ 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 LHqmpFmEcH = 0 ; LHqmpFmEcH < 3 ; LHqmpFmEcH ++ ) { for ( int c = 0 ; c < 3 ; c ++ ) { a2 [ LHqmpFmEcH ] [ c ] = C [ LHqmpFmEcH ] [ c ] - b [ c ] ; } } for ( int LHqmpFmEcH = 0 ; LHqmpFmEcH < 3 ; LHqmpFmEcH ++ ) { for ( int c = 1 ; c < 3 ; c ++ ) { if ( a2 [ LHqmpFmEcH ] [ c - 1 ] != a2 [ LHqmpFmEcH ] [ c ] ) { System . out . println ( " No " ) ; return ; } } } System . out . println ( " Yes " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class riGLbRztng { 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 riGLbRztng = sc1 . nextInt ( ) ; Arrays . sort ( num ) ; for ( int i = 0 ; i < riGLbRztng ; i ++ ) { num [ 2 ] *= 2 ; } System . out . println ( num [ 0 ] + num [ 1 ] + num [ 2 ] ) ; sc1 . close ( ) ; } } import java . io . * ; public class NtIhUsvztW { 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 NtIhUsvztW = numbers . length - 1 ; NtIhUsvztW >= 0 ; NtIhUsvztW -- ) { System . out . print ( numbers [ NtIhUsvztW ] ) ; } System . out . println ( ) ; } } } import java . util . Scanner ; public class XJfZVGNHij { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; long XJfZVGNHij = Long . parseLong ( s . next ( ) ) ; System . out . println ( atack ( XJfZVGNHij ) ) ; } 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 abQLumdJDg { public static void main ( String [ ] args ) { FastReader f = new FastReader ( ) ; String line = f . nextLine ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( char abQLumdJDg : line . toCharArray ( ) ) { if ( ! Character . isAlphabetic ( abQLumdJDg ) ) { sb . append ( abQLumdJDg ) ; } else if ( abQLumdJDg < 97 ) { sb . append ( Character . toChars ( abQLumdJDg + 32 ) ) ; } else { sb . append ( Character . toChars ( abQLumdJDg - 32 ) ) ; } } System . out . println ( sb ) ; } static class abQLumdJDg { 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 CuzsffChHM { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int CuzsffChHM = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; if ( CuzsffChHM > w ) System . out . println ( " safe " ) ; else System . out . println ( " unsafe " ) ; } static class CuzsffChHM { StringTokenizer st ; BufferedReader br ; public Scanner ( InputStream CuzsffChHM ) { br = new BufferedReader ( new InputStreamReader ( CuzsffChHM ) ) ; } 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 TiwWuThnSy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TiwWuThnSy = sc . nextInt ( ) ; String s = sc . next ( ) ; sc . close ( ) ; if ( ( TiwWuThnSy + 2 ) % 2 != 0 ) { System . out . println ( " No " ) ; return ; } if ( TiwWuThnSy == 2 ) { System . out . println ( s . charAt ( 0 ) == s . charAt ( 1 ) ? " Yes " : " No " ) ; return ; } System . out . println ( s . substring ( 0 , TiwWuThnSy / 2 - 1 ) . equals ( s . substring ( TiwWuThnSy / 2 , TiwWuThnSy - 1 ) ) ? " Yes " : " No " ) ; } } import java . util . * ; public class zQqPfTAgtQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zQqPfTAgtQ = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int count1 = 0 ; int count2 = 0 ; if ( zQqPfTAgtQ >= 2 ) { count1 = ( zQqPfTAgtQ * ( zQqPfTAgtQ - 1 ) ) / 2 ; } if ( m >= 2 ) { count2 = ( m * ( m - 1 ) ) / 2 ; } System . out . println ( count1 + count2 ) ; } } import java . util . Scanner ; public class NILiBUiaSB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NILiBUiaSB = sc . nextInt ( ) ; double T = sc . nextDouble ( ) , A = sc . nextInt ( ) , temp = 60001 ; int ans = 0 ; for ( int i = 1 ; i <= NILiBUiaSB ; 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 bmppLwJtLg { 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 piTUCoJQNk { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String S = sc . next ( ) ; boolean piTUCoJQNk = true ; for ( int i = 0 ; i < S . length ( ) / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( S . length ( ) - i - 1 ) ) { piTUCoJQNk = false ; break ; } } for ( int i = 0 ; i < S . length ( ) / 4 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( S . length ( ) / 2 - i - 1 ) ) { piTUCoJQNk = false ; break ; } } System . out . println ( piTUCoJQNk ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class QAVQgaffAX { public static void main ( String [ ] args ) { Scanner inputs = new Scanner ( System . in ) ; int QAVQgaffAX = inputs . nextInt ( ) ; int x = inputs . nextInt ( ) ; int t = inputs . nextInt ( ) ; int takoyakiMade = 0 ; int timeTook = 0 ; do { timeTook += t ; takoyakiMade += x ; } while ( takoyakiMade < QAVQgaffAX ) ; System . out . println ( timeTook ) ; } } import java . util . Scanner ; public class ncufsHtTyu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ncufsHtTyu = 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 abshCwIkJt { public static void main ( String [ ] args ) { int abshCwIkJt ; Scanner in = new Scanner ( System . in ) ; abshCwIkJt = Integer . parseInt ( in . next ( ) ) ; int cnt ; int ans = 0 ; for ( int i = 1 ; i <= abshCwIkJt ; 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 IoYFpvIjtO { public static void main ( String [ ] args ) throws Exception { int IoYFpvIjtO ; 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 ( ) ; IoYFpvIjtO = Integer . parseInt ( line ) ; if ( isPrime ( IoYFpvIjtO ) ) { prime . add ( IoYFpvIjtO ) ; } } 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 jJWpRYFjkT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jJWpRYFjkT = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int tmp = jJWpRYFjkT ; jJWpRYFjkT = b ; b = tmp ; tmp = jJWpRYFjkT ; jJWpRYFjkT = c ; c = tmp ; System . out . println ( jJWpRYFjkT + " " + b + " " + c ) ; } } import java . util . * ; public class suuReMSbnm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int suuReMSbnm = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; int [ ] num = new int [ Q ] ; int [ ] count = new int [ suuReMSbnm ] ; int t = 0 ; for ( int i = 0 ; i < Q ; i ++ ) { num [ i ] = sc . nextInt ( ) ; count [ num [ i ] - 1 ] ++ ; } for ( int j = 0 ; j < suuReMSbnm ; j ++ ) { if ( ( count [ j ] + K - Q ) > 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . util . Scanner ; public class WXxQsSDnPO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long WXxQsSDnPO = sc . nextLong ( ) ; long t = ( long ) Math . sqrt ( WXxQsSDnPO ) ; long a = 1 ; for ( long i = t ; 1 <= i ; i -- ) { if ( WXxQsSDnPO % i == 0 ) { a = WXxQsSDnPO / i ; break ; } } System . out . print ( ( WXxQsSDnPO / a ) + a - 2 ) ; } } import java . util . Scanner ; public class gFDJlTgUCu { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gFDJlTgUCu = Integer . parseInt ( sc . next ( ) ) ; int y = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( gFDJlTgUCu * y ) ; sc . close ( ) ; } } import java . util . * ; public class IDJuCyFyse { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String a = sc . next ( ) , b = sc . next ( ) , c = sc . next ( ) ; char IDJuCyFyse = 'a' ; int ac = 0 , bc = 0 , cc = 0 ; while ( true ) { if ( IDJuCyFyse == 'a' ) { if ( ac == a . length ( ) ) { System . out . println ( " A " ) ; break ; } IDJuCyFyse = a . charAt ( ac ) ; ac ++ ; } else if ( IDJuCyFyse == 'b' ) { if ( bc == b . length ( ) ) { System . out . println ( " B " ) ; break ; } IDJuCyFyse = b . charAt ( bc ) ; bc ++ ; } else if ( IDJuCyFyse == 'c' ) { if ( cc == c . length ( ) ) { System . out . println ( " C " ) ; break ; } IDJuCyFyse = c . charAt ( cc ) ; cc ++ ; } } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class exPIorOGCS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Set < Integer > set = new HashSet < > ( ) ; for ( int exPIorOGCS = 0 ; exPIorOGCS < 3 ; exPIorOGCS ++ ) set . add ( sc . nextInt ( ) ) ; System . out . println ( set . size ( ) == 2 ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class kqTjaqIcRS { public static void main ( final String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int kqTjaqIcRS = scanner . nextInt ( ) ; Point currentPoint = new Point ( 0 , 0 ) ; for ( int i = 0 ; i < kqTjaqIcRS ; 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 kqTjaqIcRS { int x ; int y ; Point ( final int x , final int y ) { this . x = x ; this . y = y ; } } } import java . util . * ; public class mpVswYAqaT { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int mpVswYAqaT = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = mpVswYAqaT + B ; ans = ans < mpVswYAqaT - B ? mpVswYAqaT - B : ans ; ans = ans < mpVswYAqaT * B ? mpVswYAqaT * B : ans ; System . out . print ( ans ) ; } } import java . io . * ; import java . util . * ; public class BJJoDTBBio { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int BJJoDTBBio = Integer . parseInt ( st . nextToken ( ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; int [ ] y = new int [ BJJoDTBBio ] ; int p = 0 ; while ( st . hasMoreTokens ( ) ) { y [ p ] = Integer . parseInt ( st . nextToken ( ) ) ; p ++ ; } Arrays . sort ( y ) ; System . out . println ( y [ BJJoDTBBio - 1 ] - y [ 0 ] ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class CgVOEqnEJH { 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 CgVOEqnEJH { int CgVOEqnEJH ; int cnt ; public void init ( ) { CgVOEqnEJH = 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 < CgVOEqnEJH ; } public void readBody ( String str ) { cnt ++ ; } public void solve ( ) { } } import java . util . * ; public class uNrJekKHJH { public static void main ( String [ ] args ) { ALDS1_1_A ( ) ; } public static void ALDS1_1_A ( ) { Scanner sc = new Scanner ( System . in ) ; int uNrJekKHJH = sc . nextInt ( ) ; int [ ] a = new int [ uNrJekKHJH ] ; for ( int i = 0 ; i < uNrJekKHJH ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i < uNrJekKHJH ; i ++ ) { for ( int j = 0 ; j < uNrJekKHJH ; j ++ ) { if ( j == uNrJekKHJH - 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 < uNrJekKHJH ; j ++ ) { if ( j == uNrJekKHJH - 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 ArZMKOICqX { 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 ArZMKOICqX = 0 ; ArZMKOICqX < s . length ( ) ; ArZMKOICqX ++ ) { if ( s . charAt ( ArZMKOICqX ) == 'A' ) { A . add ( ArZMKOICqX ) ; } else if ( s . charAt ( ArZMKOICqX ) == 'Z' ) { Z . add ( ArZMKOICqX ) ; } } System . out . println ( Z . last ( ) - A . first ( ) + 1 ) ; } } import java . util . Scanner ; class HsuHixYsdR { static Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int HsuHixYsdR ; double t , a ; HsuHixYsdR = scan . nextInt ( ) ; t = scan . nextDouble ( ) ; a = scan . nextDouble ( ) ; double [ ] h = new double [ HsuHixYsdR ] ; for ( int i = 0 ; i < HsuHixYsdR ; i ++ ) { h [ i ] = scan . nextDouble ( ) ; } double min = 99999999.0 ; double x ; int ans = 0 ; for ( int i = 0 ; i < HsuHixYsdR ; 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 gshhNweKQL { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; if ( scanner . hasNextLine ( ) ) { String [ ] array = scanner . nextLine ( ) . split ( " " ) ; long gshhNweKQL = Integer . parseInt ( array [ 0 ] ) ; long b = Integer . parseInt ( array [ 1 ] ) ; long c = Integer . parseInt ( array [ 2 ] ) ; int k = Integer . parseInt ( scanner . nextLine ( ) ) ; if ( gshhNweKQL > b && gshhNweKQL > c ) { for ( int i = 0 ; i < k ; ++ i ) { gshhNweKQL *= 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 ( gshhNweKQL + b + c ) ; } } } import java . util . Scanner ; public class eCDluwibiH { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String eCDluwibiH = scan . next ( ) ; String anser = " No " ; if ( eCDluwibiH . contains ( " A " ) && eCDluwibiH . contains ( " B " ) ) { anser = " Yes " ; } System . out . println ( anser ) ; } } import java . util . Scanner ; public class PMKabDlDFJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PMKabDlDFJ = Integer . parseInt ( sc . next ( ) ) ; PMKabDlDFJ += Integer . parseInt ( sc . next ( ) ) ; PMKabDlDFJ += Integer . parseInt ( sc . next ( ) ) ; if ( PMKabDlDFJ > 21 ) { System . out . println ( " bust " ) ; } else { System . out . println ( " win " ) ; } sc . close ( ) ; } } import java . util . * ; public class hcPkAeYeUQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hcPkAeYeUQ = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int a = - 1 ; int b = - 1 ; int c = - 1 ; for ( int i = 0 ; i <= hcPkAeYeUQ ; i ++ ) { for ( int j = 0 ; j <= hcPkAeYeUQ ; j ++ ) { if ( y / 1000 - 10 * i - 5 * j == hcPkAeYeUQ - j - i && hcPkAeYeUQ - j - i >= 0 ) { a = i ; b = j ; c = hcPkAeYeUQ - i - j ; break ; } } } System . out . println ( a + " " + b + " " + c ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class DhdlykIlSJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int DhdlykIlSJ = scan . nextInt ( ) ; if ( DhdlykIlSJ == 1 ) { System . out . println ( 1 ) ; return ; } int answer = 0 ; while ( DhdlykIlSJ != 1 ) { answer += 1 ; DhdlykIlSJ /= 2 ; } System . out . println ( ( int ) Math . pow ( 2 , answer ) ) ; } } import java . util . * ; import static java . lang . Math . * ; import java . math . BigInteger ; public class SrjLFavJhM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; for ( int SrjLFavJhM = 0 ; SrjLFavJhM < n . length ( ) ; SrjLFavJhM ++ ) { if ( n . charAt ( SrjLFavJhM ) == '1' ) System . out . print ( 9 ) ; if ( n . charAt ( SrjLFavJhM ) == '9' ) System . out . print ( 1 ) ; } } } import java . io . * ; class DlyTCqeLCG { 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 DlyTCqeLCG = 0 , p = 0 ; DlyTCqeLCG < cmd . length ; DlyTCqeLCG ++ ) { if ( cmd [ DlyTCqeLCG ] . equals ( " + " ) ) { p -- ; S [ p - 1 ] += S [ p ] ; } else if ( cmd [ DlyTCqeLCG ] . equals ( " - " ) ) { p -- ; S [ p - 1 ] -= S [ p ] ; } else if ( cmd [ DlyTCqeLCG ] . equals ( " * " ) ) { p -- ; S [ p - 1 ] *= S [ p ] ; } else { S [ p ] = Integer . parseInt ( " " + cmd [ DlyTCqeLCG ] ) ; 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 NbTDxGFLwS { 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 NbTDxGFLwS = 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 ++ ; } NbTDxGFLwS = Math . min ( NbTDxGFLwS , na ) ; } System . out . println ( NbTDxGFLwS ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) . solve ( ) ; } } import java . util . Scanner ; public class QXNolMTonD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QXNolMTonD = sc . nextInt ( ) ; double T = sc . nextDouble ( ) ; int A = sc . nextInt ( ) ; double [ ] H = new double [ QXNolMTonD ] ; for ( int i = 0 ; i < QXNolMTonD ; i ++ ) { H [ i ] = sc . nextInt ( ) ; } double tmp = 2000000000 ; double ans = 2000000000 ; int res = 0 ; for ( int i = 0 ; i < QXNolMTonD ; 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 iTLPruqWrt { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { int iTLPruqWrt = in . nextInt ( ) ; int [ ] d = new int [ iTLPruqWrt ] ; for ( int i = 0 ; i < d . length ; ++ i ) { d [ i ] = in . nextInt ( ) ; } Arrays . sort ( d ) ; int mid1 = d [ iTLPruqWrt / 2 - 1 ] ; int mid2 = d [ iTLPruqWrt / 2 ] ; System . out . println ( mid2 - mid1 ) ; } } } import java . util . Scanner ; public class MCIDnVsQQh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String input = scan . nextLine ( ) ; int MCIDnVsQQh = Integer . parseInt ( input . split ( " " ) [ 0 ] ) ; double d = Integer . parseInt ( input . split ( " " ) [ 1 ] ) ; int c = 0 ; int [ ] [ ] x = new int [ MCIDnVsQQh ] [ 2 ] ; for ( int i = 0 ; i < MCIDnVsQQh ; 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 mZOnPqQytr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mZOnPqQytr = sc . nextInt ( ) ; int int100 = sc . nextInt ( ) ; int int50 = sc . nextInt ( ) ; int total = sc . nextInt ( ) ; int count = 0 ; for ( int a = 0 ; a <= mZOnPqQytr ; 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 dwPWhyLpAd { 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 XqllYmpshy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XqllYmpshy = 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 = XqllYmpshy - 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 CSIlhlCCig { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int CSIlhlCCig = scan . nextInt ( ) , l = scan . nextInt ( ) ; ArrayList < String > dict = new ArrayList < String > ( ) ; for ( int i = 0 ; i < CSIlhlCCig ; i ++ ) { dict . add ( scan . next ( ) ) ; } Collections . sort ( dict ) ; String result = " " ; for ( int i = 0 ; i < CSIlhlCCig ; i ++ ) { result += dict . get ( i ) ; } System . out . println ( result ) ; } } import java . util . Scanner ; public class XJWegEykyT { public static void main ( String [ ] args ) { Scanner std = new Scanner ( System . in ) ; int XJWegEykyT = std . nextInt ( ) ; int b = std . nextInt ( ) ; if ( XJWegEykyT >= 13 ) { System . out . println ( b ) ; } else if ( XJWegEykyT <= 5 ) { System . out . println ( " 0 " ) ; } else { System . out . println ( b / 2 ) ; } } } import java . util . Scanner ; public class iDVnXekArd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int iDVnXekArd = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; if ( a * iDVnXekArd < b ) ans = a * iDVnXekArd ; else ans = b ; System . out . println ( ans ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class uLNLVVmcYA { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int uLNLVVmcYA = scanner . nextInt ( ) ; int [ ] nums = new int [ uLNLVVmcYA ] ; for ( int i = 0 ; i < uLNLVVmcYA ; i ++ ) nums [ i ] = scanner . nextInt ( ) ; bubbleSort ( uLNLVVmcYA , nums ) ; } private static void bubbleSort ( int uLNLVVmcYA , int [ ] a ) { boolean flg = true ; int i = 0 ; int sw = 0 ; while ( flg ) { flg = false ; for ( int j = uLNLVVmcYA - 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 xdlDnvPFkQ { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; double xdlDnvPFkQ = Double . parseDouble ( br . readLine ( ) ) ; System . out . printf ( " %.6f %.6f " , xdlDnvPFkQ * xdlDnvPFkQ * Math . PI , 2 * xdlDnvPFkQ * Math . PI ) ; } } import java . util . * ; public class vbioVgftWP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] time = new int [ 5 ] , wait = new int [ 5 ] ; int vbioVgftWP = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { time [ i ] = sc . nextInt ( ) ; wait [ i ] = ( 10 - time [ i ] % 10 ) % 10 ; vbioVgftWP += time [ i ] + wait [ i ] ; } int idx = maxIdx ( wait ) ; vbioVgftWP -= wait [ idx ] ; System . out . println ( vbioVgftWP ) ; } 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 rAUZFypOOW { public static String check ( int x , int y ) { return " " ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int rAUZFypOOW = in . nextInt ( ) ; int count = 0 ; int vit = 0 ; while ( rAUZFypOOW -- != 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 MxGXvRJFFl { 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 MxGXvRJFFl = 0 ; while ( money . compareTo ( k ) == - 1 ) { MxGXvRJFFl += 1 ; money = money . multiply ( a ) ; BigDecimal bd1 = money . setScale ( 0 , BigDecimal . ROUND_DOWN ) ; money = bd1 ; } System . out . println ( MxGXvRJFFl ) ; } } import java . util . * ; import java . io . * ; public class yovQywBulX { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; String s = sc . next ( ) ; int yovQywBulX = 0 ; int run = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( s . charAt ( i ) == 'R' ) { run ++ ; } else { yovQywBulX = Math . max ( yovQywBulX , run ) ; run = 0 ; } } yovQywBulX = Math . max ( yovQywBulX , run ) ; out . println ( yovQywBulX ) ; out . close ( ) ; } public static class yovQywBulX { 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 DNVtDZPhhX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DNVtDZPhhX = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] L = new int [ DNVtDZPhhX + 1 ] ; L [ 0 ] = 0 ; for ( int i = 1 ; i < DNVtDZPhhX + 1 ; i ++ ) { L [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; System . out . println ( Bounding ( DNVtDZPhhX + 1 , X , L , 0 , 0 ) ) ; } public static int Bounding ( int DNVtDZPhhX , int X , int [ ] L , int index , int sum ) { if ( DNVtDZPhhX <= index ) { return 0 ; } if ( sum + L [ index ] <= X ) { return 1 + Bounding ( DNVtDZPhhX , X , L , index + 1 , sum + L [ index ] ) ; } return 0 ; } } import java . util . HashSet ; import java . util . Scanner ; public class hOvoTylbdO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hOvoTylbdO = sc . nextInt ( ) ; HashSet < Integer > set = new HashSet < > ( ) ; for ( int i = 0 ; i < hOvoTylbdO ; i ++ ) { set . add ( sc . nextInt ( ) ) ; } System . out . println ( set . size ( ) ) ; } } import java . util . * ; public class anUJeAYsEI { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int anUJeAYsEI = Integer . parseInt ( sc . next ( ) ) ; if ( anUJeAYsEI < 105 ) { System . out . println ( 0 ) ; } else if ( anUJeAYsEI < 135 ) { System . out . println ( 1 ) ; } else if ( anUJeAYsEI < 165 ) { System . out . println ( 2 ) ; } else if ( anUJeAYsEI < 189 ) { System . out . println ( 3 ) ; } else if ( anUJeAYsEI < 195 ) { System . out . println ( 4 ) ; } else { System . out . println ( 5 ) ; } } } import java . util . Scanner ; public class tZkYvkVVfA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String color1 = sc . next ( ) ; sc . next ( ) ; int tZkYvkVVfA = sc . nextInt ( ) ; int color2Cnt = sc . nextInt ( ) ; String disposed = sc . next ( ) ; if ( disposed . equals ( color1 ) ) { System . out . printf ( " %d %d " , tZkYvkVVfA - 1 , color2Cnt ) ; return ; } System . out . printf ( " %d %d " , tZkYvkVVfA , color2Cnt - 1 ) ; } } import java . io . * ; class HXMeKvHNeg { 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 HXMeKvHNeg = 0 ; HXMeKvHNeg < ch . length ; HXMeKvHNeg ++ ) { if ( Character . isUpperCase ( ch [ HXMeKvHNeg ] ) ) { ch [ HXMeKvHNeg ] = Character . toLowerCase ( ch [ HXMeKvHNeg ] ) ; } else ch [ HXMeKvHNeg ] = Character . toUpperCase ( ch [ HXMeKvHNeg ] ) ; } for ( int HXMeKvHNeg = 0 ; HXMeKvHNeg < ch . length ; HXMeKvHNeg ++ ) { System . out . print ( ch [ HXMeKvHNeg ] ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class dyYMKdoStX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dyYMKdoStX = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int s = 0 ; for ( int i = 1 ; i <= dyYMKdoStX ; i ++ ) { s = s + l + i - 1 ; } int a = 0 ; for ( int i = 1 ; i <= dyYMKdoStX ; i ++ ) { if ( l - 1 + i == 0 ) { a = i ; } } if ( a == 0 ) { if ( l * l > ( l + dyYMKdoStX - 1 ) * ( l + dyYMKdoStX - 1 ) ) { a = dyYMKdoStX ; } else { a = 1 ; } } System . out . println ( s - l + 1 - a ) ; sc . close ( ) ; } } import java . util . * ; class xRAaBOtftu { final Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int xRAaBOtftu = sc . nextInt ( ) ; Set < Long > set = new HashSet < > ( ) ; for ( int i = 0 ; i < xRAaBOtftu ; 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 lNyOidltVc { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String input = br . readLine ( ) ; for ( int lNyOidltVc = 0 ; lNyOidltVc < input . length ( ) ; lNyOidltVc ++ ) { char a = input . charAt ( lNyOidltVc ) ; 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 bYpbeJOvzI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long bYpbeJOvzI = sc . nextLong ( ) ; for ( long j = bYpbeJOvzI ; j < 1000000 ; j ++ ) { int count = 0 ; for ( long i = 2 ; i < bYpbeJOvzI ; i ++ ) { if ( bYpbeJOvzI % i == 0 ) { count ++ ; } } if ( count == 0 ) { System . out . println ( bYpbeJOvzI ) ; System . exit ( 0 ) ; } bYpbeJOvzI ++ ; } } } import java . util . Scanner ; public class gJqYJRbFKL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; int gJqYJRbFKL = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != t . charAt ( i ) ) { gJqYJRbFKL ++ ; } } System . out . println ( gJqYJRbFKL ) ; } } import java . util . Scanner ; public class aNqAsTzerX { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String [ ] str ; str = new String [ 3 ] ; int aNqAsTzerX , num2 , Ans ; Ans = 0 ; for ( int i = 1 ; ; i ++ ) { str [ 0 ] = in . next ( ) ; str [ 1 ] = in . next ( ) ; str [ 2 ] = in . next ( ) ; aNqAsTzerX = Integer . parseInt ( str [ 0 ] ) ; num2 = Integer . parseInt ( str [ 2 ] ) ; if ( str [ 1 ] . equals ( " ? " ) ) { break ; } else { if ( str [ 1 ] . equals ( " + " ) ) { Ans = aNqAsTzerX + num2 ; } if ( str [ 1 ] . equals ( " - " ) ) { Ans = aNqAsTzerX - num2 ; } if ( str [ 1 ] . equals ( " * " ) ) { Ans = aNqAsTzerX * num2 ; } if ( str [ 1 ] . equals ( " / " ) ) { Ans = aNqAsTzerX / num2 ; } System . out . println ( Ans ) ; } } } } import java . util . Scanner ; public class JeKlRkefMo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int JeKlRkefMo = sc . nextInt ( ) ; int count = 0 ; for ( int i = 1 ; i <= 9 ; i ++ ) { for ( int j = 1 ; j <= 9 ; j ++ ) { if ( i * j == JeKlRkefMo ) { count = 200 ; } else { count ++ ; } } } if ( count >= 200 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . Scanner ; class JNAaHwwGtk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double JNAaHwwGtk = sc . nextDouble ( ) ; double t = sc . nextDouble ( ) ; double s = sc . nextDouble ( ) ; double sum = JNAaHwwGtk / s ; if ( sum <= t ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } } import java . util . * ; import java . io . * ; public class yTwsqKWkWE { 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 yTwsqKWkWE = 0 ; yTwsqKWkWE < Integer . parseInt ( turn ) ; yTwsqKWkWE ++ ) { 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 CTMlqoPSxa { 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 CTMlqoPSxa = 0 ; CTMlqoPSxa < c . length ; CTMlqoPSxa ++ ) c [ CTMlqoPSxa ] = 'x' ; pw . println ( c ) ; pw . flush ( ) ; pw . close ( ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; public class CzCfNZfqTa { public static void main ( String [ ] args ) { try { BufferedReader stdReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String CzCfNZfqTa = stdReader . readLine ( ) ; String [ ] inputStr = CzCfNZfqTa . 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 LhDIlGfslA { public static void main ( String [ ] args ) { BufferedReader kb = new BufferedReader ( new InputStreamReader ( System . in ) ) ; try { String [ ] str = kb . readLine ( ) . split ( " " ) ; int LhDIlGfslA = 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 < LhDIlGfslA ; 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 SZgHeymWzQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SZgHeymWzQ = 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 ( SZgHeymWzQ - 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 RczRvrxqzQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RczRvrxqzQ = 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 QdZOVyjGOs { 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 QdZOVyjGOs = 0 ; QdZOVyjGOs < n ; QdZOVyjGOs ++ ) { arr [ QdZOVyjGOs ] = ipar ( ) ; } return arr ; } public long lpar ( ) { return Long . parseLong ( tok . nextToken ( ) ) ; } public long [ ] lapar ( int n ) { long [ ] arr = new long [ n ] ; for ( int QdZOVyjGOs = 0 ; QdZOVyjGOs < n ; QdZOVyjGOs ++ ) { arr [ QdZOVyjGOs ] = 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 HDIaqyduBk { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; double HDIaqyduBk = scanner . nextDouble ( ) ; System . out . println ( String . format ( " %.5f " , Math . pow ( HDIaqyduBk , ( double ) 2 ) * Math . PI ) + " " + String . format ( " %.5f " , HDIaqyduBk * ( double ) 2 * Math . PI ) ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; public class nQBtQzfpgF { static class nQBtQzfpgF { 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 nQBtQzfpgF = ob . nextInt ( ) ; HashMap < String , Integer > map = new HashMap < > ( ) ; int count = 0 ; for ( int i = 0 ; i < nQBtQzfpgF ; i ++ ) { String s1 = ob . next ( ) ; if ( ! map . containsKey ( s1 ) ) { map . put ( s1 , 0 ) ; count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class ZWvjeHiNKP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double ZWvjeHiNKP = sc . nextDouble ( ) ; double odd = 0 ; double notOdd = 0 ; for ( int i = 1 ; i <= ZWvjeHiNKP ; i ++ ) { if ( i % 2 == 0 ) { notOdd ++ ; } else { odd ++ ; } } System . out . println ( odd / ZWvjeHiNKP ) ; } } import java . util . Scanner ; public class YqfisdIFdD { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int YqfisdIFdD = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int total = 0 ; for ( int i = YqfisdIFdD ; 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 njwZErMpLE { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int njwZErMpLE = scanner . nextInt ( ) ; int X = scanner . nextInt ( ) ; int s = X - ( njwZErMpLE - 1 ) ; int e = X + ( njwZErMpLE - 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 OGfPjVPyoO { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] lines = br . readLine ( ) . split ( " " ) ; int OGfPjVPyoO = Integer . parseInt ( lines [ 0 ] ) ; int m = Integer . parseInt ( lines [ 1 ] ) ; int [ ] rowSum = new int [ m ] ; for ( int i = 0 ; i < OGfPjVPyoO ; 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 HfeBVbFlap { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long HfeBVbFlap = sc . nextLong ( ) ; long H = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; double ans = ( HfeBVbFlap * H ) / 2.0 ; int can = 0 ; if ( x * 2 == HfeBVbFlap && y * 2 == H ) { can = 1 ; } System . out . println ( ans + " " + can ) ; } } import java . util . Scanner ; public class jwDGYqgTUh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long jwDGYqgTUh = scan . nextInt ( ) ; long B = scan . nextInt ( ) ; long gcd = GCD ( jwDGYqgTUh , B ) ; long lcm = LCM ( jwDGYqgTUh , 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 CPJLdNPDqa { final static long CPJLdNPDqa = 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 eYokUmiChF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eYokUmiChF = sc . nextInt ( ) ; Integer [ ] ans = new Integer [ eYokUmiChF ] ; for ( int n = 0 ; n < eYokUmiChF ; 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 ( eYokUmiChF - sunuke ) ; } } } import java . util . Scanner ; public class YcOHSSnDQw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YcOHSSnDQw = Integer . parseInt ( sc . next ( ) ) ; int [ ] ans = new int [ YcOHSSnDQw ] ; for ( int i = 0 ; i < YcOHSSnDQw ; 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 wOYKeldxus { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; sc . close ( ) ; String [ ] S = s . split ( " " ) ; int wOYKeldxus = Integer . parseInt ( S [ 0 ] ) ; int b = Integer . parseInt ( S [ 1 ] ) ; int count = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( wOYKeldxus > b ) { count += wOYKeldxus ; wOYKeldxus -- ; } else { count += b ; b -- ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class yBFxPEnbAF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yBFxPEnbAF = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int [ ] [ ] matrix = new int [ yBFxPEnbAF ] [ c ] ; for ( int i = 0 ; i < yBFxPEnbAF ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { matrix [ i ] [ j ] = sc . nextInt ( ) ; } } int rc_sum = 0 ; for ( int i = 0 ; i < yBFxPEnbAF ; 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 [ yBFxPEnbAF - 1 ] [ j ] + " " ) ; } System . out . println ( rc_sum ) ; } } import java . util . Scanner ; import java . util . regex . * ; class YdQVuVJlcM { public static void main ( String [ ] args ) { Scanner stdin = new Scanner ( System . in ) . useDelimiter ( " [ \t , \n ] " ) ; int YdQVuVJlcM = stdin . nextInt ( ) ; int line = stdin . nextInt ( ) ; int [ ] nums = new int [ YdQVuVJlcM + 1 ] ; for ( int i = 1 ; i <= YdQVuVJlcM ; 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 <= YdQVuVJlcM ; i ++ ) { System . out . println ( nums [ i ] ) ; } } } import java . util . Scanner ; public class aTzbNkJsrn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] [ ] [ ] BigHouse = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int aTzbNkJsrn = 0 ; aTzbNkJsrn < 4 ; aTzbNkJsrn ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { BigHouse [ aTzbNkJsrn ] [ j ] [ k ] = 0 ; } } } int order = sc . nextInt ( ) ; for ( int aTzbNkJsrn = 0 ; aTzbNkJsrn < order ; aTzbNkJsrn ++ ) { 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 aTzbNkJsrn = 0 ; aTzbNkJsrn < 4 ; aTzbNkJsrn ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = 0 ; k < 10 ; k ++ ) { System . out . print ( " " + BigHouse [ aTzbNkJsrn ] [ j ] [ k ] ) ; } System . out . println ( ) ; } if ( aTzbNkJsrn != 3 ) { System . out . println ( " #################### " ) ; } } } } import java . util . * ; public class yEXfisrlHw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long yEXfisrlHw = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = a + b ; long p = yEXfisrlHw / c ; long q = yEXfisrlHw % c ; if ( q > a ) { q = a ; } long ans = a * p + q ; System . out . println ( ans ) ; } } import java . util . Scanner ; class LWVQaioKwb { public void cubic ( ) { Scanner sc = new Scanner ( System . in ) ; int LWVQaioKwb = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; String out = " No " ; if ( LWVQaioKwb < 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 xTmOYSxuzJ { 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 xTmOYSxuzJ { public String anotherSolve ( String input ) { List < Integer > inputList = new ArrayList < Integer > ( ) ; int xTmOYSxuzJ = 0 ; int seven = 0 ; for ( String s : input . split ( " " ) ) { if ( Integer . parseInt ( s ) == 5 ) { xTmOYSxuzJ ++ ; } else if ( Integer . parseInt ( s ) == 7 ) { seven ++ ; } } if ( xTmOYSxuzJ == 2 && seven == 1 ) { return " YES " ; } else { return " NO " ; } } } } import java . util . Scanner ; public class UtscaQJKLj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; char [ ] ca = str . toCharArray ( ) ; for ( int UtscaQJKLj = 0 ; UtscaQJKLj < ca . length ; UtscaQJKLj ++ ) { System . out . print ( ca [ ca . length - 1 - UtscaQJKLj ] ) ; } System . out . println ( ) ; } } import java . io . InputStream ; import java . io . PrintStream ; import java . util . Scanner ; public class zipLbTOXvx { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int zipLbTOXvx = sc . nextInt ( ) ; int [ ] d = nextIntArray ( sc , zipLbTOXvx ) ; sc . close ( ) ; int ans = 0 ; for ( int i = 0 ; i < zipLbTOXvx - 1 ; i ++ ) { for ( int j = i + 1 ; j < zipLbTOXvx ; 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 EGHiOQjJNa { public static void main ( String [ ] args ) { Scanner In = new Scanner ( System . in ) ; int EGHiOQjJNa ; do { EGHiOQjJNa = In . nextInt ( ) ; } while ( EGHiOQjJNa <= 2 && EGHiOQjJNa >= 200000 ) ; int [ ] a = new int [ EGHiOQjJNa ] ; for ( int i = 0 ; i < EGHiOQjJNa ; 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 <= EGHiOQjJNa - 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 qJcrtHtEjH { public static void main ( String [ ] args ) { int qJcrtHtEjH = 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 ++ ) { qJcrtHtEjH += input [ i + 1 ] - input [ i ] ; } System . out . println ( qJcrtHtEjH ) ; } } import java . util . * ; public class YxFjoUwvYc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YxFjoUwvYc = sc . nextInt ( ) ; int [ ] array = new int [ YxFjoUwvYc ] ; long count = 0 ; for ( int i = 0 ; i < YxFjoUwvYc ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < ( YxFjoUwvYc - 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 lmnOGoDvHG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lmnOGoDvHG = sc . nextInt ( ) ; int otoshidama = sc . nextInt ( ) ; int x = - 1 ; int y = - 1 ; int z = - 1 ; boolean isFinish = false ; for ( int i = 0 ; i <= lmnOGoDvHG ; i ++ ) { for ( int j = 0 ; j <= lmnOGoDvHG ; j ++ ) { if ( lmnOGoDvHG - i - j >= 0 && i + j + ( lmnOGoDvHG - i - j ) == lmnOGoDvHG ) { if ( i * 10000 + j * 5000 + ( lmnOGoDvHG - i - j ) * 1000 == otoshidama ) { x = i ; y = j ; z = lmnOGoDvHG - i - j ; isFinish = true ; break ; } else if ( lmnOGoDvHG - i - j < 0 ) { break ; } } } if ( isFinish ) { break ; } } System . out . println ( x + " " + y + " " + z ) ; } } import java . util . Scanner ; public class XYapqhmLGi { private static final String XYapqhmLGi = " 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 XYapqhmLGi : r = CLOUDY ; break ; case CLOUDY : r = RAINY ; break ; case RAINY : r = XYapqhmLGi ; break ; default : break ; } System . out . println ( r ) ; sc . close ( ) ; } } import java . util . Scanner ; public class CxhHSNoGER { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int CxhHSNoGER = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; if ( CxhHSNoGER != 1 && Y != 1 ) System . out . println ( 1 ) ; else if ( CxhHSNoGER != 2 && Y != 2 ) System . out . println ( 2 ) ; else System . out . println ( 3 ) ; } } import java . util . Scanner ; public class YLDNccYsNJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String YLDNccYsNJ = sc . next ( ) ; char [ ] c = YLDNccYsNJ . toCharArray ( ) ; System . out . println ( ( char ) ( c [ 0 ] + 0x01 ) ) ; sc . close ( ) ; } } import java . math . BigInteger ; import java . util . Scanner ; public class IKwAlctvVx { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String IKwAlctvVx = scan . nextLine ( ) ; scan . close ( ) ; String [ ] substr = IKwAlctvVx . 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 TjQcIKbDyl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TjQcIKbDyl = sc . nextInt ( ) ; int [ ] p = new int [ TjQcIKbDyl ] ; for ( int i = 0 ; i < TjQcIKbDyl ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } int min = TjQcIKbDyl + 1 ; int ans = 0 ; for ( int i = 0 ; i < TjQcIKbDyl ; i ++ ) { if ( p [ i ] < min ) { min = p [ i ] ; ans ++ ; } } System . out . println ( ans ) ; } } import java . util . * ; public class yNrQtjYkrM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yNrQtjYkrM = sc . nextInt ( ) ; double Ad = ( double ) yNrQtjYkrM ; 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 VGPTJKvWzu { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int VGPTJKvWzu = Integer . parseInt ( sc . next ( ) ) ; final int K = Integer . parseInt ( sc . next ( ) ) ; int result = 0 ; int [ ] pricelist = new int [ VGPTJKvWzu ] ; for ( int i = 0 ; i < VGPTJKvWzu ; 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 XWfHlpFytt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; sc . close ( ) ; int XWfHlpFytt = 0 ; for ( int j = 0 ; j < 3 ; j ++ ) { for ( int k = j + 1 ; k < S . length ( ) ; k ++ ) { if ( S . charAt ( j ) == S . charAt ( k ) ) { XWfHlpFytt ++ ; } } } if ( XWfHlpFytt == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class iZerWJDPlc { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int iZerWJDPlc = in . nextInt ( ) ; int M = in . nextInt ( ) ; long sum = 0 ; sum = 1 ; sum *= iZerWJDPlc ; sum *= ( iZerWJDPlc - 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 BIqjdGbVjJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int BIqjdGbVjJ = scan . nextInt ( ) ; int price = scan . nextInt ( ) ; if ( BIqjdGbVjJ >= 13 ) { System . out . println ( price ) ; } else if ( BIqjdGbVjJ >= 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 gpaMnMbkzJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int gpaMnMbkzJ = scan . nextInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < gpaMnMbkzJ ; 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 QOhMceeqlh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QOhMceeqlh = sc . nextInt ( ) ; sc . close ( ) ; boolean can = false ; for ( int i = 0 ; i < 25 ; ++ i ) { for ( int j = 0 ; j < 25 ; ++ j ) { if ( QOhMceeqlh == 4 * i + 7 * j ) { can = true ; } } } if ( can == true ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } } import java . util . Scanner ; class uypRRUwukz { 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 uypRRUwukz = scn . nextInt ( ) ; if ( anntena [ 4 ] - anntena [ 0 ] > uypRRUwukz ) { System . out . println ( " :( " ) ; } else { System . out . println ( " Yay! " ) ; } } } import java . util . Scanner ; public class RYprjFbQgw { 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 RYprjFbQgw = sc . nextInt ( ) ; for ( int i = 0 ; i < RYprjFbQgw ; 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 CJPATfFPBX { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; double CJPATfFPBX = reader . nextDouble ( ) ; System . out . println ( 2 * CJPATfFPBX * 3.14159265 ) ; } } import java . util . Scanner ; import java . lang . Math ; public class FvHKcCSVik { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int FvHKcCSVik ; double [ ] ans = new double [ 1000 ] ; int k = 0 ; while ( true ) { FvHKcCSVik = scan . nextInt ( ) ; if ( FvHKcCSVik == 0 ) break ; int [ ] a = new int [ FvHKcCSVik ] ; int sum = 0 ; for ( int i = 0 ; i < FvHKcCSVik ; i ++ ) { a [ i ] = scan . nextInt ( ) ; sum += a [ i ] ; } double ave = ( double ) sum / FvHKcCSVik ; double var = 0 ; for ( int i = 0 ; i < FvHKcCSVik ; i ++ ) { var = var + ( ( a [ i ] - ave ) * ( a [ i ] - ave ) / FvHKcCSVik ) ; } 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 ItoGsFAdiu { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int ItoGsFAdiu = 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 KjfRIypQML { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KjfRIypQML , h , x , y , r ; KjfRIypQML = sc . nextInt ( ) ; h = sc . nextInt ( ) ; x = sc . nextInt ( ) ; y = sc . nextInt ( ) ; r = sc . nextInt ( ) ; if ( x + r > KjfRIypQML || y + r > h || x - r < 0 || y - r < 0 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; class uezSBXPYzb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String uezSBXPYzb = sc . nextLine ( ) ; uezSBXPYzb = uezSBXPYzb . replace ( " 2017/ " , " 2018/ " ) ; System . out . println ( uezSBXPYzb ) ; } } import java . util . Scanner ; public class OCKdClSsPQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OCKdClSsPQ = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; sc . close ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= OCKdClSsPQ ; i ++ ) { int cnt = 0 ; double p = i ; while ( p < K ) { cnt ++ ; p *= 2.0 ; } ans += 1.0 / OCKdClSsPQ * Math . pow ( 0.5 , cnt ) ; } System . out . println ( ans ) ; } } import java . util . * ; public class kKVKfNcSNw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kKVKfNcSNw = 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 < kKVKfNcSNw ; 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 HmitGqluNR { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int HmitGqluNR = in . nextInt ( ) ; int r = solve ( HmitGqluNR ) ; System . out . println ( r ) ; } private static int solve ( int HmitGqluNR ) { if ( HmitGqluNR == 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 >= HmitGqluNR ) return i ; } } } } import java . util . Scanner ; public class LwxiPFAdyK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; long LwxiPFAdyK = sc . nextLong ( ) ; if ( S . length ( ) == 1 ) { System . out . println ( S ) ; return ; } int i = 0 ; while ( i < S . length ( ) && S . charAt ( i ) == '1' ) { i ++ ; } if ( LwxiPFAdyK <= i ) { System . out . println ( 1 ) ; return ; } System . out . print ( S . charAt ( i ) ) ; } } import java . util . * ; public class uirSVbXJOg { static void swap ( int [ ] A , int i , int j ) { int uirSVbXJOg = A [ i ] ; A [ i ] = A [ j ] ; A [ j ] = uirSVbXJOg ; } 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 dWpUBMXOPG { 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 dWpUBMXOPG = 0 ; dWpUBMXOPG < str . length ; dWpUBMXOPG ++ ) { sb . setLength ( 0 ) ; for ( int j = dWpUBMXOPG ; j < dWpUBMXOPG + 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 ( dWpUBMXOPG == str . length - 1 ) { System . out . println ( " No " ) ; } } } } import java . util . * ; public class xKVEXNUTXK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = sc . next ( ) ; String r = " " ; for ( char xKVEXNUTXK : n . toCharArray ( ) ) { r += solve ( xKVEXNUTXK ) ; } System . out . print ( r ) ; } static char solve ( char xKVEXNUTXK ) { switch ( xKVEXNUTXK ) { case '1' : return '9' ; case '9' : return '1' ; default : return xKVEXNUTXK ; } } } import java . util . Scanner ; public class XIPXiNNlWd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int XIPXiNNlWd = sc . nextInt ( ) ; boolean flg = false ; int cnt = 0 ; for ( int i = 0 ; i < XIPXiNNlWd ; 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 SLWSWRqrHR { Scanner sc ; void calc ( ) { sc = new Scanner ( System . in ) ; String SLWSWRqrHR = sc . next ( ) ; if ( SLWSWRqrHR . charAt ( 2 ) == SLWSWRqrHR . charAt ( 3 ) && SLWSWRqrHR . charAt ( 4 ) == SLWSWRqrHR . 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 KlaaNuQkfv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KlaaNuQkfv = Integer . parseInt ( sc . next ( ) ) ; int l = Integer . parseInt ( sc . next ( ) ) ; int [ ] x = new int [ KlaaNuQkfv + 1 ] ; x [ 0 ] = 0 ; for ( int i = 1 ; i < KlaaNuQkfv + 1 ; i ++ ) { x [ i ] = x [ i - 1 ] + Integer . parseInt ( sc . next ( ) ) ; } int ans = 0 ; for ( int i = 0 ; i < KlaaNuQkfv + 1 ; i ++ ) { if ( x [ i ] > l ) { ans = i ; break ; } if ( i == KlaaNuQkfv ) { ans = i + 1 ; } } System . out . println ( ans ) ; } } import java . util . * ; public class jKJKtAlqmq { 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 KFEvQojDzK { 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 KFEvQojDzK = Integer . parseInt ( br . readLine ( ) ) ; if ( KFEvQojDzK == 0 ) break ; String [ ] line = br . readLine ( ) . split ( " " ) ; double [ ] points = new double [ KFEvQojDzK ] ; for ( int i = 0 ; i < KFEvQojDzK ; 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 tCmuPYVAPJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] str = sc . next ( ) . toCharArray ( ) ; int tCmuPYVAPJ = 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' ) ) { tCmuPYVAPJ ++ ; } } 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 ( tCmuPYVAPJ , tmpCount ) ) ; } } import java . util . * ; public class NZGvJKqFOx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NZGvJKqFOx = 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 < NZGvJKqFOx ; 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 raXsjxWCpq { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int raXsjxWCpq = sc . nextInt ( ) ; System . out . println ( solve ( raXsjxWCpq ) ) ; } public static int solve ( int raXsjxWCpq ) { int max = ( int ) Math . pow ( raXsjxWCpq , 0.5 ) + 1 ; int ret = 1 ; for ( int i = 2 ; i < max ; i ++ ) { int pow = 2 ; while ( Math . pow ( i , pow ) <= raXsjxWCpq ) { ret = Math . max ( ret , ( int ) Math . pow ( i , pow ) ) ; pow ++ ; } } return ret ; } } import java . util . * ; class UvgQTVGFHN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long UvgQTVGFHN = sc . nextLong ( ) + sc . nextLong ( ) ; if ( UvgQTVGFHN % 2 == 1 ) System . out . println ( " IMPOSSIBLE " ) ; else System . out . println ( UvgQTVGFHN / 2 ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class POPNIISKUJ { static class POPNIISKUJ { 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 POPNIISKUJ = " " ; try { POPNIISKUJ = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return POPNIISKUJ ; } } public static void main ( String [ ] args ) { FastReader obj = new FastReader ( ) ; String POPNIISKUJ = obj . next ( ) ; System . out . println ( ( POPNIISKUJ . compareTo ( " ABC " ) == 0 ) ? " ARC " : " ABC " ) ; } } import java . util . Scanner ; public class PbDNxQQpaR { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int PbDNxQQpaR = sc . nextInt ( ) ; int taro = 0 , hanako = 0 ; for ( int i = 0 ; i < PbDNxQQpaR ; 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 lcArdahTVj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int lcArdahTVj = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; String S = sc . next ( ) ; int [ ] count = new int [ lcArdahTVj ] ; Arrays . fill ( count , 0 ) ; for ( int i = 1 ; i < lcArdahTVj ; 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 UwkMhVvIqT { public static void main ( String [ ] age ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int UwkMhVvIqT = 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 ( UwkMhVvIqT = 1 ; UwkMhVvIqT <= H ; UwkMhVvIqT ++ ) { for ( j = 1 ; j <= W ; j ++ ) { if ( UwkMhVvIqT % 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 qSeJQKVojx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qSeJQKVojx = sc . nextInt ( ) ; int [ ] a = new int [ qSeJQKVojx ] ; for ( int i = 0 ; i < qSeJQKVojx ; 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 ntJUrVkVaq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ntJUrVkVaq = 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 ) { ntJUrVkVaq ++ ; h ++ ; } else { ntJUrVkVaq += 3 ; } } System . out . println ( ntJUrVkVaq + " " + h ) ; } } import java . util . * ; class LyGerdbsur { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long LyGerdbsur = sc . nextLong ( ) ; long money = 100 ; int year = 0 ; while ( money < LyGerdbsur ) { money *= 1.01 ; year ++ ; } System . out . println ( year ) ; } } import java . util . * ; public class BUcEqfdQgN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BUcEqfdQgN = sc . nextInt ( ) ; int [ ] values = new int [ BUcEqfdQgN ] ; for ( int i = 0 ; i < BUcEqfdQgN ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } int count = 0 ; hoge : while ( true ) { for ( int i = 0 ; i < BUcEqfdQgN ; i ++ ) { if ( values [ i ] % 2 != 0 ) { break hoge ; } values [ i ] = values [ i ] / 2 ; } count ++ ; } System . out . println ( count ) ; } } import java . io . * ; class vcMGMzWOPP { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int vcMGMzWOPP = 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 > vcMGMzWOPP ) break ; } System . out . print ( " \n " ) ; } } import java . util . Scanner ; public class umgtjnxACV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int umgtjnxACV = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; double d = 0.0 ; int coin = 0 ; int calc = 0 ; for ( int i = 1 ; i <= umgtjnxACV ; i ++ ) { calc = i ; coin = 0 ; for ( ; calc < K ; coin ++ ) calc *= 2 ; d += ( 1.0 / umgtjnxACV ) * 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 uXIdbDsAkV { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int uXIdbDsAkV = 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 ( uXIdbDsAkV = a ; uXIdbDsAkV <= b ; uXIdbDsAkV ++ ) { if ( c % uXIdbDsAkV == 0 ) { sum ++ ; } } System . out . println ( sum ) ; } } import java . util . Scanner ; class iFHakSjjJi { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( System . in ) ; int iFHakSjjJi , b , c ; iFHakSjjJi = cin . nextInt ( ) ; b = cin . nextInt ( ) ; c = cin . nextInt ( ) ; int res = serch_divisor_number ( iFHakSjjJi , b , c ) ; System . out . println ( res ) ; } private static int serch_divisor_number ( int iFHakSjjJi , int b , int c ) { int m = 0 ; for ( int i = iFHakSjjJi ; i <= b ; i ++ ) { if ( c % i == 0 ) m ++ ; } return ( m ) ; } } import java . util . Scanner ; public class ZGDeKEvQAE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String t = sc . next ( ) ; for ( int ZGDeKEvQAE = 0 ; ZGDeKEvQAE < s . length ( ) ; ZGDeKEvQAE ++ ) { 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 vqHFepldkW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int vqHFepldkW = sc . nextInt ( ) ; int num2 = sc . nextInt ( ) ; int tap = 0 ; int outlet = 1 ; while ( num2 > outlet ) { outlet += vqHFepldkW - 1 ; tap ++ ; } System . out . println ( tap ) ; } } import java . util . * ; import java . lang . * ; public class ylBxaNzJXr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ylBxaNzJXr = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 1 ; i <= 3 ; i ++ ) { int b = ( int ) Math . pow ( ylBxaNzJXr , i ) ; sum = sum + b ; } System . out . println ( sum ) ; } } import java . util . * ; public class OROJXvGBwA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OROJXvGBwA = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ OROJXvGBwA + 1 ] ; for ( int i = 1 ; i <= OROJXvGBwA ; i ++ ) h [ i ] = sc . nextInt ( ) ; int [ ] dp = new int [ OROJXvGBwA + 1 ] ; dp [ 1 ] = 0 ; for ( int i = 2 ; i <= OROJXvGBwA ; 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 [ OROJXvGBwA ] ) ; } } import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class zDIkBKHDzn { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int zDIkBKHDzn = 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 ++ ) { zDIkBKHDzn = x ; if ( min * x > X ) { break ; } } zDIkBKHDzn += N ; System . out . println ( zDIkBKHDzn ) ; } } import java . util . * ; public class TEMLpsoLhI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long TEMLpsoLhI = sc . nextLong ( ) ; long checkx = 0 ; long x = 0 ; long checky = 0 ; long y = 0 ; for ( checkx = 1 ; checkx <= Math . sqrt ( TEMLpsoLhI ) ; checkx ++ ) { if ( TEMLpsoLhI % checkx == 0 ) { checky = TEMLpsoLhI / 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 FPgFoAXThm { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int FPgFoAXThm = 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 nTWrNQAped { 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 nTWrNQAped = str . length - 1 ; nTWrNQAped >= 0 ; nTWrNQAped -- ) { if ( nTWrNQAped != 0 ) { System . out . print ( str [ nTWrNQAped ] + " " ) ; } else { System . out . print ( str [ nTWrNQAped ] ) ; } } System . out . println ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class CLEKsgCHLz { 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 CLEKsgCHLz ; for ( int i = 0 ; i < data . length / 2 ; i ++ ) { CLEKsgCHLz = data [ i ] ; data [ i ] = data [ data . length - 1 - i ] ; data [ data . length - 1 - i ] = CLEKsgCHLz ; } System . out . println ( data ) ; } } import java . io . * ; public class jZREAUKQlM { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int jZREAUKQlM = Integer . parseInt ( br . readLine ( ) ) ; if ( jZREAUKQlM == 0 ) System . out . println ( " 1 " ) ; else System . out . println ( " 0 " ) ; } } import java . io . * ; import java . util . * ; import java . lang . * ; public class IyaEYBfVbJ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int IyaEYBfVbJ = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int T = scan . nextInt ( ) ; int i = 0 , count = 0 ; ; while ( i + IyaEYBfVbJ <= ( T + 0.5 ) ) { count ++ ; i += IyaEYBfVbJ ; } System . out . println ( B * count ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; public class pqyMpzGPGy { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int pqyMpzGPGy = Integer . parseInt ( str [ 0 ] ) ; int b = Integer . parseInt ( str [ 1 ] ) ; int c = Integer . parseInt ( str [ 2 ] ) ; int d = Integer . parseInt ( str [ 3 ] ) ; int x = ( pqyMpzGPGy + d - 1 ) / d ; int y = ( c + b - 1 ) / b ; System . out . println ( x >= y ? " Yes " : " No " ) ; } } import java . util . * ; public class bPcXtuzhLb { public static void main ( String [ ] args ) throws Exception { Scanner scn = new Scanner ( System . in ) ; double bPcXtuzhLb = scn . nextDouble ( ) ; double h = scn . nextDouble ( ) ; double x = scn . nextDouble ( ) ; double y = scn . nextDouble ( ) ; double ans = bPcXtuzhLb * h / 2 ; int check = 0 ; if ( x == bPcXtuzhLb / 2 && y == h / 2 ) check = 1 ; System . out . println ( ans + " " + check ) ; } } import java . util . * ; public class NjtwgLufbk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NjtwgLufbk = sc . nextInt ( ) ; boolean b = false ; for ( int i = 1 ; i < 10 ; i ++ ) { for ( int j = i ; j < 10 ; j ++ ) { if ( i * j == NjtwgLufbk ) { b = true ; } } } if ( b ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class CWYZmIUvWg { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } private void run ( ) { int CWYZmIUvWg = sc . nextInt ( ) ; int [ ] A = new int [ CWYZmIUvWg ] ; for ( int i = 0 ; i < CWYZmIUvWg - 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 auOLNdVBjx { static final Scanner sc = new Scanner ( System . in ) ; static int auOLNdVBjx = sc . nextInt ( ) ; static long [ ] a = new long [ auOLNdVBjx ] ; public static void main ( String [ ] args ) { int sum = 0 ; for ( int i = 0 ; i < auOLNdVBjx ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } long x = 0 ; for ( int i = 0 ; i < auOLNdVBjx ; 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 vdkxcsedgL { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int vdkxcsedgL = input . nextInt ( ) ; vdkxcsedgL %= 10 ; String ans = " " ; if ( vdkxcsedgL == 3 ) ans = " bon " ; else if ( vdkxcsedgL == 0 || vdkxcsedgL == 1 || vdkxcsedgL == 6 || vdkxcsedgL == 8 ) ans = " pon " ; else ans = " hon " ; System . out . println ( ans ) ; } } import java . util . Scanner ; public class CHeSKnBXmF { public static void main ( String ... args ) { Scanner scan = new Scanner ( System . in ) ; String answer = " " ; String input = scan . next ( ) ; int CHeSKnBXmF = input . length ( ) ; for ( int i = 0 ; i < CHeSKnBXmF ; 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 fvGUMrrZmL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fvGUMrrZmL = sc . nextInt ( ) ; int intB = sc . nextInt ( ) ; double dbF ; dbF = ( double ) fvGUMrrZmL / ( double ) intB ; String f2 = String . format ( " %.5f " , dbF ) ; System . out . println ( fvGUMrrZmL / intB + " " + fvGUMrrZmL % intB + " " + f2 ) ; } } import java . util . Scanner ; public class euzQheklxq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int euzQheklxq = Integer . parseInt ( sc . next ( ) ) ; String S = sc . next ( ) ; sc . close ( ) ; if ( S . substring ( 0 , euzQheklxq / 2 ) . equals ( S . substring ( euzQheklxq / 2 , euzQheklxq ) ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class NqRPDBFMRa { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; while ( true ) { int NqRPDBFMRa = in . nextInt ( ) ; int term_end = in . nextInt ( ) ; int retest = in . nextInt ( ) ; int sum = NqRPDBFMRa + term_end ; if ( NqRPDBFMRa == - 1 && term_end == - 1 && retest == - 1 ) { break ; } else if ( NqRPDBFMRa == - 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 zliEhSOhzQ { public static void main ( String [ ] args ) throws Exception { Scanner scan = new Scanner ( System . in ) ; int zliEhSOhzQ = 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 zXaHGjzAOE { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . next ( ) ; String a = " " ; String okikae = " " ; for ( int zXaHGjzAOE = 0 ; zXaHGjzAOE < s . length ( ) ; zXaHGjzAOE ++ ) { okikae = s . substring ( zXaHGjzAOE , zXaHGjzAOE + 1 ) ; okikae = " x " ; a = a + okikae ; } System . out . println ( a ) ; scan . close ( ) ; } } import java . util . * ; public class kpjNMQfgms { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kpjNMQfgms = sc . nextInt ( ) ; HashMap < String , Integer > map = new HashMap < String , Integer > ( ) ; long ans = 0 ; for ( int i = 0 ; i < kpjNMQfgms ; 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 xcgCVHJZSS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xcgCVHJZSS = sc . nextInt ( ) ; Set < Integer > set = new HashSet < > ( ) ; int past = xcgCVHJZSS ; 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 mnLXFfHhjk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mnLXFfHhjk = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int max = Math . max ( mnLXFfHhjk - B , mnLXFfHhjk + B ) ; max = Math . max ( max , mnLXFfHhjk * B ) ; System . out . println ( max ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class BcxSJoxQeZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 3 ] ; for ( int BcxSJoxQeZ = 0 ; BcxSJoxQeZ < 3 ; BcxSJoxQeZ ++ ) { a [ BcxSJoxQeZ ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( a ) ; int cost = 0 ; for ( int BcxSJoxQeZ = 0 ; BcxSJoxQeZ < 3 ; BcxSJoxQeZ ++ ) { if ( BcxSJoxQeZ != 0 ) { cost += a [ BcxSJoxQeZ ] - a [ BcxSJoxQeZ - 1 ] ; } } System . out . println ( cost ) ; } } import java . util . * ; public class yFOEAuJXSg { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solveB ( ) ; } private void solveA ( ) { Scanner sc = new Scanner ( System . in ) ; int yFOEAuJXSg = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String s ; if ( yFOEAuJXSg >= 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 iYlnyURbEK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int iYlnyURbEK = 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 JSEoxqteXR { public static void main ( String [ ] args ) { int JSEoxqteXR , t ; int minCost = 1001 ; Scanner sc = new Scanner ( System . in ) ; JSEoxqteXR = sc . nextInt ( ) ; t = sc . nextInt ( ) ; for ( int i = 0 ; i < JSEoxqteXR ; ++ 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 TESoDVXYNt { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int TESoDVXYNt = Integer . parseInt ( sc . next ( ) ) ; long [ ] a = new long [ TESoDVXYNt ] ; for ( int i = 0 ; i < TESoDVXYNt ; 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 < TESoDVXYNt ; 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 CMsoYFDlVK { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int CMsoYFDlVK = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int [ ] ans = null ; for ( int m = 0 ; m <= CMsoYFDlVK ; m ++ ) { for ( int g = 0 ; g <= CMsoYFDlVK - m ; g ++ ) { int s = CMsoYFDlVK - ( 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 HiwBFJpQKs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] list = { sc . next ( ) , sc . next ( ) , sc . next ( ) } ; int HiwBFJpQKs = 0 ; int seven_count = 0 ; for ( String l : list ) { if ( l . equals ( " 5 " ) ) HiwBFJpQKs ++ ; else if ( l . equals ( " 7 " ) ) seven_count ++ ; } if ( HiwBFJpQKs == 2 && seven_count == 1 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } import java . util . * ; public class ahZVvhzQYA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ahZVvhzQYA = 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 ( ahZVvhzQYA <= damage ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class tjSphwrzlg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tjSphwrzlg , b , f , r , v ; int [ ] [ ] [ ] house = new int [ 4 ] [ 3 ] [ 10 ] ; String output ; String [ ] input = new String [ 4 ] ; tjSphwrzlg = Integer . parseInt ( sc . nextLine ( ) ) ; for ( int i = 0 ; i < tjSphwrzlg ; 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 jAYPRSjhqW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int jAYPRSjhqW = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int p ; String S ; int [ ] AC = new int [ jAYPRSjhqW ] ; int [ ] WA = new int [ jAYPRSjhqW ] ; for ( int i = 0 ; i < jAYPRSjhqW ; 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 < jAYPRSjhqW ; i ++ ) { clear = clear + AC [ i ] ; } System . out . print ( clear + " " + penalty ) ; } } import java . util . * ; class HDAjCYEJir { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] nl = scanner . nextLine ( ) . split ( " " , 2 ) ; int HDAjCYEJir = Integer . parseInt ( nl [ 0 ] ) ; int l = Integer . parseInt ( nl [ 1 ] ) ; String [ ] arr = new String [ HDAjCYEJir ] ; for ( int i = 0 ; i < HDAjCYEJir ; i ++ ) { arr [ i ] = scanner . nextLine ( ) ; } Arrays . sort ( arr ) ; for ( int i = 0 ; i < HDAjCYEJir ; i ++ ) { System . out . print ( arr [ i ] ) ; } System . out . print ( " \n " ) ; } } import java . util . * ; public class EIzAVdxDdd { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String n = s . nextLine ( ) ; String s1 = String . valueOf ( n . charAt ( 0 ) ) ; int EIzAVdxDdd = 0 ; int i2 = 0 ; String s2 = " " ; for ( int i = 0 ; i < n . length ( ) ; i ++ ) { if ( String . valueOf ( n . charAt ( i ) ) . equals ( s1 ) ) { EIzAVdxDdd ++ ; } else { if ( s2 . equals ( " " ) || String . valueOf ( n . charAt ( i ) ) . equals ( s2 ) ) { s2 = String . valueOf ( n . charAt ( i ) ) ; i2 ++ ; } } } System . out . println ( EIzAVdxDdd == 2 && i2 == 2 ? " Yes " : " No " ) ; } } import java . util . * ; class UYHbjtDrHR { static int UYHbjtDrHR ; 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 ; UYHbjtDrHR = scanner . nextInt ( ) ; a = new int [ UYHbjtDrHR ] ; 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 sWYdEYkwLo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sWYdEYkwLo = Integer . parseInt ( sc . nextLine ( ) ) ; double debt = 100000 ; while ( sWYdEYkwLo > 0 ) { debt *= 1.05 ; debt = 1000.0 * Math . ceil ( debt / 1000.0 ) ; sWYdEYkwLo -- ; } System . out . println ( String . format ( " %.0f " , debt ) ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class CBeMmVzTcq { 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 DcCmLGFtvS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DcCmLGFtvS = sc . nextInt ( ) ; ArrayList < Integer > vList = new ArrayList < > ( ) ; for ( int i = 0 ; i < DcCmLGFtvS ; i ++ ) { vList . add ( sc . nextInt ( ) ) ; } Collections . sort ( vList ) ; double ans = ( double ) vList . get ( 0 ) ; for ( int i = 1 ; i < DcCmLGFtvS ; i ++ ) { double sum = ans + ( double ) vList . get ( i ) ; ans = sum / 2 ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class OKvaWNNUZJ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OKvaWNNUZJ = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { OKvaWNNUZJ -= sc . nextInt ( ) ; } if ( OKvaWNNUZJ <= 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class WMoSRWkcnk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WMoSRWkcnk = sc . nextInt ( ) ; int [ ] array = new int [ WMoSRWkcnk ] ; int [ ] DP = new int [ WMoSRWkcnk + 1 ] ; Arrays . fill ( DP , Integer . MAX_VALUE ) ; DP [ 0 ] = 0 ; for ( int i = 0 ; i < WMoSRWkcnk ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < WMoSRWkcnk - 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 [ WMoSRWkcnk - 1 ] = Math . min ( DP [ WMoSRWkcnk - 1 ] , DP [ WMoSRWkcnk - 2 ] + Math . abs ( array [ WMoSRWkcnk - 1 ] - array [ WMoSRWkcnk - 2 ] ) ) ; System . out . println ( DP [ WMoSRWkcnk - 1 ] ) ; } } import java . util . * ; public class UDDvHwKair { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int UDDvHwKair = in . nextInt ( ) ; int t = in . nextInt ( ) ; int s = in . nextInt ( ) ; double time = ( double ) UDDvHwKair / s ; if ( time - t > 0 ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . * ; public class RtNHjsTSuk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] data = new int [ 3 ] ; for ( int RtNHjsTSuk = 0 ; RtNHjsTSuk < 3 ; RtNHjsTSuk ++ ) { data [ RtNHjsTSuk ] = sc . nextInt ( ) ; } int K = sc . nextInt ( ) ; int maxIdx = 0 ; int max = data [ 0 ] ; for ( int RtNHjsTSuk = 1 ; RtNHjsTSuk < 3 ; RtNHjsTSuk ++ ) { if ( max < data [ RtNHjsTSuk ] ) { max = data [ RtNHjsTSuk ] ; maxIdx = RtNHjsTSuk ; } } for ( int RtNHjsTSuk = 0 ; RtNHjsTSuk < K ; RtNHjsTSuk ++ ) { data [ maxIdx ] *= 2 ; } System . out . println ( data [ 0 ] + data [ 1 ] + data [ 2 ] ) ; sc . close ( ) ; } } import java . util . * ; public class YsJzzhlvpr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YsJzzhlvpr = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int m = 0 ; int flag = 0 ; if ( y <= YsJzzhlvpr * 2 || y <= YsJzzhlvpr * 4 ) { for ( int i = 1 ; i <= YsJzzhlvpr ; i ++ ) { int j = i * 2 ; m = i * 4 ; int h = y - j ; int h1 = y - m ; if ( ( h1 % 2 == 0 && h1 / 2 == YsJzzhlvpr - i ) || ( h % 4 == 0 && h / 4 == YsJzzhlvpr - 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 nnMMbWfoEz { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int nnMMbWfoEz = 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 / nnMMbWfoEz ) ; System . out . println ( Math . min ( ( nnMMbWfoEz * p * p - 2 * p * s + sumsq ) , ( nnMMbWfoEz * ( 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 ozBfvUrXKy { 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 ozBfvUrXKy ; Map < String , Integer > map = new TreeMap < String , Integer > ( ) ; Main ( Scanner sc ) { this . sc = sc ; this . ozBfvUrXKy = sc . nextInt ( ) ; } private List < String > solve ( ) { int max = 0 ; List < String > answer = new ArrayList < String > ( ) ; for ( int i = 0 ; i < ozBfvUrXKy ; 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 lscLflCivI { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; String S = stdIn . next ( ) ; char [ ] s = new char [ S . length ( ) ] ; for ( int lscLflCivI = 0 ; lscLflCivI < S . length ( ) ; lscLflCivI ++ ) { s [ lscLflCivI ] = S . charAt ( lscLflCivI ) ; } s [ 3 ] = '8' ; System . out . println ( s ) ; } } import java . util . * ; public class ersntPZqjq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ersntPZqjq = sc . nextInt ( ) ; String s = sc . next ( ) ; boolean val = true ; if ( s . length ( ) % 2 != 0 ) val = false ; else { for ( int i = 0 ; i < ersntPZqjq / 2 ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i + ersntPZqjq / 2 ) ) { val = false ; break ; } } } System . out . println ( val ? " Yes " : " No " ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class WOymsNNkfB { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word ; int WOymsNNkfB = 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 ) ) { WOymsNNkfB ++ ; } else { continue ; } } } System . out . println ( WOymsNNkfB ) ; } } import java . util . * ; public class yxhUtDtiiz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int yxhUtDtiiz = 1 ; while ( true ) { int a = sc . nextInt ( ) ; if ( a != 0 ) System . out . println ( " Case " + yxhUtDtiiz + " : " + a ) ; else break ; yxhUtDtiiz = yxhUtDtiiz + 1 ; } } } import java . util . * ; public class chFFlYzDsz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long chFFlYzDsz = 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 = chFFlYzDsz + 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 ( chFFlYzDsz - d ) ; } } import java . util . Scanner ; public class HUFMgvYpkl { 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 HUFMgvYpkl = 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 - HUFMgvYpkl > k ) System . out . println ( NO ) ; else System . out . println ( OK ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class bOuNQTjvMk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long bOuNQTjvMk = 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 XAVtHPubCh { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner sc = new Scanner ( System . in ) ; int XAVtHPubCh = sc . nextInt ( ) ; int [ ] A = new int [ XAVtHPubCh ] ; for ( int i = 0 ; i < XAVtHPubCh ; i ++ ) { A [ i ] = Integer . parseInt ( sc . next ( ) ) ; } sc . close ( ) ; int [ ] B = A . clone ( ) ; Arrays . sort ( B ) ; int max = B [ XAVtHPubCh - 1 ] ; int nextmax = B [ XAVtHPubCh - 2 ] ; for ( int i = 0 ; i < XAVtHPubCh ; i ++ ) { if ( A [ i ] == max ) { System . out . println ( nextmax ) ; } else { System . out . println ( max ) ; } } } } import java . util . * ; class vyDEDQTbmQ { Scanner sc = new Scanner ( System . in ) ; public int ini ( ) { return sc . nextInt ( ) ; } public int [ ] vi ( int n ) { int [ ] a = new int [ n ] ; for ( int vyDEDQTbmQ = 0 ; vyDEDQTbmQ < n ; vyDEDQTbmQ ++ ) a [ vyDEDQTbmQ ] = sc . nextInt ( ) ; return a ; } } public class vyDEDQTbmQ 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 vyDEDQTbmQ = 0 ; vyDEDQTbmQ < n - 1 ; vyDEDQTbmQ ++ ) { for ( int j = vyDEDQTbmQ + 1 ; j < n ; j ++ ) { ans += a [ vyDEDQTbmQ ] * a [ j ] ; } } return ans ; } void show ( int ans ) { System . out . println ( ans ) ; } } import java . util . Scanner ; public class YNCGAaSEkf { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YNCGAaSEkf = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) ; int x = sc . nextInt ( ) , y = sc . nextInt ( ) ; int min = x * YNCGAaSEkf + y * b ; min = Math . min ( min , 2 * y * c + Math . max ( 0 , x - y ) * YNCGAaSEkf ) ; 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 QjWKGDFtQp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int QjWKGDFtQp = 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 = QjWKGDFtQp - i ; if ( tmp2 < 0 ) { tmp2 = i - QjWKGDFtQp ; } if ( tmp2 < min ) { min = tmp2 ; result = i ; } } } System . out . println ( result ) ; } } import java . util . * ; public class faBdGWyPAx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int faBdGWyPAx , b , sum ; faBdGWyPAx = sc . nextInt ( ) ; b = sc . nextInt ( ) ; sum = 0 ; if ( ( faBdGWyPAx == 1 || faBdGWyPAx == 2 ) && ( b == 1 || b == 2 ) ) { sum = 3 ; System . out . println ( sum ) ; } else if ( ( faBdGWyPAx == 1 || faBdGWyPAx == 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 rjOmleNOjX { 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 rjOmleNOjX = 0 ; rjOmleNOjX < strArray . length ; rjOmleNOjX ++ ) { if ( Character . isUpperCase ( strArray [ rjOmleNOjX ] ) ) { strArray [ rjOmleNOjX ] = Character . toLowerCase ( strArray [ rjOmleNOjX ] ) ; } else if ( Character . isLowerCase ( strArray [ rjOmleNOjX ] ) ) { strArray [ rjOmleNOjX ] = Character . toUpperCase ( strArray [ rjOmleNOjX ] ) ; } else { strArray [ rjOmleNOjX ] = strArray [ rjOmleNOjX ] ; } } for ( int rjOmleNOjX = 0 ; rjOmleNOjX < strArray . length - 1 ; rjOmleNOjX ++ ) { System . out . print ( strArray [ rjOmleNOjX ] ) ; } System . out . println ( strArray [ strArray . length - 1 ] ) ; } } import java . util . * ; public class rixlIFnZhC { 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 rixlIFnZhC = 0 ; rixlIFnZhC < tc . length ; rixlIFnZhC ++ ) { if ( rixlIFnZhC < sc . length && sc [ rixlIFnZhC ] != tc [ rixlIFnZhC ] ) { System . out . println ( " No " ) ; break ; } if ( rixlIFnZhC == tc . length - 1 ) { System . out . println ( " Yes " ) ; } } } } import java . util . Scanner ; public class aVmYdRYspT { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int aVmYdRYspT = 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 < aVmYdRYspT ; 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 kswZwhjsyl { 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 kswZwhjsyl = 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 ( kswZwhjsyl - input [ N - 1 ] + input [ 0 ] , max ) ; System . out . println ( kswZwhjsyl - 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 nvtyFoOdyA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nvtyFoOdyA = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] A = new int [ nvtyFoOdyA ] ; 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 SvsTjqlwpR { 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 SvsTjqlwpR = Double . parseDouble ( readLineArray [ 0 ] ) ; double S = Math . PI * SvsTjqlwpR * SvsTjqlwpR ; double L = 2 * Math . PI * SvsTjqlwpR ; System . out . printf ( " %.5f %.5f " , S , L ) ; } } import java . util . Scanner ; public class eTIoaOsKOh { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int eTIoaOsKOh = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int min = 0 ; for ( int i = 1 ; i <= 1009 ; i ++ ) { if ( ( int ) ( i * 0.08 ) == eTIoaOsKOh && ( int ) ( i * 0.1 ) == b ) { min = i ; break ; } else { min = - 1 ; } } System . out . println ( min ) ; scan . close ( ) ; } } import java . util . * ; class uPOXEasHHt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String [ ] S = scan . nextLine ( ) . split ( " " ) ; int uPOXEasHHt = 0 ; for ( int i = 0 ; i < S . length / 2 ; i ++ ) { if ( ! ( S [ i ] . equals ( S [ S . length - 1 - i ] ) ) ) { uPOXEasHHt ++ ; } } System . out . println ( uPOXEasHHt ) ; } } import java . awt . * ; import java . awt . geom . * ; import java . io . * ; import java . util . * ; class RFExpoeZco { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int RFExpoeZco = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; if ( RFExpoeZco == 0 && b == 0 ) break ; System . out . println ( ( RFExpoeZco < b ) ? ( RFExpoeZco + " " + b ) : ( b + " " + RFExpoeZco ) ) ; } } } import java . util . Arrays ; import java . util . Scanner ; public class kNJokJVeCx { public static void main ( String [ ] args ) { Scanner ob = new Scanner ( System . in ) ; char [ ] c = ob . next ( ) . toCharArray ( ) ; int kNJokJVeCx = 0 ; for ( int i = 0 ; i < c . length ; i ++ ) { kNJokJVeCx = kNJokJVeCx + Character . getNumericValue ( c [ i ] ) ; } if ( kNJokJVeCx % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . io . * ; import java . util . * ; public class xfwsBWhJiy 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 xfwsBWhJiy = sc . nextInt ( ) ; if ( xfwsBWhJiy > 50 ) { xfwsBWhJiy = 50 ; } String S = sc . next ( ) ; int Y = 0 ; int U = 0 ; for ( int i = 0 ; i < xfwsBWhJiy ; 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 gaueSLPrtv { 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 gaueSLPrtv = 0 ; gaueSLPrtv < hairetsu . length ; gaueSLPrtv ++ ) { array . add ( Integer . parseInt ( hairetsu [ gaueSLPrtv ] ) ) ; } for ( int gaueSLPrtv = 0 ; gaueSLPrtv < array . size ( ) ; gaueSLPrtv ++ ) { array2 . add ( array . get ( array . size ( ) - 1 - gaueSLPrtv ) ) ; } for ( int gaueSLPrtv = 0 ; gaueSLPrtv < array2 . size ( ) ; gaueSLPrtv ++ ) { System . out . print ( array2 . get ( gaueSLPrtv ) ) ; if ( gaueSLPrtv < array2 . size ( ) - 1 ) { System . out . print ( " " ) ; } } System . out . println ( ) ; } } import java . util . * ; public class mLKgJJWrCq { public static void main ( String [ ] args ) throws Exception { String [ ] lines = getStdin ( ) ; String str = lines [ 0 ] ; long mLKgJJWrCq = Long . parseLong ( str ) ; long sum = 100 ; int count = 0 ; while ( sum < mLKgJJWrCq ) { 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 nrIGgRWLDq { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long nrIGgRWLDq = sc . nextLong ( ) ; long min = Integer . MAX_VALUE ; for ( long a = 1 ; a <= Math . sqrt ( ( double ) nrIGgRWLDq ) ; a ++ ) { if ( nrIGgRWLDq % a == 0 ) { long b = nrIGgRWLDq / 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 BsWKGLaYFp { public static void main ( String [ ] Arguments ) throws IOException { BufferedReader BR = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer ST = new StringTokenizer ( BR . readLine ( ) ) ; int BsWKGLaYFp = 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 <= BsWKGLaYFp ) ? BsWKGLaYFp - homeworkDays : - 1 ) ; } } import java . util . Scanner ; public class NEbUWRdulQ { 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 NEbUWRdulQ = 0 ; NEbUWRdulQ < str . length ; NEbUWRdulQ ++ ) { if ( str [ NEbUWRdulQ ] . equals ( S ) ) { if ( NEbUWRdulQ == 6 ) { System . out . println ( 7 ) ; } else { System . out . println ( 7 - ( NEbUWRdulQ + 1 ) ) ; } } } } } import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class rHcchwpywZ { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; String rHcchwpywZ = keyboard . nextLine ( ) ; String SB = keyboard . nextLine ( ) ; String SC = keyboard . nextLine ( ) ; String input = rHcchwpywZ . substring ( 0 , 1 ) ; keyboard . close ( ) ; System . out . print ( solve ( rHcchwpywZ , 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 XEnAFybTgz { public static int XEnAFybTgz = 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 ( XEnAFybTgz ) ; } 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 ] ; XEnAFybTgz ++ ; } } } } 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 tkkPCYnBSY { 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 tkkPCYnBSY = false ; if ( s . length ( ) >= i + 7 && s . substring ( i , i + 7 ) . equals ( " dreamer " ) ) { tkkPCYnBSY |= judge ( s , i + 7 ) ; } if ( s . length ( ) >= i + 5 && s . substring ( i , i + 5 ) . equals ( " dream " ) ) { tkkPCYnBSY |= judge ( s , i + 5 ) ; } if ( s . length ( ) >= i + 6 && s . substring ( i , i + 6 ) . equals ( " eraser " ) ) { tkkPCYnBSY |= judge ( s , i + 6 ) ; } if ( s . length ( ) >= i + 5 && s . substring ( i , i + 5 ) . equals ( " erase " ) ) { tkkPCYnBSY |= judge ( s , i + 5 ) ; } return tkkPCYnBSY ; } } 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 FCEdxSMqGQ { 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 FCEdxSMqGQ = in . nextInt ( ) ; int [ ] H = new int [ FCEdxSMqGQ ] ; for ( int i = 0 ; i < FCEdxSMqGQ ; 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 sDEnjdnQlC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; int sDEnjdnQlC = 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 ( sDEnjdnQlC < tmp ) sDEnjdnQlC = tmp ; } else { if ( sDEnjdnQlC < tmp ) sDEnjdnQlC = tmp ; tmp = 0 ; } } System . out . println ( sDEnjdnQlC ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . text . Collator ; public class mHZjHAtbIr { 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 mHZjHAtbIr = Integer . parseInt ( br . readLine ( ) ) ; int pointA = 0 ; int pointB = 0 ; int result = 0 ; for ( int i = 0 ; i < mHZjHAtbIr ; 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 rvoVLNDapQ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int rvoVLNDapQ = scan . nextInt ( ) ; int [ ] a = new int [ rvoVLNDapQ ] ; long sum = 0 ; for ( int i = 0 ; i < rvoVLNDapQ ; 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 gJntrZTwAQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gJntrZTwAQ = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; String [ ] s = new String [ gJntrZTwAQ ] ; for ( int i = 0 ; i < gJntrZTwAQ ; i ++ ) { s [ i ] = sc . next ( ) ; } Arrays . sort ( s ) ; String ans = " " ; for ( int i = 0 ; i < gJntrZTwAQ ; i ++ ) { ans += s [ i ] ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class BjQsSIbVph { 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 BjQsSIbVph = list . BjQsSIbVph ( ) ; if ( BjQsSIbVph % 2 == 0 ) { int pos = BjQsSIbVph / 2 ; long a = list . get ( pos ) ; long b = list . get ( pos - 1 ) ; System . out . println ( a + b - 2 ) ; } else { int pos = BjQsSIbVph / 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 . BjQsSIbVph ( ) - 1 ) ; int BjQsSIbVph = list . BjQsSIbVph ( ) ; if ( num / temp == temp ) { BjQsSIbVph = BjQsSIbVph - 1 ; } for ( int i = BjQsSIbVph - 1 ; i > 0 ; i -- ) { Long n = list . get ( i ) ; list . add ( num / n ) ; } return list ; } } import java . io . * ; import java . util . Arrays ; public class wIGnZSbbOQ { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { int wIGnZSbbOQ = 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 ) { wIGnZSbbOQ ++ ; } } } } System . out . println ( wIGnZSbbOQ ) ; } } } import java . util . Scanner ; class kMHYpRKkmV { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int kMHYpRKkmV = 1 ; while ( true ) { int x = scanner . nextInt ( ) ; if ( x == 0 ) break ; System . out . println ( " Case " + kMHYpRKkmV + " : " + x ) ; kMHYpRKkmV += 1 ; } } } import java . util . * ; public class NhZxNBQoLG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int NhZxNBQoLG = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int temp = y ; if ( y % 2 == 0 && y >= ( NhZxNBQoLG * 2 ) && y <= NhZxNBQoLG * 4 ) { System . out . print ( " Yes " ) ; } else System . out . print ( " No " ) ; } } import java . util . * ; import java . util . Scanner ; public class uZuXtCRjYB { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int uZuXtCRjYB = sc . nextInt ( ) ; int [ ] a = new int [ uZuXtCRjYB ] ; int res = 0 ; for ( int i = 0 ; i < uZuXtCRjYB ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; if ( a [ uZuXtCRjYB / 2 - 1 ] != a [ uZuXtCRjYB / 2 ] ) { res = a [ uZuXtCRjYB / 2 ] - a [ uZuXtCRjYB / 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 PaTBTpRtWA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PaTBTpRtWA = sc . nextInt ( ) ; int wk = 0 ; int ans = 0 ; ans = PaTBTpRtWA / 2 ; wk = PaTBTpRtWA % 2 ; if ( wk == 1 ) { ans = ans + 1 ; } System . out . println ( ans ) ; } } import java . util . Scanner ; public class GvNjiOrOcE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GvNjiOrOcE = 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 * GvNjiOrOcE ; 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 fxPYdyTlMQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int fxPYdyTlMQ = sc . nextInt ( ) ; int Q = sc . nextInt ( ) ; String S = sc . next ( ) ; int [ ] cnt = new int [ fxPYdyTlMQ + 1 ] ; for ( int i = 0 ; i < fxPYdyTlMQ - 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 GxgQiowOdW { public static void main ( String [ ] args ) { Scanner keyboard = new Scanner ( System . in ) ; int GxgQiowOdW = keyboard . nextInt ( ) ; HashMap < String , Integer > count = new HashMap < String , Integer > ( ) ; for ( int s = 0 ; s < GxgQiowOdW ; 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 QfqDEvmEgj { public static void main ( String [ ] args ) { Scanner scan = new java . util . Scanner ( System . in ) ; for ( ; ; ) { int QfqDEvmEgj = scan . nextInt ( ) ; double sum = 0 ; double m = 0 ; if ( QfqDEvmEgj == 0 ) break ; double [ ] s = new double [ QfqDEvmEgj ] ; for ( int i = 0 ; i < QfqDEvmEgj ; i ++ ) { s [ i ] = scan . nextDouble ( ) ; sum += s [ i ] ; } m = ( double ) sum / QfqDEvmEgj ; double a = 0 ; for ( int i = 0 ; i < QfqDEvmEgj ; i ++ ) { a += ( s [ i ] - m ) * ( s [ i ] - m ) ; } double ans = Math . sqrt ( a / QfqDEvmEgj ) ; if ( ans >= 0 ) { System . out . println ( ans ) ; } } } } import java . util . Scanner ; class kUKYjTWetA { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int kUKYjTWetA = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( kUKYjTWetA < 10 && b < 10 ) { System . out . println ( kUKYjTWetA * b ) ; } else { System . out . println ( - 1 ) ; } scan . close ( ) ; } } import java . util . * ; public class BYVnlMXNAi { static int BYVnlMXNAi = 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 ; BYVnlMXNAi = 0 ; } System . out . println ( sum_power ) ; } } static int doublet ( int n , int f ) { if ( n < f ) { BYVnlMXNAi = BYVnlMXNAi + 1 ; return doublet ( 2 * n , f ) ; } else return BYVnlMXNAi ; } } import java . util . * ; public class gTVLAqzCSW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double gTVLAqzCSW = sc . nextDouble ( ) ; double A = ( double ) gTVLAqzCSW * gTVLAqzCSW * Math . PI ; double L = ( double ) gTVLAqzCSW * 2 * Math . PI ; System . out . println ( String . format ( " %f " , A ) + " " + String . format ( " %f " , L ) ) ; } } import java . util . Scanner ; public class kfwTQYqESj { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String kfwTQYqESj = " ABCDEFGHIJKLMNOPQRSTUVWXYZ " ; String lowercase = " abcdefghijklmnopqrstuvwxyz " ; String alpha = scanner . nextLine ( ) ; if ( kfwTQYqESj . contains ( alpha ) ) System . out . println ( " A " ) ; else System . out . println ( " a " ) ; } } import java . math . BigInteger ; import java . util . * ; import java . io . * ; public class rCbEqoLJGl { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int rCbEqoLJGl = sc . nextInt ( ) ; pw . println ( 1 - rCbEqoLJGl ) ; pw . flush ( ) ; } static class rCbEqoLJGl { 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 rCbEqoLJGl ) throws IOException { int [ ] arr = new int [ rCbEqoLJGl ] ; for ( int i = 0 ; i < rCbEqoLJGl ; i ++ ) { arr [ i ] = Integer . parseInt ( next ( ) ) ; } return arr ; } } } import java . util . * ; public class qNKbZNsaxo { 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 qNKbZNsaxo ; 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 ++ ) { qNKbZNsaxo = t . charAt ( j ) ; sj = s . charAt ( j + startcount ) ; if ( qNKbZNsaxo == 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 YHKRBhgnHS { 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 YHKRBhgnHS = Integer . parseInt ( str [ 0 ] ) + Integer . parseInt ( str [ 1 ] ) ; System . out . println ( Integer . toString ( YHKRBhgnHS ) . length ( ) ) ; } br . close ( ) ; } catch ( Exception e ) { } } } import java . util . ArrayList ; import java . util . Scanner ; public class fqMnrcWcfb { public static void main ( String [ ] args ) { int fqMnrcWcfb = 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 ( fqMnrcWcfb ) ; break me ; } } fqMnrcWcfb ++ ; } } } import java . util . Scanner ; public class uDRgFkvyaA { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final int uDRgFkvyaA = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 1 ; i <= uDRgFkvyaA ; i ++ ) { int sum = 0 ; for ( int j = 1 ; j <= uDRgFkvyaA ; j ++ ) { if ( i % j == 0 ) { sum ++ ; } } if ( sum == 8 && i % 2 != 0 ) { ans ++ ; } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class tVWBzdbhBJ { 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 tVWBzdbhBJ ; int B ; int C ; Main ( Scanner sc ) { this . sc = sc ; this . tVWBzdbhBJ = sc . nextInt ( ) ; this . B = sc . nextInt ( ) ; this . C = sc . nextInt ( ) ; } private String solve ( ) { String answer = " No " ; if ( tVWBzdbhBJ == B && B != C || tVWBzdbhBJ == C && B != C || B == C && C != tVWBzdbhBJ ) { answer = " Yes " ; } return answer ; } public void show ( String answer ) { System . out . println ( answer ) ; } } import java . util . * ; public class GBYNxsMFWK { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String n = scan . nextLine ( ) ; String [ ] array = n . split ( " " ) ; int GBYNxsMFWK = 0 ; for ( String a : array ) { if ( a . equals ( " 7 " ) ) { GBYNxsMFWK = 1 ; } } if ( GBYNxsMFWK == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; import java . io . * ; public class lKjGlHNhbj { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int lKjGlHNhbj = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; if ( n == 0 ) { System . out . println ( lKjGlHNhbj ) ; 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 ( lKjGlHNhbj - i <= 0 ) continue ; if ( lKjGlHNhbj + i > 200 ) continue ; if ( number [ lKjGlHNhbj - i ] == 1 ) { System . out . println ( lKjGlHNhbj - i ) ; System . exit ( 0 ) ; } if ( number [ lKjGlHNhbj + i ] == 1 ) { System . out . println ( lKjGlHNhbj + i ) ; System . exit ( 0 ) ; } } System . out . println ( 0 ) ; } } class lKjGlHNhbj { } import java . util . * ; import java . util . Arrays ; public class qEpfbEClMq { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int [ ] a = new int [ 10 ] ; for ( int qEpfbEClMq = 0 ; qEpfbEClMq < a . length ; qEpfbEClMq ++ ) { a [ qEpfbEClMq ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int qEpfbEClMq = 9 ; qEpfbEClMq > 6 ; qEpfbEClMq -- ) { System . out . println ( a [ qEpfbEClMq ] ) ; } } } import java . util . Scanner ; public class dRzlETRsuL { public static void main ( String [ ] a ) { Scanner scan = new Scanner ( System . in ) ; String [ ] t = scan . nextLine ( ) . split ( " \\ s " ) ; int dRzlETRsuL = 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 SjABBrSiog { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String SjABBrSiog = sc . next ( ) ; String S1 = SjABBrSiog . substring ( 0 , 1 ) ; String S2 = SjABBrSiog . substring ( 1 , 2 ) ; String S3 = SjABBrSiog . substring ( 2 , 3 ) ; String S4 = SjABBrSiog . 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 QTwPkFvhoU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long QTwPkFvhoU = Long . parseLong ( sc . next ( ) ) ; long B = Long . parseLong ( sc . next ( ) ) ; long n = Math . abs ( QTwPkFvhoU - ( QTwPkFvhoU - B ) / 2 ) ; if ( Math . abs ( QTwPkFvhoU - n ) == Math . abs ( B - n ) ) { System . out . println ( n ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } } import java . util . Scanner ; public class ZFlLLcGone { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int ZFlLLcGone = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int ans = 0 ; if ( ZFlLLcGone == 0 && x == 0 ) break ; for ( int i = 1 ; i < ZFlLLcGone + 1 ; i ++ ) { for ( int j = i + 1 ; j < ZFlLLcGone + 1 ; j ++ ) { for ( int k = j + 1 ; k < ZFlLLcGone + 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 IqOPJFTPyS { public static void main ( String [ ] args ) { try ( Scanner scan = new Scanner ( System . in ) ) { int IqOPJFTPyS = scan . nextInt ( ) ; int inputQ = scan . nextInt ( ) ; int [ ] memory = new int [ IqOPJFTPyS + 1 ] ; memory [ 0 ] = 0 ; String inputStr = scan . next ( ) ; for ( int n = 2 ; n < IqOPJFTPyS + 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 WfnJgZJTIL { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int WfnJgZJTIL = sc . nextInt ( ) ; int No = 0 ; int [ ] buka = new int [ WfnJgZJTIL + 1 ] ; while ( sc . hasNext ( ) ) { buka [ sc . nextInt ( ) ] ++ ; } for ( int i = 1 ; i <= WfnJgZJTIL ; i ++ ) { System . out . println ( buka [ i ] ) ; } } } import java . io . * ; public class yCDCmCRIJA { 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 yCDCmCRIJA = Integer . parseInt ( sec_ ) ; m . SecToTime ( yCDCmCRIJA ) ; } public void SecToTime ( int yCDCmCRIJA ) { int h = 0 , m = 0 ; while ( yCDCmCRIJA >= 3600 ) { h ++ ; yCDCmCRIJA -= 3600 ; } while ( yCDCmCRIJA >= 60 ) { m ++ ; yCDCmCRIJA -= 60 ; } System . out . println ( h + " : " + m + " : " + yCDCmCRIJA ) ; } } import java . util . * ; public class kPZNaZjTEO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kPZNaZjTEO = sc . nextInt ( ) ; String [ ] list = new String [ kPZNaZjTEO ] ; String ans = " No " ; for ( int i = 0 ; i < kPZNaZjTEO ; i ++ ) { list [ i ] = sc . next ( ) ; } for ( int i = 1 ; i < kPZNaZjTEO ; 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 < kPZNaZjTEO ; i ++ ) { String a = list [ i ] ; for ( int j = i + 1 ; j < kPZNaZjTEO ; 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 sFCDjQGmZG { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int sFCDjQGmZG = 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 < sFCDjQGmZG ; 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 ljrlLFEwRD { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int ljrlLFEwRD = scan . nextInt ( ) ; int [ ] ar = new int [ ljrlLFEwRD ] ; for ( int i = 0 ; i < ljrlLFEwRD ; i ++ ) { ar [ i ] = scan . nextInt ( ) ; } Arrays . parallelSort ( ar ) ; float ans = 0 ; float [ ] lol = new float [ ljrlLFEwRD ] ; lol [ 0 ] = ar [ 0 ] ; for ( int i = 1 ; i < ljrlLFEwRD ; i ++ ) { lol [ i ] = ( float ) ( ( ar [ i ] + lol [ i - 1 ] ) / 2 ) ; } System . out . printf ( " %.04f " , lol [ ljrlLFEwRD - 1 ] ) ; } } import java . util . ArrayList ; import java . util . Scanner ; public class gjJbHvGkgi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gjJbHvGkgi = sc . nextInt ( ) ; ArrayList < Integer > A = new ArrayList < Integer > ( ) ; ArrayList < Integer > B = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < gjJbHvGkgi ; i ++ ) { int n = sc . nextInt ( ) ; A . add ( n ) ; B . add ( 0 ) ; } for ( int i = 0 ; i < gjJbHvGkgi ; i ++ ) { B . set ( A . get ( i ) - 1 , i + 1 ) ; } for ( int i = 0 ; i < gjJbHvGkgi ; i ++ ) { System . out . print ( B . get ( i ) + " " ) ; } sc . close ( ) ; } } import java . util . Scanner ; class CfDyWWquLK { 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 CfDyWWquLK = 0 ; for ( char c : s . toCharArray ( ) ) { CfDyWWquLK += c - '0' ; } System . out . println ( CfDyWWquLK ) ; } } } import java . util . * ; public class KGHRxfjwcK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . next ( ) ; int KGHRxfjwcK , j , flag = 0 ; for ( KGHRxfjwcK = 0 ; KGHRxfjwcK < w . length ( ) ; KGHRxfjwcK ++ ) { int cnt = 0 ; for ( j = 0 ; j < w . length ( ) ; j ++ ) { if ( w . charAt ( KGHRxfjwcK ) == 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 wCYwrjWfEL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int wCYwrjWfEL = 1 ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; String s = scan . next ( ) ; if ( s . length ( ) != a + b + 1 ) { wCYwrjWfEL = 0 ; } for ( int i = 0 ; i < a ; i ++ ) { if ( '0' <= s . charAt ( i ) && s . charAt ( i ) <= '9' ) { } else { wCYwrjWfEL = 0 ; } } if ( s . charAt ( a ) != '-' ) { wCYwrjWfEL = 0 ; } for ( int i = a + 1 ; i < s . length ( ) ; i ++ ) { if ( '0' <= s . charAt ( i ) && s . charAt ( i ) <= '9' ) { } else { wCYwrjWfEL = 0 ; } } if ( wCYwrjWfEL == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . * ; public class xAOeHEjtxy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xAOeHEjtxy = 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 SnxjPiYMnd { 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 tedvuWdNrQ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int tedvuWdNrQ = scan . nextInt ( ) ; int [ ] length = new int [ tedvuWdNrQ ] ; 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 cCpGSiuVGS { 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 cCpGSiuVGS { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int cCpGSiuVGS = in . nextInt ( ) ; String a = in . next ( ) ; String b = in . next ( ) ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < cCpGSiuVGS ; 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 lOpXHDgsYp { public static void main ( String [ ] args ) throws IOException { Scanner scanner = new Scanner ( System . in ) ; int lOpXHDgsYp = scanner . nextInt ( ) ; for ( int i = 3 ; i <= lOpXHDgsYp ; i ++ ) { if ( i % 3 == 0 || String . valueOf ( i ) . contains ( " 3 " ) ) System . out . print ( " " + i ) ; } System . out . println ( ) ; } } import java . util . Scanner ; public class rHFLyIrBVK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; long rHFLyIrBVK = sc . nextLong ( ) ; int x = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { x ++ ; if ( S . charAt ( i ) == '1' && x < rHFLyIrBVK ) { continue ; } else { System . out . println ( S . charAt ( i ) ) ; break ; } } } } import java . util . Arrays ; import java . util . Scanner ; public class bxGLuMDzMV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bxGLuMDzMV = sc . nextInt ( ) ; int [ ] A = new int [ bxGLuMDzMV ] ; for ( int i = 0 ; i < bxGLuMDzMV ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } Arrays . parallelSort ( A ) ; int count = 1 ; for ( int i = bxGLuMDzMV - 1 ; i > 0 ; i -- ) { if ( A [ i ] != A [ i - 1 ] ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; public class bnFqdjNlew { public void main ( Scanner sc ) { int bnFqdjNlew = sc . nextInt ( ) ; int a2 = sc . nextInt ( ) ; int a3 = sc . nextInt ( ) ; int max = Math . max ( bnFqdjNlew , Math . max ( a2 , a3 ) ) ; int min = Math . min ( bnFqdjNlew , 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 ummbsYRpwW { public static void main ( String [ ] args ) { int [ ] input = new int [ 10 ] ; Scanner s = new Scanner ( System . in ) ; for ( int ummbsYRpwW = 0 ; ummbsYRpwW < 10 ; ummbsYRpwW ++ ) { input [ ummbsYRpwW ] = s . nextInt ( ) ; } Arrays . sort ( input ) ; int ummbsYRpwW = input . length - 1 ; while ( ummbsYRpwW > input . length - 4 ) { System . out . println ( input [ ummbsYRpwW ] ) ; ummbsYRpwW -- ; } } } import java . util . Scanner ; public class QJQpduxupV { public static void main ( final String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; final String QJQpduxupV = sc . next ( ) ; sc . close ( ) ; if ( Character . isUpperCase ( QJQpduxupV . charAt ( 0 ) ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } return ; } } import java . util . Arrays ; import java . util . Scanner ; public class xNDxLHKMdz { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int xNDxLHKMdz = sc . nextInt ( ) , k = sc . nextInt ( ) ; int [ ] array = new int [ xNDxLHKMdz ] ; for ( int i = 0 ; i < xNDxLHKMdz ; i ++ ) array [ i ] = sc . nextInt ( ) ; Arrays . sort ( array ) ; for ( int i = xNDxLHKMdz - 1 ; i >= xNDxLHKMdz - k ; i -- ) { if ( i >= 0 ) array [ i ] = 0 ; else break ; } long sum = 0 ; for ( int i = 0 ; i < xNDxLHKMdz ; i ++ ) sum += array [ i ] ; System . out . println ( sum ) ; } } import java . util . * ; public class cgOSFqYlLv { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { long cgOSFqYlLv = sc . nextLong ( ) ; long a1 = cgOSFqYlLv ; long b = sc . nextLong ( ) ; long b1 = b ; long i ; if ( cgOSFqYlLv > b ) { for ( ; ; ) { if ( a1 % b == 0 ) { break ; } a1 += cgOSFqYlLv ; } if ( cgOSFqYlLv % b == 0 ) { System . out . println ( b + " " + a1 ) ; } else { for ( i = b / 2 ; i > 0 ; i -- ) { if ( cgOSFqYlLv % i == 0 && b % i == 0 ) { break ; } } System . out . println ( i + " " + a1 ) ; } } else if ( cgOSFqYlLv < b ) { for ( ; ; ) { if ( b1 % cgOSFqYlLv == 0 ) { break ; } b1 += b ; } if ( b % cgOSFqYlLv == 0 ) { System . out . println ( cgOSFqYlLv + " " + b1 ) ; } else { for ( i = cgOSFqYlLv / 2 ; i > 0 ; i -- ) { if ( cgOSFqYlLv % i == 0 && b % i == 0 ) { break ; } } System . out . println ( i + " " + b1 ) ; } } else { System . out . println ( b + " " + b1 ) ; } } } } import java . util . Scanner ; public class WOCOpeExkl { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . nextLine ( ) ; char WOCOpeExkl = S . charAt ( 0 ) ; System . out . println ( Character . isUpperCase ( WOCOpeExkl ) ? " A " : " a " ) ; } } import java . util . Arrays ; import java . util . Scanner ; public class dTCJxTQAar { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dTCJxTQAar = sc . nextInt ( ) ; int su ; int num = 0 ; String mark ; Boolean [ ] s = new Boolean [ 52 ] ; Arrays . fill ( s , false ) ; for ( int i = 0 ; i < dTCJxTQAar ; 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 EDjvPrEMDT { public static void main ( String [ ] args ) throws Exception { Scanner cin = new Scanner ( System . in ) ; int EDjvPrEMDT = cin . nextInt ( ) , b = cin . nextInt ( ) ; int c = EDjvPrEMDT * b ; if ( c % 2 == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Scanner ; public class jiCvEVThQp { public static void main ( String [ ] args ) { Scanner entrada = new Scanner ( System . in ) ; char jiCvEVThQp = entrada . next ( ) . charAt ( 0 ) ; if ( Character . isUpperCase ( jiCvEVThQp ) ) { System . out . println ( " A " ) ; } else { System . out . println ( " a " ) ; } } } import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class qsPQlmpMVc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qsPQlmpMVc = sc . nextInt ( ) ; String [ ] w = new String [ qsPQlmpMVc ] ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < qsPQlmpMVc ; i ++ ) { w [ i ] = sc . next ( ) ; set . add ( w [ i ] ) ; } for ( int i = 1 ; i < qsPQlmpMVc ; 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 ( ) == qsPQlmpMVc ) ? " Yes " : " No " ) ; } } import java . util . * ; class ZKluIzymyD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZKluIzymyD = Integer . parseInt ( sc . next ( ) ) ; String str = sc . next ( ) ; if ( ZKluIzymyD % 2 == 1 ) { System . out . println ( " No " ) ; return ; } else { String s_1 = str . substring ( 0 , ZKluIzymyD / 2 ) ; String s_2 = str . substring ( ZKluIzymyD / 2 , ZKluIzymyD ) ; if ( s_1 . equals ( s_2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } } import java . util . * ; public class UXcQtZyvUx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String n = String . valueOf ( sc . nextInt ( ) ) ; String rn = " " ; for ( int UXcQtZyvUx = 0 ; UXcQtZyvUx < 3 ; UXcQtZyvUx ++ ) { if ( n . charAt ( UXcQtZyvUx ) == '1' ) rn += " 9 " ; else rn += " 1 " ; } System . out . println ( Integer . valueOf ( rn ) ) ; } } import java . util . Scanner ; public class mwoTYlmILx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mwoTYlmILx = sc . nextInt ( ) ; int min = sc . nextInt ( ) ; int ans = Integer . MIN_VALUE ; for ( int i = 0 ; i < mwoTYlmILx - 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 qULKBKxsxb { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int qULKBKxsxb = 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 ] == '+' ) qULKBKxsxb = qULKBKxsxb + 1 ; else qULKBKxsxb = qULKBKxsxb - 1 ; } System . out . print ( qULKBKxsxb ) ; } } import java . util . * ; import java . math . BigDecimal ; public class ujQDtEuLqE { 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 ABnTylTWeT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ABnTylTWeT = sc . nextInt ( ) ; int [ ] h = new int [ ABnTylTWeT ] ; for ( int i = 0 ; i < ABnTylTWeT ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } int max = 1 ; for ( int i = 0 ; i < ABnTylTWeT ; 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 RWmeHNfAHk { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] C = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; int RWmeHNfAHk = C . length ; int st = 0 ; for ( int i = 0 ; i < RWmeHNfAHk ; ++ i ) { if ( C [ i ] == 'A' ) { st = i ; break ; } } int gl = 0 ; for ( int i = RWmeHNfAHk - 1 ; i >= 0 ; -- i ) { if ( C [ i ] == 'Z' ) { gl = i ; break ; } } System . out . println ( gl - st + 1 ) ; } } import java . util . Scanner ; public class ZggkwWlULP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String ZggkwWlULP = sc . next ( ) ; System . out . println ( ZggkwWlULP . contains ( " 7 " ) ? " Yes " : " No " ) ; } } import java . util . Scanner ; public class kYZVQGrfqT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kYZVQGrfqT = 0 ; int b = 0 ; int c = 0 ; int d = 0 ; int score = 0 ; String x = " " ; kYZVQGrfqT = sc . nextInt ( ) ; x = sc . next ( ) ; if ( x . length ( ) > kYZVQGrfqT ) { x = x . substring ( 0 , kYZVQGrfqT ) + " ... " ; } System . out . print ( x ) ; } } import java . util . * ; import java . io . * ; public class QwBmZMHStJ { public static void main ( String [ ] args ) throws Exception { InputStreamReader r = new InputStreamReader ( System . in ) ; String S = nextString ( r ) ; int QwBmZMHStJ = S . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < QwBmZMHStJ / 2 ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( QwBmZMHStJ - 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 fVLndTKLFd { static int keta ( int s ) { int fVLndTKLFd = 0 ; while ( s > 0 ) { fVLndTKLFd += ( s % 10 ) ; s /= 10 ; } return fVLndTKLFd ; } 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 fVLndTKLFd = 0 ; for ( int i = 1 ; i < N + 1 ; i ++ ) { if ( keta [ i ] >= A && keta [ i ] <= B ) fVLndTKLFd += i ; } System . out . println ( fVLndTKLFd ) ; } } import java . util . * ; public class BtzVSVovrD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String BtzVSVovrD = sc . next ( ) ; if ( BtzVSVovrD . 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 LCzCQHGRBz { public static final int LCzCQHGRBz = 200000 ; public static void main ( String [ ] args ) throws IOException { int [ ] Nums = new int [ LCzCQHGRBz ] ; 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 TSDmNokouD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TSDmNokouD = sc . nextInt ( ) ; int max = 0 ; int result = 1 ; for ( int i = 1 ; i <= TSDmNokouD ; 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 yuZitxqRYU { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int yuZitxqRYU = scan . nextInt ( ) ; String S = scan . next ( ) ; int x = S . length ( ) ; if ( x > yuZitxqRYU ) { String ans = S . substring ( 0 , yuZitxqRYU ) ; System . out . println ( ans + " ... " ) ; } else { System . out . println ( S ) ; } } } import java . util . * ; class nGrmhuCGYo { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int nGrmhuCGYo = stdIn . nextInt ( ) ; int b = stdIn . nextInt ( ) ; String s = String . valueOf ( nGrmhuCGYo ) + 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 EQtfQQLWBm { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int EQtfQQLWBm = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; double ans = 0.0 ; for ( int i = 1 ; i <= EQtfQQLWBm ; i ++ ) { int x = 1 ; int j = i ; while ( j < k ) { x *= 2 ; j *= 2 ; } x *= EQtfQQLWBm ; ans += ( double ) 1 / ( double ) x ; } System . out . println ( ans ) ; sc . close ( ) ; } } import java . util . * ; class wCSofeTkvT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wCSofeTkvT = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] m = new int [ wCSofeTkvT ] ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < wCSofeTkvT ; 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 buHQEdeLDo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int buHQEdeLDo = sc . nextInt ( ) ; long [ ] A = new long [ buHQEdeLDo ] ; for ( int i = 0 ; i < buHQEdeLDo ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } sc . close ( ) ; long result = 0 ; for ( int i = 1 ; i < buHQEdeLDo ; 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 iuFcWPYWWm { 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 iuFcWPYWWm = 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 = iuFcWPYWWm ; x <= b ; x ++ ) { if ( c % x == 0 ) { count ++ ; } } } else { for ( int x = iuFcWPYWWm ; 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 GvWEursoIF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] N = sc . next ( ) . toCharArray ( ) ; int GvWEursoIF = 0 ; for ( int i = 0 ; i < N . length ; i ++ ) { GvWEursoIF = ( GvWEursoIF + Character . getNumericValue ( N [ i ] ) ) % 9 ; } if ( GvWEursoIF % 9 == 0 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . HashSet ; import java . util . Scanner ; public class gXYXHjDWYh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int gXYXHjDWYh = sc . nextInt ( ) ; HashSet < Integer > A = new HashSet < > ( ) ; for ( int i = 0 ; i < gXYXHjDWYh ; i ++ ) { if ( ! A . add ( sc . nextInt ( ) ) ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; sc . close ( ) ; } } import java . util . Scanner ; public class EcdqMvTnFn { private static int EcdqMvTnFn ( int aNum , int bNum , int cNum , int k ) { int EcdqMvTnFn = 0 ; if ( k <= aNum ) { return k ; } else { EcdqMvTnFn += aNum ; k -= aNum ; } if ( k <= bNum ) { return EcdqMvTnFn ; } else { k -= bNum ; } return EcdqMvTnFn + 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 ( EcdqMvTnFn ( aNum , bNum , cNum , k ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class nupsMcmwGf { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long nupsMcmwGf = scanner . nextLong ( ) ; long a = scanner . nextLong ( ) ; long b = scanner . nextLong ( ) ; long aa = nupsMcmwGf % ( long ) ( ( long ) a + ( long ) b ) ; long as = ( long ) ( ( long ) nupsMcmwGf / ( 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 fpCHrCilhl { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int fpCHrCilhl = 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 ) { fpCHrCilhl += 3 ; } else if ( taro_card . compareTo ( hanako_card ) == 0 ) { fpCHrCilhl += 1 ; hanako_score += 1 ; } else { hanako_score += 3 ; } } System . out . println ( fpCHrCilhl + " " + hanako_score ) ; } } import java . util . Scanner ; public class poUkAFynrF { static class poUkAFynrF { Integer [ ] [ ] dp ; public void find ( int k ) { dp = new Integer [ k + 1 ] [ k + 1 ] ; long poUkAFynrF = 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 ; } poUkAFynrF += val2 ; } } } System . out . println ( poUkAFynrF ) ; } 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 wROvZCeIDh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wROvZCeIDh = sc . nextInt ( ) ; int cent = sc . nextInt ( ) ; int yes = 0 ; for ( int i = 0 ; i < wROvZCeIDh ; i ++ ) { int height = sc . nextInt ( ) ; if ( height >= cent ) { yes ++ ; } } System . out . print ( yes ) ; } } import java . util . * ; import java . io . * ; class FwSmAVsEpb { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s ; int [ ] num = new int [ 26 ] ; char FwSmAVsEpb ; while ( ( s = br . readLine ( ) ) != null ) { if ( s . length ( ) >= 1200 ) break ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { FwSmAVsEpb = s . charAt ( j ) ; if ( FwSmAVsEpb >= 0x41 && FwSmAVsEpb <= 0x5a ) { FwSmAVsEpb -= 0x41 ; num [ FwSmAVsEpb ] += 1 ; } else if ( FwSmAVsEpb >= 0x61 && FwSmAVsEpb <= 0x7a ) { FwSmAVsEpb -= 0x61 ; num [ FwSmAVsEpb ] += 1 ; } } } for ( int i = 0 ; i < 26 ; i ++ ) { FwSmAVsEpb = ( char ) ( 0x61 + i ) ; System . out . println ( FwSmAVsEpb + " : " + num [ i ] ) ; } } } import java . util . Scanner ; public class kHZPPrABhC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kHZPPrABhC = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( s . charAt ( kHZPPrABhC ) != '-' ) { System . out . println ( " No " ) ; return ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i != kHZPPrABhC ) { 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 UAGaxgBqvB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UAGaxgBqvB = sc . nextInt ( ) , m = sc . nextInt ( ) ; int k , a ; int [ ] [ ] food = new int [ UAGaxgBqvB ] [ m + 1 ] ; for ( int i = 0 ; i < UAGaxgBqvB ; ++ 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 < UAGaxgBqvB ; ++ j ) { if ( food [ j ] [ i ] == 0 ) break ; } if ( j == UAGaxgBqvB ) ++ ans ; } System . out . println ( ans ) ; } } import java . io . IOException ; import java . util . Scanner ; public class iWqAFtACiV { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int iWqAFtACiV = sc . nextInt ( ) ; long a , b , c , d , e ; a = 2 ; b = sc . nextLong ( ) ; c = b ; d = b ; e = b ; while ( a <= iWqAFtACiV ) { 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 PUYPCauUpX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long PUYPCauUpX = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = 0 ; int i = 1 ; while ( i <= b ) { if ( ( long ) PUYPCauUpX * i % b == 0 ) { c = ( long ) PUYPCauUpX * i ; break ; } else { i ++ ; } } System . out . println ( c ) ; sc . close ( ) ; } } import java . util . Scanner ; class iHBJgPyRgw { 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 iHBJgPyRgw = c . length ; iHBJgPyRgw > 0 ; iHBJgPyRgw -- ) { reverse += c [ iHBJgPyRgw - 1 ] ; } System . out . println ( reverse ) ; } } import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class qjeUlVicQr { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Integer [ ] a = new Integer [ 10 ] ; for ( int qjeUlVicQr = 0 ; qjeUlVicQr < 10 ; qjeUlVicQr ++ ) { a [ qjeUlVicQr ] = sc . nextInt ( ) ; } sc . close ( ) ; Arrays . sort ( a , Collections . reverseOrder ( ) ) ; for ( int qjeUlVicQr = 0 ; qjeUlVicQr < 3 ; qjeUlVicQr ++ ) { System . out . println ( a [ qjeUlVicQr ] ) ; } } } import java . util . Scanner ; public class uJGCcrlUcI { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int uJGCcrlUcI = Integer . parseInt ( input . nextLine ( ) ) ; int W = Integer . parseInt ( input . nextLine ( ) ) ; int [ ] v = new int [ uJGCcrlUcI ] ; for ( int i = 0 ; i < uJGCcrlUcI ; 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 < uJGCcrlUcI ; i ++ ) { System . out . println ( v [ i ] + 1 ) ; } System . exit ( 0 ) ; } } import java . util . Scanner ; public class UZZJVubmwv { static String str ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; str = sc . next ( ) ; int UZZJVubmwv = str . length ( ) ; boolean [ ] dp = new boolean [ UZZJVubmwv + 1 ] ; dp [ 0 ] = true ; for ( int i = 5 ; i <= UZZJVubmwv ; 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 [ UZZJVubmwv ] ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . * ; public class OlDYXXGcgc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long OlDYXXGcgc = sc . nextLong ( ) ; int count = 1 ; long money = 100 ; while ( true ) { money *= 1.01 ; if ( money >= OlDYXXGcgc ) { System . out . println ( count ) ; return ; } count ++ ; } } } import java . util . * ; public class mZjZYzaSgP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str1 = sc . nextLine ( ) ; String str2 = sc . nextLine ( ) ; boolean mZjZYzaSgP = 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 ) ) mZjZYzaSgP = true ; } if ( mZjZYzaSgP ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class IBxDslYxBR { private static class IBxDslYxBR { int IBxDslYxBR ; int to ; Range ( int IBxDslYxBR , int to ) { this . IBxDslYxBR = IBxDslYxBR ; 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 . IBxDslYxBR ; i < range . to ; i ++ ) { hs [ i ] += 1 ; } count ++ ; } } } } import java . util . * ; public class WALnvQzmXh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long WALnvQzmXh = sc . nextLong ( ) ; long bank = 100 ; long count = 0 ; for ( long i = bank ; i < WALnvQzmXh ; bank += bank / 100 , count ++ ) { if ( bank >= WALnvQzmXh ) { System . out . println ( count ) ; break ; } } } } import java . util . * ; public class DVjOBscXQZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int DVjOBscXQZ = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int res = DVjOBscXQZ / b ; if ( res * b < DVjOBscXQZ ) { ++ res ; } System . out . println ( res ) ; } } import java . util . Scanner ; public class lEekDVhSPm { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int [ ] [ ] [ ] houses = new int [ 4 ] [ 3 ] [ 10 ] ; int lEekDVhSPm = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] [ ] a = new int [ lEekDVhSPm ] [ m ] ; int [ ] b = new int [ m ] ; int [ ] c = new int [ lEekDVhSPm ] ; for ( int i = 0 ; i < lEekDVhSPm ; 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 < lEekDVhSPm ; 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 hZkEgJqVDP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int hZkEgJqVDP = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] queue = new int [ hZkEgJqVDP ] [ m ] ; int [ ] vector = new int [ m ] ; int [ ] vectorAns = new int [ hZkEgJqVDP ] ; 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 rFmGItyrvb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rFmGItyrvb = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; double log ; log = Math . log10 ( rFmGItyrvb ) / Math . log10 ( K ) ; int ans = ( int ) Math . floor ( log ) + 1 ; System . out . println ( ans ) ; } } import java . util . * ; public class fUcTcnRNIc { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int fUcTcnRNIc = 5 ; int [ ] array = new int [ fUcTcnRNIc ] ; for ( int i = 0 ; i < fUcTcnRNIc ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int tmp = 0 ; int tmp2 = 10 - ( array [ 0 ] % 10 ) ; for ( int i = 0 ; i < fUcTcnRNIc ; 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 < fUcTcnRNIc ; 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 mgPAyaLoJy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String w = sc . nextLine ( ) ; int mgPAyaLoJy = 0 ; String t ; while ( ! ( ( t = sc . next ( ) ) . equals ( " END_OF_TEXT " ) ) ) { if ( t . toLowerCase ( ) . equals ( w ) ) mgPAyaLoJy ++ ; } System . out . println ( mgPAyaLoJy ) ; } } import java . io . * ; public class kmhZHKNDwP { public static void main ( String [ ] args ) throws Exception { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] arr = reader . readLine ( ) . split ( " " ) ; int kmhZHKNDwP = Integer . parseInt ( arr [ 0 ] ) ; int K = Integer . parseInt ( arr [ 1 ] ) ; int cnt = 1 ; while ( Math . pow ( K , cnt ) <= kmhZHKNDwP ) cnt ++ ; System . out . println ( cnt ) ; } } import java . util . * ; public class qhkAbAKSPT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qhkAbAKSPT = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; double a = sc . nextInt ( ) ; double min = 1000000 ; int ans = 0 ; int [ ] h = new int [ qhkAbAKSPT ] ; for ( int i = 0 ; i < qhkAbAKSPT ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < qhkAbAKSPT ; 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 dHTxVukpaj { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int dHTxVukpaj = scanner . nextInt ( ) ; int a = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int total = 0 ; for ( int i = 1 ; i <= dHTxVukpaj ; 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 lXoycvVgUp { public void run ( java . io . InputStream in , java . io . PrintStream out ) { java . util . Scanner sc = new java . util . Scanner ( in ) ; int lXoycvVgUp , x ; int i , j , k , count ; for ( ; ; ) { lXoycvVgUp = sc . nextInt ( ) ; x = sc . nextInt ( ) ; if ( lXoycvVgUp == 0 && x == 0 ) break ; count = 0 ; for ( i = 1 ; i <= lXoycvVgUp ; i ++ ) { for ( j = i + 1 ; j <= lXoycvVgUp ; j ++ ) { if ( x - i - j > j && x - i - j <= lXoycvVgUp ) 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 shWTtLMMZR { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int shWTtLMMZR = 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 [ shWTtLMMZR ] ; for ( i = 0 ; i < shWTtLMMZR ; 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 MbUSqqlvKY { 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 MbUSqqlvKY = 0 ; MbUSqqlvKY < 8 ; MbUSqqlvKY ++ ) { int sum = x [ 0 ] ; for ( int j = 0 ; j < 3 ; j ++ ) { if ( ( 1 & ( MbUSqqlvKY >> 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 qHkMonvgCa { 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 qHkMonvgCa { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long qHkMonvgCa = in . nextLong ( ) , x = in . nextLong ( ) ; long count = 1 , sum = 0 ; for ( long i = 1 ; i <= qHkMonvgCa ; i ++ ) { long y = in . nextLong ( ) ; sum += y ; if ( sum <= x ) count ++ ; } out . println ( count ) ; } } } import java . util . Scanner ; public class WuWLRKllfE { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int WuWLRKllfE = sc . nextInt ( ) ; int maxHigh = 0 ; int view = 0 ; for ( int i = 0 ; i < WuWLRKllfE ; i ++ ) { int High = sc . nextInt ( ) ; if ( maxHigh <= High ) { maxHigh = High ; view ++ ; } } System . out . println ( view ) ; } } import java . util . * ; public class vtxTCOvLAC { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int vtxTCOvLAC = s . nextInt ( ) ; int [ ] check = { 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; String ans = " No " ; if ( vtxTCOvLAC >= 10 ) { for ( int i = 0 ; i < check . length ; i ++ ) { if ( vtxTCOvLAC % check [ i ] == 0 && vtxTCOvLAC / check [ i ] < 10 ) { ans = " Yes " ; break ; } } } else { ans = " Yes " ; } System . out . println ( ans ) ; } } import java . util . * ; public class mmoJaiKcpl { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { int mmoJaiKcpl = sc . nextInt ( ) ; int [ ] arr = new int [ mmoJaiKcpl ] ; int [ ] check = new int [ mmoJaiKcpl ] ; for ( int i = 0 ; i < mmoJaiKcpl ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int res = 0 ; while ( ! Arrays . equals ( arr , check ) ) { int l = 0 ; int min = Integer . MAX_VALUE ; while ( l < mmoJaiKcpl && arr [ l ] == 0 ) { l ++ ; } int cp = l ; while ( l < mmoJaiKcpl && 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 DJDLTeibeE { public static void main ( String [ ] Args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int DJDLTeibeE = s . length ( ) ; int flag = 0 ; for ( int i = 1 ; i <= DJDLTeibeE ; 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 SQNzMnDGxN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long SQNzMnDGxN = sc . nextLong ( ) ; int i = 2 ; while ( true ) { if ( i == SQNzMnDGxN ) { System . out . println ( i ) ; return ; } if ( SQNzMnDGxN % i == 0 ) { SQNzMnDGxN ++ ; i = 2 ; continue ; } else { i ++ ; } } } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class RpAeQBrxBC { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int RpAeQBrxBC = Integer . valueOf ( br . readLine ( ) ) ; int z = Integer . valueOf ( br . readLine ( ) ) ; if ( RpAeQBrxBC == 1 ) { if ( z == 2 ) { System . out . print ( " 3 " ) ; } else if ( z == 3 ) { System . out . print ( " 2 " ) ; } } else if ( RpAeQBrxBC == 2 ) { if ( z == 1 ) { System . out . print ( " 3 " ) ; } else if ( z == 3 ) { System . out . print ( " 1 " ) ; } } else if ( RpAeQBrxBC == 3 ) { if ( z == 1 ) { System . out . print ( " 2 " ) ; } else if ( z == 2 ) { System . out . print ( " 1 " ) ; } } } } import java . util . Scanner ; public class pEiuPuftXC { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int pEiuPuftXC , col ; int [ ] matrix ; pEiuPuftXC = scanner . nextInt ( ) ; col = scanner . nextInt ( ) ; matrix = new int [ col ] ; int in , sum ; for ( int rowi = 0 ; rowi < pEiuPuftXC ; 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 jnaIJVZIjz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; char jnaIJVZIjz = in . next ( ) . charAt ( 0 ) ; int integerInput = jnaIJVZIjz ; 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 YNaFgRmYjM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YNaFgRmYjM = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int ans = 0 ; while ( YNaFgRmYjM > 0 ) { YNaFgRmYjM = YNaFgRmYjM - a ; ans ++ ; } System . out . println ( ans ) ; } } import java . util . * ; public class oHpvaariaP { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int oHpvaariaP = sc . nextInt ( ) ; int [ ] a = new int [ oHpvaariaP ] ; for ( int i = 0 ; i < oHpvaariaP ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int count = 0 ; boolean flg = true ; while ( flg ) { for ( int i = 0 ; i < oHpvaariaP ; i ++ ) { if ( a [ i ] % 2 == 0 ) { a [ i ] /= 2 ; if ( i == oHpvaariaP - 1 ) count ++ ; } else { flg = false ; break ; } } } System . out . println ( count ) ; } } import java . util . Scanner ; public class msuRyvLXjH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int msuRyvLXjH = sc . nextInt ( ) ; int z = 0 ; if ( msuRyvLXjH % 2 == 0 ) { z = msuRyvLXjH / 2 ; } else { z = msuRyvLXjH / 2 + 1 ; } System . out . print ( z ) ; } } import java . io . IOException ; import java . util . Scanner ; public class ujdezyaTfi { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int ujdezyaTfi = 1 ; int i = 0 ; while ( true ) { ujdezyaTfi = sc . nextInt ( ) ; i ++ ; if ( ujdezyaTfi == 0 ) { break ; } System . out . println ( " Case " + i + " : " + ujdezyaTfi ) ; } } } import java . util . * ; public class qHlVNUlrmC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qHlVNUlrmC = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] p = s . toCharArray ( ) ; int flag = 0 ; for ( int i = 0 ; i < qHlVNUlrmC ; i ++ ) { if ( p [ i ] < '0' || p [ i ] > '9' ) { flag = 1 ; } } if ( p [ qHlVNUlrmC ] != '-' ) { flag = 1 ; } for ( int i = qHlVNUlrmC + 1 ; i <= qHlVNUlrmC + 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 eBRidnyDuL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eBRidnyDuL = sc . nextInt ( ) ; int X2 = sc . nextInt ( ) ; int X3 = sc . nextInt ( ) ; int X4 = sc . nextInt ( ) ; int X5 = sc . nextInt ( ) ; if ( eBRidnyDuL == 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 JPaoCspAfE { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int JPaoCspAfE = s . nextInt ( ) ; int B = s . nextInt ( ) ; if ( 0 < JPaoCspAfE && JPaoCspAfE < 10 && 0 < B && B < 10 ) { System . out . println ( JPaoCspAfE * B ) ; } else { System . out . println ( - 1 ) ; } s . close ( ) ; } } import java . util . * ; public class aNVdfCvMZP { public static void main ( String [ ] args ) { int aNVdfCvMZP = 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 hqqkgwlPpn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double hqqkgwlPpn = sc . nextDouble ( ) ; double calc1 = Math . pow ( hqqkgwlPpn , 2 ) ; double calc2 = Math . pow ( hqqkgwlPpn , 3 ) ; System . out . println ( ( int ) hqqkgwlPpn + ( int ) calc1 + ( int ) calc2 ) ; } } import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ; public class AdBRqzRBNZ { public static void main ( String [ ] args ) { Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int AdBRqzRBNZ = in . nextInt ( ) ; int t = in . nextInt ( ) ; int s = in . nextInt ( ) ; if ( t * s < AdBRqzRBNZ ) System . out . println ( " No " ) ; else System . out . println ( " Yes " ) ; } } import java . util . * ; public class KdBehGdyjw { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int KdBehGdyjw = sc . nextInt ( ) ; boolean [ ] b = new boolean [ 1000001 ] ; b [ KdBehGdyjw ] = true ; int i = 2 ; while ( true ) { if ( KdBehGdyjw % 2 == 0 ) { KdBehGdyjw /= 2 ; } else { KdBehGdyjw = KdBehGdyjw * 3 + 1 ; } if ( b [ KdBehGdyjw ] ) { break ; } else { b [ KdBehGdyjw ] = true ; } i ++ ; } System . out . println ( i ) ; } } import java . util . HashSet ; import java . util . Scanner ; class YmIKFhalbZ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YmIKFhalbZ = 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 ( YmIKFhalbZ - hs . size ( ) ) ; } } import java . util . * ; public class GxQockfaum { public static void main ( String [ ] args ) { int GxQockfaum ; double tSurf , tA ; Scanner sc = new Scanner ( System . in ) ; GxQockfaum = sc . nextInt ( ) ; tSurf = sc . nextDouble ( ) ; tA = sc . nextDouble ( ) ; double [ ] ts = new double [ GxQockfaum ] ; int result = 1 ; double min = 0 ; for ( int i = 0 ; i < GxQockfaum ; 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 ptMOEkeNyQ { public static void main ( String [ ] args ) { Scanner sc = null ; try { sc = new Scanner ( System . in ) ; int ptMOEkeNyQ = Integer . parseInt ( sc . nextLine ( ) ) ; int [ ] numBox = new int [ ptMOEkeNyQ ] ; 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 VEnubWkxtM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] x = new int [ 100000 ] , y = new int [ 100000 ] ; int VEnubWkxtM = 0 , a ; while ( true ) { x [ VEnubWkxtM ] = sc . nextInt ( ) ; y [ VEnubWkxtM ] = sc . nextInt ( ) ; if ( x [ VEnubWkxtM ] == 0 && y [ VEnubWkxtM ] == 0 ) break ; if ( x [ VEnubWkxtM ] > y [ VEnubWkxtM ] ) { a = x [ VEnubWkxtM ] ; x [ VEnubWkxtM ] = y [ VEnubWkxtM ] ; y [ VEnubWkxtM ] = a ; } VEnubWkxtM ++ ; } for ( int j = 0 ; j < VEnubWkxtM ; j ++ ) { System . out . println ( x [ j ] + " " + y [ j ] ) ; } } } import java . util . Scanner ; public class tcPsSvhwyn { public static void main ( String [ ] argc ) { Scanner sc = new Scanner ( System . in ) ; int tcPsSvhwyn = sc . nextInt ( ) ; int [ ] A = new int [ tcPsSvhwyn ] ; for ( int i = 0 ; i < tcPsSvhwyn ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } int count = 0 ; for ( int j = 0 ; j < tcPsSvhwyn ; j ++ ) { int min = j ; for ( int k = j ; k < tcPsSvhwyn ; 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 < tcPsSvhwyn ; m ++ ) { if ( m == tcPsSvhwyn - 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 LvQyNPmpZG { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int LvQyNPmpZG = 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 [ LvQyNPmpZG ] [ num ] ; for ( int i = 0 ; i < LvQyNPmpZG ; 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 NAlAvZvBnA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String NAlAvZvBnA = sc . next ( ) ; HashMap < String , String > map = new HashMap < > ( ) ; map . put ( " ARC " , " ABC " ) ; map . put ( " ABC " , " ARC " ) ; System . out . println ( map . get ( NAlAvZvBnA ) ) ; } } import java . util . Scanner ; public class MsgmhkYcXf { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int MsgmhkYcXf = stdIn . nextInt ( ) ; int q = stdIn . nextInt ( ) ; int r = stdIn . nextInt ( ) ; int a = MsgmhkYcXf + q ; int b = q + r ; int c = MsgmhkYcXf + 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 OTeXClnYRA { public static void main ( String [ ] args ) { int OTeXClnYRA , q , t ; int t_sum = 0 ; String pros ; Deque < String > name = new ArrayDeque < > ( ) ; Deque < Integer > time = new ArrayDeque < > ( ) ; Scanner sc = new Scanner ( System . in ) ; OTeXClnYRA = sc . nextInt ( ) ; q = sc . nextInt ( ) ; for ( int i = 0 ; i < OTeXClnYRA ; 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 RQCubRLENM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int RQCubRLENM = sc . nextInt ( ) , f = 1 ; int [ ] a = new int [ RQCubRLENM ] ; for ( int i = 0 ; i < RQCubRLENM ; 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 ChCSVeOCEa { public static void main ( String [ ] args ) { char [ ] ch = " abcdefghijklmnopqrstuvwxyz " . toCharArray ( ) ; Scanner scan = new Scanner ( System . in ) ; long ChCSVeOCEa = scan . nextLong ( ) ; StringBuilder sb = new StringBuilder ( ) ; int t ; for ( ; ChCSVeOCEa > 0 ; ChCSVeOCEa = ( ChCSVeOCEa - 1 ) / 26 ) { t = ( int ) ( ( ChCSVeOCEa - 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 RiYErJBwpp { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int RiYErJBwpp = 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 != RiYErJBwpp ) { 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 uLLENLwPaD { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uLLENLwPaD = sc . nextInt ( ) ; int [ ] a = new int [ uLLENLwPaD + 1 ] ; for ( int i = 1 ; i <= uLLENLwPaD ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int count = 0 ; boolean [ ] flag = new boolean [ uLLENLwPaD + 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 ruLZwrxxXI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ruLZwrxxXI = sc . nextLong ( ) ; long val = log2 ( ruLZwrxxXI ) ; 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 hktvuKGYZW { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long hktvuKGYZW = sc . nextLong ( ) ; long ans = 1 ; long count = 1 ; while ( hktvuKGYZW > 1 ) { hktvuKGYZW = hktvuKGYZW / 2 ; ans += Math . pow ( 2 , count ) ; count ++ ; } System . out . println ( ans ) ; } } import java . io . * ; import java . util . * ; class mHWoSDBjKG { public static void main ( String [ ] args ) throws Exception { final Scanner sc = new Scanner ( System . in ) ; String mHWoSDBjKG ; mHWoSDBjKG = sc . next ( ) ; solve ( mHWoSDBjKG ) ; } static void solve ( String mHWoSDBjKG ) { System . out . println ( calc ( mHWoSDBjKG ) ) ; } static int calc ( String mHWoSDBjKG ) { switch ( mHWoSDBjKG ) { 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 qiKInmCTTV { 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 uQAgsnpFoj { public static void main ( String [ ] args ) throws IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = in . readLine ( ) . split ( " " ) ; int uQAgsnpFoj = 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 ; } uQAgsnpFoj = uQAgsnpFoj - d ; if ( uQAgsnpFoj <= 0 ) { System . out . println ( " No " ) ; flg = false ; } } } } import java . util . * ; public class wgPBxMLbPT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String wgPBxMLbPT = sc . next ( ) ; if ( wgPBxMLbPT . equals ( " AAA " ) ) { System . out . println ( " No " ) ; } else if ( wgPBxMLbPT . equals ( " BBB " ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class yrOpTBzVgd { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long yrOpTBzVgd = sc . nextLong ( ) ; int ans = ( int ) Math . log10 ( yrOpTBzVgd ) + 1 ; for ( int i = 1 ; i <= Math . sqrt ( yrOpTBzVgd ) ; i ++ ) { if ( yrOpTBzVgd % i == 0 ) ans = ( int ) Math . min ( ans , Math . log10 ( yrOpTBzVgd / i ) + 1 ) ; } System . out . println ( ans ) ; } } import java . io . * ; public class jyhfXzgXdg { public static void main ( String [ ] args ) { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; while ( true ) { int jyhfXzgXdg , sum = 0 ; try { String line = reader . readLine ( ) ; if ( line . equals ( " 0 " ) ) break ; for ( jyhfXzgXdg = 0 ; jyhfXzgXdg < line . length ( ) ; jyhfXzgXdg ++ ) { char c = line . charAt ( jyhfXzgXdg ) ; sum += Character . getNumericValue ( c ) ; } } catch ( IOException e ) { System . out . println ( e ) ; } System . out . println ( sum ) ; } } } import java . util . Scanner ; public class buFwbGDIip { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int buFwbGDIip = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int count = 0 ; int n = 0 ; for ( int i = Math . max ( buFwbGDIip , b ) ; i >= 1 ; i -- ) { if ( buFwbGDIip % i == 0 && b % i == 0 ) { count ++ ; n = i ; if ( count >= k ) break ; } } System . out . println ( n ) ; } } import java . util . Scanner ; public class mCKoSKhnIj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int mCKoSKhnIj = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ mCKoSKhnIj ] ; long [ ] dp = new long [ mCKoSKhnIj ] ; for ( int i = 0 ; i < mCKoSKhnIj ; i ++ ) { h [ i ] = sc . nextInt ( ) ; dp [ i ] = 9223372036854775807l ; } dp [ 0 ] = 0 ; for ( int i = 1 ; i < mCKoSKhnIj ; 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 [ mCKoSKhnIj - 1 ] ) ; } } import java . util . * ; public class tmXAVxgndW { 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 tmXAVxgndW = scan . nextInt ( ) ; int x = scan . nextInt ( ) ; if ( ( tmXAVxgndW == 0 ) && ( x == 0 ) ) { break ; } listN . add ( tmXAVxgndW ) ; listX . add ( x ) ; } for ( int i = 0 ; i < listN . size ( ) ; i ++ ) { int tmXAVxgndW = listN . get ( i ) ; int x = listX . get ( i ) ; int cnt = 0 ; for ( int a = 1 ; a <= tmXAVxgndW ; a ++ ) { for ( int b = a + 1 ; b <= tmXAVxgndW ; b ++ ) { for ( int c = b + 1 ; c <= tmXAVxgndW ; c ++ ) { int sum = a + b + c ; if ( sum == x ) { cnt ++ ; } } } } System . out . println ( cnt ) ; } } } import java . util . * ; public class HwhRVmCGMQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Long N = sc . nextLong ( ) ; int HwhRVmCGMQ = ( int ) Math . floor ( Math . sqrt ( ( double ) N ) ) ; for ( int i = HwhRVmCGMQ ; 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 AvRHTReDvV { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long AvRHTReDvV = scan . nextLong ( ) , m = scan . nextLong ( ) ; for ( int i = 0 ; i < m ; i ++ ) { AvRHTReDvV -= scan . nextLong ( ) ; if ( AvRHTReDvV < 0 ) { System . out . println ( - 1 ) ; scan . close ( ) ; return ; } } System . out . println ( AvRHTReDvV ) ; scan . close ( ) ; return ; } } import java . util . Scanner ; public class uQBtbYHzBO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int uQBtbYHzBO = sc . nextInt ( ) ; int [ ] [ ] D = new int [ uQBtbYHzBO ] [ 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 LbwOXliidQ { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int LbwOXliidQ = scanner . nextInt ( ) ; final int k = scanner . nextInt ( ) ; double result = 0 ; for ( int i = 1 ; i <= LbwOXliidQ ; 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 / LbwOXliidQ ) ; } } import java . util . * ; import java . io . * ; public class VyIELglgQI { public static void main ( String [ ] args ) throws Exception { FastScanner fs = new FastScanner ( ) ; int VyIELglgQI = fs . nextInt ( ) ; if ( VyIELglgQI == 0 ) System . out . println ( 1 ) ; else System . out . println ( 0 ) ; } static class VyIELglgQI { 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 VbquoBoidP { public static void main ( String [ ] args ) { Scanner stdIn = new Scanner ( System . in ) ; int VbquoBoidP = stdIn . nextInt ( ) ; int t = stdIn . nextInt ( ) ; int s = stdIn . nextInt ( ) ; if ( VbquoBoidP <= t * s ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class vqwLyAyAiN { public static void main ( String [ ] Args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] s = new String [ 3 ] ; for ( int vqwLyAyAiN = 0 ; vqwLyAyAiN < 3 ; vqwLyAyAiN ++ ) { s [ vqwLyAyAiN ] = 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 VuwMlJDLew { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int VuwMlJDLew = scanner . nextInt ( ) ; int b = scanner . nextInt ( ) ; int tax8pricemin = ( int ) ( ( ( double ) VuwMlJDLew ) / 0.08 ) ; int tax8pricemax = ( int ) ( ( ( double ) VuwMlJDLew + 1 ) / 0.08 ) ; for ( int i = tax8pricemin ; i < tax8pricemax ; i ++ ) { int tax8 = ( int ) ( i * 0.08 ) ; int tax10 = ( int ) ( i * 0.1 ) ; if ( tax8 == VuwMlJDLew && tax10 == b ) { System . out . println ( i ) ; System . exit ( 0 ) ; } } System . out . println ( - 1 ) ; } } import java . util . Scanner ; public class wCffJZyFSU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wCffJZyFSU = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int count = 0 ; while ( true ) { if ( ( wCffJZyFSU - 1 ) * count + 1 >= B ) { break ; } count += 1 ; } System . out . println ( count ) ; } } import java . math . BigInteger ; import java . util . Scanner ; public class aqKMZsIbGf { public static void main ( String [ ] args ) { BigInteger MAX = new BigInteger ( " 1000000000000000000 " ) ; Scanner sc = new Scanner ( System . in ) ; int aqKMZsIbGf = sc . nextInt ( ) ; BigInteger [ ] s = new BigInteger [ aqKMZsIbGf ] ; BigInteger ans = BigInteger . ONE ; for ( int i = 0 ; i < aqKMZsIbGf ; i ++ ) { s [ i ] = sc . nextBigInteger ( ) ; if ( s [ i ] . compareTo ( BigInteger . ZERO ) == 0 ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } } for ( int i = 0 ; i < aqKMZsIbGf ; 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 IWZgQkTiFX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; char IWZgQkTiFX ; char [ ] ch = { 'A' , 'C' , 'G' , 'T' } ; int count = 0 ; int count_max = 0 ; boolean con ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { IWZgQkTiFX = s . charAt ( i ) ; con = true ; count ++ ; for ( int j = 0 ; j < 4 && con ; j ++ ) { if ( IWZgQkTiFX == 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 kiFaQMvdwi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; long kiFaQMvdwi = sc . nextLong ( ) ; for ( int i = 0 ; i < Math . min ( kiFaQMvdwi , 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 dqGIVOqkdX { public static int func ( int n ) { int dqGIVOqkdX = 0 ; if ( n % 2 == 0 ) { dqGIVOqkdX = n / 2 ; } else if ( n % 2 == 1 ) { dqGIVOqkdX = 3 * n + 1 ; } return dqGIVOqkdX ; } 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 SoUNCVdrMz { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int SoUNCVdrMz = in . nextInt ( ) ; int K = in . nextInt ( ) ; int [ ] h = new int [ SoUNCVdrMz ] ; int count = 0 ; for ( int i = 0 ; i < SoUNCVdrMz ; i ++ ) { h [ i ] = in . nextInt ( ) ; if ( h [ i ] >= K ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . * ; import java . io . * ; class xBLPMQhzxb { static PrintStream out = System . out ; static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int xBLPMQhzxb = 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 <= xBLPMQhzxb ) ; out . println ( ) ; } } import java . util . Scanner ; public class xHcgCTCqWB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str1 = sc . next ( ) ; String str2 = " 7 " ; int xHcgCTCqWB = str1 . indexOf ( str2 ) ; if ( xHcgCTCqWB != - 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class HUOSPHaAdI { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int HUOSPHaAdI = 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 ( HUOSPHaAdI , 2 ) + Math . pow ( B , 2 ) - 2 * HUOSPHaAdI * 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 RTcFmbXuYJ { 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 RTcFmbXuYJ { int RTcFmbXuYJ ; int M ; boolean [ ] a ; int mod = ( int ) ( 1e9 + 7 ) ; public void solve ( int testNumber , Scanner in , PrintWriter out ) { RTcFmbXuYJ = in . nextInt ( ) ; M = in . nextInt ( ) ; a = new boolean [ RTcFmbXuYJ + 1 ] ; Arrays . fill ( a , true ) ; for ( int i = 0 ; i < M ; i ++ ) { a [ in . nextInt ( ) ] = false ; } int [ ] dp = new int [ RTcFmbXuYJ + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i <= RTcFmbXuYJ ; i ++ ) { if ( a [ i ] ) { dp [ i ] = dp [ i - 1 ] ; if ( i - 2 >= 0 ) { dp [ i ] += dp [ i - 2 ] ; } dp [ i ] %= mod ; } } out . println ( dp [ RTcFmbXuYJ ] ) ; } } } import java . util . Scanner ; import java . util . regex . * ; import java . math . * ; public class rqzyJoJhnI { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int rqzyJoJhnI = 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 ( rqzyJoJhnI == 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 KXClBKQheg { static class KXClBKQheg { 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 KXClBKQheg = obj . nextInt ( ) , sn2 = obj . nextInt ( ) ; String t = obj . next ( ) ; if ( t . equals ( s1 ) ) KXClBKQheg -- ; else sn2 -- ; System . out . println ( KXClBKQheg + " " + sn2 ) ; } } import java . util . Scanner ; class AoliBTyBef { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int AoliBTyBef , X ; AoliBTyBef = sc . nextInt ( ) ; X = sc . nextInt ( ) ; int count = X - AoliBTyBef + 1 ; for ( int i = 0 ; i < ( 2 * AoliBTyBef ) - 1 ; i ++ , count ++ ) System . out . print ( count + " " ) ; System . out . println ( ) ; } } import java . util . Scanner ; public class MHFxwSzYGm { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int MHFxwSzYGm = sc . nextInt ( ) ; while ( true ) { if ( prime ( MHFxwSzYGm ) ) { break ; } MHFxwSzYGm ++ ; } System . out . println ( MHFxwSzYGm ) ; sc . close ( ) ; } private boolean prime ( int MHFxwSzYGm ) { if ( MHFxwSzYGm == 0 || MHFxwSzYGm == 1 ) { return false ; } if ( MHFxwSzYGm == 2 ) return true ; if ( MHFxwSzYGm % 2 == 0 ) return false ; for ( int i = 3 ; i * i <= MHFxwSzYGm ; i += 2 ) { if ( MHFxwSzYGm % i == 0 ) { return false ; } } return true ; } } import java . util . Scanner ; public class XNvGogrRtU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String input = sc . nextLine ( ) ; sc . close ( ) ; int XNvGogrRtU = ( int ) 'A' - ( int ) 'a' ; for ( char moji : input . toCharArray ( ) ) { if ( 'a' <= moji && moji <= 'z' ) { System . out . print ( ( char ) ( ( int ) moji + XNvGogrRtU ) ) ; } else if ( 'A' <= moji && moji <= 'Z' ) { System . out . print ( ( char ) ( ( int ) moji - XNvGogrRtU ) ) ; } else { System . out . print ( moji ) ; } } System . out . println ( ) ; } } import java . util . Scanner ; public class KNGfCIOFgt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int KNGfCIOFgt = scan . nextInt ( ) ; int min = 0 ; int max = 0 ; long amount = 0 ; for ( int i = 0 ; i < KNGfCIOFgt ; 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 jRhvJMjjkA { 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 jRhvJMjjkA = 0 ; jRhvJMjjkA < splitWord . length - 1 ; jRhvJMjjkA ++ ) { String rear = splitWord [ jRhvJMjjkA ] ; String front = splitWord [ jRhvJMjjkA + 1 ] ; if ( front . equals ( rear ) ) { return true ; } } return false ; } } import java . util . Scanner ; public class AhIeIhENeW { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String AhIeIhENeW = scan . nextLine ( ) ; String p = scan . nextLine ( ) ; AhIeIhENeW += AhIeIhENeW . substring ( 0 , AhIeIhENeW . length ( ) - 1 ) ; if ( AhIeIhENeW . indexOf ( p ) == - 1 ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . Scanner ; public class NcbxOrmWQA { 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 NcbxOrmWQA = 0 ; NcbxOrmWQA < s . length ( ) ; NcbxOrmWQA ++ ) { for ( int j = 0 ; j < c . length ; j ++ ) { c [ j ] = s . charAt ( ( j + NcbxOrmWQA ) % 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 QayXanDOJN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int QayXanDOJN = sc . nextInt ( ) ; int [ ] b = new int [ QayXanDOJN - 1 ] ; int result = 0 ; int pre = 0 ; for ( int i = 0 ; i < QayXanDOJN - 1 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; if ( i == 0 ) result = result + b [ i ] ; if ( i > 0 ) { result = result + min ( pre , b [ i ] ) ; } if ( i == QayXanDOJN - 2 ) result = result + b [ i ] ; pre = b [ i ] ; } System . out . println ( result ) ; } } import java . util . * ; public class ydaqLzFXRU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long ydaqLzFXRU = sc . nextLong ( ) ; long year = 0 ; double kingaku = 100 ; do { kingaku = kingaku * 1.01 ; kingaku = Math . floor ( kingaku ) ; year ++ ; } while ( kingaku < ydaqLzFXRU ) ; System . out . println ( year ) ; } } import java . util . Scanner ; public class amMUKLMUlu { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; for ( int amMUKLMUlu = 1 ; amMUKLMUlu > 0 ; amMUKLMUlu ++ ) { 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 eMHaLATNsQ { 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 eMHaLATNsQ = Integer . parseInt ( x [ 0 ] ) ; int b = Integer . parseInt ( x [ 1 ] ) ; int c = Integer . parseInt ( x [ 2 ] ) ; if ( b > eMHaLATNsQ && 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 GluGVfQipz { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner s = new Scanner ( System . in ) ; int GluGVfQipz = s . nextInt ( ) ; int K = s . nextInt ( ) ; Set set = new HashSet ( ) ; for ( int i = 1 ; i <= GluGVfQipz ; 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 ZlwSbZeyPs { public static void main ( String [ ] args ) { Scanner s = null ; try { s = new Scanner ( System . in ) ; String ZlwSbZeyPs = s . nextLine ( ) ; System . out . println ( powBy3 ( Integer . parseInt ( ZlwSbZeyPs ) ) ) ; } 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 MNBgxTKnZI { 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 MNBgxTKnZI = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { if ( S . charAt ( i ) == T . charAt ( i ) ) { MNBgxTKnZI ++ ; } } out . println ( MNBgxTKnZI ) ; } } import java . util . * ; import java . text . * ; public class nkQxGevche { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nkQxGevche = sc . nextInt ( ) ; int count = 0 ; int a = 0 ; for ( int i = 1 ; i <= nkQxGevche ; i ++ ) { a = i % 2 ; if ( a == 1 ) { count += 1 ; } } double prob = ( double ) count / nkQxGevche ; System . out . println ( prob ) ; } } import java . util . Scanner ; public class YxsFCgTehj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YxsFCgTehj = sc . nextInt ( ) ; int [ ] array = new int [ YxsFCgTehj ] ; for ( int i = 0 ; i < YxsFCgTehj ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } long min = 1000001 ; for ( int i = 0 ; i < YxsFCgTehj ; i ++ ) { if ( min > array [ i ] ) { min = array [ i ] ; } } long max = - 1000001 ; for ( int i = 0 ; i < YxsFCgTehj ; i ++ ) { if ( max < array [ i ] ) { max = array [ i ] ; } } long sum = 0 ; for ( int i = 0 ; i < YxsFCgTehj ; i ++ ) { sum += array [ i ] ; } System . out . println ( min + " " + max + " " + sum ) ; } } import java . util . Scanner ; public class bmMGWLAVwt { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int bmMGWLAVwt = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int s = 0 ; for ( int i = 0 ; i < 2 ; i ++ ) { if ( bmMGWLAVwt > b ) { s += bmMGWLAVwt -- ; } else { s += b -- ; } } System . out . print ( s ) ; } } import java . util . Scanner ; class jSvpANwRvi { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jSvpANwRvi = scan . nextInt ( ) ; int [ ] num = new int [ jSvpANwRvi ] ; int count ; for ( int c = 0 ; c < jSvpANwRvi ; c ++ ) { num [ c ] = scan . nextInt ( ) ; } count = bubbleSort ( num , jSvpANwRvi ) ; for ( int i = 0 ; i < jSvpANwRvi ; i ++ ) { if ( i != jSvpANwRvi - 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 PCAUeOlpjg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int PCAUeOlpjg = sc . nextInt ( ) ; int g = PCAUeOlpjg / 2 ; double ans = ( double ) ( PCAUeOlpjg - g ) / PCAUeOlpjg ; out . println ( ans ) ; } } import java . util . Scanner ; class hASrBmGXBJ { private static String toString ( int [ ] numbers ) { StringBuilder ans = new StringBuilder ( ) . append ( numbers [ 0 ] ) ; for ( int hASrBmGXBJ = 1 ; hASrBmGXBJ < numbers . length ; hASrBmGXBJ ++ ) ans . append ( " " ) . append ( numbers [ hASrBmGXBJ ] ) ; 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 kYMDHTUHkN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int kYMDHTUHkN = 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 = ( kYMDHTUHkN * kYMDHTUHkN ) + ( num2 * num2 ) - ( 2 * kYMDHTUHkN * num2 * Math . cos ( rad ) ) ; System . out . print ( Math . sqrt ( num3 ) ) ; } } import java . util . Scanner ; class MSoXrqFbCQ { 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 MSoXrqFbCQ = 0 ; long a = num [ 0 ] ; long b = num [ 1 ] ; do { MSoXrqFbCQ = a % b ; a = b ; b = MSoXrqFbCQ ; } while ( MSoXrqFbCQ != 0 ) ; return a ; } private static long lcm ( long [ ] num ) { return ( num [ 0 ] * num [ 1 ] ) / gcd ( num ) ; } } import java . util . Scanner ; public class rmpJQZQQlL { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int rmpJQZQQlL = input . nextInt ( ) ; int back , i , j = 1 ; while ( true ) { i = j * 1000 ; if ( i >= rmpJQZQQlL ) { back = i - rmpJQZQQlL ; break ; } j ++ ; } System . out . println ( back ) ; } } import java . util . Scanner ; public class mkmKWclQja { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String mkmKWclQja = sc . next ( ) ; String t = sc . next ( ) ; String T1 = t . substring ( mkmKWclQja . length ( ) - 0 ) ; if ( t . equals ( mkmKWclQja + T1 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class ftTMeVMuXy { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ftTMeVMuXy = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int value = ftTMeVMuXy + b + c ; int product = ftTMeVMuXy * b * c ; if ( value == 17 & product == 175 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Scanner ; public class TedSoQhJgC { public static void main ( String [ ] args ) { final Scanner scanner = new Scanner ( System . in ) ; final int TedSoQhJgC = scanner . nextInt ( ) ; final int x = scanner . nextInt ( ) ; final int [ ] lengths = new int [ TedSoQhJgC ] ; for ( int i = 0 ; i < lengths . length ; i ++ ) { lengths [ i ] = scanner . nextInt ( ) ; } int i ; int distance = 0 ; for ( i = 0 ; i < TedSoQhJgC ; 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 OsBYjJVuRJ { public static void main ( String [ ] args ) { try { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = reader . readLine ( ) ; int OsBYjJVuRJ = Integer . parseInt ( s ) ; String t = reader . readLine ( ) ; String [ ] u = t . split ( " " ) ; int [ ] m = new int [ OsBYjJVuRJ ] ; for ( int i = 0 ; i < OsBYjJVuRJ ; i ++ ) { m [ i ] = Integer . parseInt ( u [ i ] ) ; } for ( int j = OsBYjJVuRJ - 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 GmZrwSBUUg { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GmZrwSBUUg = sc . nextInt ( ) ; int [ ] arrs = new int [ GmZrwSBUUg + 1 ] ; for ( int i = 1 ; i <= GmZrwSBUUg ; i ++ ) { arrs [ i ] = sc . nextInt ( ) ; } int result = 0 ; for ( int i = 1 ; i <= GmZrwSBUUg ; i ++ ) { result += Math . max ( arrs [ i ] - arrs [ i - 1 ] , 0 ) ; } System . out . println ( result ) ; } } import java . util . * ; public class aGctZNAHRK { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int aGctZNAHRK = 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 < aGctZNAHRK ; 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 VRvdnxsoCN { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int VRvdnxsoCN = sc . nextInt ( ) ; double M = sc . nextInt ( ) ; int [ ] A = new int [ VRvdnxsoCN ] ; double sum = 0 ; for ( int i = 0 ; i < VRvdnxsoCN ; 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 EnbyadhUYj { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int EnbyadhUYj = input . nextInt ( ) ; int X = input . nextInt ( ) ; int [ ] L = new int [ EnbyadhUYj ] ; 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 tgtMgGZApE { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int tgtMgGZApE = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; int C = scanner . nextInt ( ) ; System . out . println ( Math . max ( 0 , C - ( tgtMgGZApE - B ) ) ) ; } } import java . util . Scanner ; public class BQAxJErIkn { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int BQAxJErIkn = Integer . parseInt ( sc . next ( ) ) ; String s = sc . next ( ) ; int result = 0 ; for ( int i = 2 ; i < BQAxJErIkn ; 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 GIqXAxsWRj { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int GIqXAxsWRj = 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 " ) ) { GIqXAxsWRj ++ ; } else if ( i == 1 && GIqXAxsWRj == 1 ) { break ; } } System . out . println ( GIqXAxsWRj ) ; } } import java . util . * ; public class YQWgqJTsHU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YQWgqJTsHU = 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 aDVFfeBDyY { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int aDVFfeBDyY = scan . nextInt ( ) ; int waza = scan . nextInt ( ) ; long [ ] hp = new long [ aDVFfeBDyY ] ; for ( int i = 0 ; i < aDVFfeBDyY ; i ++ ) { hp [ i ] = scan . nextInt ( ) ; } long sum = 0 ; Arrays . sort ( hp ) ; for ( int i = 0 ; i < aDVFfeBDyY - waza ; i ++ ) { sum += hp [ i ] ; } System . out . println ( sum ) ; scan . close ( ) ; } } import java . util . * ; public class TcaZZDzSzv { private static final Scanner scan = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int TcaZZDzSzv = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int d = TcaZZDzSzv / b ; int r = TcaZZDzSzv % b ; double f = ( double ) TcaZZDzSzv / ( double ) b ; System . out . printf ( " %d %d %f \n " , d , r , f ) ; } } import java . util . HashSet ; import java . util . Scanner ; public class slTgREikzf { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int slTgREikzf = sc . nextInt ( ) ; String [ ] S = new String [ slTgREikzf ] ; for ( int i = 0 ; i < slTgREikzf ; i ++ ) { S [ i ] = sc . next ( ) ; } HashSet < String > set = new HashSet < String > ( ) ; for ( int i = 0 ; i < slTgREikzf ; i ++ ) { set . add ( S [ i ] ) ; } System . out . println ( set . size ( ) ) ; } } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class fDLpootHFX { 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 fDLpootHFX = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { if ( list . contains ( str [ i ] ) ) { fDLpootHFX ++ ; } else { list . add ( str [ i ] ) ; } } if ( list . size ( ) > 2 ) { System . out . println ( " No " ) ; } else { if ( fDLpootHFX == 2 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } } import java . io . * ; import java . util . * ; public class FtjOWyjQvB { public static void main ( String [ ] args ) throws IOException { Scanner scn = new Scanner ( System . in ) ; int FtjOWyjQvB = scn . nextInt ( ) ; long ans = 0 ; for ( int i = 1 ; i <= FtjOWyjQvB ; i ++ ) { if ( i % 3 != 0 && i % 5 != 0 ) ans += i ; } System . out . println ( ans ) ; } static class FtjOWyjQvB { 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 zbXIUWjHqa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zbXIUWjHqa = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; if ( ( zbXIUWjHqa + b + c ) == 17 && ( zbXIUWjHqa * b * c ) == 175 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } import java . util . Arrays ; import java . util . Scanner ; class zXiysaTpkI { public static void main ( final String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int zXiysaTpkI = sc . nextInt ( ) ; String [ ] S = new String [ zXiysaTpkI ] ; int ans = 1 ; for ( int i = 0 ; i < zXiysaTpkI ; i ++ ) { S [ i ] = sc . next ( ) ; } Arrays . sort ( S ) ; for ( int i = 1 ; i < zXiysaTpkI ; i ++ ) { if ( ! S [ i - 1 ] . equals ( S [ i ] ) ) { ans ++ ; } } System . out . print ( ans ) ; } } import java . util . Scanner ; public class pAKlKAkiQC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int pAKlKAkiQC = sc . nextInt ( ) ; int [ ] a = new int [ pAKlKAkiQC ] ; for ( int i = 0 ; i < pAKlKAkiQC ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } boolean f = true ; for ( int i = pAKlKAkiQC - 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 lKAEEJytVM { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String l1 = scan . nextLine ( ) ; scan . close ( ) ; int lKAEEJytVM = Integer . valueOf ( l1 ) ; double side = lKAEEJytVM / 3.0 ; System . out . println ( String . format ( " %.12f " , side * side * side ) ) ; } } import java . util . Scanner ; class mhQdOCjErV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] iro = new int [ 8 ] ; int mhQdOCjErV = 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 { mhQdOCjErV ++ ; } } int clr = 0 ; for ( int i = 0 ; i < 8 ; i ++ ) { if ( iro [ i ] > 0 ) { clr ++ ; } } System . out . println ( Math . max ( 1 , clr ) + " " + ( clr + mhQdOCjErV ) ) ; } } import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; public class wFprejkKhw { 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 wFprejkKhw = Integer . parseInt ( br . readLine ( ) ) ; for ( int i = 0 ; i < wFprejkKhw ; 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 TmVEspANbb { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int TmVEspANbb = scanner . nextInt ( ) ; Integer [ ] a = new Integer [ TmVEspANbb ] ; boolean s = true ; int Alice = 0 ; int Bob = 0 ; for ( int i = 0 ; i < TmVEspANbb ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( a , Comparator . reverseOrder ( ) ) ; for ( int i = 0 ; i < TmVEspANbb ; 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 XncoGhInly { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; int XncoGhInly = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; System . out . println ( Math . min ( XncoGhInly * A , B ) ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class eBcYtUzfSu { 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 eBcYtUzfSu = Integer . parseInt ( result [ 0 ] ) ; int num2 = Integer . parseInt ( result [ 1 ] ) ; int num3 = Integer . parseInt ( result [ 2 ] ) ; if ( eBcYtUzfSu < num2 ) { if ( num2 < num3 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; public class ZpgKWoPWbe { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int ZpgKWoPWbe = scanner . nextInt ( ) ; int input = scanner . nextInt ( ) ; String str = new Integer ( ZpgKWoPWbe ) . toString ( ZpgKWoPWbe , input ) ; System . out . println ( str . length ( ) ) ; } } import java . util . Scanner ; public class qMFkvTdVrO { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int qMFkvTdVrO = scan . nextInt ( ) ; int M = scan . nextInt ( ) ; int [ ] num_road = new int [ qMFkvTdVrO ] ; int [ ] a = new int [ M ] ; int [ ] b = new int [ M ] ; int i ; for ( i = 0 ; i < qMFkvTdVrO ; 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 < qMFkvTdVrO ; i ++ ) { System . out . println ( num_road [ i ] ) ; } } } import java . util . Scanner ; public class OybITeRqys { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OybITeRqys = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = 0 ; if ( OybITeRqys % X > 0 ) A = 1 ; System . out . println ( ( OybITeRqys / X + A ) * T ) ; sc . close ( ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class PkSKYstxLg { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] string = br . readLine ( ) . split ( " " ) ; int PkSKYstxLg = Integer . parseInt ( string [ 0 ] ) ; int y = Integer . parseInt ( string [ 1 ] ) ; int tmp ; if ( PkSKYstxLg < y ) { tmp = PkSKYstxLg ; PkSKYstxLg = y ; y = tmp ; } int r = PkSKYstxLg % y ; while ( r != 0 ) { PkSKYstxLg = y ; y = r ; r = PkSKYstxLg % y ; } System . out . println ( y ) ; } } import java . io . * ; import java . util . * ; public class rFTnwaDtax { 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 rFTnwaDtax { public void solve ( String S ) { for ( int rFTnwaDtax = 0 ; rFTnwaDtax < 3 ; rFTnwaDtax ++ ) { if ( S . charAt ( rFTnwaDtax ) == S . charAt ( rFTnwaDtax + 1 ) ) { System . out . println ( " Bad " ) ; return ; } } System . out . println ( " Good " ) ; } } import java . util . * ; public class TUXvHTwtyS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int TUXvHTwtyS = Integer . parseInt ( str ) ; if ( ( TUXvHTwtyS % 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 YcPkdlVcuP { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int YcPkdlVcuP = sc . nextInt ( ) ; boolean ans = false ; for ( int i = 0 ; i <= YcPkdlVcuP / 7 ; i ++ ) { if ( ( YcPkdlVcuP - i * 7 ) % 4 == 0 ) { ans = true ; break ; } } if ( ans == true ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } import java . util . Scanner ; class iTWDykNUBa { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; StringBuilder str = new StringBuilder ( ) ; int iTWDykNUBa = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { switch ( s . charAt ( i ) ) { case '0' : str . append ( '0' ) ; iTWDykNUBa ++ ; break ; case '1' : str . append ( '1' ) ; iTWDykNUBa ++ ; break ; case 'B' : if ( iTWDykNUBa == 0 ) { break ; } str . deleteCharAt ( iTWDykNUBa - 1 ) ; iTWDykNUBa -- ; break ; default : break ; } } System . out . println ( str . toString ( ) ) ; sc . close ( ) ; } } import java . util . Scanner ; public class srUePTlynA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int srUePTlynA = Integer . parseInt ( sc . nextLine ( ) ) ; int [ ] point = new int [ 2 ] ; for ( int i = 0 ; i < srUePTlynA ; 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 ZXdcfftGQS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int ZXdcfftGQS = Integer . parseInt ( sc . next ( ) ) ; System . out . println ( ZXdcfftGQS + ZXdcfftGQS * ZXdcfftGQS + ZXdcfftGQS * ZXdcfftGQS * ZXdcfftGQS ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class csflgvOZRA { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int csflgvOZRA = sc . nextInt ( ) ; List < Long > a = new ArrayList < Long > ( ) ; int fe = - 1 ; int count = 0 ; for ( int i = 0 ; i < csflgvOZRA ; 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 tpTHcqPhGb { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tpTHcqPhGb = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; sc . close ( ) ; double prob = 0.0 ; for ( int i = 1 ; i <= tpTHcqPhGb ; i ++ ) { int points = i ; double diff = 1.0 / tpTHcqPhGb ; while ( points < k ) { diff *= 0.5 ; points *= 2 ; } prob += diff ; } System . out . println ( prob ) ; } } import java . util . Scanner ; public class frjCqoBUGC { @ SuppressWarnings ( " resource " ) public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; long frjCqoBUGC = scanner . nextLong ( ) ; if ( frjCqoBUGC <= s . length ( ) ) { for ( int i = 0 ; i < frjCqoBUGC ; 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 LsTPMHlJlM { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] c = sc . next ( ) . toCharArray ( ) ; sc . close ( ) ; for ( int LsTPMHlJlM = 0 ; LsTPMHlJlM < c . length ; LsTPMHlJlM ++ ) { char a = c [ LsTPMHlJlM ] ; if ( LsTPMHlJlM % 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 siJwAMFtEB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long siJwAMFtEB = 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 ( ) ) { siJwAMFtEB += map . get ( key ) * ( map . get ( key ) - 1 ) / 2 ; } System . out . println ( siJwAMFtEB ) ; } } import java . util . Scanner ; public class oSiUrCsRjb { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { char [ ] S = sc . next ( ) . toCharArray ( ) ; int oSiUrCsRjb = 0 ; for ( int i = 0 ; i < S . length ; i ++ ) { if ( S [ i ] == '+' ) { oSiUrCsRjb ++ ; } else { oSiUrCsRjb -- ; } } System . out . println ( oSiUrCsRjb ) ; } } } import java . util . * ; public class nNKpxGCQup { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int nNKpxGCQup = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; double nearest = Double . MAX_VALUE ; int ans = 0 ; for ( int i = 1 ; i <= nNKpxGCQup ; 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 hzVDmyYuzR { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int hzVDmyYuzR = 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 qhqTKJhnlp { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; int qhqTKJhnlp = 0 ; int z = 0 ; while ( s . charAt ( qhqTKJhnlp ) != 'A' ) { qhqTKJhnlp ++ ; } for ( int i = qhqTKJhnlp + 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == 'Z' ) { z = i ; } } System . out . println ( z - qhqTKJhnlp + 1 ) ; } } import java . util . Scanner ; public class zyyYeEfmrq { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int zyyYeEfmrq = scan . nextInt ( ) ; int B = scan . nextInt ( ) ; int T = scan . nextInt ( ) ; int times = T / zyyYeEfmrq ; int ans = times * B ; System . out . println ( ans ) ; } } import java . util . * ; class csGbwXYyCT { public void yatary ( ) { Scanner sc = new Scanner ( System . in ) ; int csGbwXYyCT ; int x = sc . nextInt ( ) ; int [ ] num = new int [ x ] ; for ( csGbwXYyCT = 0 ; csGbwXYyCT < x ; csGbwXYyCT ++ ) { num [ csGbwXYyCT ] = sc . nextInt ( ) ; } for ( csGbwXYyCT = x - 1 ; csGbwXYyCT >= 0 ; csGbwXYyCT -- ) { if ( csGbwXYyCT != 0 ) { System . out . print ( num [ csGbwXYyCT ] + " " ) ; } else { System . out . println ( num [ csGbwXYyCT ] ) ; } } } public static void main ( String [ ] args ) { new Main ( ) . yatary ( ) ; } } import java . util . Scanner ; class hRtxTDYOwL { static class hRtxTDYOwL { int A [ ] , hRtxTDYOwL ; Stack ( int size ) { A = new int [ size + 1 ] ; hRtxTDYOwL = 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 hRtxTDYOwL == 0 ; } boolean isFull ( ) { return hRtxTDYOwL == A . length - 1 ; } void push ( int key ) { if ( isFull ( ) ) return ; A [ ++ hRtxTDYOwL ] = key ; } int pop ( ) { if ( isEmpty ( ) ) return 0 ; return A [ hRtxTDYOwL -- ] ; } } 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 kjpliKWufJ { 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 kjpliKWufJ { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int kjpliKWufJ = in . nextInt ( ) ; int b = in . nextInt ( ) ; int res = 0 ; for ( int i = kjpliKWufJ ; i <= b ; i ++ ) if ( i / 10000 == i % 10 && i / 10 % 10 == i / 1000 % 10 ) res ++ ; out . println ( res ) ; } } } import java . util . Scanner ; public class JOKNsOpMah { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int JOKNsOpMah = scan . nextInt ( ) ; int m = scan . nextInt ( ) ; int [ ] [ ] arrayA = new int [ JOKNsOpMah ] [ m ] ; int [ ] arrayB = new int [ m ] ; for ( int i = 0 ; i < JOKNsOpMah ; 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 < JOKNsOpMah ; 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 OUAlhKNqRx { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int OUAlhKNqRx = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] A = new int [ OUAlhKNqRx ] ; for ( int i = 0 ; i < OUAlhKNqRx ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } Arrays . parallelSort ( A ) ; for ( int i = 0 ; i < OUAlhKNqRx ; i ++ ) { X -= A [ i ] ; } System . out . println ( OUAlhKNqRx + X / A [ 0 ] ) ; } } import java . util . Scanner ; public class WRbUQuMQTL { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int WRbUQuMQTL = scan . nextInt ( ) ; int [ ] b = new int [ WRbUQuMQTL ] ; int [ ] f = new int [ WRbUQuMQTL ] ; int [ ] r = new int [ WRbUQuMQTL ] ; int [ ] v = new int [ WRbUQuMQTL ] ; int [ ] [ ] [ ] num = new int [ 4 ] [ 3 ] [ 10 ] ; for ( int i = 0 ; i < WRbUQuMQTL ; 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 LMhBQmRmGV { public static final int LMhBQmRmGV = 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 += LMhBQmRmGV ; } else if ( taro . compareTo ( hanako ) == 0 ) { taroPoint += EVEN_POINTS ; hanakoPoint += EVEN_POINTS ; } else { taroPoint += LMhBQmRmGV ; } } 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 ExBJRQyaiJ { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String input = sc . next ( ) ; String [ ] inputSplit = input . split ( " " ) ; int ExBJRQyaiJ = 0 ; for ( int i = 0 ; i < inputSplit . length ; i ++ ) { if ( inputSplit [ i ] . equals ( " 0 " ) ) { ExBJRQyaiJ ++ ; } } System . out . print ( Math . min ( ExBJRQyaiJ , inputSplit . length - ExBJRQyaiJ ) * 2 ) ; } } import java . util . Scanner ; public class bfrmoYNLqj { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int bfrmoYNLqj = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; System . out . println ( ( ( bfrmoYNLqj == 5 && B == 5 && C == 7 ) || ( bfrmoYNLqj == 5 && B == 7 && C == 5 ) || ( bfrmoYNLqj == 7 && B == 5 && C == 5 ) ) ? " YES " : " NO " ) ; } } } import java . util . Scanner ; public class gPEmrgtMox { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int gPEmrgtMox , x , ans ; while ( true ) { gPEmrgtMox = scan . nextInt ( ) ; x = scan . nextInt ( ) ; ans = 0 ; if ( gPEmrgtMox == 0 && x == 0 ) break ; for ( int i = 1 ; i <= gPEmrgtMox ; i ++ ) { for ( int j = i + 1 ; j <= gPEmrgtMox ; j ++ ) { for ( int k = j + 1 ; k <= gPEmrgtMox ; 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 YjPMdYIDQp { public static void main ( String [ ] args ) throws IOException { int YjPMdYIDQp = 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 ) YjPMdYIDQp ++ ; } System . out . println ( " " + YjPMdYIDQp + " " ) ; } } import java . util . * ; public class UHMOQlXhmh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int UHMOQlXhmh = sc . nextInt ( ) ; long [ ] A = new long [ UHMOQlXhmh + 1 ] ; long [ ] B = new long [ UHMOQlXhmh ] ; for ( int i = 0 ; i < UHMOQlXhmh + 1 ; i ++ ) { A [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < UHMOQlXhmh ; i ++ ) { B [ i ] = sc . nextLong ( ) ; } long sum = 0 ; for ( int i = 0 ; i < UHMOQlXhmh ; 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 GwuNwzTZHM { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int GwuNwzTZHM = sc . nextInt ( ) ; int [ ] array = new int [ GwuNwzTZHM ] ; for ( int i = 0 ; i < GwuNwzTZHM ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int count = 0 ; Arrays . sort ( array ) ; int a = array [ GwuNwzTZHM / 2 - 1 ] ; int b = array [ GwuNwzTZHM / 2 ] ; if ( a == b ) { System . out . println ( 0 ) ; } else { System . out . println ( b - a ) ; } } } import java . util . * ; public class EkKozpSdSV { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; String [ ] str = line . split ( " " ) ; int EkKozpSdSV = Integer . parseInt ( str [ 0 ] ) ; int y = Integer . parseInt ( str [ 1 ] ) ; int z = EkKozpSdSV * y ; if ( z % 2 == 0 ) { System . out . println ( " Even " ) ; } else { System . out . println ( " Odd " ) ; } } } import java . util . Scanner ; public class HHTCUJjWAp { public static void main ( String [ ] args ) { String s = ( new Scanner ( System . in ) ) . next ( ) ; char [ ] acgt = { 'A' , 'C' , 'G' , 'T' } ; int HHTCUJjWAp = 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 ) { HHTCUJjWAp = Math . max ( HHTCUJjWAp , tmp1 ) ; tmp1 = 0 ; } } HHTCUJjWAp = Math . max ( HHTCUJjWAp , tmp1 ) ; System . out . println ( HHTCUJjWAp ) ; } } import java . util . Scanner ; public class KNzGgGvMzg { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int KNzGgGvMzg = 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 * KNzGgGvMzg ) + ( Bpizza * B ) ) ; } System . out . println ( ans ) ; } } import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class DKHWygYRuz { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int DKHWygYRuz = scan . nextInt ( ) ; ArrayList < Integer > result = new ArrayList < > ( ) ; for ( int i = 0 ; i < DKHWygYRuz ; i ++ ) { result . add ( 0 ) ; } for ( int i = 0 ; i < DKHWygYRuz - 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 TaopAbQSCX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int TaopAbQSCX = sc . nextInt ( ) ; Map < String , Integer > m = new HashMap ( ) ; for ( int i = 0 ; i < TaopAbQSCX ; 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 oUesyGQbDZ { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int oUesyGQbDZ = 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 < oUesyGQbDZ ; 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 ETOBAfMnyH { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String ETOBAfMnyH = in . next ( ) ; if ( ETOBAfMnyH . equals ( " AAA " ) || ETOBAfMnyH . equals ( " BBB " ) ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } } } import java . util . * ; public class MFITHvmkgh { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int MFITHvmkgh = sc . nextInt ( ) ; int [ ] array = new int [ MFITHvmkgh ] ; int [ ] array_min = new int [ MFITHvmkgh ] ; int min = MFITHvmkgh + 1 ; for ( int i = 0 ; i < MFITHvmkgh ; i ++ ) { array [ i ] = sc . nextInt ( ) ; if ( min > array [ i ] ) { min = array [ i ] ; } array_min [ i ] = min ; } int count = 0 ; for ( int i = 0 ; i < MFITHvmkgh ; i ++ ) { if ( array_min [ i ] >= array [ i ] ) { count ++ ; } } System . out . println ( count ) ; } } import java . util . Scanner ; public class QtszGIPnFB { public static int QtszGIPnFB = 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 SRxQKjlGxU { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int SRxQKjlGxU = sc . nextInt ( ) ; int [ ] array = new int [ SRxQKjlGxU ] ; for ( int i = 0 ; i < SRxQKjlGxU ; i ++ ) { array [ i ] = sc . nextInt ( ) ; } int buff = 0 ; int count = 0 ; for ( int i = 0 ; i < SRxQKjlGxU ; 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 nDBQIFuqrH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nDBQIFuqrH = sc . nextInt ( ) ; int res = 1 ; for ( int i = 2 ; i * i <= nDBQIFuqrH ; i ++ ) { int p = i * i ; while ( p <= nDBQIFuqrH ) { res = Math . max ( res , p ) ; p *= i ; } } System . out . println ( res ) ; sc . close ( ) ; } } import java . util . * ; class EyXKaAlqHO { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String F = sc . nextLine ( ) ; String C = sc . nextLine ( ) ; int EyXKaAlqHO = 0 ; for ( int i = 0 ; i < F . length ( ) ; i ++ ) { Character c1 = F . charAt ( i ) ; Character c2 = C . charAt ( i ) ; if ( c1 == c2 ) EyXKaAlqHO ++ ; } System . out . println ( EyXKaAlqHO ) ; } } import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class bLvmxexboj { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String bLvmxexboj = br . readLine ( ) ; if ( bLvmxexboj . contains ( " RRR " ) ) { System . out . println ( " 3 " ) ; } else if ( bLvmxexboj . contains ( " RR " ) ) { System . out . println ( " 2 " ) ; } else if ( bLvmxexboj . contains ( " R " ) ) { System . out . println ( 1 ) ; } else { System . out . println ( 0 ) ; } } } import java . util . * ; public class uRhXLfETQE { int uRhXLfETQE = 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 uRhXLfETQE = 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 ; uRhXLfETQE ++ ; } } return uRhXLfETQE ; } } import java . util . Scanner ; public class rMKOZBILSR { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long rMKOZBILSR = Integer . parseInt ( scan . next ( ) ) ; long b = Integer . parseInt ( scan . next ( ) ) ; long mult = rMKOZBILSR * b ; if ( rMKOZBILSR < b ) { long tmp = rMKOZBILSR ; rMKOZBILSR = b ; b = tmp ; } long r = rMKOZBILSR % b ; while ( r > 0 ) { rMKOZBILSR = b ; b = r ; r = rMKOZBILSR % b ; } System . out . println ( mult / b ) ; scan . close ( ) ; } } import java . util . * ; public class shvLxEWOCs { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long shvLxEWOCs = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long d = sc . nextLong ( ) ; long resultA = shvLxEWOCs * c ; resultA = resultA < shvLxEWOCs * d ? shvLxEWOCs * 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 nChYogEOMB { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int nChYogEOMB = sc . nextInt ( ) ; double probability = ( double ) ( nChYogEOMB - ( nChYogEOMB / 2 ) ) ; System . out . print ( probability / 1.0 / nChYogEOMB ) ; } } import java . util . Scanner ; public class ZkaSXHNWDS { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double ZkaSXHNWDS = sc . nextDouble ( ) ; double are = 0 ; double circ = 0 ; are = ZkaSXHNWDS * ZkaSXHNWDS * Math . PI ; circ = ( ZkaSXHNWDS + ZkaSXHNWDS ) * Math . PI ; ; System . out . printf ( " %f %f \n " , are , circ ) ; } } import java . util . HashMap ; import java . util . Scanner ; public class dTCubRZBwN { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int dTCubRZBwN = scan . nextInt ( ) ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < dTCubRZBwN - 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 < dTCubRZBwN ; 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 crFPiSUhYH { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long crFPiSUhYH = 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 ( crFPiSUhYH < total ) { if ( crFPiSUhYH >= blue ) { ans = blue ; } else if ( crFPiSUhYH < blue ) { ans = crFPiSUhYH ; } } else if ( crFPiSUhYH >= total ) { div = crFPiSUhYH / total ; mod = crFPiSUhYH % 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 ACKDvqajFg { 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 ACKDvqajFg = in . nextLong ( ) ; long rem = ACKDvqajFg % 500 ; long total = ( ACKDvqajFg - rem ) * 2 ; total += ( rem - ( rem % 5 ) ) ; out . println ( total ) ; out . close ( ) ; } static class ACKDvqajFg { 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 KgOgFzzgTL { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] str = br . readLine ( ) . split ( " " ) ; int KgOgFzzgTL = Integer . parseInt ( str [ 0 ] ) ; int a = Integer . parseInt ( str [ 1 ] ) ; br . close ( ) ; System . out . println ( ( KgOgFzzgTL + a - 1 ) / a ) ; } } import java . util . Scanner ; public class QncorUqOAi { public static void main ( String [ ] arg ) { Scanner sc = new Scanner ( System . in ) ; while ( true ) { int QncorUqOAi = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int sum = QncorUqOAi + f ; if ( QncorUqOAi == - 1 && f == - 1 && r == - 1 ) break ; else if ( QncorUqOAi == - 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 bQVadVNnpQ { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bQVadVNnpQ = sc . nextInt ( ) ; Integer [ ] mochi = new Integer [ bQVadVNnpQ ] ; int ans = 1 ; for ( int i = 0 ; i < bQVadVNnpQ ; i ++ ) { mochi [ i ] = sc . nextInt ( ) ; } Arrays . sort ( mochi , Comparator . reverseOrder ( ) ) ; for ( int i = 0 ; i < bQVadVNnpQ ; i ++ ) { if ( i != bQVadVNnpQ - 1 ) { if ( mochi [ i ] > mochi [ i + 1 ] ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . util . Scanner ; public class FNoqDtyleo { static int [ ] insertSort ( int [ ] x ) { int FNoqDtyleo , j ; for ( int i = 0 ; i < x . length ; i ++ ) { FNoqDtyleo = x [ i ] ; j = i - 1 ; while ( j >= 0 && x [ j ] > FNoqDtyleo ) { x [ j + 1 ] = x [ j ] ; j -- ; } x [ j + 1 ] = FNoqDtyleo ; 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 wTaebJkNgc { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int wTaebJkNgc = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int sum = 1 ; for ( int i = 0 ; i < wTaebJkNgc ; i ++ ) { sum = sum * 100 ; } if ( N == 100 ) { System . out . println ( 101 * sum ) ; return ; } System . out . println ( N * sum ) ; } } import java . util . * ; public class eaeMZuzwrX { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int eaeMZuzwrX = sc . nextInt ( ) ; double [ ] v = new double [ eaeMZuzwrX ] ; 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 SSBztChyWF { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int SSBztChyWF = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '+' ) SSBztChyWF ++ ; if ( s . charAt ( i ) == '-' ) SSBztChyWF -- ; } System . out . println ( SSBztChyWF ) ; } } import java . util . * ; public class AvzZNbyrRh { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String [ ] line = sc . nextLine ( ) . split ( " " ) ; int AvzZNbyrRh = Integer . parseInt ( line [ 0 ] ) ; int S = Integer . parseInt ( line [ 1 ] ) ; int ans = 0 ; for ( int x = 0 ; x <= AvzZNbyrRh ; x ++ ) { for ( int y = 0 ; y <= AvzZNbyrRh ; y ++ ) { int target = S - x - y ; if ( target >= 0 && target <= AvzZNbyrRh ) { ans ++ ; } } } System . out . println ( ans ) ; } } import java . util . * ; public class qpXLwHRbhi { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int qpXLwHRbhi = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = 0 ; for ( int i = 0 ; i < ( b - qpXLwHRbhi + 1 ) ; i ++ ) { String [ ] s = String . valueOf ( qpXLwHRbhi + i ) . split ( " " ) ; String t = s [ 4 ] + s [ 3 ] + s [ 2 ] + s [ 1 ] + s [ 0 ] ; if ( String . valueOf ( qpXLwHRbhi + 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 DPKBGMyiRW { 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 DPKBGMyiRW { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int DPKBGMyiRW = Integer . parseInt ( in . next ( ) ) ; int b = Integer . parseInt ( in . next ( ) ) ; int c = Integer . parseInt ( in . next ( ) ) ; Set < Integer > s = new HashSet < > ( ) ; s . add ( DPKBGMyiRW ) ; 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 jrJqgAwacZ { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int jrJqgAwacZ = scan . nextInt ( ) ; int [ ] costs = new int [ jrJqgAwacZ ] ; int [ ] cache = new int [ jrJqgAwacZ ] ; for ( int i = 0 ; i < jrJqgAwacZ ; 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 PPfzDxLarY { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long PPfzDxLarY = 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 ) ( PPfzDxLarY * h ) / 2 ; int hukusu = 0 ; if ( ( double ) x == ( double ) PPfzDxLarY / 2.0 && ( double ) y == ( double ) h / 2.0 ) { hukusu = 1 ; } System . out . println ( ans + " " + hukusu ) ; } } import java . util . * ; public class tvgIGPGhSo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tvgIGPGhSo = 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 gKCPUHCmNk { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { int gKCPUHCmNk = sc . nextInt ( ) ; String s = sc . next ( ) ; if ( s . length ( ) <= gKCPUHCmNk ) { System . out . println ( s ) ; } else { System . out . println ( s . subSequence ( 0 , gKCPUHCmNk ) + " ... " ) ; } } } } import java . util . Arrays ; import java . util . Scanner ; public class CzHkLrsKRT { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] A = new int [ 3 ] ; for ( int CzHkLrsKRT = 0 ; CzHkLrsKRT < 3 ; CzHkLrsKRT ++ ) { A [ CzHkLrsKRT ] = 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 EsgBokxmzL { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner s = new Scanner ( System . in ) ; int EsgBokxmzL = s . nextInt ( ) ; int k = s . nextInt ( ) ; int [ ] a = new int [ EsgBokxmzL ] ; 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 HXIGUflPnO { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int HXIGUflPnO = sc . nextInt ( ) ; int [ ] a = new int [ HXIGUflPnO ] ; String ans = " YES " ; int cnt = 0 ; for ( int i = 0 ; i < HXIGUflPnO ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] b = Arrays . copyOf ( a , HXIGUflPnO ) ; Arrays . sort ( b ) ; for ( int i = 0 ; i < HXIGUflPnO ; 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 XdVuxnmcCM { public static void main ( String [ ] args ) { final Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; final int XdVuxnmcCM = in . next ( ) . trim ( ) . length ( ) ; final StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < XdVuxnmcCM ; i ++ ) { sb . append ( " x " ) ; } System . out . println ( sb ) ; } } import java . util . Scanner ; public class BYIhvnGbsy { 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 BYIhvnGbsy = p . length ( ) ; String doubleS = s + s ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { String word = doubleS . substring ( i , i + BYIhvnGbsy ) ; if ( word . equals ( p ) ) { return true ; } } return false ; } } import java . io . ByteArrayInputStream ; import java . util . Scanner ; public class hKPwevLAcB { private static boolean strcmp ( String s , int pos , String other ) { if ( pos >= other . length ( ) ) { int hKPwevLAcB = other . length ( ) ; for ( int i = 0 ; i < hKPwevLAcB ; i ++ ) { if ( s . charAt ( pos - i - 1 ) != other . charAt ( hKPwevLAcB - 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 " ) ; } }